packages feed

liquid-fixpoint 0.5.0.1 → 0.6.0.1

raw patch · 139 files changed

+17879/−3386 lines, 139 filesdep +timedep ~basenew-uploaderPVP ok

version bump matches the API change (PVP)

Dependencies added: time

Dependency ranges changed: base

API changes (from Hackage documentation)

- Language.Fixpoint.Parse: instance GHC.Generics.Constructor Language.Fixpoint.Parse.C1_0Def
- Language.Fixpoint.Parse: instance GHC.Generics.Constructor Language.Fixpoint.Parse.C1_1Def
- Language.Fixpoint.Parse: instance GHC.Generics.Constructor Language.Fixpoint.Parse.C1_2Def
- Language.Fixpoint.Parse: instance GHC.Generics.Constructor Language.Fixpoint.Parse.C1_3Def
- Language.Fixpoint.Parse: instance GHC.Generics.Constructor Language.Fixpoint.Parse.C1_4Def
- Language.Fixpoint.Parse: instance GHC.Generics.Constructor Language.Fixpoint.Parse.C1_5Def
- Language.Fixpoint.Parse: instance GHC.Generics.Constructor Language.Fixpoint.Parse.C1_6Def
- Language.Fixpoint.Parse: instance GHC.Generics.Constructor Language.Fixpoint.Parse.C1_7Def
- Language.Fixpoint.Parse: instance GHC.Generics.Datatype Language.Fixpoint.Parse.D1Def
- Language.Fixpoint.Partition: CPart :: HashMap KVar (WfC a) -> HashMap Integer (SubC a) -> FilePath -> CPart a
- Language.Fixpoint.Partition: Deps :: !(HashSet a) -> !(HashSet a) -> GDeps a
- Language.Fixpoint.Partition: MCInfo :: Int -> Int -> Int -> MCInfo
- Language.Fixpoint.Partition: [cFileName] :: CPart a -> FilePath
- Language.Fixpoint.Partition: [depCuts] :: GDeps a -> !(HashSet a)
- Language.Fixpoint.Partition: [depNonCuts] :: GDeps a -> !(HashSet a)
- Language.Fixpoint.Partition: [mcCores] :: MCInfo -> Int
- Language.Fixpoint.Partition: [mcMaxPartSize] :: MCInfo -> Int
- Language.Fixpoint.Partition: [mcMinPartSize] :: MCInfo -> Int
- Language.Fixpoint.Partition: [pcm] :: CPart a -> HashMap Integer (SubC a)
- Language.Fixpoint.Partition: [pws] :: CPart a -> HashMap KVar (WfC a)
- Language.Fixpoint.Partition: data CPart a
- Language.Fixpoint.Partition: data GDeps a
- Language.Fixpoint.Partition: data MCInfo
- Language.Fixpoint.Partition: deps :: (TaggedC c a) => GInfo c a -> GDeps KVar
- Language.Fixpoint.Partition: elimSolGraph :: Config -> Solution -> IO ()
- Language.Fixpoint.Partition: graphStatistics :: Config -> SInfo a -> IO ()
- Language.Fixpoint.Partition: instance (GHC.Classes.Eq a, Data.Hashable.Class.Hashable a) => GHC.Base.Monoid (Language.Fixpoint.Partition.GDeps a)
- Language.Fixpoint.Partition: instance GHC.Base.Monoid (Language.Fixpoint.Partition.CPart a)
- Language.Fixpoint.Partition: instance GHC.Show.Show Language.Fixpoint.Partition.MCInfo
- Language.Fixpoint.Partition: instance GHC.Show.Show a => GHC.Show.Show (Language.Fixpoint.Partition.GDeps a)
- Language.Fixpoint.Partition: instance Language.Fixpoint.Types.PrettyPrint.PTable Language.Fixpoint.Partition.Stats
- Language.Fixpoint.Partition: mcInfo :: Config -> IO MCInfo
- Language.Fixpoint.Partition: partition :: (Fixpoint a) => Config -> FInfo a -> IO (Result (Integer, a))
- Language.Fixpoint.Partition: partition' :: Maybe MCInfo -> FInfo a -> (KVGraph, [FInfo a])
- Language.Fixpoint.Partition: partitionN :: MCInfo -> FInfo a -> [CPart a] -> [FInfo a]
- Language.Fixpoint.Smt.Bitvector: instance GHC.Generics.Constructor Language.Fixpoint.Smt.Bitvector.C1_0BvOp
- Language.Fixpoint.Smt.Bitvector: instance GHC.Generics.Constructor Language.Fixpoint.Smt.Bitvector.C1_0BvSize
- Language.Fixpoint.Smt.Bitvector: instance GHC.Generics.Constructor Language.Fixpoint.Smt.Bitvector.C1_1BvOp
- Language.Fixpoint.Smt.Bitvector: instance GHC.Generics.Constructor Language.Fixpoint.Smt.Bitvector.C1_1BvSize
- Language.Fixpoint.Smt.Bitvector: instance GHC.Generics.Datatype Language.Fixpoint.Smt.Bitvector.D1BvOp
- Language.Fixpoint.Smt.Bitvector: instance GHC.Generics.Datatype Language.Fixpoint.Smt.Bitvector.D1BvSize
- Language.Fixpoint.Smt.Interface: [cIn] :: Context -> Handle
- Language.Fixpoint.Smt.Interface: [cLog] :: Context -> Maybe Handle
- Language.Fixpoint.Smt.Interface: [cOut] :: Context -> Handle
- Language.Fixpoint.Smt.Interface: [pId] :: Context -> ProcessHandle
- Language.Fixpoint.Smt.Interface: [smtenv] :: Context -> SMTEnv
- Language.Fixpoint.Smt.Interface: [verbose] :: Context -> Bool
- Language.Fixpoint.Smt.Interface: defunc :: SMTLIB2 a => a -> SMT2 a
- Language.Fixpoint.Smt.Interface: makeZ3Context :: FilePath -> [(Symbol, Sort)] -> IO Context
- Language.Fixpoint.Smt.Interface: runSmt2 :: SMTLIB2 a => SMTEnv -> a -> Text
- Language.Fixpoint.Smt.Serialize: castWith :: Symbol -> Expr -> SMT2 Expr
- Language.Fixpoint.Smt.Serialize: defineFun :: (Symbol, Expr) -> SMT2 [Command]
- Language.Fixpoint.Smt.Serialize: defuncApp :: Expr -> SMT2 Expr
- Language.Fixpoint.Smt.Serialize: defuncApp' :: Expr -> [Expr] -> SMT2 Expr
- Language.Fixpoint.Smt.Serialize: defuncBop :: Bop -> Expr -> Expr -> StateT SMTSt Identity Expr
- Language.Fixpoint.Smt.Serialize: eliminate :: Expr -> Expr
- Language.Fixpoint.Smt.Serialize: exprSort :: Expr -> Sort
- Language.Fixpoint.Smt.Serialize: grapLambdas :: MonadState SMTSt m => Expr -> m (Expr, [(Symbol, Expr)])
- Language.Fixpoint.Smt.Serialize: initSMTEnv :: SEnv Sort
- Language.Fixpoint.Smt.Serialize: instance Language.Fixpoint.Smt.Types.SMTLIB2 Language.Fixpoint.Types.Sorts.Sort
- Language.Fixpoint.Smt.Serialize: isSMTSort :: Sort -> Bool
- Language.Fixpoint.Smt.Serialize: isSMTSymbol :: Symbol -> Bool
- Language.Fixpoint.Smt.Serialize: makeApplication :: Expr -> [Expr] -> SMT2 Expr
- Language.Fixpoint.Smt.Serialize: makeApplies :: Int -> [(Symbol, Sort)]
- Language.Fixpoint.Smt.Serialize: makeFunSymbol :: Expr -> Int -> Symbol
- Language.Fixpoint.Smt.Serialize: mkNe :: (SMTLIB2 a, SMTLIB2 a1) => a -> a1 -> Text
- Language.Fixpoint.Smt.Serialize: mkRel :: (SMTLIB2 a, SMTLIB2 a1) => Brel -> a -> a1 -> Text
- Language.Fixpoint.Smt.Serialize: smt2App :: Expr -> Text
- Language.Fixpoint.Smt.Serialize: smt2many :: [Text] -> Text
- Language.Fixpoint.Smt.Serialize: smt2s :: SMTLIB2 a => [a] -> Text
- Language.Fixpoint.Smt.Serialize: toInt :: Expr -> SMT2 Expr
- Language.Fixpoint.Smt.Theories: isBv :: FTycon -> Bool
- Language.Fixpoint.Smt.Theories: isTheorySymbol :: Symbol -> Bool
- Language.Fixpoint.Smt.Theories: theoryEnv :: HashMap Symbol Sort
- Language.Fixpoint.Smt.Types: SMTSt :: Int -> SMTEnv -> SMTSt
- Language.Fixpoint.Smt.Types: [cIn] :: Context -> Handle
- Language.Fixpoint.Smt.Types: [cLog] :: Context -> Maybe Handle
- Language.Fixpoint.Smt.Types: [cOut] :: Context -> Handle
- Language.Fixpoint.Smt.Types: [fresh] :: SMTSt -> Int
- Language.Fixpoint.Smt.Types: [pId] :: Context -> ProcessHandle
- Language.Fixpoint.Smt.Types: [smt2env] :: SMTSt -> SMTEnv
- Language.Fixpoint.Smt.Types: [smtenv] :: Context -> SMTEnv
- Language.Fixpoint.Smt.Types: [verbose] :: Context -> Bool
- Language.Fixpoint.Smt.Types: data SMTSt
- Language.Fixpoint.Smt.Types: defunc :: SMTLIB2 a => a -> SMT2 a
- Language.Fixpoint.Smt.Types: emptySMTEnv :: SEnv a
- Language.Fixpoint.Smt.Types: format :: Params ps => Format -> ps -> Text
- Language.Fixpoint.Smt.Types: freshSym :: MonadState SMTSt m => m Symbol
- Language.Fixpoint.Smt.Types: type SMT2 = State SMTSt
- Language.Fixpoint.Smt.Types: withExtendedEnv :: (Foldable t, MonadState SMTSt m) => t (Symbol, Sort) -> m b -> m b
- Language.Fixpoint.Solver.Eliminate: eliminate :: SInfo a -> (Solution, SInfo a)
- Language.Fixpoint.Solver.Graph: cGraph :: (TaggedC c a) => GInfo c a -> CGraph
- Language.Fixpoint.Solver.Graph: gSccs :: CGraph -> Int
- Language.Fixpoint.Solver.Graph: graphRanks :: Graph -> (Vertex -> DepEdge) -> (CMap Int, [[Vertex]])
- Language.Fixpoint.Solver.Graph: isTarget :: (TaggedC c a) => c a -> Bool
- Language.Fixpoint.Solver.Graph: kvReadBy :: (TaggedC c a) => GInfo c a -> KVRead
- Language.Fixpoint.Solver.Graph: kvWriteBy :: (TaggedC c a) => CMap (c a) -> CId -> [KVar]
- Language.Fixpoint.Solver.Graph: slice :: (TaggedC c a) => GInfo c a -> GInfo c a
- Language.Fixpoint.Solver.Monad: instance GHC.Generics.Constructor Language.Fixpoint.Solver.Monad.C1_0Stats
- Language.Fixpoint.Solver.Monad: instance GHC.Generics.Datatype Language.Fixpoint.Solver.Monad.D1Stats
- Language.Fixpoint.Solver.Monad: instance GHC.Generics.Selector Language.Fixpoint.Solver.Monad.S1_0_0Stats
- Language.Fixpoint.Solver.Monad: instance GHC.Generics.Selector Language.Fixpoint.Solver.Monad.S1_0_1Stats
- Language.Fixpoint.Solver.Monad: instance GHC.Generics.Selector Language.Fixpoint.Solver.Monad.S1_0_2Stats
- Language.Fixpoint.Solver.Monad: instance GHC.Generics.Selector Language.Fixpoint.Solver.Monad.S1_0_3Stats
- Language.Fixpoint.Solver.Monad: instance GHC.Generics.Selector Language.Fixpoint.Solver.Monad.S1_0_4Stats
- Language.Fixpoint.Solver.Monad: smtEnablrmbqi :: SolveM ()
- Language.Fixpoint.Solver.Solution: noKvars :: Expr -> Bool
- Language.Fixpoint.Solver.Solution: solutionGraph :: Solution -> KVGraph
- Language.Fixpoint.Solver.Solve: gradualSolve :: (Fixpoint a) => Config -> FixResult (SimpC a) -> SolveM (FixResult (SimpC a))
- Language.Fixpoint.Solver.TrivialSort: instance GHC.Generics.Constructor Language.Fixpoint.Solver.TrivialSort.C1_0NTV
- Language.Fixpoint.Solver.TrivialSort: instance GHC.Generics.Constructor Language.Fixpoint.Solver.TrivialSort.C1_1NTV
- Language.Fixpoint.Solver.TrivialSort: instance GHC.Generics.Constructor Language.Fixpoint.Solver.TrivialSort.C1_2NTV
- Language.Fixpoint.Solver.TrivialSort: instance GHC.Generics.Datatype Language.Fixpoint.Solver.TrivialSort.D1NTV
- Language.Fixpoint.Solver.Types: CGraph :: [DepEdge] -> CMap Int -> CSucc -> Int -> CGraph
- Language.Fixpoint.Solver.Types: Slice :: [CId] -> [CId] -> [DepEdge] -> Slice
- Language.Fixpoint.Solver.Types: [gEdges] :: CGraph -> [DepEdge]
- Language.Fixpoint.Solver.Types: [gRanks] :: CGraph -> CMap Int
- Language.Fixpoint.Solver.Types: [gSccs] :: CGraph -> Int
- Language.Fixpoint.Solver.Types: [gSucc] :: CGraph -> CSucc
- Language.Fixpoint.Solver.Types: [slConcCs] :: Slice -> [CId]
- Language.Fixpoint.Solver.Types: [slEdges] :: Slice -> [DepEdge]
- Language.Fixpoint.Solver.Types: [slKVarCs] :: Slice -> [CId]
- Language.Fixpoint.Solver.Types: data CGraph
- Language.Fixpoint.Solver.Types: data Slice
- Language.Fixpoint.Solver.Types: instance GHC.Classes.Eq Language.Fixpoint.Solver.Types.Slice
- Language.Fixpoint.Solver.Types: instance GHC.Show.Show Language.Fixpoint.Solver.Types.Slice
- Language.Fixpoint.Solver.Types: lookupCMap :: (?callStack :: CallStack) => CMap a -> CId -> a
- Language.Fixpoint.Solver.Types: type CId = Integer
- Language.Fixpoint.Solver.Types: type CMap a = HashMap CId a
- Language.Fixpoint.Solver.Types: type CSucc = CId -> [CId]
- Language.Fixpoint.Solver.Types: type DepEdge = (CId, CId, [CId])
- Language.Fixpoint.Solver.Types: type KVRead = HashMap KVar [CId]
- Language.Fixpoint.Solver.UniqifyBinds: instance GHC.Generics.Constructor Language.Fixpoint.Solver.UniqifyBinds.C1_0Ref
- Language.Fixpoint.Solver.UniqifyBinds: instance GHC.Generics.Constructor Language.Fixpoint.Solver.UniqifyBinds.C1_1Ref
- Language.Fixpoint.Solver.UniqifyBinds: instance GHC.Generics.Datatype Language.Fixpoint.Solver.UniqifyBinds.D1Ref
- Language.Fixpoint.Solver.Validate: sanitize :: SInfo a -> ValidateM (SInfo a)
- Language.Fixpoint.Solver.Validate: symbolSorts :: GInfo c a -> ValidateM [(Symbol, Sort)]
- Language.Fixpoint.Solver.Worklist: instance GHC.Classes.Eq Language.Fixpoint.Solver.Worklist.Rank
- Language.Fixpoint.Solver.Worklist: instance GHC.Show.Show Language.Fixpoint.Solver.Worklist.Rank
- Language.Fixpoint.SortCheck: unify :: Env -> Sort -> Sort -> Maybe TVSubst
- Language.Fixpoint.Types.Config: GQS :: Bool -> GenQualifierSort
- Language.Fixpoint.Types.Config: UAS :: Bool -> UeqAllSorts
- Language.Fixpoint.Types.Config: [genSorts] :: Config -> GenQualifierSort
- Language.Fixpoint.Types.Config: [inFile] :: Config -> FilePath
- Language.Fixpoint.Types.Config: [newcheck] :: Config -> Bool
- Language.Fixpoint.Types.Config: [outFile] :: Config -> FilePath
- Language.Fixpoint.Types.Config: [ueqAllSorts] :: Config -> UeqAllSorts
- Language.Fixpoint.Types.Config: class Command a
- Language.Fixpoint.Types.Config: command :: Command a => a -> String
- Language.Fixpoint.Types.Config: instance Data.Data.Data Language.Fixpoint.Types.Config.GenQualifierSort
- Language.Fixpoint.Types.Config: instance Data.Data.Data Language.Fixpoint.Types.Config.UeqAllSorts
- Language.Fixpoint.Types.Config: instance GHC.Classes.Eq Language.Fixpoint.Types.Config.GenQualifierSort
- Language.Fixpoint.Types.Config: instance GHC.Classes.Eq Language.Fixpoint.Types.Config.UeqAllSorts
- Language.Fixpoint.Types.Config: instance GHC.Generics.Constructor Language.Fixpoint.Types.Config.C1_0SMTSolver
- Language.Fixpoint.Types.Config: instance GHC.Generics.Constructor Language.Fixpoint.Types.Config.C1_1SMTSolver
- Language.Fixpoint.Types.Config: instance GHC.Generics.Constructor Language.Fixpoint.Types.Config.C1_2SMTSolver
- Language.Fixpoint.Types.Config: instance GHC.Generics.Datatype Language.Fixpoint.Types.Config.D1SMTSolver
- Language.Fixpoint.Types.Config: instance GHC.Show.Show Language.Fixpoint.Types.Config.GenQualifierSort
- Language.Fixpoint.Types.Config: instance GHC.Show.Show Language.Fixpoint.Types.Config.UeqAllSorts
- Language.Fixpoint.Types.Config: instance Language.Fixpoint.Types.Config.Command Language.Fixpoint.Types.Config.Config
- Language.Fixpoint.Types.Config: instance Language.Fixpoint.Types.Config.Command Language.Fixpoint.Types.Config.GenQualifierSort
- Language.Fixpoint.Types.Config: instance Language.Fixpoint.Types.Config.Command Language.Fixpoint.Types.Config.SMTSolver
- Language.Fixpoint.Types.Config: instance Language.Fixpoint.Types.Config.Command Language.Fixpoint.Types.Config.UeqAllSorts
- Language.Fixpoint.Types.Config: instance System.Console.CmdArgs.Default.Default Language.Fixpoint.Types.Config.GenQualifierSort
- Language.Fixpoint.Types.Config: instance System.Console.CmdArgs.Default.Default Language.Fixpoint.Types.Config.UeqAllSorts
- Language.Fixpoint.Types.Config: newtype GenQualifierSort
- Language.Fixpoint.Types.Config: newtype UeqAllSorts
- Language.Fixpoint.Types.Config: withTarget :: Config -> FilePath -> Config
- Language.Fixpoint.Types.Constraints: Cube :: IBindEnv -> Subst -> Cube
- Language.Fixpoint.Types.Constraints: EQL :: !Qualifier -> !Expr -> ![Expr] -> EQual
- Language.Fixpoint.Types.Constraints: Sol :: HashMap KVar a -> HashMap KVar Hyp -> Sol a
- Language.Fixpoint.Types.Constraints: [allowHO] :: GInfo c a -> !Bool
- Language.Fixpoint.Types.Constraints: [cuBinds] :: Cube -> IBindEnv
- Language.Fixpoint.Types.Constraints: [cuSubst] :: Cube -> Subst
- Language.Fixpoint.Types.Constraints: [eqPred] :: EQual -> !Expr
- Language.Fixpoint.Types.Constraints: [eqQual] :: EQual -> !Qualifier
- Language.Fixpoint.Types.Constraints: [fileName] :: GInfo c a -> FilePath
- Language.Fixpoint.Types.Constraints: [lits] :: GInfo c a -> !(SEnv Sort)
- Language.Fixpoint.Types.Constraints: [q_body] :: Qualifier -> Expr
- Language.Fixpoint.Types.Constraints: [q_name] :: Qualifier -> Symbol
- Language.Fixpoint.Types.Constraints: [q_params] :: Qualifier -> [(Symbol, Sort)]
- Language.Fixpoint.Types.Constraints: [q_pos] :: Qualifier -> !SourcePos
- Language.Fixpoint.Types.Constraints: [sHyp] :: Sol a -> HashMap KVar Hyp
- Language.Fixpoint.Types.Constraints: [sMap] :: Sol a -> HashMap KVar a
- Language.Fixpoint.Types.Constraints: data Cube
- Language.Fixpoint.Types.Constraints: data EQual
- Language.Fixpoint.Types.Constraints: data Sol a
- Language.Fixpoint.Types.Constraints: eQual :: Qualifier -> [Symbol] -> EQual
- Language.Fixpoint.Types.Constraints: instance (GHC.Classes.Eq a, GHC.Classes.Eq (c a)) => GHC.Classes.Eq (Language.Fixpoint.Types.Constraints.GInfo c a)
- Language.Fixpoint.Types.Constraints: instance (GHC.Show.Show a, GHC.Show.Show (c a), Language.Fixpoint.Types.PrettyPrint.Fixpoint a) => GHC.Show.Show (Language.Fixpoint.Types.Constraints.GInfo c a)
- Language.Fixpoint.Types.Constraints: instance Control.DeepSeq.NFData Language.Fixpoint.Types.Constraints.EQual
- Language.Fixpoint.Types.Constraints: instance Data.Data.Data Language.Fixpoint.Types.Constraints.EQual
- Language.Fixpoint.Types.Constraints: instance GHC.Base.Functor Language.Fixpoint.Types.Constraints.Sol
- Language.Fixpoint.Types.Constraints: instance GHC.Base.Monoid (Language.Fixpoint.Types.Constraints.Sol a)
- Language.Fixpoint.Types.Constraints: instance GHC.Classes.Eq Language.Fixpoint.Types.Constraints.EQual
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Constructor Language.Fixpoint.Types.Constraints.C1_0EQual
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Constructor Language.Fixpoint.Types.Constraints.C1_0GInfo
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Constructor Language.Fixpoint.Types.Constraints.C1_0Kuts
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Constructor Language.Fixpoint.Types.Constraints.C1_0Qualifier
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Constructor Language.Fixpoint.Types.Constraints.C1_0Result
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Constructor Language.Fixpoint.Types.Constraints.C1_0SimpC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Constructor Language.Fixpoint.Types.Constraints.C1_0SubC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Constructor Language.Fixpoint.Types.Constraints.C1_0WfC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Datatype Language.Fixpoint.Types.Constraints.D1EQual
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Datatype Language.Fixpoint.Types.Constraints.D1GInfo
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Datatype Language.Fixpoint.Types.Constraints.D1Kuts
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Datatype Language.Fixpoint.Types.Constraints.D1Qualifier
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Datatype Language.Fixpoint.Types.Constraints.D1Result
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Datatype Language.Fixpoint.Types.Constraints.D1SimpC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Datatype Language.Fixpoint.Types.Constraints.D1SubC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Datatype Language.Fixpoint.Types.Constraints.D1WfC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Generic Language.Fixpoint.Types.Constraints.EQual
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_0EQual
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_0GInfo
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_0Kuts
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_0Qualifier
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_0Result
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_0SimpC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_0SubC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_0WfC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_1EQual
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_1GInfo
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_1Qualifier
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_1Result
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_1SimpC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_1SubC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_1WfC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_2EQual
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_2GInfo
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_2Qualifier
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_2SimpC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_2SubC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_2WfC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_3GInfo
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_3Qualifier
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_3SimpC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_3SubC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_4GInfo
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_4SimpC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_4SubC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_5GInfo
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_5SubC
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_6GInfo
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_7GInfo
- Language.Fixpoint.Types.Constraints: instance GHC.Generics.Selector Language.Fixpoint.Types.Constraints.S1_0_8GInfo
- Language.Fixpoint.Types.Constraints: instance GHC.Show.Show Language.Fixpoint.Types.Constraints.EQual
- Language.Fixpoint.Types.Constraints: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Types.Constraints.EQual
- Language.Fixpoint.Types.Constraints: instance Language.Fixpoint.Types.PrettyPrint.PPrint a => Language.Fixpoint.Types.PrettyPrint.PPrint (Language.Fixpoint.Types.Constraints.Sol a)
- Language.Fixpoint.Types.Constraints: solFromList :: [(KVar, a)] -> [(KVar, Hyp)] -> Sol a
- Language.Fixpoint.Types.Constraints: solInsert :: KVar -> a -> Sol a -> Sol a
- Language.Fixpoint.Types.Constraints: solLookup :: Solution -> KVar -> QBind
- Language.Fixpoint.Types.Constraints: solResult :: Solution -> HashMap KVar Expr
- Language.Fixpoint.Types.Constraints: type Cand a = [(Expr, a)]
- Language.Fixpoint.Types.Constraints: type Hyp = ListNE Cube
- Language.Fixpoint.Types.Constraints: type QBind = [EQual]
- Language.Fixpoint.Types.Constraints: type Solution = Sol QBind
- Language.Fixpoint.Types.Environments: instance GHC.Generics.Constructor Language.Fixpoint.Types.Environments.C1_0IBindEnv
- Language.Fixpoint.Types.Environments: instance GHC.Generics.Constructor Language.Fixpoint.Types.Environments.C1_0SEnv
- Language.Fixpoint.Types.Environments: instance GHC.Generics.Constructor Language.Fixpoint.Types.Environments.C1_0SizedEnv
- Language.Fixpoint.Types.Environments: instance GHC.Generics.Datatype Language.Fixpoint.Types.Environments.D1IBindEnv
- Language.Fixpoint.Types.Environments: instance GHC.Generics.Datatype Language.Fixpoint.Types.Environments.D1SEnv
- Language.Fixpoint.Types.Environments: instance GHC.Generics.Datatype Language.Fixpoint.Types.Environments.D1SizedEnv
- Language.Fixpoint.Types.Environments: instance GHC.Generics.Selector Language.Fixpoint.Types.Environments.S1_0_0SEnv
- Language.Fixpoint.Types.Environments: instance GHC.Generics.Selector Language.Fixpoint.Types.Environments.S1_0_0SizedEnv
- Language.Fixpoint.Types.Environments: instance GHC.Generics.Selector Language.Fixpoint.Types.Environments.S1_0_1SizedEnv
- Language.Fixpoint.Types.Errors: instance Data.Serialize.Serialize Text.PrettyPrint.HughesPJ.TextDetails
- Language.Fixpoint.Types.Errors: instance GHC.Generics.Constructor Language.Fixpoint.Types.Errors.C1_0Error
- Language.Fixpoint.Types.Errors: instance GHC.Generics.Constructor Language.Fixpoint.Types.Errors.C1_0Error1
- Language.Fixpoint.Types.Errors: instance GHC.Generics.Constructor Language.Fixpoint.Types.Errors.C1_0FixResult
- Language.Fixpoint.Types.Errors: instance GHC.Generics.Constructor Language.Fixpoint.Types.Errors.C1_1FixResult
- Language.Fixpoint.Types.Errors: instance GHC.Generics.Constructor Language.Fixpoint.Types.Errors.C1_2FixResult
- Language.Fixpoint.Types.Errors: instance GHC.Generics.Datatype Language.Fixpoint.Types.Errors.D1Error
- Language.Fixpoint.Types.Errors: instance GHC.Generics.Datatype Language.Fixpoint.Types.Errors.D1Error1
- Language.Fixpoint.Types.Errors: instance GHC.Generics.Datatype Language.Fixpoint.Types.Errors.D1FixResult
- Language.Fixpoint.Types.Errors: instance GHC.Generics.Selector Language.Fixpoint.Types.Errors.S1_0_0Error1
- Language.Fixpoint.Types.Errors: instance GHC.Generics.Selector Language.Fixpoint.Types.Errors.S1_0_1Error1
- Language.Fixpoint.Types.Graphs: Cstr :: Integer -> CVertex
- Language.Fixpoint.Types.Graphs: DKVar :: KVar -> CVertex
- Language.Fixpoint.Types.Graphs: KVar :: KVar -> CVertex
- Language.Fixpoint.Types.Graphs: data CVertex
- Language.Fixpoint.Types.Graphs: instance Data.Hashable.Class.Hashable Language.Fixpoint.Types.Graphs.CVertex
- Language.Fixpoint.Types.Graphs: instance GHC.Classes.Eq Language.Fixpoint.Types.Graphs.CVertex
- Language.Fixpoint.Types.Graphs: instance GHC.Classes.Ord Language.Fixpoint.Types.Graphs.CVertex
- Language.Fixpoint.Types.Graphs: instance GHC.Generics.Constructor Language.Fixpoint.Types.Graphs.C1_0CVertex
- Language.Fixpoint.Types.Graphs: instance GHC.Generics.Constructor Language.Fixpoint.Types.Graphs.C1_1CVertex
- Language.Fixpoint.Types.Graphs: instance GHC.Generics.Constructor Language.Fixpoint.Types.Graphs.C1_2CVertex
- Language.Fixpoint.Types.Graphs: instance GHC.Generics.Datatype Language.Fixpoint.Types.Graphs.D1CVertex
- Language.Fixpoint.Types.Graphs: instance GHC.Generics.Generic Language.Fixpoint.Types.Graphs.CVertex
- Language.Fixpoint.Types.Graphs: instance GHC.Show.Show Language.Fixpoint.Types.Graphs.CVertex
- Language.Fixpoint.Types.Graphs: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Types.Graphs.CVertex
- Language.Fixpoint.Types.Graphs: type CEdge = (CVertex, CVertex)
- Language.Fixpoint.Types.Graphs: type Comps a = [[a]]
- Language.Fixpoint.Types.Graphs: type KVComps = Comps CVertex
- Language.Fixpoint.Types.Graphs: type KVGraph = [(CVertex, CVertex, [CVertex])]
- Language.Fixpoint.Types.Graphs: writeGraph :: FilePath -> KVGraph -> IO ()
- Language.Fixpoint.Types.Names: hpropConName :: Symbol
- Language.Fixpoint.Types.Names: instance GHC.Generics.Constructor Language.Fixpoint.Types.Names.C1_0InternedText
- Language.Fixpoint.Types.Names: instance GHC.Generics.Constructor Language.Fixpoint.Types.Names.C1_0Symbol
- Language.Fixpoint.Types.Names: instance GHC.Generics.Datatype Language.Fixpoint.Types.Names.D1InternedText
- Language.Fixpoint.Types.Names: instance GHC.Generics.Datatype Language.Fixpoint.Types.Names.D1Symbol
- Language.Fixpoint.Types.Names: instance GHC.Generics.Selector Language.Fixpoint.Types.Names.S1_0_0InternedText
- Language.Fixpoint.Types.Names: instance GHC.Generics.Selector Language.Fixpoint.Types.Names.S1_0_0Symbol
- Language.Fixpoint.Types.Names: instance GHC.Generics.Selector Language.Fixpoint.Types.Names.S1_0_1InternedText
- Language.Fixpoint.Types.Names: instance GHC.Generics.Selector Language.Fixpoint.Types.Names.S1_0_1Symbol
- Language.Fixpoint.Types.Names: instance GHC.Generics.Selector Language.Fixpoint.Types.Names.S1_0_2Symbol
- Language.Fixpoint.Types.Names: propConName :: Symbol
- Language.Fixpoint.Types.PrettyPrint: instance Language.Fixpoint.Types.PrettyPrint.PPrint GHC.Base.String
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_0Bop
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_0Brel
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_0Constant
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_0Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_0KVar
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_0Reft
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_0SortedReft
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_0Subst
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_0SymConst
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_10Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_11Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_12Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_13Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_14Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_15Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_16Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_17Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_18Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_19Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_1Bop
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_1Brel
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_1Constant
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_1Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_20Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_2Bop
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_2Brel
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_2Constant
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_2Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_3Bop
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_3Brel
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_3Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_4Bop
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_4Brel
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_4Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_5Bop
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_5Brel
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_5Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_6Bop
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_6Brel
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_6Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_7Brel
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_7Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_8Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Constructor Language.Fixpoint.Types.Refinements.C1_9Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Datatype Language.Fixpoint.Types.Refinements.D1Bop
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Datatype Language.Fixpoint.Types.Refinements.D1Brel
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Datatype Language.Fixpoint.Types.Refinements.D1Constant
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Datatype Language.Fixpoint.Types.Refinements.D1Expr
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Datatype Language.Fixpoint.Types.Refinements.D1KVar
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Datatype Language.Fixpoint.Types.Refinements.D1Reft
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Datatype Language.Fixpoint.Types.Refinements.D1SortedReft
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Datatype Language.Fixpoint.Types.Refinements.D1Subst
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Datatype Language.Fixpoint.Types.Refinements.D1SymConst
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Selector Language.Fixpoint.Types.Refinements.S1_0_0KVar
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Selector Language.Fixpoint.Types.Refinements.S1_0_0SortedReft
- Language.Fixpoint.Types.Refinements: instance GHC.Generics.Selector Language.Fixpoint.Types.Refinements.S1_0_1SortedReft
- Language.Fixpoint.Types.Refinements: isEVar :: Expr -> Bool
- Language.Fixpoint.Types.Sorts: instance GHC.Generics.Constructor Language.Fixpoint.Types.Sorts.C1_0FTycon
- Language.Fixpoint.Types.Sorts: instance GHC.Generics.Constructor Language.Fixpoint.Types.Sorts.C1_0Sort
- Language.Fixpoint.Types.Sorts: instance GHC.Generics.Constructor Language.Fixpoint.Types.Sorts.C1_0Sub
- Language.Fixpoint.Types.Sorts: instance GHC.Generics.Constructor Language.Fixpoint.Types.Sorts.C1_1Sort
- Language.Fixpoint.Types.Sorts: instance GHC.Generics.Constructor Language.Fixpoint.Types.Sorts.C1_2Sort
- Language.Fixpoint.Types.Sorts: instance GHC.Generics.Constructor Language.Fixpoint.Types.Sorts.C1_3Sort
- Language.Fixpoint.Types.Sorts: instance GHC.Generics.Constructor Language.Fixpoint.Types.Sorts.C1_4Sort
- Language.Fixpoint.Types.Sorts: instance GHC.Generics.Constructor Language.Fixpoint.Types.Sorts.C1_5Sort
- Language.Fixpoint.Types.Sorts: instance GHC.Generics.Constructor Language.Fixpoint.Types.Sorts.C1_6Sort
- Language.Fixpoint.Types.Sorts: instance GHC.Generics.Constructor Language.Fixpoint.Types.Sorts.C1_7Sort
- Language.Fixpoint.Types.Sorts: instance GHC.Generics.Constructor Language.Fixpoint.Types.Sorts.C1_8Sort
- Language.Fixpoint.Types.Sorts: instance GHC.Generics.Constructor Language.Fixpoint.Types.Sorts.C1_9Sort
- Language.Fixpoint.Types.Sorts: instance GHC.Generics.Datatype Language.Fixpoint.Types.Sorts.D1FTycon
- Language.Fixpoint.Types.Sorts: instance GHC.Generics.Datatype Language.Fixpoint.Types.Sorts.D1Sort
- Language.Fixpoint.Types.Sorts: instance GHC.Generics.Datatype Language.Fixpoint.Types.Sorts.D1Sub
- Language.Fixpoint.Types.Spans: instance GHC.Generics.Constructor Language.Fixpoint.Types.Spans.C1_0Located
- Language.Fixpoint.Types.Spans: instance GHC.Generics.Constructor Language.Fixpoint.Types.Spans.C1_0SrcSpan
- Language.Fixpoint.Types.Spans: instance GHC.Generics.Datatype Language.Fixpoint.Types.Spans.D1Located
- Language.Fixpoint.Types.Spans: instance GHC.Generics.Datatype Language.Fixpoint.Types.Spans.D1SrcSpan
- Language.Fixpoint.Types.Spans: instance GHC.Generics.Selector Language.Fixpoint.Types.Spans.S1_0_0Located
- Language.Fixpoint.Types.Spans: instance GHC.Generics.Selector Language.Fixpoint.Types.Spans.S1_0_0SrcSpan
- Language.Fixpoint.Types.Spans: instance GHC.Generics.Selector Language.Fixpoint.Types.Spans.S1_0_1Located
- Language.Fixpoint.Types.Spans: instance GHC.Generics.Selector Language.Fixpoint.Types.Spans.S1_0_1SrcSpan
- Language.Fixpoint.Types.Spans: instance GHC.Generics.Selector Language.Fixpoint.Types.Spans.S1_0_2Located
- Language.Fixpoint.Types.Visitor: instance Language.Fixpoint.Types.Visitor.SymConsts (Language.Fixpoint.Types.Constraints.FInfo a)
- Language.Fixpoint.Types.Visitor: instance Language.Fixpoint.Types.Visitor.Visitable (Language.Fixpoint.Types.Constraints.SInfo a)
- Language.Fixpoint.Utils.Statistics: instance GHC.Generics.Constructor Language.Fixpoint.Utils.Statistics.C1_0Stats
- Language.Fixpoint.Utils.Statistics: instance GHC.Generics.Datatype Language.Fixpoint.Utils.Statistics.D1Stats
- Language.Fixpoint.Utils.Statistics: instance GHC.Generics.Selector Language.Fixpoint.Utils.Statistics.S1_0_0Stats
- Language.Fixpoint.Utils.Statistics: instance GHC.Generics.Selector Language.Fixpoint.Utils.Statistics.S1_0_1Stats
- Language.Fixpoint.Utils.Statistics: instance GHC.Generics.Selector Language.Fixpoint.Utils.Statistics.S1_0_2Stats
- Language.Fixpoint.Utils.Statistics: instance GHC.Generics.Selector Language.Fixpoint.Utils.Statistics.S1_0_3Stats
- Language.Fixpoint.Utils.Statistics: instance GHC.Generics.Selector Language.Fixpoint.Utils.Statistics.S1_0_4Stats
- Language.Fixpoint.Utils.Statistics: instance GHC.Generics.Selector Language.Fixpoint.Utils.Statistics.S1_0_5Stats
+ Language.Fixpoint.Defunctionalize: class Defunc a
+ Language.Fixpoint.Defunctionalize: defunc :: Defunc a => a -> DF a
+ Language.Fixpoint.Defunctionalize: defuncAny :: Defunc a => Config -> SEnv Sort -> a -> a
+ Language.Fixpoint.Defunctionalize: defunctionalize :: (Fixpoint a) => Config -> SInfo a -> SInfo a
+ Language.Fixpoint.Defunctionalize: instance (Language.Fixpoint.Defunctionalize.Defunc (c a), Language.Fixpoint.Types.Constraints.TaggedC c a) => Language.Fixpoint.Defunctionalize.Defunc (Language.Fixpoint.Types.Constraints.GInfo c a)
+ Language.Fixpoint.Defunctionalize: instance (Language.Fixpoint.Defunctionalize.Defunc a, GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Language.Fixpoint.Defunctionalize.Defunc (Data.HashMap.Base.HashMap k a)
+ Language.Fixpoint.Defunctionalize: instance Language.Fixpoint.Defunctionalize.Defunc (Language.Fixpoint.Types.Constraints.SimpC a)
+ Language.Fixpoint.Defunctionalize: instance Language.Fixpoint.Defunctionalize.Defunc (Language.Fixpoint.Types.Constraints.WfC a)
+ Language.Fixpoint.Defunctionalize: instance Language.Fixpoint.Defunctionalize.Defunc (Language.Fixpoint.Types.Names.Symbol, Language.Fixpoint.Types.Refinements.SortedReft)
+ Language.Fixpoint.Defunctionalize: instance Language.Fixpoint.Defunctionalize.Defunc (Language.Fixpoint.Types.Names.Symbol, Language.Fixpoint.Types.Sorts.Sort)
+ Language.Fixpoint.Defunctionalize: instance Language.Fixpoint.Defunctionalize.Defunc Language.Fixpoint.Types.Environments.BindEnv
+ Language.Fixpoint.Defunctionalize: instance Language.Fixpoint.Defunctionalize.Defunc Language.Fixpoint.Types.Refinements.Expr
+ Language.Fixpoint.Defunctionalize: instance Language.Fixpoint.Defunctionalize.Defunc Language.Fixpoint.Types.Refinements.Reft
+ Language.Fixpoint.Defunctionalize: instance Language.Fixpoint.Defunctionalize.Defunc Language.Fixpoint.Types.Refinements.SortedReft
+ Language.Fixpoint.Defunctionalize: instance Language.Fixpoint.Defunctionalize.Defunc Language.Fixpoint.Types.Sorts.Sort
+ Language.Fixpoint.Defunctionalize: instance Language.Fixpoint.Defunctionalize.Defunc a => Language.Fixpoint.Defunctionalize.Defunc (Language.Fixpoint.Types.Environments.SEnv a)
+ Language.Fixpoint.Defunctionalize: instance Language.Fixpoint.Defunctionalize.Defunc a => Language.Fixpoint.Defunctionalize.Defunc (Language.Fixpoint.Types.Triggers.Triggered a)
+ Language.Fixpoint.Defunctionalize: instance Language.Fixpoint.Defunctionalize.Defunc a => Language.Fixpoint.Defunctionalize.Defunc [a]
+ Language.Fixpoint.Defunctionalize: makeLamArg :: Sort -> Int -> Symbol
+ Language.Fixpoint.Graph.Deps: Deps :: !(HashSet a) -> !(HashSet a) -> Elims a
+ Language.Fixpoint.Graph.Deps: [depCuts] :: Elims a -> !(HashSet a)
+ Language.Fixpoint.Graph.Deps: [depNonCuts] :: Elims a -> !(HashSet a)
+ Language.Fixpoint.Graph.Deps: data Elims a
+ Language.Fixpoint.Graph.Deps: decompose :: (TaggedC c a) => GInfo c a -> KVComps
+ Language.Fixpoint.Graph.Deps: elimDeps :: SInfo a -> [CEdge] -> HashSet KVar -> CDeps
+ Language.Fixpoint.Graph.Deps: elimVars :: (TaggedC c a) => Config -> GInfo c a -> ([CEdge], Elims KVar)
+ Language.Fixpoint.Graph.Deps: graphStatistics :: Config -> SInfo a -> IO ()
+ Language.Fixpoint.Graph.Deps: instance (GHC.Classes.Eq a, Data.Hashable.Class.Hashable a) => GHC.Base.Monoid (Language.Fixpoint.Graph.Deps.Elims a)
+ Language.Fixpoint.Graph.Deps: instance GHC.Show.Show a => GHC.Show.Show (Language.Fixpoint.Graph.Deps.Elims a)
+ Language.Fixpoint.Graph.Deps: instance Language.Fixpoint.Types.PrettyPrint.PPrint (Language.Fixpoint.Graph.Deps.Elims a)
+ Language.Fixpoint.Graph.Deps: instance Language.Fixpoint.Types.PrettyPrint.PTable Language.Fixpoint.Graph.Deps.Stats
+ Language.Fixpoint.Graph.Deps: isTarget :: (TaggedC c a) => c a -> Bool
+ Language.Fixpoint.Graph.Deps: kvEdges :: (TaggedC c a) => GInfo c a -> [CEdge]
+ Language.Fixpoint.Graph.Deps: slice :: (TaggedC c a) => Config -> GInfo c a -> GInfo c a
+ Language.Fixpoint.Graph.Indexed: IKVGraph :: !(HashMap CVertex (HashSet CVertex)) -> !(HashMap CVertex (HashSet CVertex)) -> IKVGraph
+ Language.Fixpoint.Graph.Indexed: [igPred] :: IKVGraph -> !(HashMap CVertex (HashSet CVertex))
+ Language.Fixpoint.Graph.Indexed: [igSucc] :: IKVGraph -> !(HashMap CVertex (HashSet CVertex))
+ Language.Fixpoint.Graph.Indexed: addLinks :: IKVGraph -> [CEdge] -> IKVGraph
+ Language.Fixpoint.Graph.Indexed: data IKVGraph
+ Language.Fixpoint.Graph.Indexed: delNodes :: IKVGraph -> [CVertex] -> IKVGraph
+ Language.Fixpoint.Graph.Indexed: edgesIkvg :: [CEdge] -> IKVGraph
+ Language.Fixpoint.Graph.Indexed: getPreds :: IKVGraph -> CVertex -> [CVertex]
+ Language.Fixpoint.Graph.Indexed: getSuccs :: IKVGraph -> CVertex -> [CVertex]
+ Language.Fixpoint.Graph.Indexed: ikvgEdges :: IKVGraph -> [CEdge]
+ Language.Fixpoint.Graph.Indexed: instance GHC.Show.Show Language.Fixpoint.Graph.Indexed.IKVGraph
+ Language.Fixpoint.Graph.Partition: CPart :: !(HashMap KVar (WfC a)) -> !(HashMap Integer (SubC a)) -> CPart a
+ Language.Fixpoint.Graph.Partition: MCInfo :: !Int -> !Int -> !Int -> MCInfo
+ Language.Fixpoint.Graph.Partition: [mcCores] :: MCInfo -> !Int
+ Language.Fixpoint.Graph.Partition: [mcMaxPartSize] :: MCInfo -> !Int
+ Language.Fixpoint.Graph.Partition: [mcMinPartSize] :: MCInfo -> !Int
+ Language.Fixpoint.Graph.Partition: [pcm] :: CPart a -> !(HashMap Integer (SubC a))
+ Language.Fixpoint.Graph.Partition: [pws] :: CPart a -> !(HashMap KVar (WfC a))
+ Language.Fixpoint.Graph.Partition: data CPart a
+ Language.Fixpoint.Graph.Partition: data MCInfo
+ Language.Fixpoint.Graph.Partition: dumpPartitions :: (Fixpoint a) => Config -> [FInfo a] -> IO ()
+ Language.Fixpoint.Graph.Partition: instance GHC.Base.Monoid (Language.Fixpoint.Graph.Partition.CPart a)
+ Language.Fixpoint.Graph.Partition: instance GHC.Show.Show Language.Fixpoint.Graph.Partition.MCInfo
+ Language.Fixpoint.Graph.Partition: mcInfo :: Config -> IO MCInfo
+ Language.Fixpoint.Graph.Partition: partition :: (Fixpoint a) => Config -> FInfo a -> IO (Result (Integer, a))
+ Language.Fixpoint.Graph.Partition: partition' :: Maybe MCInfo -> FInfo a -> [FInfo a]
+ Language.Fixpoint.Graph.Partition: partitionN :: MCInfo -> FInfo a -> [CPart a] -> [FInfo a]
+ Language.Fixpoint.Graph.Reducible: isReducible :: SInfo a -> Bool
+ Language.Fixpoint.Graph.Types: CDs :: !(CMap [SubcId]) -> !(CMap [KVar]) -> !(CMap Rank) -> !Int -> CDeps
+ Language.Fixpoint.Graph.Types: CGraph :: [DepEdge] -> !(CMap Int) -> !(CMap [SubcId]) -> !Int -> CGraph
+ Language.Fixpoint.Graph.Types: Cstr :: !Integer -> CVertex
+ Language.Fixpoint.Graph.Types: DKVar :: !KVar -> CVertex
+ Language.Fixpoint.Graph.Types: KVGraph :: [(CVertex, CVertex, [CVertex])] -> KVGraph
+ Language.Fixpoint.Graph.Types: KVar :: !KVar -> CVertex
+ Language.Fixpoint.Graph.Types: Rank :: !Int -> !Int -> !Tag -> Rank
+ Language.Fixpoint.Graph.Types: SI :: !(Sol b QBind) -> !(SInfo a) -> !CDeps -> !(HashSet KVar) -> SolverInfo a b
+ Language.Fixpoint.Graph.Types: Slice :: [SubcId] -> [SubcId] -> [DepEdge] -> Slice
+ Language.Fixpoint.Graph.Types: [cNumScc] :: CDeps -> !Int
+ Language.Fixpoint.Graph.Types: [cPrev] :: CDeps -> !(CMap [KVar])
+ Language.Fixpoint.Graph.Types: [cRank] :: CDeps -> !(CMap Rank)
+ Language.Fixpoint.Graph.Types: [cSucc] :: CDeps -> !(CMap [SubcId])
+ Language.Fixpoint.Graph.Types: [gEdges] :: CGraph -> [DepEdge]
+ Language.Fixpoint.Graph.Types: [gRanks] :: CGraph -> !(CMap Int)
+ Language.Fixpoint.Graph.Types: [gSccs] :: CGraph -> !Int
+ Language.Fixpoint.Graph.Types: [gSucc] :: CGraph -> !(CMap [SubcId])
+ Language.Fixpoint.Graph.Types: [kvgEdges] :: KVGraph -> [(CVertex, CVertex, [CVertex])]
+ Language.Fixpoint.Graph.Types: [rIcc] :: Rank -> !Int
+ Language.Fixpoint.Graph.Types: [rScc] :: Rank -> !Int
+ Language.Fixpoint.Graph.Types: [rTag] :: Rank -> !Tag
+ Language.Fixpoint.Graph.Types: [siDeps] :: SolverInfo a b -> !CDeps
+ Language.Fixpoint.Graph.Types: [siQuery] :: SolverInfo a b -> !(SInfo a)
+ Language.Fixpoint.Graph.Types: [siSol] :: SolverInfo a b -> !(Sol b QBind)
+ Language.Fixpoint.Graph.Types: [siVars] :: SolverInfo a b -> !(HashSet KVar)
+ Language.Fixpoint.Graph.Types: [slConcCs] :: Slice -> [SubcId]
+ Language.Fixpoint.Graph.Types: [slEdges] :: Slice -> [DepEdge]
+ Language.Fixpoint.Graph.Types: [slKVarCs] :: Slice -> [SubcId]
+ Language.Fixpoint.Graph.Types: data CDeps
+ Language.Fixpoint.Graph.Types: data CGraph
+ Language.Fixpoint.Graph.Types: data CVertex
+ Language.Fixpoint.Graph.Types: data KVGraph
+ Language.Fixpoint.Graph.Types: data Rank
+ Language.Fixpoint.Graph.Types: data Slice
+ Language.Fixpoint.Graph.Types: data SolverInfo a b
+ Language.Fixpoint.Graph.Types: instance Data.Hashable.Class.Hashable Language.Fixpoint.Graph.Types.CVertex
+ Language.Fixpoint.Graph.Types: instance GHC.Classes.Eq Language.Fixpoint.Graph.Types.CVertex
+ Language.Fixpoint.Graph.Types: instance GHC.Classes.Eq Language.Fixpoint.Graph.Types.Rank
+ Language.Fixpoint.Graph.Types: instance GHC.Classes.Eq Language.Fixpoint.Graph.Types.Slice
+ Language.Fixpoint.Graph.Types: instance GHC.Classes.Ord Language.Fixpoint.Graph.Types.CVertex
+ Language.Fixpoint.Graph.Types: instance GHC.Generics.Generic Language.Fixpoint.Graph.Types.CVertex
+ Language.Fixpoint.Graph.Types: instance GHC.Show.Show Language.Fixpoint.Graph.Types.CVertex
+ Language.Fixpoint.Graph.Types: instance GHC.Show.Show Language.Fixpoint.Graph.Types.Rank
+ Language.Fixpoint.Graph.Types: instance GHC.Show.Show Language.Fixpoint.Graph.Types.Slice
+ Language.Fixpoint.Graph.Types: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Graph.Types.CVertex
+ Language.Fixpoint.Graph.Types: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Graph.Types.KVGraph
+ Language.Fixpoint.Graph.Types: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Graph.Types.Rank
+ Language.Fixpoint.Graph.Types: isRealEdge :: CEdge -> Bool
+ Language.Fixpoint.Graph.Types: lookupCMap :: (?callStack :: CallStack) => CMap a -> SubcId -> a
+ Language.Fixpoint.Graph.Types: type CEdge = (CVertex, CVertex)
+ Language.Fixpoint.Graph.Types: type CMap a = HashMap SubcId a
+ Language.Fixpoint.Graph.Types: type Comps a = [[a]]
+ Language.Fixpoint.Graph.Types: type DepEdge = (SubcId, SubcId, [SubcId])
+ Language.Fixpoint.Graph.Types: type KVComps = Comps CVertex
+ Language.Fixpoint.Graph.Types: type KVRead = HashMap KVar [SubcId]
+ Language.Fixpoint.Graph.Types: type SubcId = Integer
+ Language.Fixpoint.Graph.Types: writeEdges :: FilePath -> [CEdge] -> IO ()
+ Language.Fixpoint.Graph.Types: writeGraph :: FilePath -> KVGraph -> IO ()
+ Language.Fixpoint.Minimize: minKvars :: (NFData a, Fixpoint a) => Config -> Solver a -> FInfo a -> IO (Result (Integer, a))
+ Language.Fixpoint.Minimize: minQuals :: (NFData a, Fixpoint a) => Config -> Solver a -> FInfo a -> IO (Result (Integer, a))
+ Language.Fixpoint.Misc: allCombinations :: [[a]] -> [[a]]
+ Language.Fixpoint.Misc: allMap :: (Eq k, Hashable k) => (v -> Bool) -> HashMap k v -> Bool
+ Language.Fixpoint.Misc: coalesce :: (EqHash v) => [ListNE v] -> [ListNE v]
+ Language.Fixpoint.Misc: coalesceEdges :: (EqHash v) => [ListNE v] -> [(v, v, [v])]
+ Language.Fixpoint.Misc: componentsWith :: (Ord c) => (a -> [(b, c, [c])]) -> a -> [[b]]
+ Language.Fixpoint.Misc: getUniqueInt :: IO Int
+ Language.Fixpoint.Misc: mapEither :: (a -> Either b c) -> [a] -> ([b], [c])
+ Language.Fixpoint.Misc: mapFst :: (a -> c) -> (a, b) -> (c, b)
+ Language.Fixpoint.Misc: mapSnd :: (b -> c) -> (a, b) -> (a, c)
+ Language.Fixpoint.Misc: removes :: (Eq k, Hashable k, Eq v) => k -> v -> HashMap k [v] -> HashMap k [v]
+ Language.Fixpoint.Misc: secondM :: Functor f => (b -> f c) -> (a, b) -> f (a, c)
+ Language.Fixpoint.Misc: singleton :: a -> [a]
+ Language.Fixpoint.Misc: type (|->) a b = HashMap a b
+ Language.Fixpoint.Misc: type EqHash a = (Eq a, Ord a, Hashable a)
+ Language.Fixpoint.Misc: whenM :: (Monad m) => m Bool -> m () -> m ()
+ Language.Fixpoint.Parse: AssocLeft :: Assoc
+ Language.Fixpoint.Parse: AssocNone :: Assoc
+ Language.Fixpoint.Parse: AssocRight :: Assoc
+ Language.Fixpoint.Parse: FInfix :: Maybe Int -> String -> Maybe (Expr -> Expr -> Expr) -> Assoc -> Fixity
+ Language.Fixpoint.Parse: FPostfix :: Maybe Int -> String -> Maybe (Expr -> Expr) -> Fixity
+ Language.Fixpoint.Parse: FPrefix :: Maybe Int -> String -> Maybe (Expr -> Expr) -> Fixity
+ Language.Fixpoint.Parse: [fassoc] :: Fixity -> Assoc
+ Language.Fixpoint.Parse: [fname] :: Fixity -> String
+ Language.Fixpoint.Parse: [fop1] :: Fixity -> Maybe (Expr -> Expr)
+ Language.Fixpoint.Parse: [fop2] :: Fixity -> Maybe (Expr -> Expr -> Expr)
+ Language.Fixpoint.Parse: [fpred] :: Fixity -> Maybe Int
+ Language.Fixpoint.Parse: addOperatorP :: Fixity -> Parser ()
+ Language.Fixpoint.Parse: data Assoc :: *
+ Language.Fixpoint.Parse: data Fixity
+ Language.Fixpoint.Parse: data PState
+ Language.Fixpoint.Parse: expr0P :: Parser Expr
+ Language.Fixpoint.Parse: infixIdP :: Parser String
+ Language.Fixpoint.Parse: initPState :: PState
+ Language.Fixpoint.Parse: instance Language.Fixpoint.Parse.Inputable (Language.Fixpoint.Types.Constraints.FInfoWithOpts ())
+ Language.Fixpoint.Smt.Interface: AssertAxiom :: !(Triggered Expr) -> Command
+ Language.Fixpoint.Smt.Interface: [ctxAeq] :: Context -> !Bool
+ Language.Fixpoint.Smt.Interface: [ctxBeq] :: Context -> !Bool
+ Language.Fixpoint.Smt.Interface: [ctxCin] :: Context -> !Handle
+ Language.Fixpoint.Smt.Interface: [ctxCout] :: Context -> !Handle
+ Language.Fixpoint.Smt.Interface: [ctxExt] :: Context -> !Bool
+ Language.Fixpoint.Smt.Interface: [ctxLog] :: Context -> !(Maybe Handle)
+ Language.Fixpoint.Smt.Interface: [ctxNorm] :: Context -> !Bool
+ Language.Fixpoint.Smt.Interface: [ctxPid] :: Context -> !ProcessHandle
+ Language.Fixpoint.Smt.Interface: [ctxSmtEnv] :: Context -> !SMTEnv
+ Language.Fixpoint.Smt.Interface: [ctxVerbose] :: Context -> !Bool
+ Language.Fixpoint.Smt.Interface: checkValid' :: Context -> [(Symbol, Sort)] -> Expr -> Expr -> IO Bool
+ Language.Fixpoint.Smt.Interface: makeSmtContext :: Config -> FilePath -> [(Symbol, Sort)] -> IO Context
+ Language.Fixpoint.Smt.Interface: smtAssertAxiom :: Context -> Triggered Expr -> IO ()
+ Language.Fixpoint.Smt.Interface: smtDecls :: Context -> [(Symbol, Sort)] -> IO ()
+ Language.Fixpoint.Smt.Interface: smtPop :: Context -> IO ()
+ Language.Fixpoint.Smt.Interface: smtPush :: Context -> IO ()
+ Language.Fixpoint.Smt.Serialize: instance Language.Fixpoint.Smt.Types.SMTLIB2 (Language.Fixpoint.Types.Triggers.Triggered Language.Fixpoint.Types.Refinements.Expr)
+ Language.Fixpoint.Smt.Theories: axiomLiterals :: [(Symbol, Sort)] -> [Expr]
+ Language.Fixpoint.Smt.Theories: isConName :: Symbol -> FTycon -> Bool
+ Language.Fixpoint.Smt.Theories: isSmt2App :: Expr -> [a] -> Bool
+ Language.Fixpoint.Smt.Theories: theorySEnv :: SEnv Sort
+ Language.Fixpoint.Smt.Theories: toInt :: Expr -> Sort -> Expr
+ Language.Fixpoint.Smt.Types: AssertAxiom :: !(Triggered Expr) -> Command
+ Language.Fixpoint.Smt.Types: [ctxAeq] :: Context -> !Bool
+ Language.Fixpoint.Smt.Types: [ctxBeq] :: Context -> !Bool
+ Language.Fixpoint.Smt.Types: [ctxCin] :: Context -> !Handle
+ Language.Fixpoint.Smt.Types: [ctxCout] :: Context -> !Handle
+ Language.Fixpoint.Smt.Types: [ctxExt] :: Context -> !Bool
+ Language.Fixpoint.Smt.Types: [ctxLog] :: Context -> !(Maybe Handle)
+ Language.Fixpoint.Smt.Types: [ctxNorm] :: Context -> !Bool
+ Language.Fixpoint.Smt.Types: [ctxPid] :: Context -> !ProcessHandle
+ Language.Fixpoint.Smt.Types: [ctxSmtEnv] :: Context -> !SMTEnv
+ Language.Fixpoint.Smt.Types: [ctxVerbose] :: Context -> !Bool
+ Language.Fixpoint.Smt.Types: [tsInterp] :: TheorySymbol -> !Bool
+ Language.Fixpoint.Smt.Types: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Smt.Types.Command
+ Language.Fixpoint.Smt.Types: symbolBuilder :: Symbol -> Builder
+ Language.Fixpoint.Solver.Eliminate: solverInfo :: Config -> SInfo a -> SolverInfo a b
+ Language.Fixpoint.Solver.GradualSolution: init :: Config -> SInfo a -> HashSet KVar -> GSolution
+ Language.Fixpoint.Solver.GradualSolution: instance GHC.Base.Functor Language.Fixpoint.Solver.GradualSolution.GSelect
+ Language.Fixpoint.Solver.GradualSolution: instance GHC.Base.Monoid Language.Fixpoint.Solver.GradualSolution.KInfo
+ Language.Fixpoint.Solver.GradualSolution: instance GHC.Classes.Eq Language.Fixpoint.Solver.GradualSolution.KInfo
+ Language.Fixpoint.Solver.GradualSolution: instance GHC.Classes.Ord Language.Fixpoint.Solver.GradualSolution.KInfo
+ Language.Fixpoint.Solver.GradualSolution: instance GHC.Show.Show Language.Fixpoint.Solver.GradualSolution.KInfo
+ Language.Fixpoint.Solver.GradualSolution: instance GHC.Show.Show a => GHC.Show.Show (Language.Fixpoint.Solver.GradualSolution.GSelect a)
+ Language.Fixpoint.Solver.GradualSolution: lhsPred :: SolEnv -> GSolution -> SimpC a -> [([(KVar, QBind)], Expr)]
+ Language.Fixpoint.Solver.GradualSolution: update :: Sol a QBind -> [KVar] -> [(KVar, EQual)] -> (Bool, Sol a QBind)
+ Language.Fixpoint.Solver.GradualSolve: solveGradual :: (NFData a, Fixpoint a) => Config -> SInfo a -> IO (Result (Integer, a))
+ Language.Fixpoint.Solver.Instantiate: instance GHC.Show.Show Language.Fixpoint.Solver.Instantiate.Occurence
+ Language.Fixpoint.Solver.Instantiate: instance Language.Fixpoint.Types.Refinements.Expression (Language.Fixpoint.Types.Names.Symbol, Language.Fixpoint.Types.Refinements.SortedReft)
+ Language.Fixpoint.Solver.Instantiate: instantiateAxioms :: Config -> Context -> BindEnv -> SEnv Sort -> AxiomEnv -> Integer -> SubC c -> IO (SubC c)
+ Language.Fixpoint.Solver.Instantiate: instantiateFInfo :: Config -> Context -> FInfo c -> IO (FInfo c)
+ Language.Fixpoint.Solver.Monad: filterRequired :: Cand a -> Expr -> SolveM [a]
+ Language.Fixpoint.Solver.Monad: filterValidGradual :: [Expr] -> Cand a -> SolveM [a]
+ Language.Fixpoint.Solver.Monad: smtEnablembqi :: SolveM ()
+ Language.Fixpoint.Solver.Sanitize: dropDeadSubsts :: SInfo a -> SInfo a
+ Language.Fixpoint.Solver.Sanitize: sanitize :: SInfo a -> SanitizeM (SInfo a)
+ Language.Fixpoint.Solver.Sanitize: symbolEnv :: Config -> SInfo a -> SEnv Sort
+ Language.Fixpoint.Solver.Solution: instance GHC.Base.Monoid Language.Fixpoint.Solver.Solution.KInfo
+ Language.Fixpoint.Solver.Solution: instance GHC.Classes.Eq Language.Fixpoint.Solver.Solution.KInfo
+ Language.Fixpoint.Solver.Solution: instance GHC.Classes.Ord Language.Fixpoint.Solver.Solution.KInfo
+ Language.Fixpoint.Solver.Solution: instance GHC.Show.Show Language.Fixpoint.Solver.Solution.KInfo
+ Language.Fixpoint.SortCheck: class Elaborate a
+ Language.Fixpoint.SortCheck: exprSort :: String -> Expr -> Sort
+ Language.Fixpoint.SortCheck: instance Language.Fixpoint.SortCheck.Elaborate (Language.Fixpoint.Types.Constraints.SInfo a)
+ Language.Fixpoint.SortCheck: instance Language.Fixpoint.SortCheck.Elaborate (Language.Fixpoint.Types.Constraints.SimpC a)
+ Language.Fixpoint.SortCheck: instance Language.Fixpoint.SortCheck.Elaborate (Language.Fixpoint.Types.Names.Symbol, Language.Fixpoint.Types.Sorts.Sort)
+ Language.Fixpoint.SortCheck: instance Language.Fixpoint.SortCheck.Elaborate Language.Fixpoint.Types.Environments.BindEnv
+ Language.Fixpoint.SortCheck: instance Language.Fixpoint.SortCheck.Elaborate Language.Fixpoint.Types.Refinements.Expr
+ Language.Fixpoint.SortCheck: instance Language.Fixpoint.SortCheck.Elaborate Language.Fixpoint.Types.Refinements.SortedReft
+ Language.Fixpoint.SortCheck: instance Language.Fixpoint.SortCheck.Elaborate Language.Fixpoint.Types.Sorts.Sort
+ Language.Fixpoint.SortCheck: instance Language.Fixpoint.SortCheck.Elaborate a => Language.Fixpoint.SortCheck.Elaborate [a]
+ Language.Fixpoint.SortCheck: instance Language.Fixpoint.SortCheck.Elaborate e => Language.Fixpoint.SortCheck.Elaborate (Language.Fixpoint.Types.Triggers.Triggered e)
+ Language.Fixpoint.SortCheck: unifySorts :: Sort -> Sort -> Maybe TVSubst
+ Language.Fixpoint.Types.Config: All :: Eliminate
+ Language.Fixpoint.Types.Config: None :: Eliminate
+ Language.Fixpoint.Types.Config: Some :: Eliminate
+ Language.Fixpoint.Types.Config: [allowHOqs] :: Config -> Bool
+ Language.Fixpoint.Types.Config: [alphaEquivalence] :: Config -> Bool
+ Language.Fixpoint.Types.Config: [arithmeticAxioms] :: Config -> Bool
+ Language.Fixpoint.Types.Config: [autoKuts] :: Config -> Bool
+ Language.Fixpoint.Types.Config: [betaEquivalence] :: Config -> Bool
+ Language.Fixpoint.Types.Config: [defunction] :: Config -> Bool
+ Language.Fixpoint.Types.Config: [elimBound] :: Config -> Maybe Int
+ Language.Fixpoint.Types.Config: [extensionality] :: Config -> Bool
+ Language.Fixpoint.Types.Config: [minimalSol] :: Config -> Bool
+ Language.Fixpoint.Types.Config: [minimizeKs] :: Config -> Bool
+ Language.Fixpoint.Types.Config: [minimizeQs] :: Config -> Bool
+ Language.Fixpoint.Types.Config: [nonLinCuts] :: Config -> Bool
+ Language.Fixpoint.Types.Config: [normalForm] :: Config -> Bool
+ Language.Fixpoint.Types.Config: [noslice] :: Config -> Bool
+ Language.Fixpoint.Types.Config: [rewriteAxioms] :: Config -> Bool
+ Language.Fixpoint.Types.Config: [stringTheory] :: Config -> Bool
+ Language.Fixpoint.Types.Config: data Eliminate
+ Language.Fixpoint.Types.Config: defConfig :: Config
+ Language.Fixpoint.Types.Config: instance Data.Data.Data Language.Fixpoint.Types.Config.Eliminate
+ Language.Fixpoint.Types.Config: instance Data.Serialize.Serialize Language.Fixpoint.Types.Config.Eliminate
+ Language.Fixpoint.Types.Config: instance GHC.Classes.Eq Language.Fixpoint.Types.Config.Eliminate
+ Language.Fixpoint.Types.Config: instance GHC.Generics.Generic Language.Fixpoint.Types.Config.Config
+ Language.Fixpoint.Types.Config: instance GHC.Generics.Generic Language.Fixpoint.Types.Config.Eliminate
+ Language.Fixpoint.Types.Config: instance GHC.Show.Show Language.Fixpoint.Types.Config.Eliminate
+ Language.Fixpoint.Types.Config: instance System.Console.CmdArgs.Default.Default Language.Fixpoint.Types.Config.Eliminate
+ Language.Fixpoint.Types.Config: useElim :: Config -> Bool
+ Language.Fixpoint.Types.Config: withPragmas :: Config -> [String] -> IO Config
+ Language.Fixpoint.Types.Constraints: AEnv :: ![Symbol] -> ![Equation] -> ![Rewrite] -> HashMap SubcId Int -> HashMap SubcId Bool -> AxiomEnv
+ Language.Fixpoint.Types.Constraints: Equ :: Symbol -> [Symbol] -> Expr -> Equation
+ Language.Fixpoint.Types.Constraints: FIO :: FInfo a -> [String] -> FInfoWithOpts a
+ Language.Fixpoint.Types.Constraints: GWfC :: !IBindEnv -> !(Symbol, Sort, KVar) -> !a -> !Expr -> WfC a
+ Language.Fixpoint.Types.Constraints: HOI :: Bool -> Bool -> HOInfo
+ Language.Fixpoint.Types.Constraints: SMeasure :: Symbol -> Symbol -> [Symbol] -> Expr -> Rewrite
+ Language.Fixpoint.Types.Constraints: [ae] :: GInfo c a -> AxiomEnv
+ Language.Fixpoint.Types.Constraints: [aenvEqs] :: AxiomEnv -> ![Equation]
+ Language.Fixpoint.Types.Constraints: [aenvExpand] :: AxiomEnv -> HashMap SubcId Bool
+ Language.Fixpoint.Types.Constraints: [aenvFuel] :: AxiomEnv -> HashMap SubcId Int
+ Language.Fixpoint.Types.Constraints: [aenvSimpl] :: AxiomEnv -> ![Rewrite]
+ Language.Fixpoint.Types.Constraints: [aenvSyms] :: AxiomEnv -> ![Symbol]
+ Language.Fixpoint.Types.Constraints: [asserts] :: GInfo c a -> ![Triggered Expr]
+ Language.Fixpoint.Types.Constraints: [dLits] :: GInfo c a -> !(SEnv Sort)
+ Language.Fixpoint.Types.Constraints: [eqBody] :: Equation -> Expr
+ Language.Fixpoint.Types.Constraints: [eqName] :: Equation -> Symbol
+ Language.Fixpoint.Types.Constraints: [fioFI] :: FInfoWithOpts a -> FInfo a
+ Language.Fixpoint.Types.Constraints: [fioOpts] :: FInfoWithOpts a -> [String]
+ Language.Fixpoint.Types.Constraints: [gLits] :: GInfo c a -> !(SEnv Sort)
+ Language.Fixpoint.Types.Constraints: [gresSolution] :: Result a -> !GFixSolution
+ Language.Fixpoint.Types.Constraints: [hoBinds] :: HOInfo -> Bool
+ Language.Fixpoint.Types.Constraints: [hoInfo] :: GInfo c a -> !HOInfo
+ Language.Fixpoint.Types.Constraints: [hoQuals] :: HOInfo -> Bool
+ Language.Fixpoint.Types.Constraints: [qBody] :: Qualifier -> !Expr
+ Language.Fixpoint.Types.Constraints: [qName] :: Qualifier -> !Symbol
+ Language.Fixpoint.Types.Constraints: [qParams] :: Qualifier -> [(Symbol, Sort)]
+ Language.Fixpoint.Types.Constraints: [qPos] :: Qualifier -> !SourcePos
+ Language.Fixpoint.Types.Constraints: [smArgs] :: Rewrite -> [Symbol]
+ Language.Fixpoint.Types.Constraints: [smBody] :: Rewrite -> Expr
+ Language.Fixpoint.Types.Constraints: [smDC] :: Rewrite -> Symbol
+ Language.Fixpoint.Types.Constraints: [smName] :: Rewrite -> Symbol
+ Language.Fixpoint.Types.Constraints: [wexpr] :: WfC a -> !Expr
+ Language.Fixpoint.Types.Constraints: allowHO :: GInfo c a -> Bool
+ Language.Fixpoint.Types.Constraints: allowHOquals :: GInfo c a -> Bool
+ Language.Fixpoint.Types.Constraints: data AxiomEnv
+ Language.Fixpoint.Types.Constraints: data Equation
+ Language.Fixpoint.Types.Constraints: data FInfoWithOpts a
+ Language.Fixpoint.Types.Constraints: data HOInfo
+ Language.Fixpoint.Types.Constraints: data Rewrite
+ Language.Fixpoint.Types.Constraints: getEqBody :: Equation -> Maybe Expr
+ Language.Fixpoint.Types.Constraints: instance (GHC.Classes.Eq (c a), GHC.Classes.Eq a) => GHC.Classes.Eq (Language.Fixpoint.Types.Constraints.GInfo c a)
+ Language.Fixpoint.Types.Constraints: instance (GHC.Show.Show (c a), GHC.Show.Show a, Language.Fixpoint.Types.PrettyPrint.Fixpoint a) => GHC.Show.Show (Language.Fixpoint.Types.Constraints.GInfo c a)
+ Language.Fixpoint.Types.Constraints: instance Control.DeepSeq.NFData Language.Fixpoint.Types.Config.Eliminate
+ Language.Fixpoint.Types.Constraints: instance Control.DeepSeq.NFData Language.Fixpoint.Types.Config.SMTSolver
+ Language.Fixpoint.Types.Constraints: instance Control.DeepSeq.NFData Language.Fixpoint.Types.Constraints.AxiomEnv
+ Language.Fixpoint.Types.Constraints: instance Control.DeepSeq.NFData Language.Fixpoint.Types.Constraints.Equation
+ Language.Fixpoint.Types.Constraints: instance Control.DeepSeq.NFData Language.Fixpoint.Types.Constraints.GFixSolution
+ Language.Fixpoint.Types.Constraints: instance Control.DeepSeq.NFData Language.Fixpoint.Types.Constraints.HOInfo
+ Language.Fixpoint.Types.Constraints: instance Control.DeepSeq.NFData Language.Fixpoint.Types.Constraints.Rewrite
+ Language.Fixpoint.Types.Constraints: instance Data.Binary.Class.Binary Language.Fixpoint.Types.Config.Eliminate
+ Language.Fixpoint.Types.Constraints: instance Data.Binary.Class.Binary Language.Fixpoint.Types.Config.SMTSolver
+ Language.Fixpoint.Types.Constraints: instance Data.Binary.Class.Binary Language.Fixpoint.Types.Constraints.AxiomEnv
+ Language.Fixpoint.Types.Constraints: instance Data.Binary.Class.Binary Language.Fixpoint.Types.Constraints.Equation
+ Language.Fixpoint.Types.Constraints: instance Data.Binary.Class.Binary Language.Fixpoint.Types.Constraints.GFixSolution
+ Language.Fixpoint.Types.Constraints: instance Data.Binary.Class.Binary Language.Fixpoint.Types.Constraints.HOInfo
+ Language.Fixpoint.Types.Constraints: instance Data.Binary.Class.Binary Language.Fixpoint.Types.Constraints.Rewrite
+ Language.Fixpoint.Types.Constraints: instance GHC.Base.Functor Language.Fixpoint.Types.Constraints.GFixSol
+ Language.Fixpoint.Types.Constraints: instance GHC.Base.Monoid (Language.Fixpoint.Types.Constraints.GFixSol e)
+ Language.Fixpoint.Types.Constraints: instance GHC.Base.Monoid Language.Fixpoint.Types.Constraints.AxiomEnv
+ Language.Fixpoint.Types.Constraints: instance GHC.Base.Monoid Language.Fixpoint.Types.Constraints.HOInfo
+ Language.Fixpoint.Types.Constraints: instance GHC.Classes.Eq Language.Fixpoint.Types.Constraints.AxiomEnv
+ Language.Fixpoint.Types.Constraints: instance GHC.Classes.Eq Language.Fixpoint.Types.Constraints.Equation
+ Language.Fixpoint.Types.Constraints: instance GHC.Classes.Eq Language.Fixpoint.Types.Constraints.HOInfo
+ Language.Fixpoint.Types.Constraints: instance GHC.Classes.Eq Language.Fixpoint.Types.Constraints.Rewrite
+ Language.Fixpoint.Types.Constraints: instance GHC.Generics.Generic (Language.Fixpoint.Types.Constraints.GFixSol e)
+ Language.Fixpoint.Types.Constraints: instance GHC.Generics.Generic Language.Fixpoint.Types.Constraints.AxiomEnv
+ Language.Fixpoint.Types.Constraints: instance GHC.Generics.Generic Language.Fixpoint.Types.Constraints.Equation
+ Language.Fixpoint.Types.Constraints: instance GHC.Generics.Generic Language.Fixpoint.Types.Constraints.HOInfo
+ Language.Fixpoint.Types.Constraints: instance GHC.Generics.Generic Language.Fixpoint.Types.Constraints.Rewrite
+ Language.Fixpoint.Types.Constraints: instance GHC.Show.Show Language.Fixpoint.Types.Constraints.AxiomEnv
+ Language.Fixpoint.Types.Constraints: instance GHC.Show.Show Language.Fixpoint.Types.Constraints.Equation
+ Language.Fixpoint.Types.Constraints: instance GHC.Show.Show Language.Fixpoint.Types.Constraints.GFixSolution
+ Language.Fixpoint.Types.Constraints: instance GHC.Show.Show Language.Fixpoint.Types.Constraints.HOInfo
+ Language.Fixpoint.Types.Constraints: instance GHC.Show.Show Language.Fixpoint.Types.Constraints.Rewrite
+ Language.Fixpoint.Types.Constraints: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Types.Constraints.GFixSolution
+ Language.Fixpoint.Types.Constraints: isGWfc :: WfC a -> Bool
+ Language.Fixpoint.Types.Constraints: mkQual :: Symbol -> [(Symbol, Sort)] -> Expr -> SourcePos -> Qualifier
+ Language.Fixpoint.Types.Constraints: remakeQual :: Qualifier -> Qualifier
+ Language.Fixpoint.Types.Constraints: strengthenLhs :: Expr -> SubC a -> SubC a
+ Language.Fixpoint.Types.Constraints: toGFixSol :: HashMap KVar (e, [e]) -> GFixSol e
+ Language.Fixpoint.Types.Constraints: trueQual :: Qualifier
+ Language.Fixpoint.Types.Constraints: type GFixSolution = GFixSol Expr
+ Language.Fixpoint.Types.Constraints: type SubcId = Integer
+ Language.Fixpoint.Types.Constraints: updateWfCExpr :: (Expr -> Expr) -> WfC a -> WfC a
+ Language.Fixpoint.Types.Environments: Packs :: HashMap KVar Int -> Packs
+ Language.Fixpoint.Types.Environments: SolEnv :: !BindEnv -> SolEnv
+ Language.Fixpoint.Types.Environments: [packm] :: Packs -> HashMap KVar Int
+ Language.Fixpoint.Types.Environments: [soeBinds] :: SolEnv -> !BindEnv
+ Language.Fixpoint.Types.Environments: data SolEnv
+ Language.Fixpoint.Types.Environments: elemsBindEnv :: BindEnv -> [BindId]
+ Language.Fixpoint.Types.Environments: filterBindEnv :: (BindId -> Symbol -> SortedReft -> Bool) -> BindEnv -> BindEnv
+ Language.Fixpoint.Types.Environments: filterIBindEnv :: (BindId -> Bool) -> IBindEnv -> IBindEnv
+ Language.Fixpoint.Types.Environments: fromMapSEnv :: HashMap Symbol a -> SEnv a
+ Language.Fixpoint.Types.Environments: getPack :: KVar -> Packs -> Maybe Int
+ Language.Fixpoint.Types.Environments: instance Control.DeepSeq.NFData Language.Fixpoint.Types.Environments.Packs
+ Language.Fixpoint.Types.Environments: instance Data.Binary.Class.Binary Language.Fixpoint.Types.Environments.Packs
+ Language.Fixpoint.Types.Environments: instance GHC.Base.Monoid Language.Fixpoint.Types.Environments.IBindEnv
+ Language.Fixpoint.Types.Environments: instance GHC.Base.Monoid Language.Fixpoint.Types.Environments.Packs
+ Language.Fixpoint.Types.Environments: instance GHC.Classes.Eq Language.Fixpoint.Types.Environments.Packs
+ Language.Fixpoint.Types.Environments: instance GHC.Classes.Eq Language.Fixpoint.Types.Environments.SolEnv
+ Language.Fixpoint.Types.Environments: instance GHC.Generics.Generic Language.Fixpoint.Types.Environments.Packs
+ Language.Fixpoint.Types.Environments: instance GHC.Generics.Generic Language.Fixpoint.Types.Environments.SolEnv
+ Language.Fixpoint.Types.Environments: instance GHC.Show.Show Language.Fixpoint.Types.Environments.Packs
+ Language.Fixpoint.Types.Environments: instance GHC.Show.Show Language.Fixpoint.Types.Environments.SolEnv
+ Language.Fixpoint.Types.Environments: instance Language.Fixpoint.Types.PrettyPrint.Fixpoint Language.Fixpoint.Types.Environments.Packs
+ Language.Fixpoint.Types.Environments: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Types.Environments.IBindEnv
+ Language.Fixpoint.Types.Environments: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Types.Environments.Packs
+ Language.Fixpoint.Types.Environments: instance Language.Fixpoint.Types.PrettyPrint.PPrint a => Language.Fixpoint.Types.PrettyPrint.PPrint (Language.Fixpoint.Types.Environments.SEnv a)
+ Language.Fixpoint.Types.Environments: instance Language.Fixpoint.Types.PrettyPrint.PPrint a => Language.Fixpoint.Types.PrettyPrint.PPrint (Language.Fixpoint.Types.Environments.SizedEnv a)
+ Language.Fixpoint.Types.Environments: intersectionIBindEnv :: IBindEnv -> IBindEnv -> IBindEnv
+ Language.Fixpoint.Types.Environments: makePack :: [HashSet KVar] -> Packs
+ Language.Fixpoint.Types.Environments: mapMSEnv :: (Monad m) => (a -> m b) -> SEnv a -> m (SEnv b)
+ Language.Fixpoint.Types.Environments: mapWithKeyMBindEnv :: (Monad m) => ((BindId, (Symbol, SortedReft)) -> m (BindId, (Symbol, SortedReft))) -> BindEnv -> m BindEnv
+ Language.Fixpoint.Types.Environments: memberIBindEnv :: BindId -> IBindEnv -> Bool
+ Language.Fixpoint.Types.Environments: newtype Packs
+ Language.Fixpoint.Types.Environments: nullIBindEnv :: IBindEnv -> Bool
+ Language.Fixpoint.Types.Environments: unionSEnv' :: SEnv a -> SEnv a -> SEnv a
+ Language.Fixpoint.Types.Errors: errIllScopedKVar :: (PPrint k, PPrint bs) => (k, Integer, Integer, bs) -> Error
+ Language.Fixpoint.Types.Errors: instance Data.Serialize.Serialize Text.PrettyPrint.Annotated.HughesPJ.TextDetails
+ Language.Fixpoint.Types.Errors: instance Data.Serialize.Serialize a => Data.Serialize.Serialize (Text.PrettyPrint.Annotated.HughesPJ.AnnotDetails a)
+ Language.Fixpoint.Types.Errors: instance Data.Serialize.Serialize a => Data.Serialize.Serialize (Text.PrettyPrint.Annotated.HughesPJ.Doc a)
+ Language.Fixpoint.Types.Errors: instance GHC.Generics.Generic (Text.PrettyPrint.Annotated.HughesPJ.AnnotDetails a)
+ Language.Fixpoint.Types.Names: intArgName :: Int -> Symbol
+ Language.Fixpoint.Types.Names: isLitSymbol :: Symbol -> Bool
+ Language.Fixpoint.Types.Names: lambdaName :: Symbol
+ Language.Fixpoint.Types.Names: mapConName :: Symbol
+ Language.Fixpoint.Types.Names: setConName :: Symbol
+ Language.Fixpoint.Types.Names: symbolicString :: (Symbolic a) => a -> String
+ Language.Fixpoint.Types.PrettyPrint: notracepp :: (PPrint a) => String -> a -> a
+ Language.Fixpoint.Types.PrettyPrint: showTable :: (PPrint k, PPrint v) => Tidy -> [(k, v)] -> String
+ Language.Fixpoint.Types.Refinements: (&.&) :: Pred -> Pred -> Pred
+ Language.Fixpoint.Types.Refinements: (|.|) :: Pred -> Pred -> Pred
+ Language.Fixpoint.Types.Refinements: KVS :: Symbol -> Sort -> KVar -> Subst -> KVSub
+ Language.Fixpoint.Types.Refinements: [ksuKVar] :: KVSub -> KVar
+ Language.Fixpoint.Types.Refinements: [ksuSort] :: KVSub -> Sort
+ Language.Fixpoint.Types.Refinements: [ksuSubst] :: KVSub -> Subst
+ Language.Fixpoint.Types.Refinements: [ksuVV] :: KVSub -> Symbol
+ Language.Fixpoint.Types.Refinements: data KVSub
+ Language.Fixpoint.Types.Refinements: debruijnIndex :: Expr -> Int
+ Language.Fixpoint.Types.Refinements: eAppC :: Sort -> Expr -> Expr -> Expr
+ Language.Fixpoint.Types.Refinements: instance Data.Data.Data Language.Fixpoint.Types.Refinements.KVSub
+ Language.Fixpoint.Types.Refinements: instance GHC.Classes.Eq Language.Fixpoint.Types.Refinements.KVSub
+ Language.Fixpoint.Types.Refinements: instance GHC.Generics.Generic Language.Fixpoint.Types.Refinements.KVSub
+ Language.Fixpoint.Types.Refinements: instance GHC.Show.Show Language.Fixpoint.Types.Refinements.KVSub
+ Language.Fixpoint.Types.Refinements: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Types.Refinements.KVSub
+ Language.Fixpoint.Types.Refinements: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Types.Refinements.Subst
+ Language.Fixpoint.Types.Refinements: instance Language.Fixpoint.Types.Refinements.Expression Language.Fixpoint.Types.Refinements.Reft
+ Language.Fixpoint.Types.Refinements: instance Language.Fixpoint.Types.Refinements.Expression Language.Fixpoint.Types.Refinements.SortedReft
+ Language.Fixpoint.Types.Refinements: isContraPred :: Expr -> Bool
+ Language.Fixpoint.Types.Refinements: isGradual :: Expr -> Bool
+ Language.Fixpoint.Types.Refinements: mkProp :: Expr -> Pred
+ Language.Fixpoint.Types.Refinements: pExist :: [(Symbol, Sort)] -> Pred -> Pred
+ Language.Fixpoint.Types.Refinements: pGAnd :: Expr -> Expr -> Expr
+ Language.Fixpoint.Types.Refinements: pGAnds :: [Expr] -> Expr
+ Language.Fixpoint.Types.Solutions: BP :: !Pred -> ![KIndex] -> BindPred
+ Language.Fixpoint.Types.Solutions: Bind :: !BindId -> BIndex
+ Language.Fixpoint.Types.Solutions: Cstr :: !SubcId -> BIndex
+ Language.Fixpoint.Types.Solutions: Cube :: IBindEnv -> Subst -> SubcId -> Tag -> Cube
+ Language.Fixpoint.Types.Solutions: EQL :: !Qualifier -> !Expr -> ![Expr] -> EQual
+ Language.Fixpoint.Types.Solutions: FastIdx :: !(BindId |-> BindPred) -> !(KIndex |-> KVSub) -> !(KVar |-> Hyp) -> !(CMap IBindEnv) -> !(CMap [SubcId]) -> !(SEnv Sort) -> Index
+ Language.Fixpoint.Types.Solutions: KIndex :: !BindId -> !Int -> !KVar -> KIndex
+ Language.Fixpoint.Types.Solutions: Root :: BIndex
+ Language.Fixpoint.Types.Solutions: [_eqArgs] :: EQual -> ![Expr]
+ Language.Fixpoint.Types.Solutions: [_eqQual] :: EQual -> !Qualifier
+ Language.Fixpoint.Types.Solutions: [bindExpr] :: Index -> !(BindId |-> BindPred)
+ Language.Fixpoint.Types.Solutions: [bpConc] :: BindPred -> !Pred
+ Language.Fixpoint.Types.Solutions: [bpKVar] :: BindPred -> ![KIndex]
+ Language.Fixpoint.Types.Solutions: [cuBinds] :: Cube -> IBindEnv
+ Language.Fixpoint.Types.Solutions: [cuId] :: Cube -> SubcId
+ Language.Fixpoint.Types.Solutions: [cuSubst] :: Cube -> Subst
+ Language.Fixpoint.Types.Solutions: [cuTag] :: Cube -> Tag
+ Language.Fixpoint.Types.Solutions: [envBinds] :: Index -> !(CMap IBindEnv)
+ Language.Fixpoint.Types.Solutions: [envSorts] :: Index -> !(SEnv Sort)
+ Language.Fixpoint.Types.Solutions: [envTx] :: Index -> !(CMap [SubcId])
+ Language.Fixpoint.Types.Solutions: [eqPred] :: EQual -> !Expr
+ Language.Fixpoint.Types.Solutions: [kiBIndex] :: KIndex -> !BindId
+ Language.Fixpoint.Types.Solutions: [kiKVar] :: KIndex -> !KVar
+ Language.Fixpoint.Types.Solutions: [kiPos] :: KIndex -> !Int
+ Language.Fixpoint.Types.Solutions: [kvDef] :: Index -> !(KVar |-> Hyp)
+ Language.Fixpoint.Types.Solutions: [kvUse] :: Index -> !(KIndex |-> KVSub)
+ Language.Fixpoint.Types.Solutions: data BIndex
+ Language.Fixpoint.Types.Solutions: data BindPred
+ Language.Fixpoint.Types.Solutions: data Cube
+ Language.Fixpoint.Types.Solutions: data EQual
+ Language.Fixpoint.Types.Solutions: data GBind
+ Language.Fixpoint.Types.Solutions: data Index
+ Language.Fixpoint.Types.Solutions: data KIndex
+ Language.Fixpoint.Types.Solutions: data QBind
+ Language.Fixpoint.Types.Solutions: data Sol b a
+ Language.Fixpoint.Types.Solutions: eQual :: Qualifier -> [Symbol] -> EQual
+ Language.Fixpoint.Types.Solutions: emptyGMap :: GSolution -> GSolution
+ Language.Fixpoint.Types.Solutions: equalsGb :: [[EQual]] -> GBind
+ Language.Fixpoint.Types.Solutions: fromList :: SEnv Sort -> [(KVar, a)] -> [(KVar, b)] -> [(KVar, Hyp)] -> HashMap KVar IBindEnv -> Sol a b
+ Language.Fixpoint.Types.Solutions: gbEquals :: GBind -> [[EQual]]
+ Language.Fixpoint.Types.Solutions: gbFilterM :: Monad m => ([EQual] -> m Bool) -> GBind -> m GBind
+ Language.Fixpoint.Types.Solutions: gbToQbs :: GBind -> [QBind]
+ Language.Fixpoint.Types.Solutions: glookup :: GSolution -> KVar -> Either Hyp (Either QBind (((Symbol, Sort), Expr), GBind))
+ Language.Fixpoint.Types.Solutions: instance (Language.Fixpoint.Types.PrettyPrint.PPrint a, Language.Fixpoint.Types.PrettyPrint.PPrint b) => Language.Fixpoint.Types.PrettyPrint.PPrint (Language.Fixpoint.Types.Solutions.Sol a b)
+ Language.Fixpoint.Types.Solutions: instance Control.DeepSeq.NFData Language.Fixpoint.Types.Solutions.EQual
+ Language.Fixpoint.Types.Solutions: instance Control.DeepSeq.NFData Language.Fixpoint.Types.Solutions.GBind
+ Language.Fixpoint.Types.Solutions: instance Control.DeepSeq.NFData Language.Fixpoint.Types.Solutions.QBind
+ Language.Fixpoint.Types.Solutions: instance Data.Data.Data Language.Fixpoint.Types.Solutions.EQual
+ Language.Fixpoint.Types.Solutions: instance Data.Data.Data Language.Fixpoint.Types.Solutions.GBind
+ Language.Fixpoint.Types.Solutions: instance Data.Data.Data Language.Fixpoint.Types.Solutions.QBind
+ Language.Fixpoint.Types.Solutions: instance Data.Hashable.Class.Hashable Language.Fixpoint.Types.Solutions.BIndex
+ Language.Fixpoint.Types.Solutions: instance Data.Hashable.Class.Hashable Language.Fixpoint.Types.Solutions.KIndex
+ Language.Fixpoint.Types.Solutions: instance GHC.Base.Functor (Language.Fixpoint.Types.Solutions.Sol a)
+ Language.Fixpoint.Types.Solutions: instance GHC.Base.Monoid (Language.Fixpoint.Types.Solutions.Sol a b)
+ Language.Fixpoint.Types.Solutions: instance GHC.Classes.Eq Language.Fixpoint.Types.Solutions.BIndex
+ Language.Fixpoint.Types.Solutions: instance GHC.Classes.Eq Language.Fixpoint.Types.Solutions.EQual
+ Language.Fixpoint.Types.Solutions: instance GHC.Classes.Eq Language.Fixpoint.Types.Solutions.KIndex
+ Language.Fixpoint.Types.Solutions: instance GHC.Classes.Eq Language.Fixpoint.Types.Solutions.QBind
+ Language.Fixpoint.Types.Solutions: instance GHC.Classes.Ord Language.Fixpoint.Types.Solutions.BIndex
+ Language.Fixpoint.Types.Solutions: instance GHC.Classes.Ord Language.Fixpoint.Types.Solutions.KIndex
+ Language.Fixpoint.Types.Solutions: instance GHC.Generics.Generic Language.Fixpoint.Types.Solutions.BIndex
+ Language.Fixpoint.Types.Solutions: instance GHC.Generics.Generic Language.Fixpoint.Types.Solutions.EQual
+ Language.Fixpoint.Types.Solutions: instance GHC.Generics.Generic Language.Fixpoint.Types.Solutions.GBind
+ Language.Fixpoint.Types.Solutions: instance GHC.Generics.Generic Language.Fixpoint.Types.Solutions.KIndex
+ Language.Fixpoint.Types.Solutions: instance GHC.Generics.Generic Language.Fixpoint.Types.Solutions.QBind
+ Language.Fixpoint.Types.Solutions: instance GHC.Show.Show Language.Fixpoint.Types.Solutions.BIndex
+ Language.Fixpoint.Types.Solutions: instance GHC.Show.Show Language.Fixpoint.Types.Solutions.BindPred
+ Language.Fixpoint.Types.Solutions: instance GHC.Show.Show Language.Fixpoint.Types.Solutions.Cube
+ Language.Fixpoint.Types.Solutions: instance GHC.Show.Show Language.Fixpoint.Types.Solutions.EQual
+ Language.Fixpoint.Types.Solutions: instance GHC.Show.Show Language.Fixpoint.Types.Solutions.GBind
+ Language.Fixpoint.Types.Solutions: instance GHC.Show.Show Language.Fixpoint.Types.Solutions.KIndex
+ Language.Fixpoint.Types.Solutions: instance GHC.Show.Show Language.Fixpoint.Types.Solutions.QBind
+ Language.Fixpoint.Types.Solutions: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Types.Solutions.BIndex
+ Language.Fixpoint.Types.Solutions: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Types.Solutions.BindPred
+ Language.Fixpoint.Types.Solutions: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Types.Solutions.Cube
+ Language.Fixpoint.Types.Solutions: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Types.Solutions.EQual
+ Language.Fixpoint.Types.Solutions: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Types.Solutions.KIndex
+ Language.Fixpoint.Types.Solutions: instance Language.Fixpoint.Types.PrettyPrint.PPrint Language.Fixpoint.Types.Solutions.QBind
+ Language.Fixpoint.Types.Solutions: lookup :: Sol a QBind -> KVar -> Either Hyp QBind
+ Language.Fixpoint.Types.Solutions: lookupQBind :: Sol a QBind -> KVar -> QBind
+ Language.Fixpoint.Types.Solutions: qb :: [EQual] -> QBind
+ Language.Fixpoint.Types.Solutions: qbFilter :: (EQual -> Bool) -> QBind -> QBind
+ Language.Fixpoint.Types.Solutions: qbPreds :: String -> Sol a QBind -> Subst -> QBind -> [(Pred, EQual)]
+ Language.Fixpoint.Types.Solutions: qbToGb :: QBind -> GBind
+ Language.Fixpoint.Types.Solutions: result :: Sol a QBind -> HashMap KVar Expr
+ Language.Fixpoint.Types.Solutions: resultGradual :: GSolution -> HashMap KVar (Expr, [Expr])
+ Language.Fixpoint.Types.Solutions: sScp :: Sol b a -> (HashMap KVar IBindEnv)
+ Language.Fixpoint.Types.Solutions: trueEqual :: EQual
+ Language.Fixpoint.Types.Solutions: type CMap a = HashMap SubcId a
+ Language.Fixpoint.Types.Solutions: type Cand a = [(Expr, a)]
+ Language.Fixpoint.Types.Solutions: type GSolution = Sol (((Symbol, Sort), Expr), GBind) QBind
+ Language.Fixpoint.Types.Solutions: type Hyp = ListNE Cube
+ Language.Fixpoint.Types.Solutions: type Solution = Sol () QBind
+ Language.Fixpoint.Types.Solutions: update :: Sol a QBind -> [KVar] -> [(KVar, EQual)] -> (Bool, Sol a QBind)
+ Language.Fixpoint.Types.Solutions: updateGMap :: Sol b a -> HashMap KVar b -> Sol b a
+ Language.Fixpoint.Types.Solutions: updateGMapWithKey :: [(KVar, QBind)] -> GSolution -> GSolution
+ Language.Fixpoint.Types.Sorts: instance Control.DeepSeq.NFData Language.Fixpoint.Types.Sorts.TCInfo
+ Language.Fixpoint.Types.Sorts: instance Data.Binary.Class.Binary Language.Fixpoint.Types.Sorts.TCInfo
+ Language.Fixpoint.Types.Sorts: instance Data.Data.Data Language.Fixpoint.Types.Sorts.TCInfo
+ Language.Fixpoint.Types.Sorts: instance GHC.Base.Monoid Language.Fixpoint.Types.Sorts.TCInfo
+ Language.Fixpoint.Types.Sorts: instance GHC.Classes.Eq Language.Fixpoint.Types.Sorts.TCInfo
+ Language.Fixpoint.Types.Sorts: instance GHC.Classes.Ord Language.Fixpoint.Types.Sorts.TCInfo
+ Language.Fixpoint.Types.Sorts: instance GHC.Generics.Generic Language.Fixpoint.Types.Sorts.TCInfo
+ Language.Fixpoint.Types.Sorts: instance GHC.Show.Show Language.Fixpoint.Types.Sorts.TCInfo
+ Language.Fixpoint.Types.Sorts: isFirstOrder :: Sort -> Bool
+ Language.Fixpoint.Types.Sorts: isNumeric :: Sort -> Bool
+ Language.Fixpoint.Types.Sorts: isReal :: Sort -> Bool
+ Language.Fixpoint.Types.Sorts: isString :: Sort -> Bool
+ Language.Fixpoint.Types.Sorts: mappendFTC :: FTycon -> FTycon -> FTycon
+ Language.Fixpoint.Types.Sorts: setFTyCon :: FTycon
+ Language.Fixpoint.Types.Sorts: strFTyCon :: FTycon
+ Language.Fixpoint.Types.Sorts: symbolNumInfoFTyCon :: LocSymbol -> Bool -> Bool -> FTycon
+ Language.Fixpoint.Types.Triggers: LeftHandSide :: Trigger
+ Language.Fixpoint.Types.Triggers: NoTrigger :: Trigger
+ Language.Fixpoint.Types.Triggers: TR :: Trigger -> a -> Triggered a
+ Language.Fixpoint.Types.Triggers: data Trigger
+ Language.Fixpoint.Types.Triggers: data Triggered a
+ Language.Fixpoint.Types.Triggers: defaultTrigger :: e -> Triggered e
+ Language.Fixpoint.Types.Triggers: instance Control.DeepSeq.NFData Language.Fixpoint.Types.Triggers.Trigger
+ Language.Fixpoint.Types.Triggers: instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.Fixpoint.Types.Triggers.Triggered a)
+ Language.Fixpoint.Types.Triggers: instance Data.Binary.Class.Binary Language.Fixpoint.Types.Triggers.Trigger
+ Language.Fixpoint.Types.Triggers: instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Language.Fixpoint.Types.Triggers.Triggered a)
+ Language.Fixpoint.Types.Triggers: instance GHC.Base.Functor Language.Fixpoint.Types.Triggers.Triggered
+ Language.Fixpoint.Types.Triggers: instance GHC.Classes.Eq Language.Fixpoint.Types.Triggers.Trigger
+ Language.Fixpoint.Types.Triggers: instance GHC.Classes.Eq a => GHC.Classes.Eq (Language.Fixpoint.Types.Triggers.Triggered a)
+ Language.Fixpoint.Types.Triggers: instance GHC.Generics.Generic (Language.Fixpoint.Types.Triggers.Triggered a)
+ Language.Fixpoint.Types.Triggers: instance GHC.Generics.Generic Language.Fixpoint.Types.Triggers.Trigger
+ Language.Fixpoint.Types.Triggers: instance GHC.Show.Show Language.Fixpoint.Types.Triggers.Trigger
+ Language.Fixpoint.Types.Triggers: instance GHC.Show.Show a => GHC.Show.Show (Language.Fixpoint.Types.Triggers.Triggered a)
+ Language.Fixpoint.Types.Triggers: makeTriggers :: Triggered Expr -> [Expr]
+ Language.Fixpoint.Types.Triggers: noTrigger :: e -> Triggered e
+ Language.Fixpoint.Types.Utils: sortedReftConcKVars :: Symbol -> SortedReft -> ([Pred], [KVSub], [KVSub])
+ Language.Fixpoint.Types.Visitor: class Visitable t
+ Language.Fixpoint.Types.Visitor: eapps :: Visitable t => t -> [Expr]
+ Language.Fixpoint.Types.Visitor: instance Language.Fixpoint.Types.Visitor.SymConsts (Language.Fixpoint.Types.Constraints.SimpC a)
+ Language.Fixpoint.Types.Visitor: instance Language.Fixpoint.Types.Visitor.SymConsts (c a) => Language.Fixpoint.Types.Visitor.SymConsts (Language.Fixpoint.Types.Constraints.GInfo c a)
+ Language.Fixpoint.Types.Visitor: instance Language.Fixpoint.Types.Visitor.Visitable (Language.Fixpoint.Types.Constraints.SubC a)
+ Language.Fixpoint.Types.Visitor: instance Language.Fixpoint.Types.Visitor.Visitable (c a) => Language.Fixpoint.Types.Visitor.Visitable (Language.Fixpoint.Types.Constraints.GInfo c a)
+ Language.Fixpoint.Types.Visitor: lamSize :: Visitable t => t -> Integer
+ Language.Fixpoint.Types.Visitor: mapExpr :: (Expr -> Expr) -> Expr -> Expr
+ Language.Fixpoint.Types.Visitor: mapMExpr :: (Monad m) => (Expr -> m Expr) -> Expr -> m Expr
+ Language.Fixpoint.Types.Visitor: stripCasts :: Expr -> Expr
+ Language.Fixpoint.Types.Visitor: visit :: (Visitable t, Monoid a) => Visitor a c -> c -> t -> VisitM a t
+ Language.Fixpoint.Utils.Files: BinSpec :: Ext
+ Language.Fixpoint.Utils.Files: MinKVars :: Ext
+ Language.Fixpoint.Utils.Files: MinQuals :: Ext
- Language.Fixpoint.Misc: applyNonNull :: t -> ([t1] -> t) -> [t1] -> t
+ Language.Fixpoint.Misc: applyNonNull :: b -> ([a] -> b) -> [a] -> b
- Language.Fixpoint.Misc: colorPhaseLn :: Moods -> [Char] -> [Char] -> IO ()
+ Language.Fixpoint.Misc: colorPhaseLn :: Moods -> String -> String -> IO ()
- Language.Fixpoint.Misc: doneLine :: Moods -> [Char] -> IO ()
+ Language.Fixpoint.Misc: doneLine :: Moods -> String -> IO ()
- Language.Fixpoint.Misc: executeShellCommand :: [Char] -> [Char] -> IO ExitCode
+ Language.Fixpoint.Misc: executeShellCommand :: String -> String -> IO ExitCode
- Language.Fixpoint.Misc: groupBase :: (Eq k, Foldable t, Hashable k) => HashMap k [a] -> t (k, a) -> HashMap k [a]
+ Language.Fixpoint.Misc: groupBase :: (Eq k, Hashable k) => HashMap k [v] -> [(k, v)] -> HashMap k [v]
- Language.Fixpoint.Misc: groupMap :: (Eq k, Foldable t, Hashable k) => (a -> k) -> t a -> HashMap k [a]
+ Language.Fixpoint.Misc: groupMap :: (Eq k, Hashable k) => (a -> k) -> [a] -> HashMap k [a]
- Language.Fixpoint.Misc: inserts :: (Eq k, Hashable k) => k -> a -> HashMap k [a] -> HashMap k [a]
+ Language.Fixpoint.Misc: inserts :: (Eq k, Hashable k) => k -> v -> HashMap k [v] -> HashMap k [v]
- Language.Fixpoint.Misc: startPhase :: Moods -> [Char] -> IO ()
+ Language.Fixpoint.Misc: startPhase :: Moods -> String -> IO ()
- Language.Fixpoint.Misc: tshow :: Show a => a -> Doc
+ Language.Fixpoint.Misc: tshow :: (Show a) => a -> Doc
- Language.Fixpoint.Misc: withColor :: Color -> IO a -> IO ()
+ Language.Fixpoint.Misc: withColor :: Color -> IO () -> IO ()
- Language.Fixpoint.Misc: wrapStars :: [Char] -> [Char]
+ Language.Fixpoint.Misc: wrapStars :: String -> String
- Language.Fixpoint.Parse: angles :: ParsecT String u Identity a -> ParsecT String u Identity a
+ Language.Fixpoint.Parse: angles :: ParserT u a -> ParserT u a
- Language.Fixpoint.Parse: bindP :: ParsecT String Integer Identity Symbol
+ Language.Fixpoint.Parse: bindP :: Parser Symbol
- Language.Fixpoint.Parse: blanks :: Stream s m Char => ParsecT s u m [Char]
+ Language.Fixpoint.Parse: blanks :: Parser String
- Language.Fixpoint.Parse: braces :: ParsecT String u Identity a -> ParsecT String u Identity a
+ Language.Fixpoint.Parse: braces :: ParserT u a -> ParserT u a
- Language.Fixpoint.Parse: brackets :: ParsecT String u Identity a -> ParsecT String u Identity a
+ Language.Fixpoint.Parse: brackets :: ParserT u a -> ParserT u a
- Language.Fixpoint.Parse: bvSortP :: ParsecT String u Identity Sort
+ Language.Fixpoint.Parse: bvSortP :: Parser Sort
- Language.Fixpoint.Parse: colon :: ParsecT String u Identity String
+ Language.Fixpoint.Parse: colon :: Parser String
- Language.Fixpoint.Parse: comma :: ParsecT String u Identity String
+ Language.Fixpoint.Parse: comma :: Parser String
- Language.Fixpoint.Parse: dcolon :: Stream s m Char => ParsecT s u m String
+ Language.Fixpoint.Parse: dcolon :: Parser String
- Language.Fixpoint.Parse: doParse' :: Num u => ParsecT String u Identity a -> SourceName -> String -> a
+ Language.Fixpoint.Parse: doParse' :: Parser a -> SourceName -> String -> a
- Language.Fixpoint.Parse: funAppP :: ParsecT String Integer Identity Expr
+ Language.Fixpoint.Parse: funAppP :: Parser Expr
- Language.Fixpoint.Parse: integer :: Stream s m Char => ParsecT s u m Integer
+ Language.Fixpoint.Parse: integer :: Parser Integer
- Language.Fixpoint.Parse: lexer :: GenTokenParser String u Identity
+ Language.Fixpoint.Parse: lexer :: Monad m => GenTokenParser String u m
- Language.Fixpoint.Parse: locLowerIdP :: Parser (Located Symbol)
+ Language.Fixpoint.Parse: locLowerIdP :: Parser LocSymbol
- Language.Fixpoint.Parse: locUpperIdP :: Parser (Located Symbol)
+ Language.Fixpoint.Parse: locUpperIdP :: Parser LocSymbol
- Language.Fixpoint.Parse: parens :: ParsecT String u Identity a -> ParsecT String u Identity a
+ Language.Fixpoint.Parse: parens :: ParserT u a -> ParserT u a
- Language.Fixpoint.Parse: qualifierP :: Parser Sort -> ParsecT String Integer Identity Qualifier
+ Language.Fixpoint.Parse: qualifierP :: Parser Sort -> Parser Qualifier
- Language.Fixpoint.Parse: remainderP :: Monad m => ParsecT t1 u m t -> ParsecT t1 u m (t, t1, SourcePos)
+ Language.Fixpoint.Parse: remainderP :: Parser a -> Parser (a, String, SourcePos)
- Language.Fixpoint.Parse: reserved :: String -> ParsecT String u Identity ()
+ Language.Fixpoint.Parse: reserved :: String -> Parser ()
- Language.Fixpoint.Parse: reservedOp :: String -> ParsecT String u Identity ()
+ Language.Fixpoint.Parse: reservedOp :: String -> Parser ()
- Language.Fixpoint.Parse: semi :: ParsecT String u Identity String
+ Language.Fixpoint.Parse: semi :: Parser String
- Language.Fixpoint.Parse: type Parser = Parsec String Integer
+ Language.Fixpoint.Parse: type Parser = ParsecT String Integer (State PState)
- Language.Fixpoint.Parse: whiteSpace :: ParsecT String u Identity ()
+ Language.Fixpoint.Parse: whiteSpace :: Parser ()
- Language.Fixpoint.Smt.Bitvector: Bv :: BvSize -> String -> Bv
+ Language.Fixpoint.Smt.Bitvector: Bv :: !BvSize -> !String -> Bv
- Language.Fixpoint.Smt.Interface: Assert :: (Maybe Int) -> Expr -> Command
+ Language.Fixpoint.Smt.Interface: Assert :: !(Maybe Int) -> !Expr -> Command
- Language.Fixpoint.Smt.Interface: Ctx :: ProcessHandle -> Handle -> Handle -> Maybe Handle -> Bool -> SMTEnv -> Context
+ Language.Fixpoint.Smt.Interface: Ctx :: !ProcessHandle -> !Handle -> !Handle -> !(Maybe Handle) -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !SMTEnv -> Context
- Language.Fixpoint.Smt.Interface: Declare :: Symbol -> [Sort] -> Sort -> Command
+ Language.Fixpoint.Smt.Interface: Declare :: !Symbol -> [Sort] -> !Sort -> Command
- Language.Fixpoint.Smt.Interface: Define :: Sort -> Command
+ Language.Fixpoint.Smt.Interface: Define :: !Sort -> Command
- Language.Fixpoint.Smt.Interface: Error :: Raw -> Response
+ Language.Fixpoint.Smt.Interface: Error :: !Text -> Response
- Language.Fixpoint.Smt.Interface: Values :: [(Symbol, Raw)] -> Response
+ Language.Fixpoint.Smt.Interface: Values :: [(Symbol, Text)] -> Response
- Language.Fixpoint.Smt.Interface: checkValid :: Bool -> FilePath -> [(Symbol, Sort)] -> Expr -> Expr -> IO Bool
+ Language.Fixpoint.Smt.Interface: checkValid :: Config -> FilePath -> [(Symbol, Sort)] -> Expr -> Expr -> IO Bool
- Language.Fixpoint.Smt.Interface: checkValids :: Bool -> FilePath -> [(Symbol, Sort)] -> [Expr] -> IO [Bool]
+ Language.Fixpoint.Smt.Interface: checkValids :: Config -> FilePath -> [(Symbol, Sort)] -> [Expr] -> IO [Bool]
- Language.Fixpoint.Smt.Interface: class SMTLIB2 a where defunc = return runSmt2 env a = smt2 $ evalState (defunc a) (SMTSt 0 env)
+ Language.Fixpoint.Smt.Interface: class SMTLIB2 a
- Language.Fixpoint.Smt.Interface: makeContext :: Bool -> SMTSolver -> FilePath -> IO Context
+ Language.Fixpoint.Smt.Interface: makeContext :: Config -> FilePath -> IO Context
- Language.Fixpoint.Smt.Interface: makeContextNoLog :: Bool -> SMTSolver -> IO Context
+ Language.Fixpoint.Smt.Interface: makeContextNoLog :: Config -> IO Context
- Language.Fixpoint.Smt.Interface: makeContextWithSEnv :: Bool -> SMTSolver -> FilePath -> SMTEnv -> IO Context
+ Language.Fixpoint.Smt.Interface: makeContextWithSEnv :: Config -> FilePath -> SMTEnv -> IO Context
- Language.Fixpoint.Smt.Interface: smt2 :: SMTLIB2 a => a -> Text
+ Language.Fixpoint.Smt.Interface: smt2 :: SMTLIB2 a => a -> Builder
- Language.Fixpoint.Smt.Interface: smtBracket :: Context -> IO a -> IO a
+ Language.Fixpoint.Smt.Interface: smtBracket :: Context -> String -> IO a -> IO a
- Language.Fixpoint.Smt.Interface: smtWrite :: Context -> Text -> IO ()
+ Language.Fixpoint.Smt.Interface: smtWrite :: Context -> Raw -> IO ()
- Language.Fixpoint.Smt.Theories: preamble :: Bool -> SMTSolver -> [Text]
+ Language.Fixpoint.Smt.Theories: preamble :: Config -> SMTSolver -> [Text]
- Language.Fixpoint.Smt.Theories: smt2App :: Expr -> [Text] -> Maybe Text
+ Language.Fixpoint.Smt.Theories: smt2App :: Expr -> [Builder] -> Maybe Builder
- Language.Fixpoint.Smt.Theories: smt2Sort :: Sort -> Maybe Text
+ Language.Fixpoint.Smt.Theories: smt2Sort :: Sort -> Maybe Builder
- Language.Fixpoint.Smt.Theories: smt2Symbol :: Symbol -> Maybe Text
+ Language.Fixpoint.Smt.Theories: smt2Symbol :: Symbol -> Maybe Builder
- Language.Fixpoint.Smt.Types: Assert :: (Maybe Int) -> Expr -> Command
+ Language.Fixpoint.Smt.Types: Assert :: !(Maybe Int) -> !Expr -> Command
- Language.Fixpoint.Smt.Types: Ctx :: ProcessHandle -> Handle -> Handle -> Maybe Handle -> Bool -> SMTEnv -> Context
+ Language.Fixpoint.Smt.Types: Ctx :: !ProcessHandle -> !Handle -> !Handle -> !(Maybe Handle) -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !SMTEnv -> Context
- Language.Fixpoint.Smt.Types: Declare :: Symbol -> [Sort] -> Sort -> Command
+ Language.Fixpoint.Smt.Types: Declare :: !Symbol -> [Sort] -> !Sort -> Command
- Language.Fixpoint.Smt.Types: Define :: Sort -> Command
+ Language.Fixpoint.Smt.Types: Define :: !Sort -> Command
- Language.Fixpoint.Smt.Types: Error :: Raw -> Response
+ Language.Fixpoint.Smt.Types: Error :: !Text -> Response
- Language.Fixpoint.Smt.Types: Thy :: Symbol -> Raw -> Sort -> TheorySymbol
+ Language.Fixpoint.Smt.Types: Thy :: !Symbol -> !Raw -> !Sort -> !Bool -> TheorySymbol
- Language.Fixpoint.Smt.Types: Values :: [(Symbol, Raw)] -> Response
+ Language.Fixpoint.Smt.Types: Values :: [(Symbol, Text)] -> Response
- Language.Fixpoint.Smt.Types: [tsRaw] :: TheorySymbol -> Raw
+ Language.Fixpoint.Smt.Types: [tsRaw] :: TheorySymbol -> !Raw
- Language.Fixpoint.Smt.Types: [tsSort] :: TheorySymbol -> Sort
+ Language.Fixpoint.Smt.Types: [tsSort] :: TheorySymbol -> !Sort
- Language.Fixpoint.Smt.Types: [tsSym] :: TheorySymbol -> Symbol
+ Language.Fixpoint.Smt.Types: [tsSym] :: TheorySymbol -> !Symbol
- Language.Fixpoint.Smt.Types: class SMTLIB2 a where defunc = return runSmt2 env a = smt2 $ evalState (defunc a) (SMTSt 0 env)
+ Language.Fixpoint.Smt.Types: class SMTLIB2 a
- Language.Fixpoint.Smt.Types: runSmt2 :: SMTLIB2 a => SMTEnv -> a -> Text
+ Language.Fixpoint.Smt.Types: runSmt2 :: (SMTLIB2 a) => a -> Builder
- Language.Fixpoint.Smt.Types: smt2 :: SMTLIB2 a => a -> Text
+ Language.Fixpoint.Smt.Types: smt2 :: SMTLIB2 a => a -> Builder
- Language.Fixpoint.Solver.Monad: getBinds :: SolveM BindEnv
+ Language.Fixpoint.Solver.Monad: getBinds :: SolveM SolEnv
- Language.Fixpoint.Solver.Monad: runSolverM :: Config -> GInfo c b -> Int -> SolveM a -> IO a
+ Language.Fixpoint.Solver.Monad: runSolverM :: Config -> SolverInfo b c -> Int -> SolveM a -> IO a
- Language.Fixpoint.Solver.Solution: init :: SInfo a -> Solution
+ Language.Fixpoint.Solver.Solution: init :: Config -> SInfo a -> HashSet KVar -> Solution
- Language.Fixpoint.Solver.Solution: lhsPred :: BindEnv -> Solution -> SimpC a -> Expr
+ Language.Fixpoint.Solver.Solution: lhsPred :: SolEnv -> Solution -> SimpC a -> Expr
- Language.Fixpoint.Solver.Solution: update :: Solution -> [KVar] -> [(KVar, EQual)] -> (Bool, Solution)
+ Language.Fixpoint.Solver.Solution: update :: Sol a QBind -> [KVar] -> [(KVar, EQual)] -> (Bool, Sol a QBind)
- Language.Fixpoint.Solver.Solve: solve :: (NFData a, Fixpoint a) => Config -> Solution -> SInfo a -> IO (Result (Integer, a))
+ Language.Fixpoint.Solver.Solve: solve :: (NFData a, Fixpoint a) => Config -> SInfo a -> IO (Result (Integer, a))
- Language.Fixpoint.Solver.Worklist: init :: SInfo a -> Worklist a
+ Language.Fixpoint.Solver.Worklist: init :: SolverInfo a b -> Worklist a
- Language.Fixpoint.SortCheck: elaborate :: SEnv Sort -> Expr -> Expr
+ Language.Fixpoint.SortCheck: elaborate :: Elaborate a => String -> SEnv Sort -> a -> a
- Language.Fixpoint.Types.Config: Config :: FilePath -> FilePath -> FilePath -> Maybe Int -> Int -> Int -> SMTSolver -> GenQualifierSort -> UeqAllSorts -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Config
+ Language.Fixpoint.Types.Config: Config :: FilePath -> Maybe Int -> Int -> Int -> SMTSolver -> Bool -> Bool -> Bool -> Bool -> Bool -> Eliminate -> Maybe Int -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Config
- Language.Fixpoint.Types.Config: [eliminate] :: Config -> Bool
+ Language.Fixpoint.Types.Config: [eliminate] :: Config -> Eliminate
- Language.Fixpoint.Types.Constraints: FI :: HashMap Integer (c a) -> HashMap KVar (WfC a) -> !BindEnv -> !(SEnv Sort) -> Kuts -> ![Qualifier] -> HashMap BindId a -> FilePath -> !Bool -> GInfo c a
+ Language.Fixpoint.Types.Constraints: FI :: !(HashMap SubcId (c a)) -> !(HashMap KVar (WfC a)) -> !BindEnv -> !(SEnv Sort) -> !(SEnv Sort) -> !Kuts -> ![Qualifier] -> !(HashMap BindId a) -> !HOInfo -> ![Triggered Expr] -> AxiomEnv -> GInfo c a
- Language.Fixpoint.Types.Constraints: Q :: Symbol -> [(Symbol, Sort)] -> Expr -> !SourcePos -> Qualifier
+ Language.Fixpoint.Types.Constraints: Q :: !Symbol -> [(Symbol, Sort)] -> !Expr -> !SourcePos -> Qualifier
- Language.Fixpoint.Types.Constraints: Result :: FixResult a -> FixSolution -> Result a
+ Language.Fixpoint.Types.Constraints: Result :: !(FixResult a) -> !FixSolution -> !GFixSolution -> Result a
- Language.Fixpoint.Types.Constraints: [bindInfo] :: GInfo c a -> HashMap BindId a
+ Language.Fixpoint.Types.Constraints: [bindInfo] :: GInfo c a -> !(HashMap BindId a)
- Language.Fixpoint.Types.Constraints: [cm] :: GInfo c a -> HashMap Integer (c a)
+ Language.Fixpoint.Types.Constraints: [cm] :: GInfo c a -> !(HashMap SubcId (c a))
- Language.Fixpoint.Types.Constraints: [eqArgs] :: EQual -> ![Expr]
+ Language.Fixpoint.Types.Constraints: [eqArgs] :: Equation -> [Symbol]
- Language.Fixpoint.Types.Constraints: [kuts] :: GInfo c a -> Kuts
+ Language.Fixpoint.Types.Constraints: [kuts] :: GInfo c a -> !Kuts
- Language.Fixpoint.Types.Constraints: [resSolution] :: Result a -> FixSolution
+ Language.Fixpoint.Types.Constraints: [resSolution] :: Result a -> !FixSolution
- Language.Fixpoint.Types.Constraints: [resStatus] :: Result a -> FixResult a
+ Language.Fixpoint.Types.Constraints: [resStatus] :: Result a -> !(FixResult a)
- Language.Fixpoint.Types.Constraints: [wrft] :: WfC a -> (Symbol, Sort, KVar)
+ Language.Fixpoint.Types.Constraints: [wrft] :: WfC a -> !(Symbol, Sort, KVar)
- Language.Fixpoint.Types.Constraints: [ws] :: GInfo c a -> HashMap KVar (WfC a)
+ Language.Fixpoint.Types.Constraints: [ws] :: GInfo c a -> !(HashMap KVar (WfC a))
- Language.Fixpoint.Types.Constraints: fi :: [SubC a] -> [WfC a] -> BindEnv -> SEnv Sort -> Kuts -> [Qualifier] -> HashMap BindId a -> FilePath -> Bool -> GInfo SubC a
+ Language.Fixpoint.Types.Constraints: fi :: [SubC a] -> [WfC a] -> BindEnv -> SEnv Sort -> SEnv Sort -> Kuts -> [Qualifier] -> HashMap BindId a -> Bool -> Bool -> [Triggered Expr] -> AxiomEnv -> GInfo SubC a
- Language.Fixpoint.Types.Constraints: subcId :: (TaggedC c a) => c a -> Integer
+ Language.Fixpoint.Types.Constraints: subcId :: (TaggedC c a) => c a -> SubcId
- Language.Fixpoint.Types.Environments: beBinds :: SizedEnv a -> BindMap a
+ Language.Fixpoint.Types.Environments: beBinds :: SizedEnv a -> (BindMap a)
- Language.Fixpoint.Types.Environments: lookupSEnv :: Symbol -> SEnv v -> Maybe v
+ Language.Fixpoint.Types.Environments: lookupSEnv :: Symbol -> SEnv a -> Maybe a
- Language.Fixpoint.Types.Environments: mapBindEnv :: ((Symbol, SortedReft) -> (Symbol, SortedReft)) -> BindEnv -> BindEnv
+ Language.Fixpoint.Types.Environments: mapBindEnv :: (BindId -> (Symbol, SortedReft) -> (Symbol, SortedReft)) -> BindEnv -> BindEnv
- Language.Fixpoint.Types.Environments: mapSEnv :: (a1 -> a) -> SEnv a1 -> SEnv a
+ Language.Fixpoint.Types.Environments: mapSEnv :: (a -> b) -> SEnv a -> SEnv b
- Language.Fixpoint.Types.Environments: mapSEnvWithKey :: ((Symbol, a1) -> (Symbol, a)) -> SEnv a1 -> SEnv a
+ Language.Fixpoint.Types.Environments: mapSEnvWithKey :: ((Symbol, a) -> (Symbol, b)) -> SEnv a -> SEnv b
- Language.Fixpoint.Types.Errors: errFreeVarInConstraint :: Integer -> Error
+ Language.Fixpoint.Types.Errors: errFreeVarInConstraint :: (PPrint a) => (Integer, a) -> Error
- Language.Fixpoint.Types.Names: boolToIntName :: Symbol
+ Language.Fixpoint.Types.Names: boolToIntName :: (IsString a) => a
- Language.Fixpoint.Types.Names: strConName :: Symbol
+ Language.Fixpoint.Types.Names: strConName :: (IsString a) => a
- Language.Fixpoint.Types.Refinements: PGrad :: Expr
+ Language.Fixpoint.Types.Refinements: PGrad :: !KVar -> !Subst -> !Expr -> Expr
- Language.Fixpoint.Types.Refinements: pAnd :: ListNE Expr -> Expr
+ Language.Fixpoint.Types.Refinements: pAnd :: ListNE Pred -> Pred
- Language.Fixpoint.Types.Refinements: pIte :: Expr -> Expr -> Expr -> Expr
+ Language.Fixpoint.Types.Refinements: pIte :: Pred -> Expr -> Expr -> Expr
- Language.Fixpoint.Types.Refinements: pOr :: ListNE Expr -> Expr
+ Language.Fixpoint.Types.Refinements: pOr :: ListNE Pred -> Pred
- Language.Fixpoint.Types.Sorts: FApp :: Sort -> Sort -> Sort
+ Language.Fixpoint.Types.Sorts: FApp :: !Sort -> !Sort -> Sort
- Language.Fixpoint.Types.Sorts: FObj :: Symbol -> Sort
+ Language.Fixpoint.Types.Sorts: FObj :: !Symbol -> Sort
- Language.Fixpoint.Types.Sorts: FTC :: FTycon -> Sort
+ Language.Fixpoint.Types.Sorts: FTC :: !FTycon -> Sort
- Language.Fixpoint.Types.Spans: Loc :: !SourcePos -> !SourcePos -> a -> Located a
+ Language.Fixpoint.Types.Spans: Loc :: !SourcePos -> !SourcePos -> !a -> Located a
- Language.Fixpoint.Types.Spans: [val] :: Located a -> a
+ Language.Fixpoint.Types.Spans: [val] :: Located a -> !a

Files

+ .ghci view
@@ -0,0 +1,1 @@+:set -isrc
+ .git view
@@ -0,0 +1,1 @@+gitdir: ../.git/modules/liquid-fixpoint
+ .gitignore view
@@ -0,0 +1,30 @@+.depend+*.cmi+*.cmo+*.cmx+*.o+/dist*+.liquid+/.vagrant/+/.stack-work/+/build.sh+/external/fixpoint/config.make+/external/fixpoint/fixpoint.native+/external/fixpoint/misc+/external/fixpoint/smtZ3.ml+/external/ocamlgraph/META+/external/ocamlgraph/Makefile+/external/ocamlgraph/config.status+/external/ocamlgraph/graph.a+/external/ocamlgraph/graph.cma+/external/ocamlgraph/graph.cmxa+/external/ocamlgraph/src/dot_lexer.ml+/external/ocamlgraph/src/dot_parser.ml+/external/ocamlgraph/src/dot_parser.mli+/external/ocamlgraph/src/dot_parser.output+/external/ocamlgraph/src/gml.ml+/external/ocamlgraph/src/version.ml+/tests/neg/.liquid/+/tests/pos/.liquid/+/external/ocamlgraph/config.log+/TAGS
+ .travis.yml view
@@ -0,0 +1,51 @@+language: c+sudo: false++# Only build master, develop, and PRs+branches:+  only:+  - master+  - develop+  - parser-az++matrix:+  include:+    - env: SMT="z3" CABAL=1.22 GHC=7.10.3+      addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,],sources: [hvr-ghc]}}+    - env: SMT="z3" CABAL=1.24 GHC=8.0.1+      addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1,],sources: [hvr-ghc]}}+    - env: SMT="z3" CABAL=1.24 GHC=8.0.2+      addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.2,],sources: [hvr-ghc]}}+    - env: CABALVER=head GHCVER=head+      addons: {apt: {packages: [cabal-install-head,ghc-head],  sources: [hvr-ghc]}}++  allow_failures:+   - env: CABALVER=head GHCVER=head++cache:+  directories:+  - $HOME/.cabal+  - $HOME/.ghc++before_install:+ - export PATH="$HOME/.cabal/bin:/opt/ghc/$GHC/bin:/opt/cabal/$CABAL/bin:$PATH"+ - scripts/travis clean_cache "$SMT"++install:+ - scripts/travis install_cabal_deps+ - scripts/travis install_smt "$SMT"++script:+ - scripts/travis do_build && scripts/travis do_test "$SMT"+ - scripts/travis clean_cache "$SMT"++after_failure:+ - scripts/travis dump_fail_logs++notifications:+  slack:+    rooms:+      secure: VT1SqW+4WQKb2PXgObQ/rNdQN8pFK5LaFacxB0fEvRZ2FSbM3qp1NGgii7WHlQdr598+L5qYhkpy1B8ssgNeR7iMmYP4GV/fhCoMd8nTQHLSrTMH8iQgT0D7SnuKdk5FQq1IXWtHjUzXtTIhnkfwOJF/xYf6BMMrO0sCta5JZgg=+    on_success: change+    on_failure: always+    on_start: never
+ CHANGES.md view
@@ -0,0 +1,29 @@+# CHANGES++## NEXT++## 0.3.0.0++- Make interpreted mul and div the default, when `solver = z3`+- Use `higherorder` flag to allow higher order binders into the environment ++## 0.2.2.0++- Added support for theory of Arrays `Map_t`, `Map_select`, `Map_store`++- Added support for theory of Bitvectors -- see `Language.Fixpoint.Smt.Bitvector`++- Added support for string literals++## 0.2.1.0++- Pre-compiled binaries of the underlying ocaml solver are now+  provided for Linux, Mac OSX, and Windows.++  No more need to install Ocaml!++## 0.2.0.0++- Parsing has been improved to require *much* fewer parentheses.++- Experimental support for Z3's theory of real numbers with the `--real` flag.
+ Makefile view
@@ -0,0 +1,59 @@++OPTS="-W -O2 -XStandaloneDeriving"+PROFOPTS="-O2 -rtsopts -prof -auto-all -caf-all -XStandaloneDeriving -XDeriveDataTypeable"++CABAL=cabal+CABALI=$(CABAL) install --ghc-options=$(OPTS)+CABALP=$(CABAL) install --ghc-options=$(OPTS) -p++DEPS=unix-compat transformers mtl filemanip text parsec ghc-paths deepseq comonad contravariant semigroupoids semigroups bifunctors hscolour ansi-terminal hashable unordered-containers++TASTY=./dist/build/test/test++all:+	$(CABAL) install --ghc-options=$(OPTS)++force:+	$(CABAL) install --force-reinstalls --ghc-options=$(OPTS)++rebuild: ocaml+	make++igoto:+	$(CABAL) configure --ghc-options=$(OPTS)++goto:+	$(CABAL) build --ghc-options=$(OPTS)+	cp dist/build/liquid/liquid ~/.cabal/bin/++prof:+	$(CABAL) install --enable-executable-profiling --enable-library-profiling --ghc-options=$(PROFOPTS)++clean:+	cabal clean++docs:+	$(CABAL) haddock --executables --internal --hoogle --hyperlink-source #--html-location=http://goto.ucsd.edu/~rjhala/llvm-haskell/+++deps:+	$(CABALI) $(DEPS)++pdeps:+	$(CABALP) $(DEPS)++lint:+	hlint --colour --report .++tags:+	hasktags -c src/+	hasktags -e src/+	hasktags -x -c src/++test:+	cabal configure -fdevel --enable-tests --disable-library-profiling -O2+	cabal build+	cabal exec $(TASTY)++test710:+	$(TASTY)
+ README.md view
@@ -0,0 +1,303 @@+Liquid Fixpoint [![Hackage](https://img.shields.io/hackage/v/liquid-fixpoint.svg)](https://hackage.haskell.org/package/liquid-fixpoint) [![Hackage-Deps](https://img.shields.io/hackage-deps/v/liquid-fixpoint.svg)](http://packdeps.haskellers.com/feed?needle=liquid-fixpoint) [![Build Status](https://img.shields.io/travis/ucsd-progsys/liquid-fixpoint/master.svg)](https://travis-ci.org/ucsd-progsys/liquid-fixpoint)+===============+++This package implements a Horn-Clause/Logical Implication constraint solver used+for various Liquid Types. The solver uses SMTLIB2 to implement an algorithm similar to:+++ [Houdini](https://users.soe.ucsc.edu/~cormac/papers/fme01.pdf)++ [cartesian predicate abstraction](http://swt.informatik.uni-freiburg.de/berit/papers/boolean-and-cartesian-....pdf)+++Requirements+------------++In addition to the .cabal dependencies you require an SMTLIB2 compatible solver binary:++- [Z3](http://z3.codeplex.com)+- [CVC4](http://cvc4.cs.nyu.edu)+- [MathSat](http://mathsat.fbk.eu/download.html)++If on Windows, please make sure to place the binary and any associated DLLs somewhere+in your path.++How To Build and Install+------------------------++Simply do:++    git clone https://github.com/ucsd-progsys/liquid-fixpoint.git+    cd liquid-fixpoint+    stack install++or (`cabal` instead of `stack` if you prefer.)+++Using SMTLIB-based SMT Solvers+------------------------------++You can use one of several SMTLIB2 compliant solvers, by:++    fixpoint --smtsolver=z3 path/to/file.hs++Currently, we support++    * Z3+    * CVC4+    * MathSat++++Configuration Management+------------------------++It is very important that the version of Liquid Fixpoint be maintained properly.++Suppose that the current version of Liquid Haskell is `A.B.C.D`:+++ After a release to hackage is made, if any of the components `B`, `C`, or `D` are missing, they shall be added and set to `0`. Then the `D` component of Liquid Fixpoint shall be incremented by `1`. The version of Liquid Fixpoint is now `A.B.C.(D + 1)`+++ The first time a new function or type is exported from Liquid Fixpoint, if any of the components `B`, or `C` are missing, they shall be added and set to `0`. Then the `C` component shall be incremented by `1`, and the `D` component shall stripped. The version of Liquid Fixpoint is now `A.B.(C + 1)`+++ The first time the signature of an exported function or type is changed, or an exported function or type is removed (this includes functions or types that Liquid Fixpoint re-exports from its own dependencies), if the `B` component is missing, it shall be added and set to `0`. Then the `B` component shall be incremented by `1`, and the `C` and `D` components shall be stripped. The version of Liquid Fixpoint is now `A.(B + 1)`+++ The `A` component shall be updated at the sole discretion of the project owners.++It is recommended to use the [Bumper](https://hackage.haskell.org/package/bumper) utility to manage the versioning of Liquid Fixpoint. Bumper will automatically do the correct update to the cabal file. Additionally, it will update any packages that you have the source for that depend on Liquid Fixpoint.++To update Liquid Fixpoint and Liquid Haskell, first clone Liquid Haskell and Liquid Fixpoint to a common location:++```+git clone https://github.com/ucsd-progsys/liquidhaskell.git+git clone https://github.com/ucsd-progsys/liquid-fixpoint.git+```++To increment the `D` component of Liquid Fixpoint:++```+./path/to/bumper -3 liquid-fixpoint+```++This will update the `D` component of Liquid Fixpoint. If necessary, this will update the `Build-Depends` of Liquid Haskell. If the `Build-Depends` was updated, Liquid Haskell's `D` component will be incremented.++To increment the `C` component of Liquid Fixpoint, and strip the `D` component:++```+./path/to/bumper --minor liquid-fixpoint+```++As before, this will update Liquid Fixpoint and, if necessary, Liquid Haskell.++To increment the `B` component of Liquid Fixpoint, and strip the `D` and `C` components:++```+./path/to/bumper --major liquid-fixpoint+```++As before, this will update Liquid Fixpoint and, if necessary, Liquid Haskell++SMTLIB2 Interface+-----------------++There is a new SMTLIB2 interface directly from Haskell:+++ Language.Fixpoint.SmtLib2++See `tests/smt2/{Smt.hs, foo.smt2}` for an example of how to use it.++Options+-------++`--higherorder` allows higher order binders into the environment++`--extsolver` runs the **deprecated** external solver.++`--parts` Partitions an `FInfo` into a `[FInfo]` and emits a bunch of files. So:++    $ fixpoint -n -p path/to/foo.fq++will now emit files:++    path/to/.liquid/foo.1.fq+    path/to/.liquid/foo.2.fq+    . . .+    path/to/.liquid/foo.k.fq++and also a dot file with the constraint dependency graph:++    path/to/.liquid/foo.fq.dot+++## FInfo Invariants++### Binders++This is the field++```+     , bs       :: !BindEnv         -- ^ Bind  |-> (Symbol, SortedReft)+```++or in the .fq files as++```+bind 1 x : ...+bind 2 y : ...+```++* Each `BindId` must be a distinct `Int`,+* Each `BindId` that appears in a constraint+  environment i.e. inside _any_ `IBindEnv`+  must appear inside the `bs`++### Environments++* Each constraint's environment is a set of `BindId`+  which must be defined in the `bindInfo`. Furthermore++* Each constraint should not have _duplicate_ names in its+  environment, that is if you have two binders++```+  bind 1 x : ...+  bind 12 x : ...+```++  Then a single `IBindEnv` should only mention _at most_+  one of `1` or `12`.++* There is also a "tree-shape" property that its a bit hard+  to describe ... TODO     ++### LHS++Each `slhs` of a constraint is a `SortedReft`.++- Each `SortredReft` is basically a `Reft` -- a logical predicate.+  The important bit is that a `KVar` i.e. terms of the formalized++```+     $k1[x1:=y1][x2:=y2]...[xn:=yn]+```++  That is represented in the `Expr` type as++```+  | PKVar  !KVar !Subst+```++  must appear _only_ at the **top-level** that is not under _any_+  other operators, i.e. not as a sub-`Expr` of other expressions.+++- This is basically a predicate that needs to be "well sorted"+  with respect to the `BindId`, intuitively++```+    x:int, y:int |- x + y : int+```++  is well sorted. but++```+    x:int  |- x + y : int+```++  is not, and++```+    x:int, y: list |- x + y : int+```++  is not. The exact definition is formalized in `Language.Fixpoint.SortCheck`+++### RHS++Similarly each `rhs` of a `SubC` must either be a single `$k[...]` or an plain `$k`-free `Expr`.++### Global vs. Distinct Literals++```+     , gLits    :: !(SEnv Sort)               -- ^ Global Constant symbols+     , dLits    :: !(SEnv Sort)       +```++The _global_ literals `gLits` are symbols that+are in scope _everywhere_ i.e. need not be separately+defined in individual environments. These include things like++- uninterpreted _measure_ functions `len`, `height`,+- uninterpreted _data constructor_ literals `True`, `False`++Suppose you have an enumerated type like:++```+data Day = Sun | Mon | Tue | Wed | ... | Sat+```++You can model the above values in fixpoint as:++```+constant lit#Sun : Day+constant lit#Mon : Day+constant lit#Tue : Day+constant lit#Wed : Day+```++The _distinct_ literals are a subset of the above where we+want to tell the SMT solver that the values are *distinct*+i.e. **not equal** to each other, for example, you can+**additionally** specify this as:++```+distinct lit#Sun : Day+distinct lit#Mon : Day+distinct lit#Tue : Day+distinct lit#Wed : Day+```++The above two are represented programmatically by generating   +suitable `Symbol` values (for the literals  see `litSymbol`)+and `Sort` values as `FTC FTycon` and then making an `SEnv`+from the `[(Symbol, Sort)]`.++### Sorts++> What's the difference between an FTC and an FObj?++In early versions of fixpoint, there was support for +three sorts for expressions (`Expr`) that were sent +to the SMT solver:++1. `int`+2. `bool`+3. "other"++The `FObj` sort was introduced to represent essentially _all_ +non-int and non-bool values (e.g. tuples, lists, trees, pointers...)++However, we later realized that it is valuable to keep _more_+precise information for `Expr`s and so we introduced the `FTC`+(fixpoint type constructor), which lets us represent the above+respectively as:++- `FTC "String" []`                   -- in Haskell `String`+- `FTC "Tuple"  [FInt, Bool]`         -- in Haskell `(Int, Bool)`+- `FTC "List" [FTC "List" [FInt]]`    -- in Haskell `[[Int]]`++> There is a comment that says FObj's are uninterpretted types;+> so probably a type the SMT solver doesn't know about?+> Does that then make FTC types that the SMT solver does+> know about (bools, ints, lists, sets, etc.)?++The SMT solver knows about `bool`, `int` and `set` (also `bitvector` +and `map`) but _all_ other types are _currently_ represented as plain +`Int` inside the SMT solver. However, we _will be_ changing this +to make use of SMT support for ADTs ...++To sum up: the `FObj` is there for historical reasons; it has been +subsumed by `FTC` which is what I recomend you use. However `FObj` +is there if you want a simple "unitype" / "any" type for terms +that are not "interpreted".+
+ TODO.md view
@@ -0,0 +1,37 @@+# TODO++## Proper Encoding of DataTypes++```+(declare-datatypes (T) ((LL lnil (lcons (lhd T) (ltl LL)))))+(declare-fun l1 () (LL Int))+(declare-fun l2 () (LL Int))+(declare-fun l3 () (LL Int))+(declare-fun x  () Int)+(declare-fun zzz () Int)++(assert (not (= l1 (as lnil (LL Int)))))+(assert (not (= l2 (as lnil (LL Int)))))++(assert (= (lhd l1) (lhd l2)))+(assert (not (= l1 l2)))+(assert (= l3 (lcons x l2)))+(assert (> x 100))+(check-sat)++(get-model)+++(declare-fun xs () (LL Int))+(declare-fun ys () (LL Int))+(declare-fun y  () Int)++(assert (= xs (as lnil (LL Int))))+(assert (= ys (lcons y ys)))+(assert (= xs ys))+(check-sat)+++;; (assert (= (ltl l1) (ltl l2)))+;; (check-sat)+```
+ default.nix view
@@ -0,0 +1,32 @@+{ fetchgitLocal }:+{ mkDerivation, ansi-terminal, array, ascii-progress, async+, attoparsec, base, bifunctors, binary, boxes, bytestring, cereal+, cmdargs, containers, deepseq, directory, filemanip, filepath+, ghc-prim, hashable, intern, located-base, mtl, parallel, parsec, pretty+, process, stdenv, syb, tasty, tasty-hunit, tasty-rerun, text+, text-format, transformers, unordered-containers, z3+, dotgen, fgl, fgl-visualize+}:+mkDerivation {+  pname = "liquid-fixpoint";+  version = "9.9.9.9";+  src = fetchgitLocal ./.;+  isLibrary = true;+  isExecutable = true;+  libraryHaskellDepends = [+    ansi-terminal array ascii-progress async attoparsec base bifunctors+    binary boxes bytestring cereal cmdargs containers deepseq directory+    filemanip filepath ghc-prim hashable intern located-base mtl parallel parsec+    pretty process syb text text-format transformers+    unordered-containers+    dotgen fgl fgl-visualize+  ];+  executableHaskellDepends = [ base ];+  testHaskellDepends = [+    base directory filepath process tasty tasty-hunit tasty-rerun text+  ];+  testSystemDepends = [ z3 ];+  homepage = "https://github.com/ucsd-progsys/liquid-fixpoint";+  description = "Predicate Abstraction-based Horn-Clause/Implication Constraint Solver";+  license = stdenv.lib.licenses.bsd3;+}
liquid-fixpoint.cabal view
@@ -1,6 +1,6 @@ name:                liquid-fixpoint-version:             0.5.0.1-Copyright:           2010-15 Ranjit Jhala, University of California, San Diego.+version:             0.6.0.1+Copyright:           2010-17 Ranjit Jhala, University of California, San Diego. synopsis:            Predicate Abstraction-based Horn-Clause/Implication Constraint Solver homepage:            https://github.com/ucsd-progsys/liquid-fixpoint license:             BSD3@@ -10,7 +10,10 @@ category:            Language build-type:          Simple cabal-version:       >=1.10+Tested-With:         GHC == 7.10.3, GHC == 8.0.1 ++ description:     This package is a Haskell wrapper to the SMTLIB-based                  Horn-Clause/Logical Implication constraint solver used                  for Liquid Types.@@ -48,7 +51,7 @@   if flag(devel)     ghc-options: -Werror   hs-source-dirs: bin-  Build-Depends: base >= 4.7 && < 5+  Build-Depends: base >= 4.8 && < 5                , liquid-fixpoint  Library@@ -56,6 +59,7 @@   ghc-options:     -W -fno-warn-missing-methods   if flag(devel)     ghc-options:   -Werror+  ghc-prof-options: -fprof-auto   hs-source-dirs:  src   Exposed-Modules: Language.Fixpoint.Types.Names,                    Language.Fixpoint.Types.Errors,@@ -68,15 +72,22 @@                    Language.Fixpoint.Types.Substitutions,                    Language.Fixpoint.Types.Environments,                    Language.Fixpoint.Types.Constraints,-                   Language.Fixpoint.Types.Graphs,+                   Language.Fixpoint.Types.Triggers,+                   Language.Fixpoint.Types.Solutions,                    Language.Fixpoint.Types.Utils,                    Language.Fixpoint.Types,+                   Language.Fixpoint.Graph.Types,+                   Language.Fixpoint.Graph.Reducible,+                   Language.Fixpoint.Graph.Indexed,+                   Language.Fixpoint.Graph.Partition,+                   Language.Fixpoint.Graph.Deps,+                   Language.Fixpoint.Graph,+                   Language.Fixpoint.Defunctionalize,                    Language.Fixpoint.Smt.Types,                    Language.Fixpoint.Smt.Bitvector,                    Language.Fixpoint.Smt.Theories,                    Language.Fixpoint.Smt.Serialize,                    Language.Fixpoint.Smt.Interface,-                   Language.Fixpoint.Partition,                    Language.Fixpoint.Minimize,                    Language.Fixpoint.Solver,                    Language.Fixpoint.Parse,@@ -84,8 +95,7 @@                    Language.Fixpoint.Misc,                    Language.Fixpoint.Utils.Progress,                    Language.Fixpoint.Utils.Files,-                   Language.Fixpoint.Solver.Types,-                   Language.Fixpoint.Solver.Graph,+                   Language.Fixpoint.Solver.GradualSolution,                    Language.Fixpoint.Solver.Solution,                    Language.Fixpoint.Solver.Worklist,                    Language.Fixpoint.Solver.Monad,@@ -93,11 +103,13 @@                    Language.Fixpoint.Solver.UniqifyKVars,                    Language.Fixpoint.Solver.UniqifyBinds,                    Language.Fixpoint.Solver.Eliminate,-                   Language.Fixpoint.Solver.Validate,+                   Language.Fixpoint.Solver.Instantiate,+                   Language.Fixpoint.Solver.Sanitize,                    Language.Fixpoint.Utils.Statistics,+                   Language.Fixpoint.Solver.GradualSolve,                    Language.Fixpoint.Solver.Solve -  Build-Depends: base >= 4.7 && < 5+  Build-Depends: base >= 4.8 && < 5                , array                , async                , attoparsec@@ -130,6 +142,8 @@                , fgl                , fgl-visualize                , dotgen+               , time+   if impl(ghc >= 7.10.2)     Build-Depends: located-base   if !os(windows)@@ -154,3 +168,59 @@                     tasty-hunit,                     tasty-rerun >= 1.1,                     text++test-suite testparser+  default-language: Haskell98+  type:             exitcode-stdio-1.0+  hs-source-dirs:   tests+  ghc-options:      -threaded+  if flag(devel)+    ghc-options:    -Werror+  main-is:          testParser.hs+  build-depends:    base,+                    directory,+                    filepath,+                    tasty >= 0.10,+                    tasty-hunit,+                    tasty-rerun >= 1.1,+                    text+  if flag(devel)+    hs-source-dirs:   tests src+    build-depends:+                 array+               , async+               , attoparsec+               , syb+               , cmdargs+               , ansi-terminal+               , bifunctors+               , binary+               , bytestring+               , containers+               , deepseq+               , directory+               , filemanip+               , filepath+               , ghc-prim+               , intern+               , mtl+               , parsec+               , pretty+               , boxes+               , parallel+               , process+               , syb+               , text+               , transformers+               , hashable+               , unordered-containers+               , cereal+               , text-format+               , fgl+               , fgl-visualize+               , dotgen+               , time+    if impl(ghc >= 7.10.2)+      Build-Depends: located-base+  else+    build-depends: liquid-fixpoint
+ scripts/travis view
@@ -0,0 +1,137 @@+#!/bin/bash++set -eu+set -o pipefail++## Helper Functions++function loud {+  echo "$ $@"+  $@+}++# Source: https://github.com/travis-ci/travis-build/blob/fc4ae8a2ffa1f2b3a2f62533bbc4f8a9be19a8ae/lib/travis/build/script/templates/header.sh#L104-L123+RED="\033[31;1m"+GREEN="\033[32;1m"+RESET="\033[0m"+function travis_retry {+  local result=0+  local count=1+  while [ $count -le 3 ]; do+    [ $result -ne 0 ] && {+      echo -e "\n${RED}The command \"$@\" failed. Retrying, $count of 3.${RESET}\n" >&2+    }+    set +e+    "$@"+    result=$?+    set -e+    [ $result -eq 0 ] && break+    count=$(($count + 1))+    sleep 1+  done++  [ $count -eq 4 ] && {+    echo "\n${RED}The command \"$@\" failed 3 times.${RESET}\n" >&2+  }++  return $result+}++function prevent_timeout {+  local cmd="$@"++  $cmd &+  local cmd_pid=$!++  poke_stdout &+  local poke_pid=$!++  wait $cmd_pid+  exit_code=$?++  kill $poke_pid+  (wait $poke_pid 2>/dev/null) || true++  return $exit_code+}++function poke_stdout {+  # Print an invisible character every minute+  while true; do+    echo -ne "\xE2\x80\x8B"+    sleep 60+  done+}++function pastebin {+  curl -s -F 'clbin=<-' https://clbin.com+}++## Testing Stages++function clean_cache {+  local smt="$1"++  loud ghc-pkg unregister liquid-fixpoint --force || true+  loud rm "$HOME/.cabal/bin/$smt" || true+}++function install_smt {+  local smt="$1"++  mkdir -p "$HOME/.cabal/bin"+  loud curl "http://goto.ucsd.edu/~gridaphobe/$smt" -o "$HOME/.cabal/bin/$smt"+  loud chmod a+x "$HOME/.cabal/bin/$smt"+}++function install_cabal_deps {+  if ! _install_cabal_deps; then+    echo " ==> Cabal install failed. Clearing dependency cache and retrying."+    loud rm -rf "$HOME/.cabal"+    loud rm -rf "$HOME/.ghc"+    _install_cabal_deps+  fi+}++function _install_cabal_deps {+  loud travis_retry cabal update || return 1+  loud travis_retry cabal install --only-dependencies --enable-tests || return 1+}++function do_build {+  loud cabal configure -fbuild-external --enable-tests -v2+  loud prevent_timeout cabal build -j2+  loud cabal haddock+}++function do_test {+  loud prevent_timeout ./dist/build/test/test+}++function dump_fail_logs {+  find . -type f -wholename '*/.liquid/*' -name '*.log' -print0 | while IFS= read -r -d $'\0' file; do+    echo "${file}:"+    echo "    $(pastebin < "${file}")"+  done+}++function test_source_pkg {+  loud cabal sdist++  local src_tgz="dist/$(cabal info . | awk '{print $2 ".tar.gz";exit}')"++  if [ -f "$src_tgz" ]; then+    loud prevent_timeout cabal install -j4 "$src_tgz"+  else+    echo "expected '$src_tgz' not found"+    return 1+  fi+}++## Run Test Stage++stage="$1"+shift++$stage "$@"+
+ shell.nix view
@@ -0,0 +1,17 @@+{ nixpkgs ? import <nixpkgs> {}, compiler ? "default" }:++let++  inherit (nixpkgs) pkgs;++  f = import ./default.nix { inherit (pkgs) fetchgitLocal; };++  haskellPackages = if compiler == "default"+                       then pkgs.haskellPackages+                       else pkgs.haskell.packages.${compiler};++  drv = haskellPackages.callPackage f { inherit (pkgs) z3; };++in++  if pkgs.lib.inNixShell then drv.env else drv
+ src/Language/Fixpoint/Defunctionalize.hs view
@@ -0,0 +1,368 @@+{-# LANGUAGE TypeSynonymInstances #-}+{-# LANGUAGE FlexibleContexts     #-}+{-# LANGUAGE FlexibleInstances    #-}+{-# LANGUAGE TupleSections        #-}+{-# LANGUAGE PatternGuards        #-}+{-# LANGUAGE OverloadedStrings    #-}++--------------------------------------------------------------------------------+-- | `defunctionalize` traverses the query to:+--      1. "normalize" lambda terms by renaming binders,+--      2. generate alpha- and beta-equality axioms for+--   The lambdas and redexes found in the query.+--+--   NOTE: `defunctionalize` should happen **BEFORE**+--   `elaborate` as the latter converts all actual `EApp`+--   into the (uninterpreted) `smt_apply`.+--   We cannot elaborate prior to `defunc` as we need the+--   `EApp` and `ELam` to determine the lambdas and redexes.+--------------------------------------------------------------------------------++module Language.Fixpoint.Defunctionalize (defunctionalize, Defunc(..), defuncAny, makeLamArg) where++import qualified Data.HashMap.Strict as M+import           Data.Hashable+import           Data.Maybe             (isJust, maybeToList)+import qualified Data.List           as L++import           Control.Monad.State+import           Language.Fixpoint.Misc            (sortNub, fM, whenM, secondM, mapSnd)+import           Language.Fixpoint.Solver.Sanitize (symbolEnv)+import           Language.Fixpoint.Types        hiding (allowHO)+import           Language.Fixpoint.Types.Config+import           Language.Fixpoint.SortCheck       (checkSortExpr)+import           Language.Fixpoint.Types.Visitor   (mapMExpr, stripCasts)+-- import Debug.Trace (trace)++defunctionalize :: (Fixpoint a) => Config -> SInfo a -> SInfo a+defunctionalize cfg si = evalState (defunc si) (makeInitDFState cfg si)++defuncAny :: Defunc a => Config -> SEnv Sort -> a -> a +defuncAny cfg env e = evalState (defunc e) (makeDFState cfg env emptyIBindEnv)+++--------------------------------------------------------------------------------+-- | Expressions defunctionalization -------------------------------------------+--------------------------------------------------------------------------------+txExpr :: Expr -> DF Expr+txExpr e = do+  hoFlag <- gets dfHO+  if hoFlag then defuncExpr e else return e++defuncExpr :: Expr -> DF Expr+defuncExpr = mapMExpr reBind+         >=> mapMExpr logLam+         >=> mapMExpr logRedex+         >=> mapMExpr (fM normalizeLams)++reBind :: Expr -> DF Expr+reBind (ELam (x, s) e) = (\y -> ELam (y, s) (subst1 e (x, EVar y))) <$> freshSym s+reBind e               = return e++maxLamArg :: Int+maxLamArg = 7++-- NIKI TODO: allow non integer lambda arguments+-- sorts = [setSort intSort, bitVecSort intSort, mapSort intSort intSort, boolSort, realSort, intSort]+makeLamArg :: Sort -> Int -> Symbol+makeLamArg _ = intArgName++--------------------------------------------------------------------------------++makeAxioms :: DF [Expr]+makeAxioms = do+  alphEqs <- concatMap makeAlphaAxioms <$> getLams+  betaEqs <- concatMap makeBetaAxioms  <$> getRedexes+  env     <- gets dfEnv+  return   $ filter (validAxiom env) (alphEqs ++ betaEqs)++validAxiom :: SEnv Sort -> Expr -> Bool+validAxiom env = isJust . checkSortExpr env++--------------------------------------------------------------------------------+-- | Alpha Equivalence ---------------------------------------------------------+--------------------------------------------------------------------------------+makeAlphaAxioms ::  Expr -> [Expr]+makeAlphaAxioms = makeAlphaEq . normalizeLams++makeAlphaEq :: Expr -> [Expr]+makeAlphaEq e = go e ++ go' e+  where+    go ee+      = makeEqForAll ee (normalize ee)+    go' ee@(ELam (x, s) e)+      = [makeEq ee ee'+         | (i, ee') <- map (\j -> normalizeLamsFromTo j (ELam (x, s) e)) [1..maxLamArg-1]+         , i <= maxLamArg ]+    go' _+      = []++--------------------------------------------------------------------------------+-- | Normalizations ------------------------------------------------------------+--------------------------------------------------------------------------------++-- head normal form [TODO: example]++normalize :: Expr -> Expr+normalize = snd . go+  where+    go (ELam (y, sy) e) = let (i', e') = go e+                              y'      = makeLamArg sy i'+                          in (i'+1, ELam (y', sy) (e' `subst1` (y, EVar y')))+    go (EApp e e2)+      |  (ELam (x, _) bd) <- unECst e+                        = let (i1, e1') = go bd+                              (i2, e2') = go e2+                          in (max i1 i2, e1' `subst1` (x, e2'))+    go (EApp e1 e2)     = let (i1, e1') = go e1+                              (i2, e2') = go e2+                          in (max i1 i2, EApp e1' e2')+    go (ECst e s)       = mapSnd (`ECst` s) (go e)+    go (PAll bs e)      = mapSnd (PAll bs)  (go e)+    go e                = (1, e)++    unECst (ECst e _) = unECst e+    unECst e          = e++-- normalize lambda arguments [TODO: example]++normalizeLams :: Expr -> Expr+normalizeLams e = snd $ normalizeLamsFromTo 1 e++normalizeLamsFromTo :: Int -> Expr -> (Int, Expr)+normalizeLamsFromTo i   = go+  where+    go (ELam (y, sy) e) = let (i', e') = go e+                              y'      = makeLamArg sy i'+                          in (i' + 1, ELam (y', sy) (e' `subst1` (y, EVar y')))+    go (EApp e1 e2)     = let (i1, e1') = go e1+                              (i2, e2') = go e2+                          in (max i1 i2, EApp e1' e2')+    go (ECst e s)       = mapSnd (`ECst` s) (go e)+    go (PAll bs e)      = mapSnd (PAll bs) (go e)+    go e                = (i, e)++--------------------------------------------------------------------------------+-- | Beta Equivalence ----------------------------------------------------------+--------------------------------------------------------------------------------+makeBetaAxioms :: Expr -> [Expr]+makeBetaAxioms e = makeEqForAll (normalizeLams e) (normalize e)+  -- where+  --  e             = trace ("BETA-NL e = " ++ showpp e0) e0++makeEq :: Expr -> Expr -> Expr+makeEq e1 e2+  | e1 == e2  = PTrue+  | otherwise = EEq e1 e2++makeEqForAll :: Expr -> Expr -> [Expr]+makeEqForAll e1 e2 = [ makeEq (closeLam su e1') (closeLam su e2') | su <- instantiate xs]+  where+    (xs1, e1')     = splitPAll [] e1+    (xs2, e2')     = splitPAll [] e2+    xs             = L.nub (xs1 ++ xs2)++closeLam :: [(Symbol, (Symbol, Sort))] -> Expr -> Expr+closeLam ((x,(y,s)):su) e = ELam (y,s) (subst1 (closeLam su e) (x, EVar y))+closeLam []             e = e++splitPAll :: [(Symbol, Sort)] -> Expr -> ([(Symbol, Sort)], Expr)+splitPAll acc (PAll xs e) = splitPAll (acc ++ xs) e+splitPAll acc e           = (acc, e)++-- NOPROP instantiate :: [(Symbol, Sort)] -> [[(Symbol, (Symbol,Sort))]]+-- NOPROP instantiate []     = [[]]+-- NOPROP instantiate xs     = L.foldl' (\acc x -> combine (instOne x) acc) [] xs+  -- NOPROP where+    -- NOPROP instOne (x, s) = [(x, (makeLamArg s i, s)) | i <- [1..maxLamArg]]+    -- NOPROP combine xs []  = [[x] | x <- xs]+    -- NOPROP combine xs acc = concat [(x:) <$> acc | x <- xs]++instantiate    :: [(Symbol, Sort)] -> [[(Symbol, (Symbol,Sort))]]+instantiate     = choices . map inst1+  where+    inst1 (x,s) = [(x, (makeLamArg s i, s)) | i <- [1..maxLamArg]]++choices :: [[a]] -> [[a]]+choices []       = [[]]+choices (xs:xss) = [a:as | a <- xs, as <- choices xss]++--------------------------------------------------------------------------------+-- | Containers defunctionalization --------------------------------------------+--------------------------------------------------------------------------------++class Defunc a where+  defunc :: a -> DF a++instance (Defunc (c a), TaggedC c a) => Defunc (GInfo c a) where+  defunc fi = do+    cm'    <- defunc $ cm    fi+    ws'    <- defunc $ ws    fi+    -- NOPROP setBinds $ mconcat ((senv <$> M.elems (cm fi)) ++ (wenv <$> M.elems (ws fi)))+    gLits' <- defunc $ gLits fi+    dLits' <- defunc $ dLits fi+    bs'    <- defunc $ bs    fi+    ass'   <- defunc $ asserts fi +    -- NOPROP quals' <- defunc $ quals fi+    axioms <- makeAxioms+    return $ fi { cm      = cm'+                , ws      = ws'+                , gLits   = gLits'+                , dLits   = dLits'+                , bs      = bs'+                -- NOPROP , quals   = quals'+                , asserts = (noTrigger <$> axioms) ++ ass' +                }++instance (Defunc a) => Defunc (Triggered a) where+  defunc (TR t e) = TR t <$> defunc e ++instance Defunc (SimpC a) where+  defunc sc = do crhs' <- defunc $ _crhs sc+                 return $ sc {_crhs = crhs'}++instance Defunc (WfC a)   where+  defunc wf@(WfC {}) = do+    let (x, t, k) = wrft wf+    t' <- defunc t+    return $ wf { wrft = (x, t', k) }+  defunc wf@(GWfC {}) = do+    let (x, t, k) = wrft wf+    t' <- defunc t+    e' <- defunc $ wexpr wf+    return $ wf { wrft = (x, t', k), wexpr = e' }++instance Defunc SortedReft where+  defunc (RR s r) = RR s <$> defunc r++instance Defunc (Symbol, SortedReft) where+  defunc (x, sr) = (x,) <$> defunc sr++instance Defunc (Symbol, Sort) where+  defunc (x, t) = (x,) <$> defunc t++instance Defunc Reft where+  defunc (Reft (x, e)) = Reft . (x,) <$> defunc e++instance Defunc Expr where+  defunc = txExpr++instance Defunc a => Defunc (SEnv a) where+  defunc = mapMSEnv defunc++instance Defunc BindEnv   where+  defunc bs = do dfbs <- gets dfBEnv+                 let f (i, xs) = if i `memberIBindEnv` dfbs+                                       then  (i,) <$> defunc xs+                                       else  (i,) <$> matchSort xs+                 mapWithKeyMBindEnv f bs+   where+    -- The refinement cannot be elaborated thus defunc-ed because+    -- the bind does not appear in any contraint,+    -- thus unique binders does not perform properly+    -- The sort should be defunc, to ensure same sort on double binders+    matchSort (x, RR s r) = ((x,) . (`RR` r)) <$> defunc s++-- Sort defunctionalization [should be done by elaboration]+instance Defunc Sort where+  defunc = return++instance Defunc a => Defunc [a] where+  defunc = mapM defunc++instance (Defunc a, Eq k, Hashable k) => Defunc (M.HashMap k a) where+  defunc m = M.fromList <$> mapM (secondM defunc) (M.toList m)++type DF    = State DFST++data DFST = DFST+  { dfFresh   :: !Int+  , dfEnv   :: !(SEnv Sort)+  , dfBEnv  :: !IBindEnv+  , dfLam   :: !Bool        -- ^ normalize lams+  , dfExt   :: !Bool        -- ^ enable extensionality axioms+  , dfAEq   :: !Bool        -- ^ enable alpha equivalence axioms+  , dfBEq   :: !Bool        -- ^ enable beta equivalence axioms+  , dfNorm  :: !Bool        -- ^ enable normal form axioms+  , dfHO    :: !Bool        -- ^ allow higher order thus defunctionalize+  , dfLNorm :: !Bool+  , dfLams  :: ![Expr]      -- ^ lambda expressions appearing in the expressions+  , dfRedex :: ![Expr]      -- ^ redexes appearing in the expressions+  , dfBinds :: !(SEnv Sort) -- ^ sorts of new lambda-binders+  }+++makeDFState :: Config -> SEnv Sort -> IBindEnv -> DFST+makeDFState cfg senv ibind = DFST+  { dfFresh = 0+  , dfEnv   = senv +  , dfBEnv  = ibind+  , dfLam   = True+  , dfExt   = False +  , dfAEq   = alphaEquivalence cfg+  , dfBEq   = betaEquivalence  cfg+  , dfNorm  = normalForm       cfg+  , dfHO    = allowHO cfg  || defunction cfg+  , dfLNorm = True+  -- INVARIANT: lambads and redexes are not defunctionalized+  , dfLams  = []+  , dfRedex = []+  , dfBinds = mempty+  }+++makeInitDFState :: Config -> SInfo a -> DFST+makeInitDFState cfg si +  = makeDFState cfg +         (symbolEnv cfg si) +         (mconcat ((senv <$> M.elems (cm si)) ++ (wenv <$> M.elems (ws si))))++--------------------------------------------------------------------------------+-- | Low level monad manipulation ----------------------------------------------+--------------------------------------------------------------------------------+freshSym :: Sort -> DF Symbol+freshSym t = do+  n    <- gets dfFresh+  let x = intSymbol "lambda_fun_" n+  modify $ \s -> s {dfFresh = n + 1, dfBinds = insertSEnv x t (dfBinds s)}+  return x++logLam :: Expr -> DF Expr+logLam e = whenM (gets dfAEq) (putLam e) >> return e++logRedex :: Expr -> DF Expr+logRedex e = whenM (gets dfBEq) (putRedex e) >> return e++putLam :: Expr -> DF ()+putLam e@(ELam {}) = modify $ \s -> s { dfLams = e : dfLams s}+putLam _           = return ()++putRedex :: Expr -> DF ()+putRedex e@(EApp f _)+  | ELam _ _ <- stripCasts f+  = modify $ \s -> s { dfRedex = e : dfRedex s }+putRedex _+  = return ()+++-- | getLams and getRedexes return the (previously seen) lambdas and redexes,+--   after "closing" them by quantifying out free vars corresponding to the+--   fresh binders in `dfBinds`.+getLams    :: DF [Expr]+getLams    = getClosedField dfLams++getRedexes :: DF [Expr]+getRedexes = getClosedField dfRedex++getClosedField :: (DFST -> [Expr]) -> DF [Expr]+getClosedField fld = do+  env <- gets dfBinds+  es  <- gets fld+  return (closeLams env <$> es)++closeLams :: SEnv Sort -> Expr -> Expr+closeLams env e = PAll (freeBinds env e) e++freeBinds :: SEnv Sort -> Expr -> [(Symbol, Sort)]+freeBinds env e = [ (y, t) | y <- sortNub (syms e)+                           , t <- maybeToList (lookupSEnv y env) ]
+ src/Language/Fixpoint/Graph.hs view
@@ -0,0 +1,10 @@+-- | This module re-exports the data types, operations and+--   serialization functions for representing and computing+--   with constraint dependencies.++module Language.Fixpoint.Graph (module X ) where++import Language.Fixpoint.Graph.Types     as X+import Language.Fixpoint.Graph.Partition as X+import Language.Fixpoint.Graph.Reducible as X+import Language.Fixpoint.Graph.Deps      as X
+ src/Language/Fixpoint/Graph/Deps.hs view
@@ -0,0 +1,549 @@+{-# LANGUAGE TupleSections         #-}+{-# LANGUAGE OverloadedStrings     #-}+{-# LANGUAGE ConstraintKinds       #-}+{-# LANGUAGE TypeOperators         #-}+{-# LANGUAGE RecordWildCards       #-}++module Language.Fixpoint.Graph.Deps (+       -- * Remove Constraints that don't affect Targets+         slice++       -- * Predicate describing Targets+       , isTarget++      -- * Eliminatable KVars+      , Elims (..)+      , elimVars+      , elimDeps++      -- * Compute Raw Dependencies+      , kvEdges++      -- * Partition+      , decompose++      -- * Debug+      , graphStatistics+      ) where++import           Prelude hiding (init)+import           Data.Maybe                       (mapMaybe, fromMaybe)+import           Data.Tree (flatten)+import           Language.Fixpoint.Misc+import           Language.Fixpoint.Utils.Files+import           Language.Fixpoint.Types.Config+import qualified Language.Fixpoint.Types.Visitor      as V+import           Language.Fixpoint.Types.PrettyPrint+import qualified Language.Fixpoint.Types              as F+import           Language.Fixpoint.Graph.Types+import           Language.Fixpoint.Graph.Reducible  (isReducible)+import           Language.Fixpoint.Graph.Indexed++import           Control.Monad             (when)+import qualified Data.HashSet                         as S+import qualified Data.List                            as L+import qualified Data.HashMap.Strict                  as M+import qualified Data.Graph                           as G+import           Data.Function (on)+import           Data.Hashable+import           Text.PrettyPrint.HughesPJ+import           Debug.Trace (trace)++--------------------------------------------------------------------------------+-- | Compute constraints that transitively affect target constraints,+--   and delete everything else from F.SInfo a+--------------------------------------------------------------------------------+slice :: (F.TaggedC c a) => Config -> F.GInfo c a -> F.GInfo c a+--------------------------------------------------------------------------------+slice cfg fi +  | noslice cfg +  = fi +  | otherwise+  = fi { F.cm = cm'+       , F.ws = ws' }+  where+     cm' = M.filterWithKey inC (F.cm fi)+     ws' = M.filterWithKey inW (F.ws fi)+     ks  = sliceKVars fi sl+     is  = S.fromList (slKVarCs sl ++ slConcCs sl)+     sl  = mkSlice fi+     inC i _ = S.member i is+     inW k _ = S.member k ks++sliceKVars :: (F.TaggedC c a) => F.GInfo c a -> Slice -> S.HashSet F.KVar+sliceKVars fi sl = S.fromList $ concatMap (subcKVars be) cs+  where+    cs           = lookupCMap cm <$> slKVarCs sl ++ slConcCs sl+    be           = F.bs fi+    cm           = F.cm fi++subcKVars :: (F.TaggedC c a) => F.BindEnv -> c a -> [F.KVar]+subcKVars be c = V.envKVars be c ++ V.rhsKVars c++--------------------------------------------------------------------------------+mkSlice :: (F.TaggedC c a) => F.GInfo c a -> Slice+--------------------------------------------------------------------------------+mkSlice fi        = mkSlice_ (F.cm fi) g' es v2i i2v+  where+    g'            = G.transposeG g  -- "inverse" of g (reverse the dep-edges)+    (g, vf, cf)   = G.graphFromEdges es+    es            = gEdges $ cGraph fi+    v2i           = fst3 . vf+    i2v i         = fromMaybe (errU i) $ cf i+    errU i        = errorstar $ "graphSlice: Unknown constraint " ++ show i++mkSlice_ :: F.TaggedC c a+         => M.HashMap F.SubcId (c a)+         -> G.Graph+         -> [DepEdge]+         -> (G.Vertex -> F.SubcId)+         -> (F.SubcId -> G.Vertex)+         -> Slice+mkSlice_ cm g' es v2i i2v = Slice { slKVarCs = kvarCs+                                  , slConcCs = concCs+                                  , slEdges  = sliceEdges kvarCs es+                                  }+  where+    -- n                  = length kvarCs+    concCs             = [ i | (i, c) <- M.toList cm, isTarget c ]+    kvarCs             = v2i <$> reachVs+    rootVs             = i2v <$> concCs+    reachVs            = concatMap flatten $ G.dfs g' rootVs++sliceEdges :: [F.SubcId] -> [DepEdge] -> [DepEdge]+sliceEdges is es = [ (i, i, filter inSlice js) | (i, _, js) <- es, inSlice i ]+  where+    inSlice i    = M.member i im+    im           = M.fromList $ (, ()) <$> is++-- | DO NOT DELETE!+-- sliceCSucc :: Slice -> CSucc+-- sliceCSucc sl = \i -> M.lookupDefault [] i im+  -- where+    -- im        = M.fromList [(i, is) | (i,_,is) <- slEdges sl]++--------------------------------------------------------------------------------+isTarget :: (F.TaggedC c a) => c a -> Bool+--------------------------------------------------------------------------------+isTarget c   = V.isConcC c && isNonTriv c+  where+   isNonTriv = not .  F.isTautoPred . F.crhs+++--------------------------------------------------------------------------------+-- | Constraint Graph ----------------------------------------------------------+--------------------------------------------------------------------------------+cGraph :: (F.TaggedC c a) => F.GInfo c a -> CGraph+---------------------------------------------------------------------------+cGraph fi = CGraph { gEdges = es+                   , gRanks = outRs+                   , gSucc  = next+                   , gSccs  = length sccs }+  where+    es             = [(i, i, M.lookupDefault [] i next) | i <- M.keys $ F.cm fi]+    next           = kvSucc fi+    (g, vf, _)     = G.graphFromEdges es+    (outRs, sccs)  = graphRanks g vf++--------------------------------------------------------------------------------+-- | Ranks from Graph ----------------------------------------------------------+--------------------------------------------------------------------------------+graphRanks :: G.Graph -> (G.Vertex -> DepEdge) -> (CMap Int, [[G.Vertex]])+---------------------------------------------------------------------------+graphRanks g vf = (M.fromList irs, sccs)+  where+    irs        = [(v2i v, r) | (r, vs) <- rvss, v <- vs ]+    rvss       = zip [0..] sccs+    sccs       = L.reverse $ map flatten $ G.scc g+    v2i        = fst3 . vf++--------------------------------------------------------------------------------+-- | Dependencies --------------------------------------------------------------+--------------------------------------------------------------------------------+kvSucc :: (F.TaggedC c a) => F.GInfo c a -> CMap [F.SubcId]+--------------------------------------------------------------------------------+kvSucc fi = succs cm rdBy+  where+    rdBy  = kvReadBy fi+    cm    = F.cm     fi++succs :: (F.TaggedC c a) => CMap (c a) -> KVRead -> CMap [F.SubcId]+succs cm rdBy = (sortNub . concatMap kvReads . kvWrites) <$> cm+  where+    kvReads k = M.lookupDefault [] k rdBy+    kvWrites  = V.kvars . F.crhs++--------------------------------------------------------------------------------+kvWriteBy :: (F.TaggedC c a) => CMap (c a) -> F.SubcId -> [F.KVar]+--------------------------------------------------------------------------------+kvWriteBy cm = V.kvars . F.crhs . lookupCMap cm++--------------------------------------------------------------------------------+kvReadBy :: (F.TaggedC c a) => F.GInfo c a -> KVRead+--------------------------------------------------------------------------------+kvReadBy fi = group [ (k, i) | (i, ci) <- M.toList cm+                             , k       <- V.envKVars bs ci]+  where+    cm      = F.cm fi+    bs      = F.bs fi++--------------------------------------------------------------------------------+decompose :: (F.TaggedC c a) => F.GInfo c a -> KVComps+--------------------------------------------------------------------------------+decompose = componentsWith (kvgEdges . kvGraph)++--------------------------------------------------------------------------------+kvGraph :: (F.TaggedC c a) => F.GInfo c a -> KVGraph+--------------------------------------------------------------------------------+kvGraph = edgeGraph . kvEdges++edgeGraph :: [CEdge] -> KVGraph+edgeGraph es = KVGraph [(v, v, vs) | (v, vs) <- groupList es ]++kvEdges :: (F.TaggedC c a) => F.GInfo c a -> [CEdge]+kvEdges fi = selfes ++ concatMap (subcEdges bs) cs+  where+    bs     = F.bs fi+    cs     = M.elems (F.cm fi)+    ks     = fiKVars fi+    selfes =  [(Cstr i , Cstr  i) | c <- cs, let i = F.subcId c]+           ++ [(KVar k , DKVar k) | k <- ks]+           ++ [(DKVar k, DKVar k) | k <- ks]++fiKVars :: F.GInfo c a -> [F.KVar]+fiKVars = M.keys . F.ws++subcEdges :: (F.TaggedC c a) => F.BindEnv -> c a -> [CEdge]+subcEdges bs c =  [(KVar k, Cstr i ) | k  <- V.envKVars bs c]+               ++ [(Cstr i, KVar k') | k' <- V.rhsKVars c ]+  where+    i          = F.subcId c++--------------------------------------------------------------------------------+-- | Eliminated Dependencies+--------------------------------------------------------------------------------+elimDeps :: F.SInfo a -> [CEdge] -> S.HashSet F.KVar -> CDeps+elimDeps si es nonKutVs = graphDeps si es'+  where+    es'                 = graphElim es nonKutVs+    _msg                = "graphElim: " ++ show (length es')++{- | `graphElim` "eliminates" a kvar k by replacing every "path"++          ki -> ci -> k -> c++      with an edge++          ki ------------> c+-}+graphElim :: [CEdge] -> S.HashSet F.KVar -> [CEdge]+graphElim es ks = ikvgEdges $ elimKs ks $ edgesIkvg es+  where+    elimKs      = flip (S.foldl' elimK)++elimK  :: IKVGraph -> F.KVar -> IKVGraph+elimK g k   = (g `addLinks` es') `delNodes` (kV : cis)+  where+   es'      = [(ki, c) | ki@(KVar _) <- kis, c@(Cstr _) <- cs]+   cs       = getSuccs g kV+   cis      = getPreds g kV+   kis      = concatMap (getPreds g) cis+   kV       = KVar k++--------------------------------------------------------------------------------+-- | Generic Dependencies ------------------------------------------------------+--------------------------------------------------------------------------------+data Elims a+  = Deps { depCuts    :: !(S.HashSet a)+         , depNonCuts :: !(S.HashSet a)+         }+    deriving (Show)++instance PPrint (Elims a) where+  pprintTidy _ d = "#Cuts ="    <+> ppSize (depCuts d) <+>+                   "#NonCuts =" <+> ppSize (depNonCuts d)+    where+      ppSize     = pprint . S.size++instance (Eq a, Hashable a) => Monoid (Elims a) where+  mempty                            = Deps S.empty S.empty+  mappend (Deps d1 n1) (Deps d2 n2) = Deps (S.union d1 d2) (S.union n1 n2)++dCut, dNonCut :: (Hashable a) => a -> Elims a+dNonCut v = Deps S.empty (S.singleton v)+dCut    v = Deps (S.singleton v) S.empty++--------------------------------------------------------------------------------+-- | Compute Dependencies and Cuts ---------------------------------------------+--------------------------------------------------------------------------------+elimVars :: (F.TaggedC c a) => Config -> F.GInfo c a -> ([CEdge], Elims F.KVar)+--------------------------------------------------------------------------------+elimVars cfg si = (es, ds)+  where+    ds          = edgeDeps cfg si es+    es          = kvEdges si++removeKutEdges ::  S.HashSet F.KVar -> [CEdge] -> [CEdge]+removeKutEdges ks = filter (not . isKut . snd)+  where+    cutVs         = S.map KVar ks+    isKut         = (`S.member` cutVs)++cutVars :: (F.TaggedC c a) => Config -> F.GInfo c a -> S.HashSet F.KVar+cutVars cfg si+  | autoKuts cfg = S.empty+  | otherwise    = F.ksVars . F.kuts $ si++forceKuts :: (Hashable a, Eq a) => S.HashSet a -> Elims a  -> Elims a+forceKuts xs (Deps cs ns) = Deps (S.union cs xs) (S.difference ns xs)++edgeDeps :: (F.TaggedC c a) => Config -> F.GInfo c a -> [CEdge] -> Elims F.KVar+edgeDeps cfg si  = forceKuts ks+                 . edgeDeps' cfg+                 . removeKutEdges ks+                 . filter isRealEdge+  where+    ks           = givenKs `S.union` nlKs+    givenKs      = cutVars cfg    si+    nlKs+      | nonLinCuts cfg = nonLinearKVars si+      | otherwise      = mempty++edgeDeps' :: Config -> [CEdge] -> Elims F.KVar+edgeDeps' cfg es = Deps (takeK cs) (takeK ns)+  where+    Deps cs ns   = gElims cfg kF cutF g+    g            = kvgEdges    (edgeGraph es)+    cutF         = edgeRankCut (edgeRank es)+    takeK        = sMapMaybe tx+    tx (KVar z)  = Just z+    tx _         = Nothing+    kF (KVar _)  = True+    kF _         = False++sMapMaybe :: (Hashable b, Eq b) => (a -> Maybe b) -> S.HashSet a -> S.HashSet b+sMapMaybe f = S.fromList . mapMaybe f . S.toList++--------------------------------------------------------------------------------+type EdgeRank = M.HashMap F.KVar Integer+--------------------------------------------------------------------------------+edgeRank :: [CEdge] -> EdgeRank+edgeRank es = minimum . (n :) <$> kiM+  where+    n       = 1 + maximum [ i | (Cstr i, _)     <- es ]+    kiM     = group [ (k, i) | (KVar k, Cstr i) <- es ]++edgeRankCut :: EdgeRank -> Cutter CVertex+edgeRankCut km vs = case ks of+                      []  -> Nothing+                      k:_ -> Just (KVar k, [x | x@(u,_,_) <- vs, u /= KVar k])+  where+    ks            = orderBy [k | (KVar k, _ ,_) <- vs]+    rank          = (km M.!)+    orderBy       = L.sortBy (compare `on` rank)++--------------------------------------------------------------------------------+type Cutter a = [(a, a, [a])] -> Maybe (a, [(a, a, [a])])+--------------------------------------------------------------------------------++--------------------------------------------------------------------------------+type Cutable a = (Eq a, Ord a, Hashable a, Show a)+--------------------------------------------------------------------------------+gElims :: (Cutable a) => Config -> (a -> Bool) -> Cutter a -> [(a, a, [a])] -> Elims a+--------------------------------------------------------------------------------+gElims cfg kF cutF g = boundElims cfg kF g $ sccElims cutF g++--------------------------------------------------------------------------------+-- | `sccElims` returns an `Elims` that renders the dependency graph acyclic+--    by picking _at least one_ kvar from each non-trivial SCC in the graph+--------------------------------------------------------------------------------++sccElims :: (Cutable a) => Cutter a -> [(a, a, [a])] -> Elims a+sccElims f = sccsToDeps f . G.stronglyConnCompR++sccsToDeps :: (Cutable a) => Cutter a -> [G.SCC (a, a, [a])] -> Elims a+sccsToDeps f xs = mconcat $ sccDep f <$> xs++sccDep :: (Cutable a) =>  Cutter a -> G.SCC (a, a, [a]) -> Elims a+sccDep _ (G.AcyclicSCC (v,_,_)) = dNonCut v+sccDep f (G.CyclicSCC vs)      = cycleDep f vs++cycleDep :: (Cutable a) => Cutter a -> [(a, a, [a])] -> Elims a+cycleDep _ [] = mempty+cycleDep f vs = addCut f (f vs)++addCut :: (Cutable a) => Cutter a -> Maybe (a, [(a, a, [a])]) -> Elims a+addCut _ Nothing         = mempty+addCut f (Just (v, vs')) = mconcat $ dCut v : (sccDep f <$> sccs)+  where+    sccs                 = G.stronglyConnCompR vs'+++--------------------------------------------------------------------------------+-- | `boundElims` extends the input `Elims` by adding kuts that ensure that+--   the *maximum distance* between an eliminated KVar and a cut KVar is+--   *upper bounded* by a given threshold.+--------------------------------------------------------------------------------+boundElims :: (Cutable a) => Config -> (a -> Bool) -> [(a, a, [a])] -> Elims a -> Elims a+--------------------------------------------------------------------------------+boundElims cfg isK es ds = maybe ds (bElims isK es ds) (elimBound cfg)++bElims :: (Cutable a) => (a -> Bool) -> [(a, a, [a])] -> Elims a -> Int -> Elims a+bElims isK es ds dMax   = forceKuts kS' ds+  where+    (_ , kS')           = L.foldl' step (M.empty, depCuts ds) vs+    vs                  = topoSort ds es+    predM               = invertEdges es+    addK v ks+      | isK v           = S.insert v ks+      | otherwise       = ks++    zero                = (0, S.empty)++    step (dM, kS) v+      | v `S.member` kS = (M.insert v zero  dM,        kS)+      | vDist < dMax    = (M.insert v dv    dM,        kS)+      | otherwise       = (M.insert v zero  dM, addK v kS)+      where+        dv              = trace msg dv_+        msg             = show v ++ " DIST =" ++ show vDist ++ " SIZE = " ++ show vSize+        dv_@(vDist, s)  = distV predM v dM+        vSize           = S.size s++distV :: (Cutable a) => M.HashMap a [a] -> a -> M.HashMap a (Int, S.HashSet a) -> (Int, S.HashSet a)+distV predM v dM = (d, s)+  where+    d            = 1 + maximumDef 0 (fst . du <$> us)+    s            = S.insert v (S.unions (snd . du <$> us))+    du u         = fromMaybe (oops u) $ M.lookup u dM+    us           = M.lookupDefault [] v predM+    oops u       = errorstar $ "dist: don't have dist for " ++ show u ++ " when checking " ++ show v++topoSort :: (Cutable a) => Elims a -> [(a, a, [a])] -> [a]+topoSort ds = G.flattenSCCs . reverse . G.stronglyConnComp . ripKuts ds++ripKuts :: (Cutable a) => Elims a -> [(a, a, [a])] -> [(a, a, [a])]+ripKuts ds es = [ (u, x, notKuts vs) | (u, x, vs) <- es ]+  where+    notKuts   = filter (not . (`S.member` ks))+    ks        = depCuts ds++invertEdges :: (Cutable a) => [(a, a, [a])] -> M.HashMap a [a]+invertEdges es = group [ (v, u) | (u, _, vs) <- es, v <- vs ]++maximumDef :: (Ord a) => a -> [a] -> a+maximumDef d [] = d+maximumDef _ xs = maximum xs+++---------------------------------------------------------------------------+graphDeps :: F.SInfo a -> [CEdge] -> CDeps+---------------------------------------------------------------------------+graphDeps fi cs = CDs { cSucc   = gSucc cg+                      , cPrev   = cPrevM+                      , cNumScc = gSccs cg+                      , cRank   = M.fromList [(i, rf i) | i <- is ]+                      }+  where+    rf          = rankF (F.cm fi) outRs inRs+    inRs        = inRanks fi es outRs+    outRs       = gRanks cg+    es          = gEdges cg+    cg          = cGraphCE cs+    is          = [i | (Cstr i, _) <- cs]+    cPrevM      = sortNub <$> group [ (i, k) | (KVar k, Cstr i) <- cs ]++--TODO merge these with cGraph and kvSucc+cGraphCE :: [CEdge] -> CGraph+cGraphCE cs = CGraph { gEdges = es+                     , gRanks = outRs+                     , gSucc  = next+                     , gSccs  = length sccs }+  where+    es             = [(i, i, M.lookupDefault [] i next) | (Cstr i, _) <- cs]+    next           = cSuccM cs+    (g, vf, _)     = G.graphFromEdges es+    (outRs, sccs)  = graphRanks g vf++cSuccM      :: [CEdge] -> CMap [F.SubcId]+cSuccM es    = (sortNub . concatMap kRdBy) <$> iWrites+  where+    kRdBy k  = M.lookupDefault [] k kReads+    iWrites  = group [ (i, k) | (Cstr i, KVar k) <- es ]+    kReads   = group [ (k, j) | (KVar k, Cstr j) <- es ]++rankF :: CMap (F.SimpC a) -> CMap Int -> CMap Int -> F.SubcId -> Rank+rankF cm outR inR = \i -> Rank (outScc i) (inScc i) (tag i)+  where+    outScc        = lookupCMap outR+    inScc         = lookupCMap inR+    tag           = F._ctag . lookupCMap cm++---------------------------------------------------------------------------+inRanks :: F.SInfo a -> [DepEdge] -> CMap Int -> CMap Int+---------------------------------------------------------------------------+inRanks fi es outR+  | ks == mempty      = outR+  | otherwise         = fst $ graphRanks g' vf'+  where+    ks                = F.kuts fi+    cm                = F.cm fi+    (g', vf', _)      = G.graphFromEdges es'+    es'               = [(i, i, filter (not . isCut i) js) | (i,_,js) <- es ]+    isCut i j         = S.member i cutCIds && isEqOutRank i j+    isEqOutRank i j   = lookupCMap outR i == lookupCMap outR j+    cutCIds           = S.fromList [i | i <- M.keys cm, isKutWrite i ]+    isKutWrite        = any (`F.ksMember` ks) . kvWriteBy cm++--------------------------------------------------------------------------------+graphStatistics :: Config -> F.SInfo a -> IO ()+--------------------------------------------------------------------------------+graphStatistics cfg si = when (elimStats cfg) $ do+  -- writeGraph f  (kvGraph si)+  writeEdges f es'+  appendFile f . ppc . ptable $ graphStats cfg si+  where+    f        = queryFile Dot cfg+    es'      = removeKutEdges (depCuts ds) es+    (es, ds) = elimVars cfg si+    ppc d    = showpp $ vcat [" ", " ", "/*", pprint d, "*/"]++data Stats = Stats {+    stNumKVCuts   :: !Int   -- ^ number of kvars whose removal makes deps acyclic+  , stNumKVNonLin :: !Int   -- ^ number of kvars that appear >= 2 in some LHS+  , stNumKVTotal  :: !Int   -- ^ number of kvars+  , stIsReducible :: !Bool  -- ^ is dep-graph reducible+  , stSetKVNonLin :: !(S.HashSet F.KVar) -- ^ set of non-linear kvars+  }++instance PTable Stats where+  ptable (Stats {..})  = DocTable [+      ("# KVars [Cut]"    , pprint stNumKVCuts)+    , ("# KVars [NonLin]" , pprint stNumKVNonLin)+    , ("# KVars [All]"    , pprint stNumKVTotal)+    , ("# Reducible"      , pprint stIsReducible)+    , ("KVars NonLin"     , pprint stSetKVNonLin)+    ]++graphStats :: Config -> F.SInfo a -> Stats+graphStats cfg si = Stats {+    stNumKVCuts   = S.size $ F.tracepp "CUTS:" (depCuts d)+  , stNumKVNonLin = S.size  nlks+  , stNumKVTotal  = S.size (depCuts d) + S.size (depNonCuts d)+  , stIsReducible = isReducible si+  , stSetKVNonLin = nlks+  }+  where+    nlks          = nonLinearKVars si+    d             = snd $ elimVars cfg si++--------------------------------------------------------------------------------+nonLinearKVars :: (F.TaggedC c a) => F.GInfo c a -> S.HashSet F.KVar+--------------------------------------------------------------------------------+nonLinearKVars fi = S.unions $ nlKVarsC bs <$> cs+  where+    bs            = F.bs fi+    cs            = M.elems (F.cm fi)++nlKVarsC :: (F.TaggedC c a) => F.BindEnv -> c a -> S.HashSet F.KVar+nlKVarsC bs c = S.fromList [ k |  (k, n) <- V.envKVarsN bs c, n >= 2]
+ src/Language/Fixpoint/Graph/Indexed.hs view
@@ -0,0 +1,100 @@+--------------------------------------------------------------------------------+-- | This module implements Indexed KV Graphs,+--   a representation of the KVGraph with a fast+--   succ, pred lookup+--------------------------------------------------------------------------------++{-# LANGUAGE OverloadedStrings #-}++module Language.Fixpoint.Graph.Indexed (+  -- * (Abstract) Indexed Graphs+    IKVGraph (..)++  -- * Constructor+  , edgesIkvg++  -- * Destructor+  , ikvgEdges++  -- * Modify+  , addLinks+  , delNodes++  -- * Lookup+  , getSuccs+  , getPreds+  ) where++import           Language.Fixpoint.Graph.Types+import qualified Data.HashSet              as S+import qualified Data.HashMap.Strict       as M+import qualified Data.List as L+import           Data.Hashable (Hashable)++--------------------------------------------------------------------------------+-- | `IKVGraph` is representation of the KVGraph with a fast succ, pred lookup+--------------------------------------------------------------------------------++data IKVGraph = IKVGraph+  { igSucc :: !(M.HashMap CVertex (S.HashSet CVertex))  -- ^ out-edges of a `CVertex`+  , igPred :: !(M.HashMap CVertex (S.HashSet CVertex))  -- ^ in-edges  of a `CVertex`+  } deriving (Show)+++addLinks :: IKVGraph -> [CEdge] -> IKVGraph+addLinks = L.foldl' addLink++addLink :: IKVGraph -> CEdge -> IKVGraph+addLink g (u, v) = addSucc (u, v) . addPred (u, v) $ g++delNodes :: IKVGraph -> [CVertex] -> IKVGraph+delNodes = L.foldl' delNode++delNode :: IKVGraph -> CVertex -> IKVGraph+delNode g v = delVtx v . txMany delSucc uvs . txMany delPred vws $ g+  where+    uvs     = [ (u, v) | u <- getPreds g v ]+    vws     = [ (v, w) | w <- getSuccs g v ]++edgesIkvg :: [CEdge] -> IKVGraph+edgesIkvg = addLinks empty++ikvgEdges :: IKVGraph -> [CEdge]+ikvgEdges g = [ (u, v) | (u, vs) <- M.toList (igSucc g), v <- S.toList vs]++getSuccs :: IKVGraph -> CVertex -> [CVertex]+getSuccs g u = S.toList $ M.lookupDefault S.empty u (igSucc g)++getPreds :: IKVGraph -> CVertex -> [CVertex]+getPreds g v = S.toList $ M.lookupDefault S.empty v (igPred g)++--------------------------------------------------------------------------------+empty :: IKVGraph+empty = IKVGraph M.empty M.empty++txMany :: (a -> b -> b) -> [a] -> b -> b+txMany op es g = L.foldl' (flip op) g es++addSucc :: CEdge -> IKVGraph -> IKVGraph+addSucc (u, v) g = g { igSucc = inserts u v (igSucc g) }++addPred :: CEdge -> IKVGraph -> IKVGraph+addPred (u, v) g = g { igPred = inserts v u (igPred g) }++delSucc :: CEdge -> IKVGraph -> IKVGraph+delSucc (u, v) g = g { igSucc = removes u v (igSucc g)}++delPred :: (CVertex, CVertex) -> IKVGraph -> IKVGraph+delPred (u, v) g = g { igPred = removes v u (igPred g)}++delVtx :: CVertex -> IKVGraph -> IKVGraph+delVtx v g = g { igSucc = M.delete v (igSucc g) }+               { igPred = M.delete v (igPred g) }++inserts :: (Eq k, Eq v, Hashable k, Hashable v)+        => k -> v -> M.HashMap k (S.HashSet v) -> M.HashMap k (S.HashSet v)+inserts k v m = M.insert k (S.insert v $ M.lookupDefault S.empty k m) m++removes :: (Eq k, Eq v, Hashable k, Hashable v)+        => k -> v -> M.HashMap k (S.HashSet v) -> M.HashMap k (S.HashSet v)+removes k v m = M.insert k (S.delete v (M.lookupDefault S.empty k m)) m
+ src/Language/Fixpoint/Graph/Partition.hs view
@@ -0,0 +1,213 @@+{-# LANGUAGE ConstraintKinds   #-}+{-# LANGUAGE OverloadedStrings #-}++-- | This module implements functions to build constraint / kvar+--   dependency graphs, partition them and print statistics about+--   their structure.++module Language.Fixpoint.Graph.Partition (++  -- * Split constraints+    CPart (..)+  , partition, partition', partitionN++  -- * Information about cores+  , MCInfo (..)+  , mcInfo++  -- * Debug+  , dumpPartitions++  ) where++import           GHC.Conc                  (getNumProcessors)+import           Control.Monad             (forM_)+-- import           GHC.Generics              (Generic)+import           Language.Fixpoint.Misc         -- hiding (group)+import           Language.Fixpoint.Utils.Files+import           Language.Fixpoint.Types.Config+-- import           Language.Fixpoint.Types.PrettyPrint+-- import qualified Language.Fixpoint.Types.Visitor      as V+import qualified Language.Fixpoint.Types              as F+import           Language.Fixpoint.Graph.Types+import           Language.Fixpoint.Graph.Deps++import qualified Data.HashMap.Strict                  as M+-- import qualified Data.Graph                           as G+-- import qualified Data.Tree                            as T+-- import           Data.Function (on)+import           Data.Maybe                     (fromMaybe)+import           Data.Hashable+import           Text.PrettyPrint.HughesPJ+import           Data.List (sortBy)+-- import qualified Data.HashSet              as S++-- import qualified Language.Fixpoint.Solver.Solution    as So+-- import Data.Graph.Inductive++++--------------------------------------------------------------------------------+-- | Constraint Partition Container --------------------------------------------+--------------------------------------------------------------------------------++data CPart a = CPart { pws :: !(M.HashMap F.KVar (F.WfC a))+                     , pcm :: !(M.HashMap Integer (F.SubC a))+                     }++instance Monoid (CPart a) where+   mempty = CPart mempty mempty+   mappend l r = CPart { pws = pws l `mappend` pws r+                       , pcm = pcm l `mappend` pcm r+                       }++--------------------------------------------------------------------------------+-- | Multicore info ------------------------------------------------------------+--------------------------------------------------------------------------------++data MCInfo = MCInfo { mcCores       :: !Int+                     , mcMinPartSize :: !Int+                     , mcMaxPartSize :: !Int+                     } deriving (Show)++mcInfo :: Config -> IO MCInfo+mcInfo c = do+   np <- getNumProcessors+   let nc = fromMaybe np (cores c)+   return MCInfo { mcCores = nc+                 , mcMinPartSize = minPartSize c+                 , mcMaxPartSize = maxPartSize c+                 }++partition :: (F.Fixpoint a) => Config -> F.FInfo a -> IO (F.Result (Integer, a))+partition cfg fi+  = do dumpPartitions cfg fis+       -- writeGraph      f   g+       return mempty+    where+      --f   = queryFile Dot cfg+      fis = partition' Nothing fi++------------------------------------------------------------------------------+-- | Partition an FInfo into multiple disjoint FInfos. Info is Nothing to+--   produce the maximum possible number of partitions. Or a MultiCore Info+--   to control the partitioning+------------------------------------------------------------------------------+partition' :: Maybe MCInfo -> F.FInfo a -> [F.FInfo a]+------------------------------------------------------------------------------+partition' mn fi  = case mn of+   Nothing -> fis mkPartition id+   Just mi -> partitionN mi fi $ fis mkPartition' finfoToCpart+  where+    css            = decompose fi+    fis partF ctor = applyNonNull [ctor fi] (pbc partF) css+    pbc partF      = partitionByConstraints partF fi++-- | Partition an FInfo into a specific number of partitions of roughly equal+-- amounts of work+partitionN :: MCInfo    -- ^ describes thresholds and partiton amounts+           -> F.FInfo a   -- ^ The originial FInfo+           -> [CPart a] -- ^ A list of the smallest possible CParts+           -> [F.FInfo a] -- ^ At most N partitions of at least thresh work+partitionN mi fi cp+   | cpartSize (finfoToCpart fi) <= minThresh = [fi]+   | otherwise = map (cpartToFinfo fi) $ toNParts sortedParts+   where+      toNParts p+         | isDone p = p+         | otherwise = toNParts $ insertSorted firstTwo rest+            where (firstTwo, rest) = unionFirstTwo p+      isDone [] = True+      isDone [_] = True+      isDone fi'@(a:b:_) = length fi' <= prts+                            && (cpartSize a >= minThresh+                                || cpartSize a + cpartSize b >= maxThresh)+      sortedParts = sortBy sortPredicate cp+      unionFirstTwo (a:b:xs) = (a `mappend` b, xs)+      unionFirstTwo _        = errorstar "Partition.partitionN.unionFirstTwo called on bad arguments"+      sortPredicate lhs rhs+         | cpartSize lhs < cpartSize rhs = GT+         | cpartSize lhs > cpartSize rhs = LT+         | otherwise = EQ+      insertSorted a []     = [a]+      insertSorted a (x:xs) = if sortPredicate a x == LT+                              then x : insertSorted a xs+                              else a : x : xs+      prts      = mcCores mi+      minThresh = mcMinPartSize mi+      maxThresh = mcMaxPartSize mi+++-- | Return the "size" of a CPart. Used to determine if it's+-- substantial enough to be worth parallelizing.+cpartSize :: CPart a -> Int+cpartSize c = (M.size . pcm) c + (length . pws) c++-- | Convert a CPart to an FInfo+cpartToFinfo :: F.FInfo a -> CPart a -> F.FInfo a+cpartToFinfo fi p = fi { F.cm = pcm p+                       , F.ws = pws p+                       }++-- | Convert an FInfo to a CPart+finfoToCpart :: F.FInfo a -> CPart a+finfoToCpart fi = CPart { pcm = F.cm fi+                        , pws = F.ws fi+                        }++-------------------------------------------------------------------------------------+dumpPartitions :: (F.Fixpoint a) => Config -> [F.FInfo a] -> IO ()+-------------------------------------------------------------------------------------+dumpPartitions cfg fis =+  forM_ (zip [0..] fis) $ \(i, fi) ->+    writeFile (queryFile (Part i) cfg) (render $ F.toFixpoint cfg fi)+++-- | Type alias for a function to construct a partition. mkPartition and+--   mkPartition' are the two primary functions that conform to this interface+type PartitionCtor a b = F.FInfo a+                       -> M.HashMap Int [(Integer, F.SubC a)]+                       -> M.HashMap Int [(F.KVar, F.WfC a)]+                       -> Int+                       -> b -- ^ typically a F.FInfo a or F.CPart a++partitionByConstraints :: PartitionCtor a b -- ^ mkPartition or mkPartition'+                          -> F.FInfo a+                          -> KVComps+                          -> ListNE b -- ^ [F.FInfo a] or [F.CPart a]+partitionByConstraints f fi kvss = f fi icM iwM <$> js+  where+    js   = fst <$> jkvs                                -- groups+    gc   = groupFun cM                                 -- (i, ci) |-> j+    gk   = groupFun kM                                 -- k       |-> j++    iwM  = groupMap (gk . fst) (M.toList (F.ws fi))    -- j |-> [w]+    icM  = groupMap (gc . fst) (M.toList (F.cm fi))    -- j |-> [(i, ci)]++    jkvs = zip [1..] kvss+    kvI  = [ (x, j) | (j, kvs) <- jkvs, x <- kvs ]+    kM   = M.fromList [ (k, i) | (KVar k, i) <- kvI ]+    cM   = M.fromList [ (c, i) | (Cstr c, i) <- kvI ]++mkPartition :: F.GInfo F.SubC a+            -> M.HashMap Int [(Integer, c a)]+            -> M.HashMap Int [(F.KVar, F.WfC a)]+            -> Int+            -> F.GInfo c a+mkPartition fi icM iwM j+  = fi { F.cm       = M.fromList $ M.lookupDefault [] j icM+       , F.ws       = M.fromList $ M.lookupDefault [] j iwM+       }++mkPartition' :: F.FInfo a1+             -> M.HashMap Int [(Integer, F.SubC a)]+             -> M.HashMap Int [(F.KVar, F.WfC a)]+             -> Int+             -> CPart a+mkPartition' _ icM iwM j+  = CPart { pcm       = M.fromList $ M.lookupDefault [] j icM+          , pws       = M.fromList $ M.lookupDefault [] j iwM+          }++groupFun :: (Show k, Eq k, Hashable k) => M.HashMap k Int -> k -> Int+groupFun m k = safeLookup ("groupFun: " ++ show k) k m
+ src/Language/Fixpoint/Graph/Reducible.hs view
@@ -0,0 +1,62 @@+{-# LANGUAGE ConstraintKinds   #-}+{-# LANGUAGE OverloadedStrings #-}++-- | This module a test for whether the constraint dependencies form a+--   reducible graph.++module Language.Fixpoint.Graph.Reducible ( isReducible ) where++import qualified Data.Tree                            as T+import qualified Data.HashMap.Strict                  as M+import           Data.Graph.Inductive++import           Language.Fixpoint.Misc         -- hiding (group)+import qualified Language.Fixpoint.Types.Visitor      as V+import qualified Language.Fixpoint.Types              as F+++--------------------------------------------------------------------------------+isReducible :: F.SInfo a -> Bool+--------------------------------------------------------------------------------+isReducible fi = all (isReducibleWithStart g) vs+  where+    g  = convertToGraph fi+    vs = {- trace (showDot $ fglToDotGeneric g show (const "") id) -} nodes g++isReducibleWithStart :: Gr a b -> Node -> Bool+isReducibleWithStart g x = all (isBackEdge domList) rEdges+  where+    dfsTree              = head $ dff [x] g --head because only care about nodes reachable from 'start node'?+    rEdges               = [ e | e@(a,b) <- edges g, isDescendant a b dfsTree]+    domList              = dom g x++++convertToGraph :: F.SInfo a -> Gr Int ()+convertToGraph fi = mkGraph vs es+  where+    subCs        = M.elems (F.cm fi)+    es           = lUEdge <$> concatMap (subcEdges' kvI $ F.bs fi) subCs+    ks           = M.keys (F.ws fi)+    kiM          = M.fromList $ zip ks [0..]+    kvI k        = safeLookup ("convertToGraph: " ++ show k) k kiM+    vs           = lNode . kvI <$> M.keys (F.ws fi)+    lNode i      = (i, i)+    lUEdge (i,j) = (i, j, ())++isDescendant :: Node -> Node -> T.Tree Node -> Bool+isDescendant x y (T.Node z f) | z == y    = f `contains` x+                              | z == x    = False+                              | otherwise = any (isDescendant x y) f++contains :: [T.Tree Node] -> Node -> Bool+contains t x = x `elem` concatMap T.flatten t++isBackEdge :: [(Node, [Node])] -> Edge -> Bool+isBackEdge t (u,v) = v `elem` xs+  where+    (Just xs) = lookup u t++subcEdges' :: (F.KVar -> Node) -> F.BindEnv -> F.SimpC a -> [(Node, Node)]+subcEdges' kvI be c = [(kvI k1, kvI k2) | k1 <- V.envKVars be c+                                        , k2 <- V.kvars $ F.crhs c]
+ src/Language/Fixpoint/Graph/Types.hs view
@@ -0,0 +1,184 @@++-- | This module contains the types for representing dependency+--   graphs between kvars and constraints.++{-# LANGUAGE ImplicitParams        #-}+{-# LANGUAGE DeriveGeneric     #-}+{-# LANGUAGE OverloadedStrings #-}++module Language.Fixpoint.Graph.Types (++  -- * Graphs+    CVertex (..)+  , CEdge+  , isRealEdge+  , KVGraph (..)++  -- * Components+  , Comps+  , KVComps++  -- * Printing+  , writeGraph+  , writeEdges++  -- * Constraints+  , F.SubcId+  , KVRead+  , DepEdge++  -- * Slice of relevant constraints+  , Slice (..)++  -- * Constraint Dependency Graphs+  , CGraph (..)++  -- * Alias for Constraint Maps+  , F.CMap+  , lookupCMap++  -- * Ranks+  , Rank (..)++  -- * Constraint Dependencies+  , CDeps (..)++  -- * Solver Info+  , SolverInfo (..)+  )+  where++import           GHC.Generics              (Generic)+import           Data.Hashable+import           Text.PrettyPrint.HughesPJ++import           Language.Fixpoint.Misc         -- hiding (group)+import           Language.Fixpoint.Types.PrettyPrint+import           Language.Fixpoint.Types.Refinements -- Constraints+import qualified Language.Fixpoint.Types.Solutions as F+-- import           Language.Fixpoint.Misc (safeLookup)+import qualified Language.Fixpoint.Types   as F+import qualified Data.HashMap.Strict       as M+import qualified Data.HashSet              as S++import GHC.Stack+--------------------------------------------------------------------------------++data CVertex = KVar  !KVar    -- ^ real kvar vertex+             | DKVar !KVar    -- ^ dummy to ensure each kvar has a successor+             | Cstr  !Integer -- ^ constraint-id which creates a dependency+               deriving (Eq, Ord, Show, Generic)++instance PPrint CVertex where+  pprintTidy _ (KVar k)  = doubleQuotes $ pprint $ kv k+  pprintTidy _ (Cstr i)  = text "id_" <> pprint i+  pprintTidy _ (DKVar k) = pprint k   <> text "*"+++instance Hashable CVertex++data KVGraph    = KVGraph { kvgEdges :: [(CVertex, CVertex, [CVertex])] }+type CEdge      = (CVertex, CVertex)+type Comps a    = [[a]]+type KVComps    = Comps CVertex++instance PPrint KVGraph where+  pprintTidy _ = pprint . kvgEdges++--------------------------------------------------------------------------------+writeGraph :: FilePath -> KVGraph -> IO ()+--------------------------------------------------------------------------------+writeGraph f = writeEdges f . graphEdges+  where+    graphEdges :: KVGraph -> [CEdge]+    graphEdges (KVGraph g) = [ (v, v') | (v,_,vs) <- g, v' <- vs]++--------------------------------------------------------------------------------+writeEdges :: FilePath -> [CEdge] -> IO ()+--------------------------------------------------------------------------------+writeEdges f = writeFile f . render . ppEdges++ppEdges :: [CEdge] -> Doc+ppEdges             = vcat . wrap ["digraph Deps {"] ["}"]+                           . map ppE+                           . (if True then filter isRealEdge else txEdges)  -- RJ: use this to collapse "constraint" vertices+  where+    ppE (v, v')     = pprint v <+> "->" <+> pprint v'++isRealEdge :: CEdge -> Bool+isRealEdge (DKVar _, _)     = False+isRealEdge (_, DKVar _)     = False+isRealEdge (Cstr _, Cstr _) = False+isRealEdge _                = True++txEdges    :: [CEdge] -> [CEdge]+txEdges es = concatMap iEs is+  where+    is     = [i | (Cstr i, Cstr _) <- es]+    kvInM  = group [ (i, k) | (KVar k, Cstr i) <- es]+    kvOutM = group [ (i, k') | (Cstr i, KVar k') <- es]+    ins i  = M.lookupDefault [] i kvInM+    outs i = M.lookupDefault [] i kvOutM+    iEs i  = case (ins i, outs i) of+                 (ks, [] ) -> [(KVar k, Cstr i ) | k  <- ks ]+                 ([], ks') -> [(Cstr i, KVar k') | k' <- ks']+                 (ks, ks') -> [(KVar k, KVar k') | k  <- ks, k' <- ks']++++---------------------------------------------------------------------------+-- | Dramatis Personae+---------------------------------------------------------------------------+type KVRead  = M.HashMap F.KVar [F.SubcId]+type DepEdge = (F.SubcId, F.SubcId, [F.SubcId])++data Slice = Slice { slKVarCs :: [F.SubcId]     -- ^ F.SubcIds that transitively "reach" below+                   , slConcCs :: [F.SubcId]     -- ^ F.SubcIds with Concrete RHS+                   , slEdges  :: [DepEdge] -- ^ Dependencies between slKVarCs+                   } deriving (Eq, Show)++data CGraph = CGraph { gEdges :: [DepEdge]+                     , gRanks :: !(F.CMap Int)+                     , gSucc  :: !(F.CMap [F.SubcId])+                     , gSccs  :: !Int+                     }++---------------------------------------------------------------------------+-- | CMap API -------------------------------------------------------------+---------------------------------------------------------------------------+lookupCMap :: (?callStack :: CallStack) => F.CMap a -> F.SubcId -> a+lookupCMap rm i = safeLookup err i rm+  where+    err      = "lookupCMap: cannot find info for " ++ show i++--------------------------------------------------------------------------------+-- | Constraint Dependencies ---------------------------------------------------+--------------------------------------------------------------------------------++data CDeps = CDs { cSucc   :: !(F.CMap [F.SubcId]) -- ^ Constraints *written by* a SubcId+                 , cPrev   :: !(F.CMap [F.KVar])   -- ^ (Cut) KVars *read by*    a SubcId+                 , cRank   :: !(F.CMap Rank)       -- ^ SCC rank of a SubcId+                 , cNumScc :: !Int                 -- ^ Total number of Sccs+                 }+++-- | Ranks ---------------------------------------------------------------------++data Rank = Rank { rScc  :: !Int    -- ^ SCC number with ALL dependencies+                 , rIcc  :: !Int    -- ^ SCC number without CUT dependencies+                 , rTag  :: !F.Tag  -- ^ The constraint's Tag+                 } deriving (Eq, Show)++instance PPrint Rank where+  pprintTidy _ = text . show++--------------------------------------------------------------------------------+-- | `SolverInfo` contains all the stuff needed to produce a result, and is the+--   the essential ingredient of the state needed by solve_+--------------------------------------------------------------------------------+data SolverInfo a b = SI+  { siSol     :: !(F.Sol b F.QBind)             -- ^ the initial solution+  , siQuery   :: !(F.SInfo a)                   -- ^ the whole input query+  , siDeps    :: !CDeps                         -- ^ dependencies between constraints/ranks etc.+  , siVars    :: !(S.HashSet F.KVar)            -- ^ set of KVars to actually solve for+  }
src/Language/Fixpoint/Minimize.hs view
@@ -1,74 +1,132 @@--- | This module implements a "delta-debugging" based query minimizer---   that attempts to shrink UNSAT queries down to a minimal subset---   of constraints.+-- | This module implements a "delta-debugging" based query minimizer.+--   Exported clients of that minimizer include one that attempts to+--   shrink UNSAT queries down to a minimal subset of constraints,+--   one that shrinks SAT queries down to a minimal subset of qualifiers,+--   and one that shrinks SAT queries down to a minimal subset of KVars+--   (replacing all others by True).  {-# LANGUAGE ScopedTypeVariables #-} -module Language.Fixpoint.Minimize ( minQuery ) where+module Language.Fixpoint.Minimize ( minQuery, minQuals, minKvars ) where  import qualified Data.HashMap.Strict                as M import           Control.Monad                      (filterM)-import           Language.Fixpoint.Types.Config     (Config (..))+import           Language.Fixpoint.Types.Visitor    (mapKVars)+import           Language.Fixpoint.Types.Config     (Config (..), queryFile) import           Language.Fixpoint.Types.Errors+import           Language.Fixpoint.Misc             (safeHead) import           Language.Fixpoint.Utils.Files      hiding (Result)-import           Language.Fixpoint.Partition        -- (mcInfo, partition, partition')+import           Language.Fixpoint.Graph import           Language.Fixpoint.Types import           Control.DeepSeq -concatMapM :: (Monad m) => (a -> m [b]) -> [a] -> m [b]-concatMapM f = fmap concat . mapM f- ----------------------------------------------------------------------------minQuery :: (NFData a, Fixpoint a) => Config -> Solver a -> FInfo a-         -> IO (Result (Integer, a))-----------------------------------------------------------------------------minQuery cfg solve fi = do-  let cfg'     = cfg { minimize = False }-  let (_, fis) = partition' Nothing fi-  failFis     <- filterM (fmap isUnsafe . solve cfg') fis-  failCs      <- concatMapM (getMinFailingCons cfg' solve) failFis-  let minFi    = fi { cm = M.fromList failCs, fileName = minFileName fi }-  saveQuery cfg' minFi-  putStrLn $ "Minimized Constraints: " ++ show (fst <$> failCs)-  return mempty--minFileName :: FInfo a -> FilePath-minFileName = extFileName Min . fileName--isUnsafe :: Result a -> Bool-isUnsafe (Result Safe _)  = False-isUnsafe _                = True--type ConsList a = [(Integer, SubC a)]-type Oracle a c = (Config -> Solver a -> FInfo a -> [c] -> IO Bool)- -- polymorphic delta debugging implementation-deltaDebug :: Oracle a c -> Config -> Solver a -> FInfo a -> [c] -> [c] -> IO [c]-deltaDebug testSet cfg solve finfo set r = do+---------------------------------------------------------------------------+deltaDebug :: Bool -> Oracle a c -> Config -> Solver a -> FInfo a -> [c] -> [c] -> IO [c]+deltaDebug min testSet cfg solve finfo set r = do   let (s1, s2) = splitAt (length set `div` 2) set   if length set == 1-    then return set+    then deltaDebug1 min testSet cfg solve finfo set r     else do       test1 <- testSet cfg solve finfo (s1 ++ r)       if test1-        then deltaDebug testSet cfg solve finfo s1 r+        then deltaDebug min testSet cfg solve finfo s1 r         else do           test2 <- testSet cfg solve finfo (s2 ++ r)           if test2-            then deltaDebug testSet cfg solve finfo s2 r+            then deltaDebug min testSet cfg solve finfo s2 r             else do-              d1 <- deltaDebug testSet cfg solve finfo s1 (s2 ++ r)-              d2 <- deltaDebug testSet cfg solve finfo s2 (s1 ++ r)+              d1 <- deltaDebug min testSet cfg solve finfo s1 (s2 ++ r)+              d2 <- deltaDebug min testSet cfg solve finfo s2 (d1 ++ r)               return (d1 ++ d2) -testConstraints :: (NFData a, Fixpoint a) => Config -> Solver a -> FInfo a -> ConsList a -> IO Bool-testConstraints cfg solve fi cons  = do-  let fi' = fi { cm = M.fromList cons }-  res <- solve cfg fi'-  return $ isUnsafe res+deltaDebug1 :: Bool -> (a -> b -> c -> d -> IO Bool)+            -> a -> b -> c -> [e] -> d+            -> IO [e]+deltaDebug1 True  _       _   _     _     set _ = return set+deltaDebug1 False testSet cfg solve finfo set r = do+  test <- testSet cfg solve finfo r+  if test then return [] else return set --- run delta debugging on a failing partition to find minimal set of failing constraints-getMinFailingCons :: (NFData a, Fixpoint a) => Config -> Solver a -> FInfo a -> IO (ConsList a)-getMinFailingCons cfg solve fi = do-  let cons = M.toList $ cm fi-  deltaDebug testConstraints cfg solve fi cons []+type Oracle a c = (Config -> Solver a -> FInfo a -> [c] -> IO Bool)++commonDebug :: (NFData a, Fixpoint a) => (FInfo a -> [c])+                                      -> (FInfo a -> [c] -> FInfo a)+                                      -> (Result (Integer, a) -> Bool)+                                      -> Bool+                                      -> Config+                                      -> Solver a+                                      -> FInfo a+                                      -> Ext+                                      -> (FInfo a -> [c] -> String)+                                      -> IO (Result (Integer, a))+commonDebug init updateFi checkRes min cfg solve fi ext formatter = do+  let cs0 = init fi+  let oracle = mkOracle updateFi checkRes+  cs <- deltaDebug min oracle cfg solve fi cs0 []+  let minFi = updateFi fi cs+  saveQuery (addExt ext cfg) minFi+  putStrLn $ formatter fi cs+  return mempty++---------------------------------------------------------------------------+minQuery :: (NFData a, Fixpoint a) => Config -> Solver a -> FInfo a+         -> IO (Result (Integer, a))+---------------------------------------------------------------------------+minQuery cfg solve fi = do+  let cfg'  = cfg { minimize = False }+  let fis   = partition' Nothing fi+  failFis  <- filterM (fmap (not . isSafe) . solve cfg') fis+  let failFi = safeHead "--minimize can only be called on UNSAT fq" failFis+  let format _ cs = "Minimized Constraints: " ++ show (fst <$> cs)+  let update fi cs = fi { cm = M.fromList cs }+  commonDebug (M.toList . cm) update (not . isSafe) True cfg' solve failFi Min format++---------------------------------------------------------------------------+minQuals :: (NFData a, Fixpoint a) => Config -> Solver a -> FInfo a+         -> IO (Result (Integer, a))+---------------------------------------------------------------------------+minQuals cfg solve fi = do+  let cfg'  = cfg { minimizeQs = False }+  let format fi qs = "Required Qualifiers: " ++ show (length qs)+                  ++ "; Total Qualifiers: "  ++ show (length $ quals fi)+  let update fi qs = fi { quals = qs }+  commonDebug quals update isSafe False cfg' solve fi MinQuals format++---------------------------------------------------------------------------+minKvars :: (NFData a, Fixpoint a) => Config -> Solver a -> FInfo a+         -> IO (Result (Integer, a))+---------------------------------------------------------------------------+minKvars cfg solve fi = do+  let cfg'  = cfg { minimizeKs = False }+  let format fi ks = "Required KVars: " ++ show (length ks)+                  ++ "; Total KVars: "  ++ show (length $ ws fi)+  commonDebug (M.keys . ws) removeOtherKs isSafe False cfg' solve fi MinKVars format++removeOtherKs :: FInfo a -> [KVar] -> FInfo a+removeOtherKs fi0 ks = fi1 { ws = ws', cm = cm' }+  where+    fi1 = mapKVars go fi0+    go k | k `elem` ks = Nothing+         | otherwise   = Just PTrue+    ws' = M.filterWithKey (\k _ -> k `elem` ks) $ ws fi1+    cm' = M.filter (isNonTrivial . srhs) $ cm fi1++---------------------------------------------------------------------------+-- Helper functions+---------------------------------------------------------------------------+isSafe :: Result a -> Bool+isSafe (Result Safe _ _) = True+isSafe _                 = False++addExt :: Ext -> Config -> Config+addExt ext cfg = cfg { srcFile = queryFile ext cfg }++mkOracle :: (NFData a, Fixpoint a) => (FInfo a -> [c] -> FInfo a)+                                   -> (Result (Integer, a) -> Bool)+                                   -> Oracle a c+mkOracle updateFi checkRes cfg solve fi qs = do+  let fi' = updateFi fi qs+  res <- solve cfg fi'+  return $ checkRes res
src/Language/Fixpoint/Misc.hs view
@@ -3,6 +3,8 @@ {-# LANGUAGE OverloadedStrings         #-} {-# LANGUAGE ScopedTypeVariables       #-} {-# LANGUAGE TupleSections             #-}+{-# LANGUAGE ConstraintKinds           #-}+{-# LANGUAGE TypeOperators             #-} {-# LANGUAGE ImplicitParams            #-} -- ignore hlint  module Language.Fixpoint.Misc where@@ -12,13 +14,16 @@ import           Data.Hashable -- import           Data.IORef import           Control.Arrow                    (second)-import           Control.Monad                    (forM_)+import           Control.Monad                    (when, forM_) import qualified Data.HashMap.Strict              as M import qualified Data.List                        as L import           Data.Tuple                       (swap) import           Data.Maybe-import           Data.Array                hiding (indices)+import           Data.Array                       hiding (indices) import           Data.Function                    (on)+import qualified Data.Graph                       as G+import qualified Data.Tree                        as T+import           Data.Unique import           Debug.Trace                      (trace) import           System.Console.ANSI import           System.Console.CmdArgs.Verbosity (whenLoud)@@ -26,9 +31,9 @@ import           System.Directory                 (createDirectoryIfMissing) import           System.FilePath                  (takeDirectory) import           Text.PrettyPrint.HughesPJ        hiding (first)-import           System.IO                       (stdout, hFlush )-import Control.Concurrent.Async-+import           System.IO                        (stdout, hFlush )+import           System.Exit                      (ExitCode)+import           Control.Concurrent.Async  #ifdef MIN_VERSION_located_base import Prelude hiding (error, undefined)@@ -36,6 +41,8 @@ import GHC.Stack #endif +type (|->) a b = M.HashMap a b+ firstMaybe :: (a -> Maybe b) -> [a] -> Maybe b firstMaybe f = listToMaybe . mapMaybe f @@ -50,6 +57,16 @@ hashMapToAscList = L.sortBy (compare `on` fst) . M.toList  ---------------------------------------------------------------+-- | Unique Int -----------------------------------------------+---------------------------------------------------------------++getUniqueInt :: IO Int+getUniqueInt = do+  n1 <- hashUnique <$> newUnique+  n2 <- hashUnique <$> newUnique+  return (n1 * n2)++--------------------------------------------------------------- -- | Edit Distance -------------------------------------------- --------------------------------------------------------------- @@ -75,35 +92,49 @@  data Moods = Ok | Loud | Sad | Happy | Angry +moodColor :: Moods -> Color moodColor Ok    = Black moodColor Loud  = Blue moodColor Sad   = Magenta moodColor Happy = Green moodColor Angry = Red +wrapStars :: String -> String wrapStars msg = "\n**** " ++ msg ++ " " ++ replicate (74 - length msg) '*' +withColor :: Color -> IO () -> IO () -- withColor _ act = act withColor c act    = do setSGR [ SetConsoleIntensity BoldIntensity, SetColor Foreground Vivid c]         act         setSGR [ Reset] +colorStrLn :: Moods -> String -> IO () colorStrLn c       = withColor (moodColor c) . putStrLn++colorPhaseLn :: Moods -> String -> String -> IO () colorPhaseLn c msg = colorStrLn c . wrapStars .  (msg ++)++startPhase :: Moods -> String -> IO () startPhase c msg   = colorPhaseLn c "START: " msg >> colorStrLn Ok " "++doneLine   :: Moods -> String -> IO () doneLine   c msg   = colorPhaseLn c "DONE:  " msg >> colorStrLn Ok " " +donePhase :: Moods -> String -> IO () donePhase c str   = case lines str of       (l:ls) -> doneLine c l >> forM_ ls (colorPhaseLn c "") >> hFlush stdout       _      -> return () +putBlankLn :: IO () putBlankLn = putStrLn "" >> hFlush stdout ------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+wrap :: [a] -> [a] -> [a] -> [a] wrap l r s = l ++ s ++ r +repeats :: Int -> [a] -> [a] repeats n  = concat . replicate n  #ifdef MIN_VERSION_located_base@@ -123,6 +154,9 @@ thd3 ::  (a, b, c) -> c thd3 (_,_,x) = x +secondM :: Functor f => (b -> f c) -> (a, b) -> f (a, c)+secondM act (x, y) = (x,) <$> act y+ #ifdef MIN_VERSION_located_base mlookup    :: (?callStack :: CallStack, Eq k, Show k, Hashable k) => M.HashMap k v -> k -> v safeLookup :: (?callStack :: CallStack, Eq k, Hashable k) => String -> k -> M.HashMap k v -> v@@ -137,33 +171,41 @@   where     err     = errorstar $ "mlookup: unknown key " ++ show k -safeLookup msg k m = fromMaybe (errorstar msg) (M.lookup k m)-+safeLookup msg k m   = fromMaybe (errorstar msg) (M.lookup k m) mfromJust _ (Just x) = x mfromJust s Nothing  = errorstar $ "mfromJust: Nothing " ++ s --- inserts       ::  Hashable k => k -> v -> M.HashMap k [v] -> M.HashMap k [v]+inserts ::  (Eq k, Hashable k) => k -> v -> M.HashMap k [v] -> M.HashMap k [v] inserts k v m = M.insert k (v : M.lookupDefault [] k m) m +removes ::  (Eq k, Hashable k, Eq v) => k -> v -> M.HashMap k [v] -> M.HashMap k [v]+removes k v m = M.insert k (L.delete v (M.lookupDefault [] k m)) m+ count :: (Eq k, Hashable k) => [k] -> [(k, Int)] count = M.toList . fmap sum . group . fmap (, 1) -group         :: (Eq k, Hashable k) => [(k, v)] -> M.HashMap k [v]-group         = groupBase M.empty+group :: (Eq k, Hashable k) => [(k, v)] -> M.HashMap k [v]+group = groupBase M.empty -groupBase     = L.foldl' (\m (k, v) -> inserts k v m)+groupBase :: (Eq k, Hashable k) => M.HashMap k [v] -> [(k, v)] -> M.HashMap k [v]+groupBase = L.foldl' (\m (k, v) -> inserts k v m) -groupList     = M.toList . group+groupList :: (Eq k, Hashable k) => [(k, v)] -> [(k, [v])]+groupList = M.toList . group --- groupMap      :: Hashable k => (a -> k) -> [a] -> M.HashMap k [a]+groupMap   :: (Eq k, Hashable k) => (a -> k) -> [a] -> M.HashMap k [a] groupMap f = L.foldl' (\m x -> inserts (f x) x m) M.empty +allMap :: (Eq k, Hashable k) => (v -> Bool) -> M.HashMap k v -> Bool+allMap p = L.foldl' (\a v -> a && p v) True+ sortNub :: (Ord a) => [a] -> [a] sortNub = nubOrd . L.sort-  where nubOrd (x:t@(y:_))-          | x == y    = nubOrd t-          | otherwise = x : nubOrd t-        nubOrd xs = xs+  where+    nubOrd (x:t@(y:_))+      | x == y    = nubOrd t+      | otherwise = x : nubOrd t+    nubOrd xs     = xs   #ifdef MIN_VERSION_located_base@@ -176,8 +218,9 @@   = zip xs ys   | otherwise   = errorstar $ "safeZip called on non-eq-sized lists (nxs = " ++ show nxs ++ ", nys = " ++ show nys ++ ") : " ++ msg-  where nxs = length xs-        nys = length ys+  where+    nxs = length xs+    nys = length ys  safeZipWith msg f xs ys   | nxs == nys@@ -205,6 +248,7 @@ safeUnsnoc :: String -> ListNE a -> ([a], a) #endif + safeHead _   (x:_) = x safeHead msg _     = errorstar $ "safeHead with empty list " ++ msg @@ -219,32 +263,73 @@  safeUnsnoc msg = swap . second reverse . safeUncons msg . reverse -+executeShellCommand :: String -> String -> IO ExitCode executeShellCommand phase cmd   = do writeLoud $ "EXEC: " ++ cmd        bracket_ (startPhase Loud phase) (donePhase Loud phase) $ system cmd +applyNonNull :: b -> ([a] -> b) -> [a] -> b applyNonNull def _ [] = def applyNonNull _   f xs = f xs -+arrow, dcolon :: Doc arrow              = text "->" dcolon             = colon <> colon++intersperse :: Doc -> [Doc] -> Doc intersperse d ds   = hsep $ punctuate d ds +tshow :: (Show a) => a -> Doc tshow              = text . show --- | if loud, write a string to stdout+-- | If loud, write a string to stdout writeLoud :: String -> IO () writeLoud s = whenLoud $ putStrLn s >> hFlush stdout - ensurePath :: FilePath -> IO () ensurePath = createDirectoryIfMissing True . takeDirectory +singleton :: a -> [a]+singleton x = [x]+ fM :: (Monad m) => (a -> b) -> a -> m b fM f = return . f +whenM :: (Monad m) => m Bool -> m () -> m ()+whenM cond act = do+  b <- cond+  when b act+++mapEither :: (a -> Either b c) -> [a] -> ([b], [c])+mapEither _ []     = ([], [])+mapEither f (x:xs) = case f x of+                       Left y  -> (y:ys, zs)+                       Right z -> (ys, z:zs)+                     where+                       (ys, zs) = mapEither f xs++componentsWith :: (Ord c) => (a -> [(b, c, [c])]) -> a -> [[b]]+componentsWith eF x = map (fst3 . f) <$> vss+  where+    (g,f,_)         = G.graphFromEdges . eF $ x+    vss             = T.flatten <$> G.components g+++type EqHash a = (Eq a, Ord a, Hashable a)++-- >>> coalesce [[1], [2,1], [5], [5, 6], [5, 7], [9, 6], [10], [10,100]]+-- [[1,2],[5,7,6,9],[10,100]]++coalesce :: (EqHash v) => [ListNE v] -> [ListNE v]+coalesce = componentsWith coalesceEdges++coalesceEdges :: (EqHash v) => [ListNE v] -> [(v, v, [v])]+coalesceEdges vss = [ (u, u, vs) | (u, vs) <- groupList (uvs ++ vus) ]+  where+    vus           = swap <$> uvs+    uvs           = [ (u, v) | (u : vs) <- vss, v <- vs ]+ {- exitColorStrLn :: Moods -> String -> IO () exitColorStrLn c s = do@@ -252,3 +337,17 @@   putStrLn "\n"   colorStrLn c s -}++mapFst :: (a -> c) -> (a, b) -> (c, b)+mapFst f (x, y) = (f x, y)++mapSnd :: (b -> c) -> (a, b) -> (a, c)+mapSnd f (x, y) = (x, f y)+++{-@ allCombinations :: xss:[[a]] -> [{v:[a]| len v == len xss}] @-}+allCombinations :: [[a]] -> [[a]]+allCombinations []          = [[]]+allCombinations [[]]        = [[]]+allCombinations ([]:_)     = []+allCombinations ((x:xs):ys) = ((x:) <$> allCombinations ys) ++ allCombinations (xs:ys)
src/Language/Fixpoint/Parse.hs view
@@ -5,7 +5,6 @@ {-# LANGUAGE TypeSynonymInstances      #-} {-# LANGUAGE UndecidableInstances      #-} {-# LANGUAGE DeriveGeneric             #-}-{-# LANGUAGE PatternGuards             #-} {-# LANGUAGE OverloadedStrings         #-}  module Language.Fixpoint.Parse (@@ -33,6 +32,7 @@   --   fTyConP  -- Type constructors   , lowerIdP    -- Lower-case identifiers   , upperIdP    -- Upper-case identifiers+  , infixIdP    -- String Haskell infix Id   , symbolP     -- Arbitrary Symbols   , constantP   -- (Integer) Constants   , integer     -- Integer@@ -52,7 +52,7 @@   , bvSortP     -- Bit-Vector Sort    -- * Some Combinators-  , condIdP     -- condIdP  :: [Char] -> (Text -> Bool) -> Parser Text+  , condIdP     --  condIdP  :: [Char] -> (Text -> Bool) -> Parser Text    -- * Add a Location to a parsed value   , locParserP@@ -69,15 +69,21 @@    -- * Utilities   , isSmall++  , initPState, PState++  , Fixity(..), Assoc(..), addOperatorP++  -- * For testing+  , expr0P   ) where  import qualified Data.HashMap.Strict         as M import qualified Data.HashSet                as S import qualified Data.Text                   as T-import           Data.Maybe                  (fromJust)-import           Text.Parsec+import           Data.Maybe                  (fromJust, fromMaybe)+import           Text.Parsec       hiding (State) import           Text.Parsec.Expr-import           Text.Parsec.Language        (emptyDef) import qualified Text.Parsec.Token           as Token -- import           Text.Printf                 (printf) import           GHC.Generics                (Generic)@@ -85,22 +91,46 @@ import           Data.Char                   (isLower) import           Language.Fixpoint.Smt.Bitvector import           Language.Fixpoint.Types.Errors-import           Language.Fixpoint.Misc      (tshow, sortNub, thd3)+import           Language.Fixpoint.Misc      (tshow, thd3) import           Language.Fixpoint.Smt.Types---import           Language.Fixpoint.Types.Names     (headSym)-import           Language.Fixpoint.Types.Visitor   (foldSort, mapSort)+-- import           Language.Fixpoint.Types.Names     (headSym)+-- import           Language.Fixpoint.Types.Visitor   (foldSort, mapSort) import           Language.Fixpoint.Types hiding    (mapSort) import           Text.PrettyPrint.HughesPJ         (text, nest, vcat, (<+>))-type Parser = Parsec String Integer +import Control.Monad.State++type Parser = ParsecT String Integer (State PState)+type ParserT u a = ParsecT String u (State PState) a++data PState = PState {fixityTable :: OpTable}++ -------------------------------------------------------------------- ++emptyDef :: Monad m => Token.GenLanguageDef String a m+emptyDef    = Token.LanguageDef+               { Token.commentStart   = ""+               , Token.commentEnd     = ""+               , Token.commentLine    = ""+               , Token.nestedComments = True+               , Token.identStart     = letter <|> char '_'+               , Token.identLetter    = alphaNum <|> oneOf "_"+               , Token.opStart        = Token.opLetter emptyDef+               , Token.opLetter       = oneOf ":!#$%&*+./<=>?@\\^|-~'"+               , Token.reservedOpNames= []+               , Token.reservedNames  = []+               , Token.caseSensitive  = True+               }++languageDef :: Monad m => Token.GenLanguageDef String a m languageDef =   emptyDef { Token.commentStart    = "/* "            , Token.commentEnd      = " */"            , Token.commentLine     = "//"-           , Token.identStart      = satisfy (const False)-           , Token.identLetter     = satisfy (const False)+           -- , Token.identStart      = satisfy (const False)+           -- , Token.identLetter     = satisfy (const False)            , Token.reservedNames   = [ "SAT"                                      , "UNSAT"                                      , "true"@@ -108,19 +138,54 @@                                      , "mod"                                      , "data"                                      , "Bexp"+                                     , "True"+                                     , "Int"+                                     , "import"+                                     , "if", "then", "else"+                                     , "func"++                                     -- reserved words used in liquid haskell                                      , "forall"                                      , "exists"-                                     , "assume"-                                     , "measure"                                      , "module"                                      , "spec"                                      , "where"-                                     , "True"-                                     , "Int"++                                     , "decrease"+                                     , "lazyvar"+                                     , "LIQUID"+                                     , "lazy"+                                     , "local"+                                     , "assert"+                                     , "assume"+                                     , "automatic-instances"+                                     , "autosize"+                                     , "axiomatize"+                                     , "bound"+                                     , "class"+                                     , "data"+                                     , "define"+                                     , "defined"+                                     , "embed"+                                     , "expression"                                      , "import"-                                     , "_|_"-                                     , "|"-                                     , "if", "then", "else"+                                     , "include"+                                     , "infix"+                                     , "infixl"+                                     , "infixr"+                                     , "inline"+                                     , "instance"+                                     , "invariant"+                                     , "measure"+                                     , "newtype"+                                     , "predicate"+                                     , "qualif"+                                     , "reflect"+                                     , "type"+                                     , "using"+                                     , "with"++                                      ]            , Token.reservedOpNames = [ "+", "-", "*", "/", "\\", ":"                                      , "<", ">", "<=", ">=", "=", "!=" , "/="@@ -131,35 +196,59 @@                                      , "->"                                      , ":="                                      , "&", "^", "<<", ">>", "--"-                                     , "?", "Bexp" -- , "'"+                                     , "?", "Bexp"+                                     , "'"+                                     , "_|_"+                                     , "|"+                                     , "<:"+                                     , "|-"+                                     , "::"+                                     , "."                                      ]            } -lexer         = Token.makeTokenParser languageDef+lexer :: Monad m => Token.GenTokenParser String u m+lexer = Token.makeTokenParser languageDef+++reserved :: String -> Parser () reserved      = Token.reserved      lexer++reservedOp :: String -> Parser () reservedOp    = Token.reservedOp    lexer++parens, brackets, angles, braces :: ParserT u a -> ParserT u a parens        = Token.parens        lexer brackets      = Token.brackets      lexer angles        = Token.angles        lexer+braces        = Token.braces        lexer++semi, colon, comma, stringLiteral :: Parser String semi          = Token.semi          lexer colon         = Token.colon         lexer comma         = Token.comma         lexer-whiteSpace    = Token.whiteSpace    lexer stringLiteral = Token.stringLiteral lexer-braces        = Token.braces        lexer++whiteSpace :: Parser ()+whiteSpace    = Token.whiteSpace    lexer++double :: Parser Double double        = Token.float         lexer -- integer       = Token.integer       lexer  -- identifier = Token.identifier lexer -+-- TODO:AZ: pretty sure there is already a whitespace eater in parsec,+blanks :: Parser String blanks  = many (satisfy (`elem` [' ', '\t'])) +-- | Integer+integer :: Parser Integer integer = posInteger  --  try (char '-' >> (negate <$> posInteger)) --       <|> posInteger-+posInteger :: Parser Integer posInteger = toI <$> (many1 digit <* spaces)   where     toI :: String -> Integer@@ -178,6 +267,7 @@  -- FIXME: we (LH) rely on this parser being dumb and *not* consuming trailing -- whitespace, in order to avoid some parsers spanning multiple lines..+ condIdP  :: S.HashSet Char -> (String -> Bool) -> Parser Symbol condIdP chars f   = do c  <- letter <|> char '_'@@ -185,24 +275,43 @@        blanks        if f (c:cs) then return (symbol $ c:cs) else parserZero +-- | Lower-case identifiers upperIdP :: Parser Symbol-upperIdP = condIdP symChars (not . isSmall . head)+upperIdP = do+  c <- upper+  cs <- many (satisfy (`S.member` symChars))+  blanks+  return (symbol $ c:cs) +-- | Lower-case identifiers lowerIdP :: Parser Symbol-lowerIdP = condIdP symChars (isSmall . head)--isSmall :: Char -> Bool-isSmall c = isLower c || c == '_'+lowerIdP = do+  c <- satisfy (\c -> isLower c || c == '_' )+  cs <- many (satisfy (`S.member` symChars))+  blanks+  return (symbol $ c:cs)  symCharsP :: Parser Symbol symCharsP = condIdP symChars (`notElem` keyWordSyms)+  where+    keyWordSyms = ["if", "then", "else", "mod"] +-- | String Haskell infix Id+infixIdP :: Parser String+infixIdP = many (satisfy (`notElem` [' ', '.']))++isSmall :: Char -> Bool+isSmall c = isLower c || c == '_'++locLowerIdP, locUpperIdP :: Parser LocSymbol locLowerIdP = locParserP lowerIdP locUpperIdP = locParserP upperIdP +-- | Arbitrary Symbols symbolP :: Parser Symbol symbolP = symbol <$> symCharsP +-- | (Integer) Constants constantP :: Parser Constant constantP =  try (R <$> double)          <|> I <$> integer@@ -215,16 +324,27 @@   =  (fastIfP EIte exprP)  <|> (ESym <$> symconstP)  <|> (ECon <$> constantP)- <|> (reserved "_|_" >> return EBot)+ <|> (reservedOp "_|_" >> return EBot)  <|> lamP- <|> try (parens  exprP)- <|> try (parens  exprCastP)+  -- TODO:AZ get rid of these try, after the rest+ <|> try (parens exprP)+ <|> try (parens exprCastP)  <|> (charsExpr <$> symCharsP)+  where +exprCastP :: Parser Expr+exprCastP+  = do e  <- exprP+       (try dcolon) <|> colon+       so <- sortP+       return $ ECst e so++charsExpr :: Symbol -> Expr charsExpr cs   | isSmall (headSym cs) = expr cs   | otherwise            = EVar cs +fastIfP :: (Expr -> a -> a -> a) -> Parser a -> Parser a fastIfP f bodyP   = do reserved "if"        p <- predP@@ -245,69 +365,121 @@       return $ f p b1 b2 -} +-- | Used as input to @Text.Parsec.Expr.buildExpressionParser@ to create @exprP@ expr1P :: Parser Expr expr1P   =  try funAppP  <|> expr0P +-- | Expressions exprP :: Parser Expr-exprP = buildExpressionParser bops expr1P+exprP = (fixityTable <$> get) >>= (`buildExpressionParser` expr1P) -funAppP            =  (try litP) <|> (try exprFunSpacesP) <|> (try exprFunSemisP) <|> exprFunCommasP <|> simpleAppP+data Fixity+  = FInfix   {fpred :: Maybe Int, fname :: String, fop2 :: Maybe (Expr -> Expr -> Expr), fassoc :: Assoc}+  | FPrefix  {fpred :: Maybe Int, fname :: String, fop1 :: Maybe (Expr -> Expr)}+  | FPostfix {fpred :: Maybe Int, fname :: String, fop1 :: Maybe (Expr -> Expr)}+++-- Invariant : OpTable has 10 elements+type OpTable = OperatorTable String Integer (State PState) Expr++addOperatorP :: Fixity -> Parser ()+addOperatorP op+  = modify $ \s -> s{fixityTable =  addOperator op (fixityTable s)}++addOperator :: Fixity -> OpTable -> OpTable+addOperator (FInfix p x f assoc) ops+ = insertOperator (makePrec p) (Infix (reservedOp x >> return (makeInfixFun x f)) assoc) ops+addOperator (FPrefix p x f) ops+ = insertOperator (makePrec p) (Prefix (reservedOp x >> return (makePrefixFun x f))) ops+addOperator (FPostfix p x f) ops+ = insertOperator (makePrec p) (Postfix (reservedOp x >> return (makePrefixFun x f))) ops++makePrec :: Maybe Int -> Int+makePrec = fromMaybe 9++makeInfixFun :: String -> Maybe (Expr -> Expr -> Expr) -> Expr -> Expr -> Expr+makeInfixFun x = fromMaybe (\e1 e2 -> EApp (EApp (EVar $ symbol x) e1) e2)++makePrefixFun :: String -> Maybe (Expr -> Expr) -> Expr -> Expr+makePrefixFun x = fromMaybe (EApp (EVar $ symbol x))++insertOperator :: Int -> Operator String Integer (State PState) Expr -> OpTable -> OpTable+insertOperator i op ops = go (9 - i) ops   where-    exprFunSpacesP = mkEApp <$> funSymbolP <*> sepBy1 expr0P blanks-    exprFunCommasP = mkEApp <$> funSymbolP <*> parens        (sepBy exprP comma)-    exprFunSemisP  = mkEApp <$> funSymbolP <*> parenBrackets (sepBy exprP semi)-    simpleAppP     = EApp <$> (parens exprP) <*> (parens exprP)+    go _ []       = die $ err dummySpan (text "insertOperator on empty ops")+    go 0 (xs:xss) = (xs++[op]):xss+    go i (xs:xss) = xs:go (i-1) xss++initOpTable :: OpTable+initOpTable = replicate 10 [] --  take 10 (repeat [])++bops :: OpTable+bops = foldl (flip addOperator) initOpTable buildinOps+  where+-- Build in Haskell ops https://www.haskell.org/onlinereport/decls.html#fixity+    buildinOps = [ FPrefix (Just 9) "-"   (Just ENeg)+                 , FInfix  (Just 7) "*"   (Just $ EBin Times) AssocLeft+                 , FInfix  (Just 7) "/"   (Just $ EBin Div)   AssocLeft+                 , FInfix  (Just 6) "-"   (Just $ EBin Minus) AssocLeft+                 , FInfix  (Just 6) "+"   (Just $ EBin Plus)  AssocLeft+                 , FInfix  (Just 5) "mod" (Just $ EBin Mod)   AssocLeft -- Haskell gives mod 7+                 ]++-- | Function Applications+funAppP :: Parser Expr+funAppP            =  litP <|> exprFunP <|> simpleAppP+  where+    exprFunP = mkEApp <$> funSymbolP <*> funRhsP+    funRhsP  =  sepBy1 expr0P blanks+            <|> parens innerP+    innerP =   brackets (sepBy exprP semi)+           <|> sepBy exprP comma++    -- TODO:AZ the parens here should be superfluous, but it hits an infinite loop if removed+    simpleAppP     = EApp <$> parens exprP <*> parens exprP     funSymbolP     = locParserP symbolP  +-- TODO:AZ: The comment says BitVector literal, but it accepts any @Sort@ -- | BitVector literal: lit "#x00000001" (BitVec (Size32 obj))+litP :: Parser Expr litP = do reserved "lit"           l <- stringLiteral           t <- sortP           return $ ECon $ L (T.pack l) t -parenBrackets  = parens . brackets--bops = [ [ Prefix (reservedOp "-"   >> return ENeg)]-       , [ Infix  (reservedOp "*"   >> return (EBin Times)) AssocLeft-         , Infix  (reservedOp "/"   >> return (EBin Div  )) AssocLeft-         ]-       , [ Infix  (reservedOp "-"   >> return (EBin Minus)) AssocLeft-         , Infix  (reservedOp "+"   >> return (EBin Plus )) AssocLeft-         ]-       , [ Infix  (reservedOp "mod"  >> return (EBin Mod  )) AssocLeft]-       ]+-- parenBrackets :: Parser a -> Parser a+-- parenBrackets  = parens . brackets  -- eMinus     = EBin Minus (expr (0 :: Integer)) -- eCons x xs = EApp (dummyLoc consName) [x, xs] -- eNil       = EVar nilName -exprCastP-  = do e  <- exprP-       (try dcolon) <|> colon-       so <- sortP-       return $ ECst e so--+lamP :: Parser Expr lamP-  = do reserved "\\"+  = do reservedOp "\\"        x <- symbolP        colon        t <- sortP-       reserved "->"+       reservedOp "->"        e  <- exprP        return $ ELam (x, t) e -+dcolon :: Parser String dcolon = string "::" <* spaces +varSortP :: Parser Sort varSortP  = FVar  <$> parens intP++funcSortP :: Parser Sort funcSortP = parens $ mkFFunc <$> intP <* comma <*> sortsP +sortsP :: Parser [Sort] sortsP = brackets $ sepBy sortP semi +-- | Sort sortP    :: Parser Sort sortP    = sortP' (sepBy sortArgP blanks) @@ -323,18 +495,19 @@  sortP' :: Parser [Sort] -> Parser Sort sortP' appArgsP-   =  try (parens sortP)-  <|> try (string "func" >> funcSortP)-  <|> try (fAppTC listFTyCon . single <$> brackets sortP)-  <|> try bvSortP-  <|> try (fAppTC <$> fTyConP <*> appArgsP)-  <|> try (fApp   <$> tvarP   <*> appArgsP)+   =  parens sortP+  <|> (reserved "func" >> funcSortP)+  <|> (fAppTC listFTyCon . single <$> brackets sortP)+  <|> bvSortP+  <|> (fAppTC <$> fTyConP <*> appArgsP)+  <|> (fApp   <$> tvarP   <*> appArgsP) +single :: a -> [a] single x = [x]  tvarP :: Parser Sort tvarP-   =  try (string "@" >> varSortP)+   =  (string "@" >> varSortP)   <|> (FObj . symbol <$> lowerIdP)  @@ -343,21 +516,22 @@   =   (reserved "int"     >> return intFTyCon)   <|> (reserved "Integer" >> return intFTyCon)   <|> (reserved "Int"     >> return intFTyCon)-  <|> (reserved "int"     >> return intFTyCon)+  <|> (reserved "int"     >> return intFTyCon) -- TODO:AZ duplicate?   <|> (reserved "real"    >> return realFTyCon)   <|> (reserved "bool"    >> return boolFTyCon)   <|> (reserved "num"     >> return numFTyCon)+  <|> (reserved "Str"     >> return strFTyCon)   <|> (symbolFTycon      <$> locUpperIdP) -bvSortP-  = mkSort <$> (bvSizeP "Size32" S32 <|> bvSizeP "Size64" S64)+-- | Bit-Vector Sort+bvSortP :: Parser Sort+bvSortP = mkSort <$> (bvSizeP "Size32" S32 <|> bvSizeP "Size64" S64)+  where+    bvSizeP ss s = do+      parens (reserved "BitVec" >> reserved ss)+      return s -bvSizeP ss s = do-  parens (reserved "BitVec" >> reserved ss)-  return s -keyWordSyms = ["if", "then", "else", "mod"]- -------------------------------------------------------------------------------- -- | Predicates ---------------------------------------------------------------- --------------------------------------------------------------------------------@@ -365,16 +539,22 @@ pred0P :: Parser Expr pred0P =  trueP       <|> falseP-      <|> try (reserved "??" >> return PGrad)-      <|> try kvarPredP-      <|> try (fastIfP pIte predP)+      <|> (reservedOp "??" >> makeUniquePGrad)+      <|> kvarPredP+      <|> (fastIfP pIte predP)       <|> try predrP-      <|> try (parens predP)-      <|> try (reserved "?" *> exprP)+      <|> (parens predP)+      <|> (reservedOp "?" *> exprP)       <|> try funAppP-      <|> try (reservedOp "&&" >> PAnd <$> predsP)-      <|> try (reservedOp "||" >> POr  <$> predsP)+      <|> (eVar <$> symbolP)+      <|> (reservedOp "&&" >> pGAnds <$> predsP)+      <|> (reservedOp "||" >> POr  <$> predsP) +makeUniquePGrad :: Parser Expr +makeUniquePGrad+  = do uniquePos <- getPosition+       return $ PGrad (KV $ symbol $ show uniquePos) mempty mempty+ -- qmP    = reserved "?" <|> reserved "Bexp"  trueP, falseP :: Parser Expr@@ -390,23 +570,23 @@ substP :: Parser Subst substP = mkSubst <$> many (brackets $ pairP symbolP aP exprP)   where-    aP = reserved ":="--predP  :: Parser Expr-predP  = buildExpressionParser lops pred0P-+    aP = reservedOp ":=" +predsP :: Parser [Expr] predsP = brackets $ sepBy predP semi --lops = [ [Prefix (reservedOp "~"    >> return PNot)]-       , [Prefix (reservedOp "not " >> return PNot)]-       , [Infix  (reservedOp "&&"   >> return (\x y -> PAnd [x,y])) AssocRight]-       , [Infix  (reservedOp "||"   >> return (\x y -> POr  [x,y])) AssocRight]-       , [Infix  (reservedOp "=>"   >> return PImp) AssocRight]-       , [Infix  (reservedOp "==>"  >> return PImp) AssocRight]-       , [Infix  (reservedOp "<=>"  >> return PIff) AssocRight]]+predP  :: Parser Expr+predP  = buildExpressionParser lops pred0P+  where+    lops = [ [Prefix (reservedOp "~"    >> return PNot)]+           , [Prefix (reservedOp "not " >> return PNot)]+           , [Infix  (reservedOp "&&"   >> return (\x y -> pGAnd x y)) AssocRight]+           , [Infix  (reservedOp "||"   >> return (\x y -> POr  [x,y])) AssocRight]+           , [Infix  (reservedOp "=>"   >> return PImp) AssocRight]+           , [Infix  (reservedOp "==>"  >> return PImp) AssocRight]+           , [Infix  (reservedOp "<=>"  >> return PIff) AssocRight]] +predrP :: Parser Expr predrP = do e1    <- exprP             r     <- brelP             e2    <- exprP@@ -424,36 +604,49 @@      <|> (reservedOp ">"  >> return (PAtom Gt))      <|> (reservedOp ">=" >> return (PAtom Ge)) ------------------------------------------------------------------------------------------------------------------------ BareTypes ----------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | BareTypes -----------------------------------------------------------------+-------------------------------------------------------------------------------- +-- | Refa refaP :: Parser Expr refaP =  try (pAnd <$> brackets (sepBy predP semi))      <|> predP  -+-- | (Sorted) Refinements with configurable sub-parsers refBindP :: Parser Symbol -> Parser Expr -> Parser (Reft -> a) -> Parser a refBindP bp rp kindP   = braces $ do       x  <- bp       t  <- kindP-      reserved "|"+      reservedOp "|"       ra <- rp <* spaces       return $ t (Reft (x, ra)) + -- bindP      = symbol    <$> (lowerIdP <* colon)-bindP      = symbolP <* colon+-- | Binder (lowerIdP <* colon)+bindP :: Parser Symbol+bindP = symbolP <* colon++optBindP :: Symbol -> Parser Symbol optBindP x = try bindP <|> return x +-- | (Sorted) Refinements+refP :: Parser (Reft -> a) -> Parser a refP       = refBindP bindP refaP++-- | (Sorted) Refinements with default binder+refDefP :: Symbol -> Parser Expr -> Parser (Reft -> a) -> Parser a refDefP x  = refBindP (optBindP x)  --------------------------------------------------------------------- -- | Parsing Qualifiers --------------------------------------------- --------------------------------------------------------------------- +-- | Qualifiers+qualifierP :: Parser Sort -> Parser Qualifier qualifierP tP = do   pos    <- getPosition   n      <- upperIdP@@ -461,62 +654,43 @@   _      <- colon   body   <- predP   return  $ mkQual n params body pos--sortBindP = pairP symbolP colon+  where+    sortBindP = pairP symbolP colon  pairP :: Parser a -> Parser z -> Parser b -> Parser (a, b) pairP xP sepP yP = (,) <$> xP <* sepP <*> yP -mkQual :: Symbol -> [(Symbol, Sort)] -> Expr -> SourcePos -> Qualifier-mkQual n xts p = Q n ((v, t) : yts) (subst su p)-  where-    (v, t):zts = gSorts xts-    -- yts        = first mkParam <$> zts-    yts        = zts-    su         = mkSubst $ zipWith (\(z,_) (y,_) -> (z, eVar y)) zts yts- -- mkParam :: Symbol -> Symbol -- mkParam s       = unsafeTextSymbol ('~' `T.cons` toUpper c `T.cons` cs) --  where --    Just (c,cs) = T.uncons $ symbolSafeText s -gSorts :: [(a, Sort)] -> [(a, Sort)]-gSorts xts     = [(x, substVars su t) | (x, t) <- xts]-  where-    su         = (`zip` [0..]) . sortNub . concatMap (sortVars . snd) $ xts -substVars :: [(Symbol, Int)] -> Sort -> Sort-substVars su = mapSort tx-  where-    tx (FObj x)-      | Just i <- lookup x su = FVar i-    tx t                      = t--sortVars :: Sort -> [Symbol]-sortVars = foldSort go []-  where-    go b (FObj x) = x : b-    go b _        = b-- --------------------------------------------------------------------- -- | Parsing Constraints (.fq files) -------------------------------- ---------------------------------------------------------------------  -- Entities in Query File data Def a-  = Srt Sort-  | Axm Expr-  | Cst (SubC a)-  | Wfc (WfC a)-  | Con Symbol Sort-  | Qul Qualifier-  | Kut KVar-  | IBind Int Symbol SortedReft+  = Srt !Sort+  | Axm !Expr+  | Cst !(SubC a)+  | Wfc !(WfC a)+  | Con !Symbol !Sort+  | Dis !Symbol !Sort+  | Qul !Qualifier+  | Kut !KVar+  | Pack !KVar !Int+  | IBind !Int !Symbol !SortedReft+  | Opt !String   deriving (Show, Generic)   --  Sol of solbind   --  Dep of FixConstraint.dep +fInfoOptP :: Parser (FInfoWithOpts ())+fInfoOptP = do ps <- many defP+               return $ FIO (defsFInfo ps) [s | Opt s <- ps]+ fInfoP :: Parser (FInfo ()) fInfoP = defsFInfo <$> {-# SCC "many-defP" #-} many defP @@ -526,9 +700,12 @@     <|> Cst   <$> (reserved "constraint" >> colon >> {-# SCC "subCP" #-} subCP)     <|> Wfc   <$> (reserved "wf"         >> colon >> {-# SCC "wfCP"  #-} wfCP)     <|> Con   <$> (reserved "constant"   >> symbolP) <*> (colon >> sortP)+    <|> Dis   <$> (reserved "distinct"   >> symbolP) <*> (colon >> sortP)+    <|> Pack  <$> (reserved "pack"       >> kvarP)   <*> (colon >> intP)     <|> Qul   <$> (reserved "qualif"     >> qualifierP sortP)     <|> Kut   <$> (reserved "cut"        >> kvarP)     <|> IBind <$> (reserved "bind"       >> intP) <*> symbolP <*> (colon >> {-# SCC "sortedReftP" #-} sortedReftP)+    <|> Opt   <$> (reserved "fixpoint"   >> stringLiteral)  sortedReftP :: Parser SortedReft sortedReftP = refP (RR <$> (sortP <* spaces))@@ -555,6 +732,14 @@            pos' <- getPosition            return $ subC' env lhs rhs i tag pos pos' +subC' :: IBindEnv+      -> SortedReft+      -> SortedReft+      -> Integer+      -> Tag+      -> SourcePos+      -> SourcePos+      -> SubC () subC' env lhs rhs i tag l l'   = case cs of       [c] -> c@@ -575,15 +760,17 @@ intP = fromInteger <$> integer  defsFInfo :: [Def a] -> FInfo a-defsFInfo defs = {-# SCC "defsFI" #-} FI cm ws bs lts kts qs mempty mempty False +defsFInfo defs = {-# SCC "defsFI" #-} FI cm ws bs lts dts kts qs mempty mempty mempty mempty   where-    cm     = M.fromList       [(cid c, c)       | Cst c       <- defs]-    ws     = M.fromList       [(thd3 $ wrft w, w) | Wfc w     <- defs]-    bs     = bindEnvFromList  [(n, x, r)        | IBind n x r <- defs]-    lts    = fromListSEnv     [(x, t)           | Con x t     <- defs]-    kts    = KS $ S.fromList  [k                | Kut k       <- defs]-    qs     =                  [q                | Qul q       <- defs]-    cid    = fromJust . sid+    cm         = M.fromList         [(cid c, c)         | Cst c       <- defs]+    ws         = M.fromList         [(thd3 $ wrft w, w) | Wfc w       <- defs]+    bs         = bindEnvFromList    [(n, x, r)          | IBind n x r <- defs]+    lts        = fromListSEnv       [(x, t)             | Con x t     <- defs]+    dts        = fromListSEnv       [(x, t)             | Dis x t     <- defs]+    kts        = KS $ S.fromList    [k                  | Kut k       <- defs]+    -- pks        = Packs $ M.fromList [(k, i)             | Pack k i    <- defs]+    qs         =                    [q                  | Qul q       <- defs]+    cid        = fromJust . sid     -- msg    = show $ "#Lits = " ++ (show $ length consts)  ---------------------------------------------------------------------@@ -596,44 +783,49 @@  <|> (reserved "UNSAT" >> Unsafe <$> brackets (sepBy pp comma))  <|> (reserved "CRASH" >> crashP pp) -crashP pp-  = do i   <- pp-       msg <- many anyChar-       return $ Crash [i] msg--predSolP-  = parens (predP  <* (comma >> iQualP))+crashP :: Parser a -> Parser (FixResult a)+crashP pp = do+  i   <- pp+  msg <- many anyChar+  return $ Crash [i] msg +predSolP :: Parser Expr+predSolP = parens (predP  <* (comma >> iQualP)) -iQualP-  = upperIdP >> parens (sepBy symbolP comma)+iQualP :: Parser [Symbol]+iQualP = upperIdP >> parens (sepBy symbolP comma) -solution1P-  = do reserved "solution:"-       k  <- kvP-       reserved ":="-       ps <- brackets $ sepBy predSolP semi-       return (k, simplify $ PAnd ps)-    where-      kvP = try kvarP <|> (KV <$> symbolP)+solution1P :: Parser (KVar, Expr)+solution1P = do+  reserved "solution:"+  k  <- kvP+  reservedOp ":="+  ps <- brackets $ sepBy predSolP semi+  return (k, simplify $ PAnd ps)+  where+    kvP = try kvarP <|> (KV <$> symbolP)  solutionP :: Parser (M.HashMap KVar Expr)-solutionP-  = M.fromList <$> sepBy solution1P whiteSpace--solutionFileP-  = (,) <$> fixResultP integer <*> solutionP+solutionP = M.fromList <$> sepBy solution1P whiteSpace -------------------------------------------------------------------------+solutionFileP :: Parser (FixResult Integer, M.HashMap KVar Expr)+solutionFileP = (,) <$> fixResultP integer <*> solutionP +--------------------------------------------------------------------------------+remainderP :: Parser a -> Parser (a, String, SourcePos) remainderP p   = do res <- p        str <- getInput        pos <- getPosition        return (res, str, pos) ++initPState :: PState+initPState = PState {fixityTable = bops}++doParse' :: Parser a -> SourceName -> String -> a doParse' parser f s-  = case runParser (remainderP (whiteSpace >> parser)) 0 f s of+  = case evalState (runParserT (remainderP (whiteSpace >> parser)) 0 f s) initPState of       Left e            -> die $ err (errorSpan e) (dErr e)       Right (r, "", _)  -> r       Right (_, r, l)   -> die $ err (SS l l) (dRem r)@@ -644,6 +836,8 @@                     , nest 4 (text r)                     , "when parsing from" <+> text f ] ++errorSpan :: ParseError -> SrcSpan errorSpan e = SS l l where l = errorPos e  parseFromFile :: Parser b -> SourceName -> IO b@@ -657,9 +851,10 @@ --------------------------------------------------------------------- -- Standalone SMTLIB2 commands -------------------------------------- ----------------------------------------------------------------------+commandsP :: Parser [Command] commandsP = sepBy commandP semi +commandP :: Parser Command commandP   =  (reserved "var"      >> cmdVarP)  <|> (reserved "push"     >> return Push)@@ -668,11 +863,11 @@  <|> (reserved "assert"   >> (Assert Nothing <$> predP))  <|> (reserved "distinct" >> (Distinct <$> brackets (sepBy exprP comma))) -cmdVarP-  = do x <- bindP-       t <- sortP-       return $ Declare x [] t-+cmdVarP :: Parser Command+cmdVarP = do+  x <- bindP+  t <- sortP+  return $ Declare x [] t  --------------------------------------------------------------------- -- Bundling Parsers into a Typeclass --------------------------------@@ -701,6 +896,9 @@  instance Inputable (FInfo ()) where   rr' = {-# SCC "fInfoP" #-} doParse' fInfoP++instance Inputable (FInfoWithOpts ()) where+  rr' = {-# SCC "fInfoWithOptsP" #-} doParse' fInfoOptP  instance Inputable Command where   rr' = doParse' commandP
− src/Language/Fixpoint/Partition.hs
@@ -1,463 +0,0 @@-{-# LANGUAGE ConstraintKinds   #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE RecordWildCards #-}---- | This module implements functions to build constraint / kvar---   dependency graphs, partition them and print statistics about---   their structure.--module Language.Fixpoint.Partition (--  -- * Split constraints-    CPart (..)-  , partition, partition', partitionN--  -- * Information about cores-  , MCInfo (..)-  , mcInfo--  -- * Queries over dependencies-  , graphStatistics-  , GDeps (..)-  , deps-  -- , isReducible--  -- * Debug-  , elimSolGraph-  ) where--import           GHC.Conc                  (getNumProcessors)-import           Control.Monad             (when, forM_)--- import           GHC.Generics              (Generic)-import           Language.Fixpoint.Misc         -- hiding (group)-import           Language.Fixpoint.Utils.Files-import           Language.Fixpoint.Types.Config-import           Language.Fixpoint.Types.PrettyPrint-import qualified Language.Fixpoint.Types.Visitor      as V-import qualified Language.Fixpoint.Solver.Solution    as So-import qualified Language.Fixpoint.Types              as F-import           Language.Fixpoint.Types.Graphs-import qualified Data.HashMap.Strict                  as M-import qualified Data.Graph                           as G-import qualified Data.Tree                            as T-import           Data.Function (on)-import           Data.Maybe                     (mapMaybe, fromMaybe)-import           Data.Hashable-import           Text.PrettyPrint.HughesPJ-import           Data.List (sortBy)-import qualified Data.HashSet              as S--import Data.Graph.Inductive--------------------------------------------------------------------------------------- | Constraint Partition Container -------------------------------------------------------------------------------------------------------------------------------data CPart a = CPart { pws :: M.HashMap F.KVar (F.WfC a)-                     , pcm :: M.HashMap Integer (F.SubC a)-                     , cFileName :: FilePath-                     }--instance Monoid (CPart a) where-   mempty = CPart mempty mempty mempty-   mappend l r = CPart { pws = pws l `mappend` pws r-                       , pcm = pcm l `mappend` pcm r-                       , cFileName = cFileName l-                       }------------------------------------------------------------------------------------- | Multicore info -----------------------------------------------------------------------------------------------------------------------------------------------data MCInfo = MCInfo { mcCores :: Int-                     , mcMinPartSize :: Int-                     , mcMaxPartSize :: Int-                     } deriving (Show)--mcInfo :: Config -> IO MCInfo-mcInfo c = do-   np <- getNumProcessors-   let nc = fromMaybe np (cores c)-   return MCInfo { mcCores = nc-                 , mcMinPartSize = minPartSize c-                 , mcMaxPartSize = maxPartSize c-                 }--partition :: (F.Fixpoint a) => Config -> F.FInfo a -> IO (F.Result (Integer, a))-partition cfg fi-  = do dumpPartitions cfg fis-       writeGraph      f   g-       return mempty-    where-      f        = queryFile Dot cfg-      (g, fis) = partition' Nothing fi----------------------------------------------------------------------------------- | Partition an FInfo into multiple disjoint FInfos--------------------------------------------------------------------------------partition' :: Maybe MCInfo -- ^ Nothing to produce the maximum possible-                             -- number of partitions. Or a MultiCore Info-                             -- to control the partitioning-           -> F.FInfo a -> (KVGraph, [F.FInfo a])--------------------------------------------------------------------------------partition' mn fi  = case mn of-   Nothing -> (g, fis mkPartition id)-   Just mi -> (g, partitionN mi fi $ fis mkPartition' finfoToCpart)-  where-    g              = kvGraph   fi-    css            = decompose g-    fis partF ctor = applyNonNull [ctor fi] (pbc partF) css-    pbc partF      = partitionByConstraints partF fi----- | Partition an FInfo into a specific number of partitions of roughly equal--- amounts of work-partitionN :: MCInfo    -- ^ describes thresholds and partiton amounts-           -> F.FInfo a   -- ^ The originial FInfo-           -> [CPart a] -- ^ A list of the smallest possible CParts-           -> [F.FInfo a] -- ^ At most N partitions of at least thresh work-partitionN mi fi cp-   | cpartSize (finfoToCpart fi) <= minThresh = [fi]-   | otherwise = map (cpartToFinfo fi) $ toNParts sortedParts-   where-      toNParts p-         | isDone p = p-         | otherwise = toNParts $ insertSorted firstTwo rest-            where (firstTwo, rest) = unionFirstTwo p-      isDone [] = True-      isDone [_] = True-      isDone fi'@(a:b:_) = length fi' <= prts-                            && (cpartSize a >= minThresh-                                || cpartSize a + cpartSize b >= maxThresh)-      sortedParts = sortBy sortPredicate cp-      unionFirstTwo (a:b:xs) = (a `mappend` b, xs)-      unionFirstTwo _        = errorstar "Partition.partitionN.unionFirstTwo called on bad arguments"-      sortPredicate lhs rhs-         | cpartSize lhs < cpartSize rhs = GT-         | cpartSize lhs > cpartSize rhs = LT-         | otherwise = EQ-      insertSorted a []     = [a]-      insertSorted a (x:xs) = if sortPredicate a x == LT-                              then x : insertSorted a xs-                              else a : x : xs-      prts      = mcCores mi-      minThresh = mcMinPartSize mi-      maxThresh = mcMaxPartSize mi----- | Return the "size" of a CPart. Used to determine if it's--- substantial enough to be worth parallelizing.-cpartSize :: CPart a -> Int-cpartSize c = (M.size . pcm) c + (length . pws) c---- | Convert a CPart to an FInfo-cpartToFinfo :: F.FInfo a -> CPart a -> F.FInfo a-cpartToFinfo fi p = fi { F.cm = pcm p-                       , F.ws = pws p-                       , F.fileName = cFileName p-                       }---- | Convert an FInfo to a CPart-finfoToCpart :: F.FInfo a -> CPart a-finfoToCpart fi = CPart { pcm = F.cm fi-                        , pws = F.ws fi-                        , cFileName = F.fileName fi-                        }----------------------------------------------------------------------------------------dumpPartitions :: (F.Fixpoint a) => Config -> [F.FInfo a] -> IO ()---------------------------------------------------------------------------------------dumpPartitions cfg fis =-  forM_ (zip [0..] fis) $ \(i, fi) ->-    writeFile (partFile fi i) (render $ F.toFixpoint cfg fi)--partFile :: F.FInfo a -> Int -> FilePath-partFile fi j = extFileName (Part j) (F.fileName fi)----- | Type alias for a function to construct a partition. mkPartition and--- mkPartition' are the two primary functions that conform to this interface-type PartitionCtor a b = F.FInfo a-                         -> M.HashMap Int [(Integer, F.SubC a)]-                         -> M.HashMap Int [(F.KVar, F.WfC a)]-                         -> Int-                         -> b -- ^ typically a F.FInfo a or F.CPart a--partitionByConstraints :: PartitionCtor a b -- ^ mkPartition or mkPartition'-                          -> F.FInfo a-                          -> KVComps-                          -> ListNE b -- ^ [F.FInfo a] or [F.CPart a]-partitionByConstraints f fi kvss = f fi icM iwM <$> js-  where-    js   = fst <$> jkvs                                -- groups-    gc   = groupFun cM                                 -- (i, ci) |-> j-    gk   = groupFun kM                                 -- k       |-> j--    iwM  = groupMap (gk . fst) (M.toList (F.ws fi))             -- j |-> [w]-    icM  = groupMap (gc . fst) (M.toList (F.cm fi))  -- j |-> [(i, ci)]--    jkvs = zip [1..] kvss-    kvI  = [ (x, j) | (j, kvs) <- jkvs, x <- kvs ]-    kM   = M.fromList [ (k, i) | (KVar k, i) <- kvI ]-    cM   = M.fromList [ (c, i) | (Cstr c, i) <- kvI ]--mkPartition fi icM iwM j-  = fi { F.cm       = M.fromList $ M.lookupDefault [] j icM-       , F.ws       = M.fromList $ M.lookupDefault [] j iwM-       , F.fileName = partFile fi j-       }--mkPartition' fi icM iwM j-  = CPart { pcm       = M.fromList $ M.lookupDefault [] j icM-          , pws       = M.fromList $ M.lookupDefault [] j iwM-          , cFileName = partFile fi j-          }--groupFun :: (Show k, Eq k, Hashable k) => M.HashMap k Int -> k -> Int-groupFun m k = safeLookup ("groupFun: " ++ show k) k m-----------------------------------------------------------------------------------decompose :: KVGraph -> KVComps---------------------------------------------------------------------------------decompose kg = map (fst3 . f) <$> vss-  where-    (g,f,_)  = G.graphFromEdges kg-    vss      = T.flatten <$> G.components g----------------------------------------------------------------------------------kvGraph :: (F.TaggedC c a) => F.GInfo c a -> KVGraph---------------------------------------------------------------------------------kvGraph = edgeGraph . kvEdges--edgeGraph :: [CEdge] -> KVGraph-edgeGraph es = [(v,v,vs) | (v, vs) <- groupList es ]--kvEdges :: (F.TaggedC c a) => F.GInfo c a -> [CEdge]-kvEdges fi = selfes ++ concatMap (subcEdges bs) cs-  where-    bs     = F.bs fi-    cs     = M.elems (F.cm fi)-    ks     = fiKVars fi-    selfes =  [(Cstr i, Cstr i)   | c <- cs, let i = F.subcId c]-           ++ [(KVar k, DKVar k)  | k <- ks]-           ++ [(DKVar k, DKVar k) | k <- ks]---fiKVars :: F.GInfo c a -> [F.KVar]-fiKVars = M.keys . F.ws--subcEdges :: (F.TaggedC c a) => F.BindEnv -> c a -> [CEdge]-subcEdges bs c =  [(KVar k, Cstr i ) | k  <- V.envKVars bs c]-               ++ [(Cstr i, KVar k') | k' <- V.rhsKVars c ]-  where-    i          = F.subcId c------------------------------------------------------------------------------------- | Generic Dependencies ----------------------------------------------------------------------------------------------------------------------------------------data GDeps a-  = Deps { depCuts    :: !(S.HashSet a)-         , depNonCuts :: !(S.HashSet a)-         }-    deriving (Show)--instance (Eq a, Hashable a) => Monoid (GDeps a) where-  mempty                            = Deps S.empty S.empty-  mappend (Deps d1 n1) (Deps d2 n2) = Deps (S.union d1 d2) (S.union n1 n2)--dCut, dNonCut :: (Hashable a) => a -> GDeps a-dNonCut v = Deps S.empty (S.singleton v)-dCut    v = Deps (S.singleton v) S.empty------------------------------------------------------------------------------------- | Compute Dependencies and Cuts -------------------------------------------------------------------------------------------------------------------------------deps :: (F.TaggedC c a) => F.GInfo c a -> GDeps F.KVar----------------------------------------------------------------------------------deps si         = Deps (takeK cs) (takeK ns)-  where-    Deps cs ns  = gDeps cutF (edgeGraph es)-    es          = kvEdges si-    -- ORIG cutF = chooseCut isK (cuts si)-    cutF        = edgeRankCut (edgeRank es)-    takeK       = sMapMaybe tx-    tx (KVar z) = Just z-    tx _        = Nothing---- crash _ = undefined--- cutter :: F.TaggedC c a => F.GInfo c a -> Cutter CVertex--- cutter si = chooseCut isK (cuts si)---- ORIG isK :: CVertex -> Bool--- ORIG isK (KVar _) = True--- ORIG isK _        = False--- ORIG cuts :: (F.TaggedC c a) => F.GInfo c a -> S.HashSet CVertex--- ORIG cuts = S.map KVar . F.ksVars . F.kuts---sMapMaybe :: (Hashable b, Eq b) => (a -> Maybe b) -> S.HashSet a -> S.HashSet b-sMapMaybe f = S.fromList . mapMaybe f . S.toList-----------------------------------------------------------------------------------type EdgeRank = M.HashMap F.KVar Integer----------------------------------------------------------------------------------edgeRank :: [CEdge] -> EdgeRank-edgeRank es = minimum . (n :) <$> kiM-  where-    n       = 1 + maximum [ i | (Cstr i, _)     <- es ]-    kiM     = group [ (k, i) | (KVar k, Cstr i) <- es ]--edgeRankCut :: EdgeRank -> Cutter CVertex-edgeRankCut km vs = case ks of-                      [] -> Nothing-                      k:_ -> Just (KVar k, [x | x@(u,_,_) <- vs, u /= KVar k])-  where-    ks            = orderBy [k | (KVar k, _ ,_) <- vs]-    rank          = (km M.!)-    orderBy       = sortBy (compare `on` rank)-----------------------------------------------------------------------------------type Cutter a = [(a, a, [a])] -> Maybe (a, [(a, a, [a])])------------------------------------------------------------------------------------ ORIG chooseCut :: (Cutable a) => (a -> Bool) -> S.HashSet a -> Cutter a--- ORIG ----------------------------------------------------------------------------------- ORIG chooseCut f ks vs = case vs'' of-                      -- ORIG []  -> Nothing-                      -- ORIG v:_ -> Just (v, [x | x@(u,_,_) <- vs, u /= v])-  -- ORIG where-    -- ORIG vs'           = [x | (x,_,_) <- vs, f x]-    -- ORIG is            = S.intersection (S.fromList vs') ks-    -- ORIG vs''          = if S.null is then vs' else S.toList is-       -- ORIG -- ^ -- we select a RANDOM element,-       -- ORIG ------- instead pick the "first" element.-------------------------------------------------------------------------------------type Cutable a = (Eq a, Ord a, Hashable a, Show a)----------------------------------------------------------------------------------gDeps :: (Cutable a) => Cutter a -> [(a, a, [a])] -> GDeps a----------------------------------------------------------------------------------gDeps f g = sccsToDeps f (G.stronglyConnCompR g)---sccsToDeps :: (Cutable a) => Cutter a -> [G.SCC (a, a, [a])] -> GDeps a-sccsToDeps f xs = mconcat $ sccDep f <$> xs--sccDep :: (Cutable a) =>  Cutter a -> G.SCC (a, a, [a]) -> GDeps a-sccDep _ (G.AcyclicSCC (v,_,_)) = dNonCut v-sccDep f (G.CyclicSCC vs)      = cycleDep f vs---cycleDep :: (Cutable a) => Cutter a -> [(a,a,[a])] -> GDeps a-cycleDep _ [] = mempty-cycleDep f vs = addCut f (f vs)--addCut _ Nothing         = mempty-addCut f (Just (v, vs')) = mconcat $ dCut v : (sccDep f <$> sccs)-  where-    sccs                 = G.stronglyConnCompR vs'-----------------------------------------------------------------------------------isReducible :: F.SInfo a -> Bool----------------------------------------------------------------------------------isReducible fi = all (isReducibleWithStart g) vs-  where-    g  = convertToGraph fi-    vs = {- trace (showDot $ fglToDotGeneric g show (const "") id) -} nodes g--isReducibleWithStart :: Gr a b -> Node -> Bool-isReducibleWithStart g x = all (isBackEdge domList) rEdges-  where-    dfsTree = head $ dff [x] g --head because only care about nodes reachable from 'start node'?-    rEdges = [e | e@(a,b) <- edges g, isDescendant a b dfsTree]-    domList = dom g x--convertToGraph :: F.SInfo a -> Gr Int ()-convertToGraph fi = mkGraph vs es-  where-    subCs        = M.elems (F.cm fi)-    es           = lUEdge <$> concatMap (subcEdges' kvI $ F.bs fi) subCs-    ks           = M.keys (F.ws fi)-    kiM          = M.fromList $ zip ks [0..]-    kvI k        = safeLookup ("convertToGraph: " ++ show k) k kiM-    vs           = lNode . kvI <$> M.keys (F.ws fi)-    lNode i      = (i, i)-    lUEdge (i,j) = (i, j, ())--isDescendant :: Node -> Node -> T.Tree Node -> Bool-isDescendant x y (T.Node z f) | z == y    = f `contains` x-                              | z == x    = False-                              | otherwise = any (isDescendant x y) f--contains :: [T.Tree Node] -> Node -> Bool-contains t x = x `elem` concatMap T.flatten t--isBackEdge :: [(Node, [Node])] -> Edge -> Bool-isBackEdge t (u,v) = v `elem` xs-  where-    (Just xs) = lookup u t--subcEdges' :: (F.KVar -> Node) -> F.BindEnv -> F.SimpC a -> [(Node, Node)]-subcEdges' kvI be c = [(kvI k1, kvI k2) | k1 <- V.envKVars be c-                                        , k2 <- V.kvars $ F.crhs c]-----------------------------------------------------------------------------------graphStatistics :: Config -> F.SInfo a -> IO ()----------------------------------------------------------------------------------graphStatistics cfg si = when (elimStats cfg) $ do-  writeGraph f  (kvGraph si)-  appendFile f . ppc . ptable $ graphStats si-  where-    f     = queryFile Dot cfg-    ppc d = showpp $ vcat [" ", " ", "/*", pprint d, "*/"]--data Stats = Stats {-    stNumKVCuts   :: !Int   -- ^ number of kvars whose removal makes deps acyclic-  , stNumKVNonLin :: !Int   -- ^ number of kvars that appear >= 2 in some LHS-  , stNumKVTotal  :: !Int   -- ^ number of kvars-  , stIsReducible :: !Bool  -- ^ is dep-graph reducible-  , stSetKVNonLin :: S.HashSet F.KVar -- ^ set of non-linear kvars-  }--instance PTable Stats where-  ptable (Stats {..})  = DocTable [-      ("# KVars [Cut]"    , pprint stNumKVCuts)-    , ("# KVars [NonLin]" , pprint stNumKVNonLin)-    , ("# KVars [All]"    , pprint stNumKVTotal)-    , ("# Reducible"      , pprint stIsReducible)-    , ("KVars NonLin"     , pprint stSetKVNonLin)-    ]--graphStats :: F.SInfo a -> Stats-graphStats si     = Stats {-    stNumKVCuts   = S.size (depCuts d)-  , stNumKVNonLin = S.size  nlks-  , stNumKVTotal  = S.size (depCuts d) + S.size (depNonCuts d)-  , stIsReducible = isReducible si-  , stSetKVNonLin = nlks-  }-  where-    nlks          = nlKVars si-    d             = deps si--nlKVars :: (F.TaggedC c a) => F.GInfo c a -> S.HashSet F.KVar-nlKVars fi = S.unions $ nlKVarsC bs <$> cs-  where-    bs     = F.bs fi-    cs     = M.elems (F.cm fi)--nlKVarsC :: (F.TaggedC c a) => F.BindEnv -> c a -> S.HashSet F.KVar-nlKVarsC bs c = S.fromList [ k |  (k, n) <- V.envKVarsN bs c, n >= 2]------------------------------------------------------------------------------------- | Build and print the graph of post eliminate solution, which has an edge---   from k -> k' if k' appears directly inside the "solution" for k----------------------------------------------------------------------------------elimSolGraph :: Config -> F.Solution -> IO ()-elimSolGraph cfg s = writeGraph f (So.solutionGraph s)-  where-    f              = queryFile Dot cfg
src/Language/Fixpoint/Smt/Bitvector.hs view
@@ -29,7 +29,7 @@ import           Language.Fixpoint.Types.Names import           Language.Fixpoint.Types -data Bv     = Bv BvSize String+data Bv     = Bv !BvSize !String  data BvSize = S32   | S64               deriving (Eq, Ord, Show, Data, Typeable, Generic)
src/Language/Fixpoint/Smt/Interface.hs view
@@ -4,6 +4,7 @@ {-# LANGUAGE OverloadedStrings         #-} {-# LANGUAGE RecordWildCards           #-} {-# LANGUAGE UndecidableInstances      #-}+{-# LANGUAGE ScopedTypeVariables       #-}  -- | This module contains an SMTLIB2 interface for --   1. checking the validity, and,@@ -37,50 +38,61 @@      -- * Query API     , smtDecl+    , smtDecls     , smtAssert+    , smtAssertAxiom     , smtCheckUnsat     , smtCheckSat     , smtBracket     , smtDistinct--    -- * Theory Symbols-    -- , theorySymbols-      -- smt_set_funs+    , smtPush, smtPop      -- * Check Validity-    , checkValid, checkValidWithContext+    , checkValid+    , checkValid'+    , checkValidWithContext     , checkValids-    , makeZ3Context+    , makeSmtContext      ) where -import           Language.Fixpoint.Types.Config (SMTSolver (..))-import           Language.Fixpoint.Misc   (errorstar)+import           Language.Fixpoint.Types.Config ( SMTSolver (..)+                                                , Config+                                                , solver+                                                , extensionality+                                                , alphaEquivalence+                                                , betaEquivalence+                                                , normalForm+                                                , stringTheory)+import           Language.Fixpoint.Misc         (errorstar) import           Language.Fixpoint.Types.Errors+-- import           Language.Fixpoint.SortCheck    (elaborate) import           Language.Fixpoint.Utils.Files-import           Language.Fixpoint.Types+import           Language.Fixpoint.Types hiding (allowHO) import           Language.Fixpoint.Smt.Types-import           Language.Fixpoint.Smt.Theories  (preamble)-import           Language.Fixpoint.Smt.Serialize (initSMTEnv)--+import qualified Language.Fixpoint.Smt.Theories as Thy+import           Language.Fixpoint.Smt.Serialize ()  import           Control.Applicative      ((<|>)) import           Control.Monad+import           Control.Exception import           Data.Char import           Data.Monoid import qualified Data.Text                as T-import           Data.Text.Format         hiding (format)+import           Data.Text.Format import qualified Data.Text.IO             as TIO--- import qualified Data.Text.Lazy           as LT--- import qualified Data.Text.Lazy.IO        as LTIO+import qualified Data.Text.Lazy           as LT+import qualified Data.Text.Lazy.Builder   as Builder+import qualified Data.Text.Lazy.IO        as LTIO import           System.Directory import           System.Console.CmdArgs.Verbosity import           System.Exit              hiding (die) import           System.FilePath-import           System.IO                (IOMode (..), hClose, hFlush, openFile)+import           System.IO                (Handle, IOMode (..), hClose, hFlush, openFile) import           System.Process import qualified Data.Attoparsec.Text     as A+import qualified Data.HashMap.Strict      as M+import           Data.Attoparsec.Internal.Types (Parser) import           Text.PrettyPrint.HughesPJ (text) {- runFile f@@ -98,39 +110,44 @@   -- TODO take makeContext's Bool from caller instead of always using False?-makeZ3Context :: FilePath -> [(Symbol, Sort)] -> IO Context-makeZ3Context f xts-  = do me <- makeContextWithSEnv False Z3 f $ fromListSEnv xts-       smtDecls me (toListSEnv initSMTEnv)-       smtDecls me xts-       return me+makeSmtContext :: Config -> FilePath -> [(Symbol, Sort)] -> IO Context+makeSmtContext cfg f xts = do+  me <- makeContextWithSEnv cfg f $ fromListSEnv xts+  smtDecls me theoryDecls+  smtDecls me xts+  return me -checkValidWithContext :: Context -> [(Symbol, Sort)] -> Expr -> Expr -> IO Bool-checkValidWithContext me xts p q-  = smtBracket me $ do smtDecls me xts-                       smtAssert me $ pAnd [p, PNot q]-                       smtCheckUnsat me+theoryDecls :: [(Symbol, Sort)]+theoryDecls = [ (x, tsSort ty) | (x, ty) <- M.toList Thy.theorySymbols, not (tsInterp ty)] +checkValidWithContext :: Context -> [(Symbol, Sort)] -> Expr -> Expr -> IO Bool+checkValidWithContext me xts p q =+  smtBracket me "checkValidWithContext" $+    checkValid' me xts p q  -- | type ClosedPred E = {v:Pred | subset (vars v) (keys E) } -- checkValid :: e:Env -> ClosedPred e -> ClosedPred e -> IO Bool-checkValid :: Bool -> FilePath -> [(Symbol, Sort)] -> Expr -> Expr -> IO Bool-checkValid u f xts p q-  = do me <- makeContext u Z3 f-       smtDecls me xts-       smtAssert me $ pAnd [p, PNot q]-       smtCheckUnsat me+checkValid :: Config -> FilePath -> [(Symbol, Sort)] -> Expr -> Expr -> IO Bool+checkValid cfg f xts p q = do+  me <- makeContext cfg f+  checkValid' me xts p q +checkValid' :: Context -> [(Symbol, Sort)] -> Expr -> Expr -> IO Bool+checkValid' me xts p q = do+  smtDecls me xts+  smtAssert me $ pAnd [p, PNot q]+  smtCheckUnsat me+ -- | If you already HAVE a context, where all the variables have declared types --   (e.g. if you want to make MANY repeated Queries)  -- checkValid :: e:Env -> [ClosedPred e] -> IO [Bool]-checkValids :: Bool -> FilePath -> [(Symbol, Sort)] -> [Expr] -> IO [Bool]-checkValids u f xts ps-  = do me <- makeContext u Z3 f+checkValids :: Config -> FilePath -> [(Symbol, Sort)] -> [Expr] -> IO [Bool]+checkValids cfg f xts ps+  = do me <- makeContext cfg f        smtDecls me xts        forM ps $ \p ->-          smtBracket me $+          smtBracket me "checkValids" $             smtAssert me (PNot p) >> smtCheckUnsat me  -- debugFile :: FilePath@@ -144,15 +161,15 @@ -------------------------------------------------------------------------- command              :: Context -> Command -> IO Response ---------------------------------------------------------------------------command me !cmd      = {-# SCC "command" #-} say cmd >> hear cmd+command me !cmd       = say cmd >> hear cmd   where-    say               = smtWrite me . runSmt2 (smtenv me)+    say               = smtWrite me . Builder.toLazyText . runSmt2     hear CheckSat     = smtRead me     hear (GetValue _) = smtRead me     hear _            = return Ok  -smtWrite :: Context -> T.Text -> IO ()+smtWrite :: Context -> Raw -> IO () smtWrite me !s = smtWriteRaw me s  smtRead :: Context -> IO Response@@ -162,22 +179,29 @@        case A.eitherResult res of          Left e  -> errorstar $ "SMTREAD:" ++ e          Right r -> do-           maybe (return ()) (\h -> hPutStrLnNow h $ format "; SMT Says: {}" (Only $ show r)) (cLog me)+           maybe (return ()) (\h -> hPutStrLnNow h $ format "; SMT Says: {}" (Only $ show r)) (ctxLog me)            -- when (verbose me) $ TIO.putStrLn $ format "SMT Says: {}" (Only $ show r)            return r +type SmtParser a = Parser T.Text a++responseP :: SmtParser Response responseP = {-# SCC "responseP" #-} A.char '(' *> sexpP          <|> A.string "sat"     *> return Sat          <|> A.string "unsat"   *> return Unsat          <|> A.string "unknown" *> return Unknown +sexpP :: SmtParser Response sexpP = {-# SCC "sexpP" #-} A.string "error" *> (Error <$> errorP)      <|> Values <$> valuesP +errorP :: SmtParser T.Text errorP = A.skipSpace *> A.char '"' *> A.takeWhile1 (/='"') <* A.string "\")" +valuesP :: SmtParser [(Symbol, T.Text)] valuesP = A.many1' pairP <* A.char ')' +pairP :: SmtParser (Symbol, T.Text) pairP = {-# SCC "pairP" #-}   do A.skipSpace      A.char '('@@ -187,107 +211,129 @@      A.char ')'      return (x,v) +symbolP :: SmtParser Symbol symbolP = {-# SCC "symbolP" #-} symbol <$> A.takeWhile1 (not . isSpace) +valueP :: SmtParser T.Text valueP = {-# SCC "valueP" #-} negativeP       <|> A.takeWhile1 (\c -> not (c == ')' || isSpace c)) +negativeP :: SmtParser T.Text negativeP   = do v <- A.char '(' *> A.takeWhile1 (/=')') <* A.char ')'        return $ "(" <> v <> ")" --- {- pairs :: {v:[a] | (len v) mod 2 = 0} -> [(a,a)] -}--- pairs :: [a] -> [(a,a)]--- pairs !xs = case L.splitAt 2 xs of---              ([],_)      -> []---              ([x,y], zs) -> (x,y) : pairs zs--smtWriteRaw      :: Context -> T.Text -> IO ()+smtWriteRaw      :: Context -> Raw -> IO () smtWriteRaw me !s = {-# SCC "smtWriteRaw" #-} do-  hPutStrLnNow (cOut me) s-  -- whenLoud $ TIO.appendFile debugFile (s <> "\n")-  maybe (return ()) (`hPutStrLnNow` s) (cLog me)+  -- whenLoud $ do LTIO.appendFile debugFile (s <> "\n")+  --               LTIO.putStrLn ("CMD-RAW:" <> s <> ":CMD-RAW:DONE")+  hPutStrLnNow (ctxCout me) s+  maybe (return ()) (`hPutStrLnNow` s) (ctxLog me) -smtReadRaw       :: Context -> IO Raw-smtReadRaw me    = {-# SCC "smtReadRaw" #-} TIO.hGetLine (cIn me)+smtReadRaw       :: Context -> IO T.Text+smtReadRaw me    = {-# SCC "smtReadRaw" #-} TIO.hGetLine (ctxCin me) -hPutStrLnNow h !s   = TIO.hPutStrLn h s >> hFlush h+hPutStrLnNow     :: Handle -> LT.Text -> IO ()+hPutStrLnNow h !s = LTIO.hPutStrLn h s >> hFlush h  -------------------------------------------------------------------------- -- | SMT Context --------------------------------------------------------- --------------------------------------------------------------------------  ---------------------------------------------------------------------------makeContext   :: Bool -> SMTSolver -> FilePath -> IO Context+makeContext   :: Config -> FilePath -> IO Context ---------------------------------------------------------------------------makeContext u s f-  = do me   <- makeProcess s-       pre  <- smtPreamble u s me+makeContext cfg f+  = do me   <- makeProcess cfg+       pre  <- smtPreamble cfg (solver cfg) me        createDirectoryIfMissing True $ takeDirectory smtFile        hLog <- openFile smtFile WriteMode-       let me' = me { cLog = Just hLog }+       let me' = me { ctxLog = Just hLog }        mapM_ (smtWrite me') pre        return me'     where        smtFile = extFileName Smt2 f -makeContextWithSEnv :: Bool -> SMTSolver -> FilePath  -> SMTEnv -> IO Context-makeContextWithSEnv u s f env-  = (\cxt -> cxt {smtenv = env}) <$> makeContext u s f+makeContextWithSEnv :: Config -> FilePath -> SMTEnv -> IO Context+makeContextWithSEnv cfg f env+  = (\cxt -> cxt {ctxSmtEnv = env}) <$> makeContext cfg f+  -- where msg = "makeContextWithSEnv" ++ show env -makeContextNoLog :: Bool -> SMTSolver -> IO Context-makeContextNoLog u s-  = do me  <- makeProcess s-       pre <- smtPreamble u s me+makeContextNoLog :: Config -> IO Context+makeContextNoLog cfg+  = do me  <- makeProcess cfg+       pre <- smtPreamble cfg (solver cfg) me        mapM_ (smtWrite me) pre        return me -makeProcess :: SMTSolver -> IO Context-makeProcess s-  = do (hOut, hIn, _ ,pid) <- runInteractiveCommand $ smtCmd s+makeProcess :: Config -> IO Context+makeProcess cfg+  = do (hOut, hIn, _ ,pid) <- runInteractiveCommand $ smtCmd (solver cfg)        loud <- isLoud-       return Ctx { pId     = pid-                  , cIn     = hIn-                  , cOut    = hOut-                  , cLog    = Nothing-                  , verbose = loud-                  , smtenv  = initSMTEnv+       return Ctx { ctxPid     = pid+                  , ctxCin     = hIn+                  , ctxCout    = hOut+                  , ctxLog     = Nothing+                  , ctxVerbose = loud+                  , ctxExt     = extensionality cfg+                  , ctxAeq     = alphaEquivalence cfg+                  , ctxBeq     = betaEquivalence  cfg+                  , ctxNorm    = normalForm       cfg+                  , ctxSmtEnv  = Thy.theorySEnv                   }  -------------------------------------------------------------------------- cleanupContext :: Context -> IO ExitCode ---------------------------------------------------------------------------cleanupContext (Ctx {..})-  = do hClose cIn-       hClose cOut-       maybe (return ()) hClose cLog-       waitForProcess pId+cleanupContext (Ctx {..}) = do+  hCloseMe "ctxCin"  ctxCin+  hCloseMe "ctxCout" ctxCout+  maybe (return ()) (hCloseMe "ctxLog") ctxLog+  waitForProcess ctxPid +hCloseMe :: String -> Handle -> IO ()+hCloseMe msg h = hClose h `catch` (\(exn :: IOException) -> putStrLn $ "OOPS, hClose breaks: " ++ msg ++ show exn)+ {- "z3 -smt2 -in"                   -} {- "z3 -smtc SOFT_TIMEOUT=1000 -in" -} {- "z3 -smtc -in MBQI=false"        -} +smtCmd         :: SMTSolver -> String --  T.Text smtCmd Z3      = "z3 -smt2 -in" smtCmd Mathsat = "mathsat -input=smt2" smtCmd Cvc4    = "cvc4 --incremental -L smtlib2"  -- DON'T REMOVE THIS! z3 changed the names of options between 4.3.1 and 4.3.2...-smtPreamble u Z3 me+smtPreamble :: Config -> SMTSolver -> Context -> IO [LT.Text]+smtPreamble cfg Z3 me   = do smtWrite me "(get-info :version)"        v:_ <- T.words . (!!1) . T.splitOn "\"" <$> smtReadRaw me-       if T.splitOn "." v `versionGreater` ["4", "3", "2"]-         then return $ z3_432_options ++ preamble u Z3-         else return $ z3_options     ++ preamble u Z3-smtPreamble u s _-  = return $ preamble u s+       checkValidStringFlag Z3 v cfg+       if T.splitOn "." v `versionGreaterEq` ["4", "3", "2"]+         then return $ z3_432_options ++ makeMbqi cfg ++ Thy.preamble cfg Z3+         else return $ z3_options     ++ makeMbqi cfg ++ Thy.preamble cfg Z3+smtPreamble cfg s _+  = checkValidStringFlag s "" cfg >> return (Thy.preamble cfg s) -versionGreater (x:xs) (y:ys)+checkValidStringFlag :: SMTSolver -> T.Text -> Config -> IO ()+checkValidStringFlag smt v cfg+  = when (noString smt v cfg) $+      die $ err dummySpan (text "stringTheory is only supported by z3 version >=4.2.2")++noString :: SMTSolver -> T.Text -> Config -> Bool+noString smt v cfg+  =  stringTheory cfg+  && not (smt == Z3 && (T.splitOn "." v `versionGreaterEq` ["4", "4", "2"]))+++versionGreaterEq :: Ord a => [a] -> [a] -> Bool+versionGreaterEq (x:xs) (y:ys)   | x >  y = True-  | x == y = versionGreater xs ys+  | x == y = versionGreaterEq xs ys   | x <  y = False-versionGreater _  [] = True-versionGreater [] _  = False-versionGreater _ _ = errorstar "Interface.versionGreater called with bad arguments"+versionGreaterEq _  [] = True+versionGreaterEq [] _  = False+versionGreaterEq _ _ = errorstar "Interface.versionGreater called with bad arguments"  ----------------------------------------------------------------------------- -- | SMT Commands -----------------------------------------------------------@@ -297,9 +343,8 @@ smtPush me        = interact' me Push smtPop me         = interact' me Pop - smtDecls :: Context -> [(Symbol, Sort)] -> IO ()-smtDecls me xts = forM_ xts (\(x,t) -> smtDecl me x t)+smtDecls = mapM_ . uncurry . smtDecl  smtDecl :: Context -> Symbol -> Sort -> IO () smtDecl me x t = interact' me (Declare x ins out)@@ -311,45 +356,57 @@                 Just (_, ins, out) -> (ins, out)                 Nothing            -> ([] , t  ) +-- hack now this is used only for checking gradual condition. smtCheckSat :: Context -> Expr -> IO Bool smtCheckSat me p--- hack now this is used only for checking gradual condition.  = smtAssert me p >> (ans <$> command me CheckSat)  where    ans Sat = True    ans _   = False  smtAssert :: Context -> Expr -> IO ()-smtAssert me p    = interact' me (Assert Nothing p)+smtAssert me p  = interact' me (Assert Nothing p) ++smtAssertAxiom :: Context -> Triggered Expr -> IO ()+smtAssertAxiom me p  = interact' me (AssertAxiom p)+ smtDistinct :: Context -> [Expr] -> IO () smtDistinct me az = interact' me (Distinct az)  smtCheckUnsat :: Context -> IO Bool smtCheckUnsat me  = respSat <$> command me CheckSat -smtBracket :: Context -> IO a -> IO a-smtBracket me a   = do smtPush me-                       r <- a-                       smtPop me-                       return r+smtBracket :: Context -> String -> IO a -> IO a+smtBracket me _msg a   = do+  smtPush me+  r <- a+  smtPop me+  return r +respSat :: Response -> Bool respSat Unsat   = True respSat Sat     = False respSat Unknown = False respSat r       = die $ err dummySpan $ text ("crash: SMTLIB2 respSat = " ++ show r) +interact' :: Context -> Command -> IO () interact' me cmd  = void $ command me cmd +makeMbqi :: Config -> [LT.Text]+makeMbqi cfg+  | extensionality cfg = [""]+  | otherwise          = ["\n(set-option :smt.mbqi false)"]+ -- DON'T REMOVE THIS! z3 changed the names of options between 4.3.1 and 4.3.2...+z3_432_options :: [LT.Text] z3_432_options   = [ "(set-option :auto-config false)"     , "(set-option :model true)"-    , "(set-option :model.partial false)"-    , "(set-option :smt.mbqi false)" ]+    , "(set-option :model.partial false)"] +z3_options :: [LT.Text] z3_options   = [ "(set-option :auto-config false)"     , "(set-option :model true)"-    , "(set-option :model-partial false)"-    , "(set-option :mbqi false)" ]+    , "(set-option :model-partial false)"]
src/Language/Fixpoint/Smt/Serialize.hs view
@@ -3,88 +3,61 @@ {-# LANGUAGE OverloadedStrings    #-} {-# LANGUAGE PatternGuards        #-} {-# LANGUAGE FlexibleContexts     #-}+{-# LANGUAGE DoAndIfThenElse      #-}  -- | This module contains the code for serializing Haskell values --   into SMTLIB2 format, that is, the instances for the @SMTLIB2@ --   typeclass. We split it into a separate module as it depends on --   Theories (see @smt2App@). -module Language.Fixpoint.Smt.Serialize where+module Language.Fixpoint.Smt.Serialize () where  import           Language.Fixpoint.Types---import           Language.Fixpoint.Types.Names (mulFuncName, divFuncName) import           Language.Fixpoint.Smt.Types import qualified Language.Fixpoint.Smt.Theories as Thy-import qualified Data.Text                      as T-import           Data.Text.Format               hiding (format)-import           Language.Fixpoint.Misc (errorstar) -- , traceShow)--import           Language.Fixpoint.SortCheck (elaborate)--import           Control.Monad.State- +import           Data.Monoid+import qualified Data.Text.Lazy.Builder         as Builder+import           Data.Text.Format+import           Language.Fixpoint.Misc (errorstar) import           Data.Maybe (fromMaybe) --{--    (* (L t1 t2 t3) is now encoded as-        ---> (((L @ t1) @ t2) @ t3)-        ---> App(@, [App(@, [App(@, [L[]; t1]); t2]); t3])-        The following decodes the above as-     *)-    let rec app_args_of_t acc = function-      | App (c, [t1; t2]) when c = tc_app -> app_args_of_t (t2 :: acc) t1-      | App (c, [])                       -> (c, acc)-      | t                                 -> (tc_app, t :: acc)--      (*-      | Ptr (Loc s)                       -> (tycon s, acc)-      | t                                 -> assertf "app_args_of_t: unexpected t1 = %s" (to_string t)-      *)--    let app_of_t = function-      | App (c, _) as t when c = tc_app   -> Some (app_args_of_t [] t)-      | App (c, ts)                       -> Some (c, ts)-      | _                                 -> None---}+-- instance SMTLIB2 Sort where+--   smt2 s@(FFunc _ _)           = errorstar $ "smt2 FFunc: " ++ showpp s+--   smt2 FInt                    = "Int"+--   smt2 FReal                   = "Real"+--   smt2 t+--     | t == boolSort            = "Bool"+--   smt2 t+--     | Just d <- Thy.smt2Sort t = d+--   smt2 _                       = "Int" -instance SMTLIB2 Sort where-  smt2 s@(FFunc _ _)           = errorstar $ "smt2 FFunc: " ++ show s-  smt2 FInt                    = "Int"-  smt2 FReal                   = "Real"-  smt2 t-    | t == boolSort            = "Bool"-  smt2 t-    | Just d <- Thy.smt2Sort t = d-  smt2 _                       = "Int"+instance SMTLIB2 (Symbol, Sort) where+  smt2 c@(sym, t) = build "({} {})" (smt2 sym, smt2Sort c t) -  defunc (FAbs _ t)      = defunc t-  defunc (FFunc _ _)     = return $ intSort-  defunc t | isSMTSort t = return t-  defunc _               = return intSort+smt2Sort :: (PPrint a) => a -> Sort -> Builder.Builder+smt2Sort msg = go+  where+    go s@(FFunc _ _)             = errorstar $ unwords ["smt2 FFunc:", showpp msg, showpp s]+    go FInt                      = "Int"+    go FReal                     = "Real"+    go t+      | t == boolSort            = "Bool"+    go t+      | Just d <- Thy.smt2Sort t = d+    go _                         = "Int"  instance SMTLIB2 Symbol where   smt2 s     | Just t <- Thy.smt2Symbol s = t-  smt2 s                         = symbolSafeText  s--instance SMTLIB2 (Symbol, Sort) where-  smt2 (sym, t) = format "({} {})" (smt2 sym, smt2 t)--  defunc (sym, t) = do bx <- defunc sym -                       bt <- defunc t -                       return $ (bx, bt)-+  smt2 s                         = Builder.fromText $ symbolSafeText  s  instance SMTLIB2 SymConst where-  smt2   = smt2   . symbol-+  smt2 = smt2 . symbol  instance SMTLIB2 Constant where-  smt2 (I n)   = format "{}" (Only n)-  smt2 (R d)   = format "{}" (Only d)-  smt2 (L t _) = format "{}" (Only t) -- errorstar $ "Horrors, how to translate: " ++ show c+  smt2 (I n)   = build "{}" (Only n)+  smt2 (R d)   = build "{}" (Only d)+  smt2 (L t _) = build "{}" (Only t)  instance SMTLIB2 LocSymbol where   smt2 = smt2 . val@@ -92,8 +65,8 @@ instance SMTLIB2 Bop where   smt2 Plus   = "+"   smt2 Minus  = "-"-  smt2 Times  = symbolSafeText mulFuncName-  smt2 Div    = symbolSafeText divFuncName+  smt2 Times  = Builder.fromText $ symbolSafeText mulFuncName+  smt2 Div    = Builder.fromText $ symbolSafeText divFuncName   smt2 RTimes = "*"   smt2 RDiv   = "/"   smt2 Mod    = "mod"@@ -109,366 +82,94 @@  -- NV TODO: change the way EApp is printed instance SMTLIB2 Expr where-  smt2 (ESym z)         = smt2 (symbol z)+  smt2 (ESym z)         = smt2 z   smt2 (ECon c)         = smt2 c   smt2 (EVar x)         = smt2 x   smt2 e@(EApp _ _)     = smt2App e-  smt2 (ENeg e)         = format "(- {})" (Only $ smt2 e)-  smt2 (EBin o e1 e2)   = format "({} {} {})" (smt2 o, smt2 e1, smt2 e2)-  smt2 (EIte e1 e2 e3)  = format "(ite {} {} {})" (smt2 e1, smt2 e2, smt2 e3)+  smt2 (ENeg e)         = build "(- {})" (Only $ smt2 e)+  smt2 (EBin o e1 e2)   = build "({} {} {})" (smt2 o, smt2 e1, smt2 e2)+  smt2 (EIte e1 e2 e3)  = build "(ite {} {} {})" (smt2 e1, smt2 e2, smt2 e3)   smt2 (ECst e _)       = smt2 e   smt2 (PTrue)          = "true"   smt2 (PFalse)         = "false"   smt2 (PAnd [])        = "true"-  smt2 (PAnd ps)        = format "(and {})"   (Only $ smt2s ps)+  smt2 (PAnd ps)        = build "(and {})"   (Only $ smt2s ps)   smt2 (POr [])         = "false"-  smt2 (POr ps)         = format "(or  {})"   (Only $ smt2s ps)-  smt2 (PNot p)         = format "(not {})"   (Only $ smt2  p)-  smt2 (PImp p q)       = format "(=> {} {})" (smt2 p, smt2 q)-  smt2 (PIff p q)       = format "(= {} {})"  (smt2 p, smt2 q)-  smt2 (PExist bs p)    = format "(exists ({}) {})"  (smt2s bs, smt2 p)-  smt2 (PAll   bs p)    = format "(forall ({}) {})"  (smt2s bs, smt2 p)+  smt2 (POr ps)         = build "(or  {})"   (Only $ smt2s ps)+  smt2 (PNot p)         = build "(not {})"   (Only $ smt2  p)+  smt2 (PImp p q)       = build "(=> {} {})" (smt2 p, smt2 q)+  smt2 (PIff p q)       = build "(= {} {})"  (smt2 p, smt2 q)+  smt2 (PExist [] p)    = smt2 p+  smt2 (PExist bs p)    = build "(exists ({}) {})"  (smt2s bs, smt2 p)+  smt2 (PAll   [] p)    = smt2 p+  smt2 (PAll   bs p)    = build "(forall ({}) {})"  (smt2s bs, smt2 p)    smt2 (PAtom r e1 e2)  = mkRel r e1 e2-  smt2 PGrad            = "true"+  smt2 (ELam (x, _) e)  = smt2Lam x e   smt2  e               = errorstar ("smtlib2 Pred  " ++ show e)  --- new version -  defunc e@(ESym _)       = return e -  defunc e@(ECon _)       = return e -  defunc e@(EVar _)       = return e -  defunc e@(EApp _ _)     = defuncApp e-  defunc (ENeg e)         = ENeg <$> defunc e -  defunc (EBin o e1 e2)   = defuncBop o e1 e2-  defunc (EIte e1 e2 e3)  = do e1'   <- defunc e1 -                               e2'   <- defunc e2 -                               e3'   <- defunc e3 -                               return $ EIte e1' e2' e3'-  defunc (ECst e t)       = (`ECst` t) <$> defunc e-  defunc (PTrue)          = return PTrue-  defunc (PFalse)         = return PFalse-  defunc (PAnd [])        = return PTrue-  defunc (PAnd ps)        = PAnd <$> mapM defunc ps-  defunc (POr [])         = return PFalse-  defunc (POr ps)         = POr <$> mapM defunc ps-  defunc (PNot p)         = PNot <$> defunc  p-  defunc (PImp p q)       = PImp <$> defunc p <*> defunc q -  defunc (PIff p q)       = PIff <$> defunc p <*> defunc q -  defunc (PExist bs p)    = do bs' <- mapM defunc bs -                               p'  <- withExtendedEnv bs $ defunc p -                               return $ PExist bs' p'-  defunc (PAll   bs p)    = do bs' <- mapM defunc bs -                               p'  <- withExtendedEnv bs $ defunc p -                               return $ PAll bs' p' -  defunc (PAtom r e1 e2)  = PAtom r <$> defunc e1 <*> defunc e2 -  defunc PGrad            = return PGrad-  defunc  e               = errorstar ("smtlib2 Pred  " ++ show e)--defuncBop o e1 e2-  | o == Times, s1 == FReal, s2 == FReal-  = do e1' <- defunc e1 -       e2' <- defunc e2-       return $ EBin RTimes e1' e2'-  | o == Div, s1 == FReal, s2 == FReal-  = do e1' <- defunc e1-       e2' <- defunc e2-       return $ EBin RDiv e1' e2' -  | otherwise-  = do e1' <- defunc e1 -       e2' <- defunc e2 -       return $ EBin o e1' e2' -  where-    s1 = exprSort e1-    s2 = exprSort e2-+smt2Lam :: Symbol -> Expr -> Builder.Builder+smt2Lam x e = build "({} {} {})" (smt2 lambdaName, smt2 x, smt2 e) -smt2App :: Expr -> T.Text-smt2App e = fromMaybe (format "({} {})" (smt2 f, smt2many (smt2 <$> es))) (Thy.smt2App (eliminate f) $ (smt2 <$> es))+smt2App :: Expr -> Builder.Builder+smt2App e = fromMaybe (build "({} {})" (smt2 f, smt2s es)) $ Thy.smt2App (eliminate f) $ map smt2 es   where-    (f, es) = splitEApp e+    (f, es) = splitEApp' e  -defuncApp :: Expr -> SMT2 Expr -defuncApp e = case Thy.smt2App (eliminate f) $ (smt2 <$> es) of -                Just _ -> eApps f <$> mapM defunc es  -                _      -> defuncApp' f es+splitEApp' :: Expr -> (Expr, [Expr])+splitEApp'            = go []   where-    (f, es) = splitEApp e+    go acc (EApp f e) = go (e:acc) f+    go acc (ECst e _) = go acc e+    go acc e          = (e, acc) -eliminate (ECst e _) = e+eliminate :: Expr -> Expr+eliminate (ECst e _) = eliminate e eliminate e          = e -defuncApp' :: Expr -> [Expr] -> SMT2 Expr -defuncApp' f [] = defunc f-defuncApp' f es = makeApplication f es--- smt2App' env f es = format "({} {})" (smt2 env f, smt2many (smt2 env <$> es)) -- makeApplication env f es--+mkRel :: Brel -> Expr -> Expr -> Builder.Builder+mkRel Ne  e1 e2 = mkNe e1 e2+mkRel Une e1 e2 = mkNe e1 e2+mkRel r   e1 e2 = build "({} {} {})" (smt2 r, smt2 e1, smt2 e2) -mkRel Ne  e1 e2         = mkNe e1 e2-mkRel Une e1 e2         = mkNe e1 e2-mkRel r   e1 e2         = format "({} {} {})" (smt2 r, smt2 e1, smt2 e2)-mkNe  e1 e2             = format "(not (= {} {}))" (smt2 e1, smt2 e2)+mkNe :: Expr -> Expr -> Builder.Builder+mkNe  e1 e2              = build "(not (= {} {}))" (smt2 e1, smt2 e2)  instance SMTLIB2 Command where   -- NIKI TODO: formalize this transformation-  smt2 (Declare x ts t)    = format "(declare-fun {} ({}) {})"     (smt2 x, smt2s ts, smt2 t)-  smt2 (Define t)          = format "(declare-sort {})"            (Only $ smt2 t)-  smt2 (Assert Nothing p)  = format "(assert {})"                  (Only $ smt2 p)-  smt2 (Assert (Just i) p) = format "(assert (! {} :named p-{}))"  (smt2 p, i)+  smt2 c@(Declare x ts t)  = build "(declare-fun {} ({}) {})"     (smt2 x, smt2many (smt2Sort c <$> ts), smt2Sort c t) -- HEREHEREHERE (smt2 x, smt2s ts, smt2 t)+  smt2 c@(Define t)        = build "(declare-sort {})"            (Only $ smt2Sort c t)+  smt2 (Assert Nothing p)  = build "(assert {})"                  (Only $ smt2 p)+  smt2 (Assert (Just i) p) = build "(assert (! {} :named p-{}))"  (smt2 p, i)   smt2 (Distinct az)     -- Distinct must have at least 2 arguments     | length az < 2        = ""-    | otherwise            = format "(assert (distinct {}))"       (Only $ smt2s az)+    | otherwise            = build "(assert (distinct {}))"       (Only $ smt2s az)+  smt2 (AssertAxiom t)     = build "(assert {})"                  (Only $ smt2 t)   smt2 (Push)              = "(push 1)"   smt2 (Pop)               = "(pop 1)"   smt2 (CheckSat)          = "(check-sat)"-  smt2 (GetValue xs)       = T.unwords $ ["(get-value ("] ++ fmap smt2 xs ++ ["))"]+  smt2 (GetValue xs)       = "(get-value (" <> smt2s xs <> "))"   smt2 (CMany cmds)        = smt2many (smt2 <$> cmds) --  defunc (Declare x ts t)-     | isSMTSymbol x-     = do dx  <- defunc x -          dts <- mapM defunc ts-          dt  <- defunc t   -          return $ Declare dx dts dt -     | null ts && isSMTSort t-     = do dx <- defunc x -          dt <- defunc t-          return $ Declare dx [] dt -     | otherwise-     = do dx <- defunc x -          return $ Declare dx [] intSort--  defunc (Define t)  = return $ Define t -  defunc (Assert Nothing p)  -    = do env <- smt2env <$> get -         (p', fs) <- grapLambdas $ elaborate env p-         dfs <- mapM defineFun fs -         p'' <- defunc p'-         return $ CMany (concat dfs ++ [Assert Nothing p''])--  defunc (Assert (Just i) p) -    = do env <- smt2env <$> get -         (p', fs) <- grapLambdas $ elaborate env p-         dfs <- mapM defineFun fs -         p'' <- defunc p' -         return $ CMany (concat dfs ++ [Assert (Just i) p''])---   smt2 env (Assert (Just i) p) = format "(assert (! {} :named p-{}))"  (smt2 env $ elaborate env p, i)-  defunc (Distinct az)       = Distinct <$> mapM defunc az -  defunc (Push)              = return Push -  defunc (Pop)               = return Pop -  defunc (CheckSat)          = return CheckSat-  defunc (GetValue xs)       = return $ GetValue xs -  defunc (CMany cmds)        = CMany <$> mapM defunc cmds --smt2s    :: SMTLIB2 a => [a] -> T.Text-smt2s as = smt2many (smt2 <$> as)--smt2many :: [T.Text] -> T.Text-smt2many = T.intercalate " "---defineFun :: (Symbol, Expr) -> SMT2 [Command]-defineFun (f, ELam (x, t) (ECst e tr))-  = do decl   <- defunc $ Declare f (t:(snd <$> xts)) tr -       assert <- withExtendedEnv [(f, FFunc t tr)] $ -                   defunc $ Assert Nothing (PAll ((x,t):xts) -                                  (PAtom Eq (mkApp (EApp (EVar f) (EVar x)) (fst <$> xts)) bd))-       return $ [decl, assert]-  where-    go acc (ELam (x, t) e) = go ((x,t):acc) e -    go acc (ECst e _)      = go acc e -    go acc e               = (acc, e)-    -    (xts, bd) = go [] e --    mkApp e' []     = e' -    mkApp e' (x:xs) = mkApp (EApp e' (EVar x)) xs--defineFun  _ -  = errorstar "die"---isSMTSymbol x = Thy.isTheorySymbol x || memberSEnv x initSMTEnv --{--(declare-fun x () Int)-(declare-fun y () Int)-(assert (<= 0 x))-(assert (< x y))-(push 1)-(assert (not (<= 0 y)))-(check-sat)-(pop 1)-(push 1)-(assert (<= 0 y))-(check-sat)-(pop 1)--}+instance SMTLIB2 (Triggered Expr) where+  smt2 (TR NoTrigger e)       = smt2 e  +  smt2 (TR _ (PExist [] p))   = smt2 p+  smt2 t@(TR _ (PExist bs p)) = build "(exists ({}) (! {} :pattern({})))"  (smt2s bs, smt2 p, smt2s $ makeTriggers t)+  smt2 (TR _ (PAll   [] p))   = smt2 p+  smt2 t@(TR _ (PAll   bs p)) = build "(forall ({}) (! {} :pattern({})))"  (smt2s bs, smt2 p, smt2s $ makeTriggers t)+  smt2 (TR _ e)               = smt2 e   -------------------------------------------------------------------------------------------------------  Defunctionalizaion ----------------------------------------------------------------------------------------------------------------------------------------grapLambdas e = go [] e -  where-    go acc e@(ELam _ _) = do f <- freshSym -                             return (EVar f, (f, e):acc)-    go acc e@(ESym _)   = return (e, acc)-    go acc e@(ECon _)   = return (e, acc)-    go acc e@(EVar _)   = return (e, acc)-    go acc (EApp e1 e2) = do (e1', fs1) <- go [] e1 -                             (e2', fs2) <- go [] e2-                             return (EApp e1' e2', fs1 ++ fs2 ++ acc) -    go acc (ENeg e)     = do (e', fs) <- go acc e -                             return (ENeg e', fs)-    go acc (PNot e)     = do (e', fs) <- go acc e -                             return (PNot e', fs)-    go acc (EBin b e1 e2) = do (e1', fs1) <- go [] e1 -                               (e2', fs2) <- go [] e2-                               return (EBin b e1' e2', fs1 ++ fs2 ++ acc) -    go acc (PAtom b e1 e2) = do (e1', fs1) <- go [] e1 -                                (e2', fs2) <- go [] e2-                                return (PAtom b e1' e2', fs1 ++ fs2 ++ acc) -    go acc (EIte e e1 e2) = do (e' , fs)  <- go [] e-                               (e1', fs1) <- go [] e1 -                               (e2', fs2) <- go [] e2-                               return (EIte e' e1' e2', fs ++ fs1 ++ fs2 ++ acc) -    go acc (ECst e s)     = do (e', fs) <- go acc e-                               return (ECst e' s, fs)-    go acc (ETAbs e s)    = do (e', fs) <- go acc e -                               return (ETAbs e' s, fs)-    go acc (ETApp e s)    = do (e', fs) <- go acc e -                               return (ETApp e' s, fs)-    go acc (PAnd es)      = do es' <- mapM (go []) es-                               return (PAnd (fst <$> es'), concat (acc:(snd <$> es')))-    go acc (POr es)       = do es' <- mapM (go []) es-                               return (POr (fst <$> es'),  concat (acc:(snd <$> es')))-    go acc (PImp e1 e2)   = do (e1', fs1) <- go [] e1 -                               (e2', fs2) <- go [] e2-                               return (PImp e1' e2', fs1 ++ fs2 ++ acc) -    go acc (PIff e1 e2)   = do (e1', fs1) <- go [] e1 -                               (e2', fs2) <- go [] e2-                               return (PIff e1' e2', fs1 ++ fs2 ++ acc) -    go acc (PAll bs e)    = do (e', fs) <- go acc e -                               return (PAll bs e', fs) -    go acc (PExist bs e)  = do (e', fs) <- go acc e -                               return (PExist bs e', fs) -    go acc e@PGrad        = return (e, acc)-    go acc e@(PKVar _ _)  = return (e, acc)---- NIKI: This is new code, check and formalize!----- make Application is called on uninterpreted functions------ makeApplication e [e1, ..., en] =  apply^n_s (e, toInt e1, ..., toInt en)--- where--- applyn :: (Int, Int, ..., Int) -> s--- e      :: (Int, ..., Int) -> s--- toInt e = e, if e :: s, s is smt uninterpeted--- toInt e = s_to_Int (e), otherwise---- s_to_Int :: s -> Int--makeApplication :: Expr -> [Expr] -> SMT2 Expr -makeApplication e es-  = do df  <- defunc f -       de  <- defunc e -       des <- mapM toInt es -       return $ eApps (EVar df) (de:des)-  where-    f  = makeFunSymbol e $ length es---makeFunSymbol :: Expr -> Int -> Symbol-makeFunSymbol e i-  | (FApp (FTC c) _)          <- s, fTyconSymbol c == "Set_Set"-  = setApplyName i-  | (FApp (FApp (FTC c) _) _) <- s, fTyconSymbol c == "Map_t"-  = mapApplyName i-  | (FApp (FTC bv) (FTC s))   <- s, Thy.isBv bv, Just _ <- Thy.sizeBv s-  = bitVecApplyName i-  | FTC c                     <- s, c == boolFTyCon-  = boolApplyName i-  | s == FReal-  = realApplyName i-  | otherwise-  = intApplyName i-  where-    s = dropArgs i $ exprSort e--    dropArgs 0 t           = t-    dropArgs i (FAbs _ t)  = dropArgs i t-    dropArgs i (FFunc _ t) = dropArgs (i-1) t-    dropArgs _ _           = die $ err dummySpan "dropArgs: the impossible happened"--toInt :: Expr -> SMT2 Expr -toInt e-  |  (FApp (FTC c) _)         <- s, fTyconSymbol c == "Set_Set"-  = castWith setToIntName e-  | (FApp (FApp (FTC c) _) _) <- s, fTyconSymbol c == "Map_t"-  = castWith mapToIntName e-  | (FApp (FTC bv) (FTC s))   <- s, Thy.isBv bv, Just _ <- Thy.sizeBv s-  = castWith bitVecToIntName e-  | FTC c                     <- s, c == boolFTyCon-  = castWith boolToIntName e-  | FTC c                     <- s, c == realFTyCon-  = castWith realToIntName e-  | otherwise-  = defunc e-  where-    s = exprSort e--isSMTSort :: Sort -> Bool-isSMTSort s-  | (FApp (FTC c) _)         <- s, fTyconSymbol c == "Set_Set"-  = True-  | (FApp (FApp (FTC c) _) _) <- s, fTyconSymbol c == "Map_t"-  = True-  | (FApp (FTC bv) (FTC s))   <- s, Thy.isBv bv, Just _ <- Thy.sizeBv s-  = True-  | FTC c                     <- s, c == boolFTyCon-  = True-  | s == FReal-  = True-  | otherwise-  = False---castWith :: Symbol -> Expr -> SMT2 Expr -castWith s e = -  do bs <- defunc s -     be <- defunc e-     return $ EApp (EVar bs) be--initSMTEnv = fromListSEnv $-  [ (setToIntName,    FFunc (setSort intSort)   intSort)-  , (bitVecToIntName, FFunc bitVecSort intSort)-  , (mapToIntName,    FFunc (mapSort intSort intSort) intSort)-  , (boolToIntName,   FFunc boolSort   intSort)-  , (realToIntName,   FFunc realSort   intSort)-  ]-  ++ concatMap makeApplies [1..7]--makeApplies i =-  [ (intApplyName i,    go i intSort)-  , (setApplyName i,    go i (setSort intSort))-  , (bitVecApplyName i, go i bitVecSort)-  , (mapApplyName i,    go i $ mapSort intSort intSort)-  , (realApplyName i,   go i realSort)-  , (boolApplyName i,   go i boolSort)-  ]-  where-    go 0 s = FFunc intSort s-    go i s = FFunc intSort $ go (i-1) s-+{-# INLINE smt2s #-}+smt2s    :: SMTLIB2 a => [a] -> Builder.Builder+smt2s as = smt2many (map smt2 as) -exprSort :: Expr -> Sort-exprSort (ECst _ s) = s-exprSort e          = errorstar ("\nexprSort on unexpected expressions" ++ show e)+smt2many :: [Builder.Builder] -> Builder.Builder+smt2many []     = mempty+smt2many [b]    = b+smt2many (b:bs) = b <> mconcat [ " " <> b | b <- bs ]+{-# INLINE smt2many #-}
src/Language/Fixpoint/Smt/Theories.hs view
@@ -16,42 +16,50 @@      , preamble         -- * Bit Vector Operations-     , isBv, sizeBv+     , sizeBv+     , toInt -     , isTheorySymbol-     , theoryEnv+       -- * Theory Symbols+     , theorySymbols+     , theorySEnv +     -- * String+     -- , string+     -- , genLen+        -- * Theories-     , theorySymbols      , setEmpty, setEmp, setCap, setSub, setAdd, setMem      , setCom, setCup, setDif, setSng, mapSel, mapSto++      -- * Query Theories+     , isSmt2App+     , isConName+     , axiomLiterals      ) where  import           Prelude hiding (map)+import           Language.Fixpoint.Types.Sorts import           Language.Fixpoint.Types.Config import           Language.Fixpoint.Types import           Language.Fixpoint.Smt.Types import qualified Data.HashMap.Strict      as M-import qualified Data.Text                as T-import           Data.Text.Format         hiding (format)-+import           Data.Maybe (catMaybes, isJust)+import           Data.Monoid+import qualified Data.Text.Lazy           as T+import qualified Data.Text.Lazy.Builder   as Builder+import           Data.Text.Format+import qualified Data.Text+import           Data.String                 (IsString(..))  -------------------------------------------------------------------------- -- | Set Theory ---------------------------------------------------------- -------------------------------------------------------------------------- -elt, set, map :: Raw +elt, set, map :: Raw elt  = "Elt" set  = "Set" map  = "Map" ---- bit, sz32, sz64 :: Raw--- bit  = symbolText bitVecName -- "BitVec"--- sz32 = symbolText size32Name -- "Size32"--- sz64 = symbolText size64Name -- "Size64"-- emp, add, cup, cap, mem, dif, sub, com, sel, sto :: Raw emp   = "smt_set_emp" add   = "smt_set_add"@@ -64,7 +72,6 @@ sel   = "smt_map_sel" sto   = "smt_map_sto" - setEmpty, setEmp, setCap, setSub, setAdd, setMem, setCom, setCup, setDif, setSng, mapSel, mapSto :: Symbol setEmpty = "Set_empty" setEmp   = "Set_emp"@@ -79,9 +86,36 @@ mapSel   = "Map_select" mapSto   = "Map_store" -z3Preamble :: Bool -> [T.Text]++strLen, strSubstr, strConcat :: (IsString a) => a -- Symbol+strLen    = "strLen"+strSubstr = "subString"+strConcat = "concatString"+-- NOPROP genLen :: Symbol+-- NOPROP genLen = "len"++-- NOPROP strlen, strsubstr, strconcat :: Raw+-- NOPROP strlen    = "strLen"+-- NOPROP strsubstr = "subString"+-- NOPROP strconcat = "concatString"++z3strlen, z3strsubstr, z3strconcat :: Raw+z3strlen    = "str.len"+z3strsubstr = "str.substr"+z3strconcat = "str.++"++strLenSort, substrSort, concatstrSort :: Sort+strLenSort    = FFunc strSort intSort+substrSort    = mkFFunc 0 [strSort, intSort, intSort, strSort]+concatstrSort = mkFFunc 0 [strSort, strSort, strSort]++string :: Raw+string = strConName++z3Preamble :: Config -> [T.Text] z3Preamble u-  = [ format "(define-sort {} () Int)"+  = stringPreamble u +++    [ format "(define-sort {} () Int)"         (Only elt)     , format "(define-sort {} () (Array {} Bool))"         (set, elt)@@ -107,20 +141,27 @@         (sel, map, elt, elt)     , format "(define-fun {} ((m {}) (k {}) (v {})) {} (store m k v))"         (sto, map, elt, elt, map)-    , uifDef u (symbolText mulFuncName) ("*"::T.Text)-    , uifDef u (symbolText divFuncName) ("div"::T.Text)+    , format "(define-fun {} ((b Bool)) Int (ite b 1 0))"+        (Only (boolToIntName :: T.Text))+    , uifDef u (symbolText mulFuncName) ("*"   :: T.Text)+    , uifDef u (symbolText divFuncName) "div"     ]  -- RJ: Am changing this to `Int` not `Real` as (1) we usually want `Int` and -- (2) have very different semantics. TODO: proper overloading, post genEApp-uifDef u f op | u         = format "(declare-fun {} (Int Int) Int)" (Only f)-              | otherwise = format "(define-fun {} ((x Int) (y Int)) Int ({} x y))" (f, op)+uifDef :: Config -> Data.Text.Text -> T.Text -> T.Text+uifDef cfg f op+  | linear cfg || Z3 /= solver cfg+  = format "(declare-fun {} (Int Int) Int)" (Only f)+  | otherwise+  = format "(define-fun {} ((x Int) (y Int)) Int ({} x y))" (f, op) -cvc4Preamble :: Bool -> [T.Text]+cvc4Preamble :: Config -> [T.Text] cvc4Preamble _ --TODO use uif flag u (see z3Preamble)   = [        "(set-logic ALL_SUPPORTED)"     , format "(define-sort {} () Int)"       (Only elt)     , format "(define-sort {} () Int)"       (Only set)+    , format "(define-sort {} () Int)"       (Only string)     , format "(declare-fun {} () {})"        (emp, set)     , format "(declare-fun {} ({} {}) {})"   (add, set, elt, set)     , format "(declare-fun {} ({} {}) {})"   (cup, set, set, set)@@ -134,9 +175,11 @@         (sel, map, elt, elt)     , format "(define-fun {} ((m {}) (k {}) (v {})) {} (store m k v))"         (sto, map, elt, elt, map)+    , format "(define-fun {} ((b Bool)) Int (ite b 1 0))"+        (Only (boolToIntName :: Raw))     ] -smtlibPreamble :: Bool -> [T.Text]+smtlibPreamble :: Config -> [T.Text] smtlibPreamble _ --TODO use uif flag u (see z3Preamble)   = [       --  "(set-logic QF_AUFRIA)",       format "(define-sort {} () Int)"       (Only elt)@@ -151,64 +194,168 @@     , format "(define-sort {} () Int)"       (Only map)     , format "(declare-fun {} ({} {}) {})"    (sel, map, elt, elt)     , format "(declare-fun {} ({} {} {}) {})" (sto, map, elt, elt, map)+    , format "(declare-fun {} ({} {} {}) {})" (sto, map, elt, elt, map)+    , format "(define-fun {} ((b Bool)) Int (ite b 1 0))" (Only (boolToIntName :: Raw))     ] -{--mkSetSort _ _  = set-mkEmptySet _ _ = emp-mkSetAdd _ s x = format "({} {} {})" (add, s, x)-mkSetMem _ x s = format "({} {} {})" (mem, x, s)-mkSetCup _ s t = format "({} {} {})" (cup, s, t)-mkSetCap _ s t = format "({} {} {})" (cap, s, t)-mkSetDif _ s t = format "({} {} {})" (dif, s, t)-mkSetSub _ s t = format "({} {} {})" (sub, s, t)--} --- smt_set_funs :: M.HashMap Symbol Raw--- smt_set_funs = M.fromList [ (setEmp, emp), (setAdd, add), (setCup, cup)---                           , (setCap, cap), (setMem, mem), (setDif, dif)---                           , (setSub, sub), (setCom, com)]+stringPreamble :: Config -> [T.Text]+stringPreamble cfg | stringTheory cfg+  = [+      format "(define-sort {} () String)" (Only string)+    , format "(define-fun {} ((s {})) Int ({} s))"+        (strLen :: Raw, string, z3strlen)+    , format "(define-fun {} ((s {}) (i Int) (j Int)) {} ({} s i j))"+        (strSubstr :: Raw, string, string, z3strsubstr)+    , format "(define-fun {} ((x {}) (y {})) {} ({} x y))"+        (strConcat :: Raw, string, string, string, z3strconcat)+    ]+stringPreamble _+  = [+      format "(define-sort {} () Int)" (Only string)+    , format "(declare-fun {} ({}) Int)"+        (strLen :: Raw, string)+    , format "(declare-fun {} ({} Int Int) {})"+        (strSubstr :: Raw, string, string)+    , format "(declare-fun {} ({} {}) {})"+        (strConcat :: Raw, string, string, string)+    ]  -isTheorySymbol :: Symbol -> Bool-isTheorySymbol x = M.member x theorySymbols -theoryEnv = M.map tsSort theorySymbols +-------------------------------------------------------------------------------+-- | Exported API -------------------------------------------------------------+-------------------------------------------------------------------------------+smt2Symbol :: Symbol -> Maybe Builder.Builder+smt2Symbol x = Builder.fromLazyText . tsRaw <$> M.lookup x theorySymbols +smt2Sort :: Sort -> Maybe Builder.Builder+smt2Sort (FApp (FTC c) _)+  | isConName setConName c      = Just $ build "{}" (Only set)+smt2Sort (FApp (FApp (FTC c) _) _)+  | isConName mapConName c      = Just $ build "{}" (Only map)+smt2Sort (FApp (FTC bv) (FTC s))+  | isConName bitVecName bv+  , Just n <- sizeBv s          = Just $ build "(_ BitVec {})" (Only n)+smt2Sort s+  | isString s                  = Just $ build "{}" (Only string)+smt2Sort _                      = Nothing++smt2App :: Expr -> [Builder.Builder] -> Maybe Builder.Builder+smt2App (EVar f) [d]+  | f == setEmpty = Just $ build "{}"             (Only emp)+  | f == setEmp   = Just $ build "(= {} {})"      (emp, d)+  | f == setSng   = Just $ build "({} {} {})"     (add, emp, d)+smt2App (EVar f) (d:ds)+  | Just s <- M.lookup f theorySymbols+  = Just $ build "({} {})" (tsRaw s, d <> mconcat [ " " <> d | d <- ds])+smt2App _ _           = Nothing++-- isSmt2App :: Expr -> [a] -> Bool+-- isSmt2App e xs = tracepp ("isSmt2App e := " ++ show e) (isSmt2App' e xs)++isSmt2App :: Expr -> [a] -> Bool+isSmt2App (EVar f) [_]+  | f == setEmpty = True+  | f == setEmp   = True+  | f == setSng   = True+isSmt2App (EVar f) _+  =  isJust $ M.lookup f theorySymbols+isSmt2App _ _+  = False+++preamble :: Config -> SMTSolver -> [T.Text]+preamble u Z3   = z3Preamble u+preamble u Cvc4 = cvc4Preamble u+preamble u _    = smtlibPreamble u++--------------------------------------------------------------------------------+-- | Converting Non-Int types to Int -------------------------------------------+--------------------------------------------------------------------------------+-- toInt :: Expr -> Sort -> Expr+-- toInt e s = tracepp msg (toInt' e s)+  -- where+    -- msg   = "toInt e = " ++ show e ++ ", t = " ++ show s++toInt :: Expr -> Sort -> Expr+toInt e s+  |  (FApp (FTC c) _) <- s+  , isConName setConName c+  = castWith setToIntName e+  | (FApp (FApp (FTC c) _) _) <- s+  , isConName mapConName c+  = castWith mapToIntName e+  | (FApp (FTC bv) (FTC s)) <- s+  , isConName bitVecName bv+  , Just _ <- sizeBv s+  = castWith bitVecToIntName e+  | FTC c <- s+  , c == boolFTyCon+  = castWith boolToIntName e+  | FTC c <- s+  , c == realFTyCon+  = castWith realToIntName e+  | otherwise+  = e++castWith :: Symbol -> Expr -> Expr+castWith s = eAppC intSort (EVar s)++--------------------------------------------------------------------------------+-- | Theory Symbols : `uninterpSEnv` should be disjoint from see `interpSEnv`+--   to avoid duplicate SMT definitions.  `uninterpSEnv` is for uninterpreted+--   symbols, and `interpSEnv` is for interpreted symbols.+--------------------------------------------------------------------------------+theorySEnv :: SEnv Sort+theorySEnv = fromListSEnv . M.toList . fmap tsSort $ theorySymbols++-- | `theorySymbols` contains the list of ALL SMT symbols with interpretations,+--   i.e. which are given via `define-fun` (as opposed to `declare-fun`) theorySymbols :: M.HashMap Symbol TheorySymbol-theorySymbols = M.fromList-  [ tSym setEmp   emp (FAbs 0 $ FFunc (setSort $ FVar 0) boolSort)-  , tSym setEmpty emp (FAbs 0 $ FFunc intSort (setSort $ FVar 0))-  , tSym setAdd add   setbopSort -  , tSym setCup cup   setbopSort-  , tSym setCap cap   setbopSort-  , tSym setMem mem   setmemSort-  , tSym setDif dif   setbopSort-  , tSym setSub sub   setcmpSort-  , tSym setCom com   setcmpSort-  , tSym mapSel sel   mapselSort-  , tSym mapSto sto   mapstoSort-  , tSym bvOrName "bvor"   bvbopSort-  , tSym bvAndName "bvand" bvbopSort+theorySymbols = M.fromList $ uninterpSymbols ++ interpSymbols++-- isTheorySymbol :: Symbol -> Bool+-- isTheorySymbol x = M.member x theorySymbols++interpSymbols :: [(Symbol, TheorySymbol)]+interpSymbols =+  [ interpSym setEmp   emp  (FAbs 0 $ FFunc (setSort $ FVar 0) boolSort)+  , interpSym setEmpty emp  (FAbs 0 $ FFunc intSort (setSort $ FVar 0))+  , interpSym setAdd   add   setBopSort+  , interpSym setCup   cup   setBopSort+  , interpSym setCap   cap   setBopSort+  , interpSym setMem   mem   setMemSort+  , interpSym setDif   dif   setBopSort+  , interpSym setSub   sub   setCmpSort+  , interpSym setCom   com   setCmpSort+  , interpSym mapSel   sel   mapSelSort+  , interpSym mapSto   sto   mapStoSort+  , interpSym bvOrName "bvor"   bvBopSort+  , interpSym bvAndName "bvand" bvBopSort+  , interpSym strLen    strLen    strLenSort+  , interpSym strSubstr strSubstr substrSort+  , interpSym strConcat strConcat concatstrSort+  , interpSym boolInt   boolInt   (FFunc boolSort intSort)   ]   where-    setbopSort = FAbs 0 $ FFunc (setSort $ FVar 0) $ FFunc (setSort $ FVar 0) (setSort $ FVar 0)-    setmemSort = FAbs 0 $ FFunc (FVar 0) $ FFunc (setSort $ FVar 0) boolSort-    setcmpSort = FAbs 0 $ FFunc (setSort $ FVar 0) $ FFunc (setSort $ FVar 0) boolSort-    mapselSort = FAbs 0 $ FAbs 1 $ FFunc (mapSort (FVar 0) (FVar 1)) $ FFunc (FVar 0) (FVar 0)-    mapstoSort = FAbs 0 $ FAbs 1 $ FFunc (mapSort (FVar 0) (FVar 1)) -                                 $ FFunc (FVar 0) -                                 $ FFunc (FVar 1) +    boolInt    = boolToIntName+    setBopSort = FAbs 0 $ FFunc (setSort $ FVar 0) $ FFunc (setSort $ FVar 0) (setSort $ FVar 0)+    setMemSort = FAbs 0 $ FFunc (FVar 0) $ FFunc (setSort $ FVar 0) boolSort+    setCmpSort = FAbs 0 $ FFunc (setSort $ FVar 0) $ FFunc (setSort $ FVar 0) boolSort+    mapSelSort = FAbs 0 $ FAbs 1 $ FFunc (mapSort (FVar 0) (FVar 1)) $ FFunc (FVar 0) (FVar 1)+    mapStoSort = FAbs 0 $ FAbs 1 $ FFunc (mapSort (FVar 0) (FVar 1))+                                 $ FFunc (FVar 0)+                                 $ FFunc (FVar 1)                                          (mapSort (FVar 0) (FVar 1))-    bvbopSort  = FFunc bitVecSort $ FFunc bitVecSort bitVecSort+    bvBopSort  = FFunc bitVecSort $ FFunc bitVecSort bitVecSort  -tSym :: Symbol -> Raw -> Sort -> (Symbol, TheorySymbol)-tSym x n t = (x, Thy x n t)-+interpSym :: Symbol -> Raw -> Sort -> (Symbol, TheorySymbol)+interpSym x n t = (x, Thy x n t True) -isBv :: FTycon -> Bool-isBv = (bitVecName ==) . val . fTyconSymbol+isConName :: Symbol -> FTycon -> Bool+isConName s = (s ==) . val . fTyconSymbol  sizeBv :: FTycon -> Maybe Int sizeBv tc@@ -218,36 +365,53 @@   where     s               = val $ fTyconSymbol tc +uninterpSymbols :: [(Symbol, TheorySymbol)]+uninterpSymbols = [ (x, uninterpSym x t) | (x, t) <- uninterpSymbols'] ----------------------------------------------------------------------------------- | Exported API ---------------------------------------------------------------------------------------------------------------------------------------------+uninterpSym :: Symbol -> Sort -> TheorySymbol+uninterpSym x t =  Thy x (lt x) t False+  where+    lt           = T.fromStrict . symbolSafeText -smt2Symbol :: Symbol -> Maybe T.Text-smt2Symbol x = tsRaw <$> M.lookup x theorySymbols+uninterpSymbols' :: [(Symbol, Sort)]+uninterpSymbols' =+  [ (setToIntName,    FFunc (setSort intSort)   intSort)+  , (bitVecToIntName, FFunc bitVecSort intSort)+  , (mapToIntName,    FFunc (mapSort intSort intSort) intSort)+  , (realToIntName,   FFunc realSort   intSort)+  , (lambdaName   ,   FFunc intSort (FFunc intSort intSort))+  ]+  ++ concatMap makeApplies [1..maxLamArg]+  ++ [(makeLamArg s i, s) | i <- [1..maxLamArg], s <- sorts] -smt2Sort :: Sort -> Maybe T.Text-smt2Sort (FApp (FTC c) _)-  | fTyconSymbol c == "Set_Set" = Just $ format "{}" (Only set)-smt2Sort (FApp (FApp (FTC c) _) _)-  | fTyconSymbol c == "Map_t"   = Just $ format "{}" (Only map)-smt2Sort (FApp (FTC bv) (FTC s))-  | isBv bv-  , Just n <- sizeBv s          = Just $ format "(_ BitVec {})" (Only n)-smt2Sort _                      = Nothing+-- THESE ARE DUPLICATED IN DEFUNCTIONALIZATION+maxLamArg :: Int+maxLamArg = 7 -smt2App :: Expr -> [T.Text] -> Maybe T.Text-smt2App (EVar f) [d]-  | f == setEmpty = Just $ format "{}"             (Only emp)-  | f == setEmp   = Just $ format "(= {} {})"      (emp, d)-  | f == setSng   = Just $ format "({} {} {})"     (add, emp, d)-smt2App (EVar f) ds-  | Just s <- M.lookup f theorySymbols-  = Just $ format "({} {})" (tsRaw s, T.intercalate " " ds) -smt2App _ _           = Nothing+sorts :: [Sort]+sorts = [intSort] +-- NIKI TODO: allow non integer lambda arguments+-- sorts = [setSort intSort, bitVecSort intSort, mapSort intSort intSort, boolSort, realSort, intSort] -preamble :: Bool -> SMTSolver -> [T.Text]-preamble u Z3   = z3Preamble u-preamble u Cvc4 = cvc4Preamble u-preamble u _    = smtlibPreamble u+makeLamArg :: Sort -> Int  -> Symbol+makeLamArg _ = intArgName++makeApplies :: Int -> [(Symbol, Sort)]+makeApplies i =+  [ (intApplyName i,    go i intSort)+  , (setApplyName i,    go i (setSort intSort))+  , (bitVecApplyName i, go i bitVecSort)+  , (mapApplyName i,    go i $ mapSort intSort intSort)+  , (realApplyName i,   go i realSort)+  , (boolApplyName i,   go i boolSort)+  ]+  where+    go 0 s = FFunc intSort s+    go i s = FFunc intSort $ go (i-1) s++axiomLiterals :: [(Symbol, Sort)] -> [Expr]+axiomLiterals lts = catMaybes [ lenAxiom l <$> litLen l | (l, t) <- lts, isString t ]+  where+    lenAxiom l n  = EEq (EApp (expr (strLen :: Symbol)) (expr l)) (expr n `ECst` intSort)+    litLen        = fmap (Data.Text.length .  symbolText) . unLitSymbol
src/Language/Fixpoint/Smt/Types.hs view
@@ -10,6 +10,7 @@      -- * Serialized Representation       Raw+    , symbolBuilder      -- * Commands     , Command  (..)@@ -19,106 +20,102 @@      -- * Typeclass for SMTLIB2 conversion     , SMTLIB2 (..)+    , runSmt2      -- * SMTLIB2 Process Context     , Context (..) -    -- * SMTLIB2 symbol environment -    , SMTEnv, emptySMTEnv, SMTSt(..), withExtendedEnv, SMT2, freshSym-     -- * Theory Symbol     , TheorySymbol (..)--    -- * Strict Formatter-    , format-+    , SMTEnv     ) where  import           Language.Fixpoint.Types-import qualified Data.Text.Format         as DTF-import           Data.Text.Format.Params  (Params)+-- import           Language.Fixpoint.Misc   (traceShow) import qualified Data.Text                as T import qualified Data.Text.Lazy           as LT+import qualified Data.Text.Lazy.Builder   as LT+import           Text.PrettyPrint.HughesPJ + import           System.IO                (Handle) import           System.Process-import           Control.Monad.State ------------------------------------------------------------------------------ | Types ------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | Types ---------------------------------------------------------------------+--------------------------------------------------------------------------------+type Raw          = LT.Text -type Raw          = T.Text+symbolBuilder :: Symbol -> LT.Builder+symbolBuilder = LT.fromText . symbolSafeText  -- | Commands issued to SMT engine data Command      = Push                   | Pop                   | CheckSat-                  | Declare   Symbol [Sort] Sort-                  | Define    Sort-                  | Assert    (Maybe Int) Expr+                  | Declare   !Symbol [Sort] !Sort+                  | Define    !Sort+                  | Assert    !(Maybe Int) !Expr+                  | AssertAxiom  !(Triggered Expr)                   | Distinct  [Expr] -- {v:[Expr] | 2 <= len v}                   | GetValue  [Symbol]                   | CMany [Command]                   deriving (Eq, Show) +instance PPrint Command where+  pprintTidy _ = ppCmd++ppCmd :: Command -> Doc+ppCmd Push          = text "Push"+ppCmd Pop           = text "Pop"+ppCmd CheckSat      = text "CheckSat"+ppCmd (Declare {})  = text "Declare ..."+ppCmd (Define {})   = text "Define ..."+ppCmd (Assert _ e)  = text "Assert" <+> pprint e+ppCmd (AssertAxiom _) = text "AssertAxiom ..."+ppCmd (Distinct {}) = text "Distinct ..."+ppCmd (GetValue {}) = text "GetValue ..."+ppCmd (CMany {})    = text "CMany ..."+ -- | Responses received from SMT engine data Response     = Ok                   | Sat                   | Unsat                   | Unknown-                  | Values [(Symbol, Raw)]-                  | Error Raw+                  | Values [(Symbol, T.Text)]+                  | Error !T.Text                   deriving (Eq, Show)  -- | Information about the external SMT process-data Context      = Ctx { pId     :: ProcessHandle-                        , cIn     :: Handle-                        , cOut    :: Handle-                        , cLog    :: Maybe Handle-                        , verbose :: Bool-                        , smtenv  :: SMTEnv-                        }---- | Theory Symbol-data TheorySymbol  = Thy { tsSym  :: Symbol-                         , tsRaw  :: Raw-                         , tsSort :: Sort-                         }-                     deriving (Eq, Ord, Show)---------------------------------------------------------------------------- | AST Conversion: Types that can be serialized -----------------------------------------------------------------------------------------------format :: Params ps => DTF.Format -> ps -> T.Text-format f x = LT.toStrict $ DTF.format f x--type SMTEnv = SEnv Sort -data SMTSt  = SMTSt {fresh :: Int , smt2env :: SMTEnv}--type SMT2   = State SMTSt+data Context = Ctx+  { ctxPid     :: !ProcessHandle+  , ctxCin     :: !Handle+  , ctxCout    :: !Handle+  , ctxLog     :: !(Maybe Handle)+  , ctxVerbose :: !Bool+  , ctxExt     :: !Bool              -- ^ flag to enable function extentionality axioms+  , ctxAeq     :: !Bool              -- ^ flag to enable lambda a-equivalence axioms+  , ctxBeq     :: !Bool              -- ^ flag to enable lambda b-equivalence axioms+  , ctxNorm    :: !Bool              -- ^ flag to enable lambda normal form equivalence axioms+  , ctxSmtEnv  :: !SMTEnv+  } -emptySMTEnv = emptySEnv +type SMTEnv = SEnv Sort -withExtendedEnv bs act = do -  env <- smt2env <$> get -  let env' = foldl (\env (x, t) -> insertSEnv x t env) env bs-  modify $ \s -> s{smt2env = env'}-  r <- act -  modify $ \s -> s{smt2env = env}-  return r +-- | Theory Symbol+data TheorySymbol  = Thy+  { tsSym    :: !Symbol    -- ^ name+  , tsRaw    :: !Raw       -- ^ serialized SMTLIB2 name+  , tsSort   :: !Sort      -- ^ sort+  , tsInterp :: !Bool      -- ^ TRUE = defined (interpreted), FALSE = declared (uninterpreted)+  }+  deriving (Eq, Ord, Show) -freshSym = do -  n <- fresh <$> get -  modify $ \s -> s{fresh = n + 1}-  return $ intSymbol "lambda_fun_" n +--------------------------------------------------------------------------------+-- | AST Conversion: Types that can be serialized ------------------------------+-------------------------------------------------------------------------------- --- | Types that can be serialized class SMTLIB2 a where-  defunc :: a -> SMT2 a-  defunc = return --  smt2 :: a -> T.Text +  smt2 :: a -> LT.Builder -  runSmt2 :: SMTEnv -> a -> T.Text -  runSmt2 env a = smt2 $ evalState (defunc a) (SMTSt 0 env)+runSmt2 :: (SMTLIB2 a) => a -> LT.Builder+runSmt2 = smt2
src/Language/Fixpoint/Solver.hs view
@@ -18,70 +18,70 @@   , parseFInfo ) where - import           Control.Concurrent import           Data.Binary--- import           Data.Maybe                         (fromMaybe)--- import           Data.List                          hiding (partition)--- import qualified Data.HashSet                       as S import           System.Exit                        (ExitCode (..))---- import           System.Console.CmdArgs.Verbosity   hiding (Loud)+import           System.Console.CmdArgs.Verbosity   (whenNormal) import           Text.PrettyPrint.HughesPJ          (render)--- import           Text.Printf                        (printf) import           Control.Monad                      (when) import           Control.Exception                  (catch)--import           Language.Fixpoint.Solver.Graph     -- (slice)-import           Language.Fixpoint.Solver.Validate  (sanitize)-import qualified Language.Fixpoint.Solver.Eliminate as E--- import           Language.Fixpoint.Solver.Deps      -- (deps, GDeps (..))+import           Language.Fixpoint.Solver.Sanitize  (symbolEnv, sanitize) import           Language.Fixpoint.Solver.UniqifyBinds (renameAll)+import           Language.Fixpoint.Defunctionalize (defunctionalize)+import           Language.Fixpoint.SortCheck            (Elaborate (..)) import           Language.Fixpoint.Solver.UniqifyKVars (wfcUniqify) import qualified Language.Fixpoint.Solver.Solve     as Sol--- import           Language.Fixpoint.Solver.Solution  (Solution)--import           Language.Fixpoint.Types.Config           (queryFile, multicore, Config (..))+import           Language.Fixpoint.Types.Config import           Language.Fixpoint.Types.Errors import           Language.Fixpoint.Utils.Files            hiding (Result) import           Language.Fixpoint.Misc-import           Language.Fixpoint.Utils.Progress import           Language.Fixpoint.Utils.Statistics (statistics)-import           Language.Fixpoint.Partition        -- (mcInfo, partition, partition')-import           Language.Fixpoint.Parse            (rr', mkQual)+import           Language.Fixpoint.Graph+import           Language.Fixpoint.Parse            (rr') import           Language.Fixpoint.Types-import           Language.Fixpoint.Minimize (minQuery)+import           Language.Fixpoint.Minimize (minQuery, minQuals, minKvars)+import           Language.Fixpoint.Solver.Instantiate (instantiateFInfo)+import           Language.Fixpoint.Smt.Interface (makeSmtContext, smtPush) import           Control.DeepSeq - --------------------------------------------------------------------------- -- | Solve an .fq file ---------------------------------------------------- --------------------------------------------------------------------------- solveFQ :: Config -> IO ExitCode --------------------------------------------------------------------------- solveFQ cfg = do-    fi      <- readFInfo file-    r       <- solve cfg fi-    let stat = resStatus $!! r+    (fi, opts) <- readFInfo file+    cfg'       <- withPragmas cfg opts+    let fi'     = ignoreQualifiers cfg' fi+    r          <- solve cfg' fi'+    let stat    = resStatus $!! r     -- let str  = render $ resultDoc $!! (const () <$> stat)     -- putStrLn "\n"-    colorStrLn (colorResult stat) (statStr $!! stat)+    whenNormal $ colorStrLn (colorResult stat) (statStr $!! stat)     return $ eCode r   where-    file    = inFile       cfg+    file    = srcFile      cfg     eCode   = resultExit . resStatus     statStr = render . resultDoc . fmap fst ------------------------------------------------------------------------------- | Solve FInfo system of horn-clause constraints ----------------------------------------------------------------------------------------------------+ignoreQualifiers :: Config -> FInfo a -> FInfo a+ignoreQualifiers cfg fi+  | eliminate cfg == All = fi { quals = [] }+  | otherwise            = fi+++--------------------------------------------------------------------------------+-- | Solve FInfo system of horn-clause constraints -----------------------------+-------------------------------------------------------------------------------- solve :: (NFData a, Fixpoint a) => Solver a----------------------------------------------------------------------------+-------------------------------------------------------------------------------- solve cfg q-  | parts cfg    = partition  cfg        $!! q-  | stats cfg    = statistics cfg        $!! q-  | minimize cfg = minQuery   cfg solve' $!! q-  | otherwise    = solve'     cfg        $!! q+  | parts cfg      = partition  cfg        $!! q+  | stats cfg      = statistics cfg        $!! q+  | minimize cfg   = minQuery   cfg solve' $!! q+  | minimizeQs cfg = minQuals cfg solve'   $!! q+  | minimizeKs cfg = minKvars cfg solve'   $!! q+  | otherwise      = solve'     cfg        $!! q  solve' :: (NFData a, Fixpoint a) => Solver a solve' cfg q = do@@ -93,98 +93,107 @@   | multicore cfg = solveParWith   | otherwise     = solveSeqWith -----------------------------------------------------------------------------readFInfo :: FilePath -> IO (FInfo ())-----------------------------------------------------------------------------readFInfo f        = fixFileName <$> act-  where-    fixFileName q  = q {fileName = f}-    act-      | isBinary f = readBinFq f-      | otherwise  = readFq f+--------------------------------------------------------------------------------+readFInfo :: FilePath -> IO (FInfo (), [String])+--------------------------------------------------------------------------------+readFInfo f+  | isBinary f = (,) <$> readBinFq f <*> return []+  | otherwise  = readFq f -readFq :: FilePath -> IO (FInfo ())+readFq :: FilePath -> IO (FInfo (), [String]) readFq file = do   str   <- readFile file-  let q = {-# SCC "parsefq" #-} rr' file str :: FInfo ()-  return q+  let q  = {-# SCC "parsefq" #-} rr' file str :: FInfoWithOpts ()+  return (fioFI q, fioOpts q)  readBinFq :: FilePath -> IO (FInfo ()) readBinFq file = {-# SCC "parseBFq" #-} decodeFile file ----------------------------------------------------------------------------+-------------------------------------------------------------------------------- -- | Solve in parallel after partitioning an FInfo to indepdendant parts----------------------------------------------------------------------------+-------------------------------------------------------------------------------- solveSeqWith :: (Fixpoint a) => Solver a -> Solver a-solveSeqWith s c fi0 = withProgressFI fi $ s c fi+solveSeqWith s c fi0 = {- withProgressFI fi $ -} s c fi   where-    fi               = slice fi0-+    fi               = slice c fi0 ----------------------------------------------------------------------------+-------------------------------------------------------------------------------- -- | Solve in parallel after partitioning an FInfo to indepdendant parts----------------------------------------------------------------------------+-------------------------------------------------------------------------------- solveParWith :: (Fixpoint a) => Solver a -> Solver a----------------------------------------------------------------------------+-------------------------------------------------------------------------------- solveParWith s c fi0 = do   -- putStrLn "Using Parallel Solver \n"-  let fi       = slice fi0-  withProgressFI fi $ do-    mci <- mcInfo c-    let (_, fis) = partition' (Just mci) fi-    writeLoud $ "Number of partitions : " ++ show (length fis)-    writeLoud $ "number of cores      : " ++ show (cores c)-    writeLoud $ "minimum part size    : " ++ show (minPartSize c)-    writeLoud $ "maximum part size    : " ++ show (maxPartSize c)-    case fis of-      []        -> errorstar "partiton' returned empty list!"-      [onePart] -> s c onePart-      _         -> inParallelUsing (s c) fis+  let fi    = slice c fi0+  mci      <- mcInfo c+  let fis   = partition' (Just mci) fi+  writeLoud $ "Number of partitions : " ++ show (length fis)+  writeLoud $ "number of cores      : " ++ show (cores c)+  writeLoud $ "minimum part size    : " ++ show (minPartSize c)+  writeLoud $ "maximum part size    : " ++ show (maxPartSize c)+  case fis of+    []        -> errorstar "partiton' returned empty list!"+    [onePart] -> s c onePart+    _         -> inParallelUsing (f s c) $ zip [1..] fis+    where+      f s c (j, fi) = s (c {srcFile = queryFile (Part j) c}) fi --------------------------------------------------------------------------------+-------------------------------------------------------------------------------- -- | Solve a list of FInfos using the provided solver function in parallel--------------------------------------------------------------------------------+-------------------------------------------------------------------------------- inParallelUsing :: (a -> IO (Result b)) -> [a] -> IO (Result b)--------------------------------------------------------------------------------+-------------------------------------------------------------------------------- inParallelUsing f xs = do    setNumCapabilities (length xs)    rs <- asyncMapM f xs    return $ mconcat rs ------------------------------------------------------------------------------- | Native Haskell Solver ----------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | Native Haskell Solver -----------------------------------------------------+-------------------------------------------------------------------------------- solveNative, solveNative' :: (NFData a, Fixpoint a) => Solver a----------------------------------------------------------------------------+-------------------------------------------------------------------------------- solveNative !cfg !fi0 = (solveNative' cfg fi0)                           `catch`                              (return . result)  result :: Error -> Result a-result e = Result (Crash [] msg) mempty+result e = Result (Crash [] msg) mempty mempty   where     msg  = showpp e +loudDump :: (Fixpoint a) => Int -> Config -> SInfo a -> IO ()+loudDump i cfg si = writeLoud $ msg ++ render (toFixpoint cfg si)+  where+    msg           = "fq file after Uniqify & Rename " ++ show i ++ "\n"+ solveNative' !cfg !fi0 = do   -- writeLoud $ "fq file in: \n" ++ render (toFixpoint cfg fi)   -- rnf fi0 `seq` donePhase Loud "Read Constraints"   -- let qs   = quals fi0   -- whenLoud $ print qs-  let fi1  = fi0 { quals = remakeQual <$> quals fi0 }+  -- TODO: make this less of a hack+  ctx <- makeSmtContext cfg (srcFile cfg ++ ".evals") []+  smtPush ctx+  fi1 <- instantiateFInfo cfg ctx $ fi0 { quals = remakeQual <$> quals fi0 }   -- whenLoud $ putStrLn $ showFix (quals fi1)   let si0   = {-# SCC "convertFormat" #-} convertFormat fi1   -- writeLoud $ "fq file after format convert: \n" ++ render (toFixpoint cfg si0)   -- rnf si0 `seq` donePhase Loud "Format Conversion"-  let si1 = either die id $ {-# SCC "validate" #-} sanitize $!! si0-  -- writeLoud $ "fq file after validate: \n" ++ render (toFixpoint cfg si1)+  let si1 = either die id $ {-# SCC "sanitize" #-} sanitize $!! si0+  -- writeLoud $ "fq file after sanitize: \n" ++ render (toFixpoint cfg si1)   -- rnf si1 `seq` donePhase Loud "Validated Constraints"   graphStatistics cfg si1   let si2  = {-# SCC "wfcUniqify" #-} wfcUniqify $!! si1-  let si3  = {-# SCC "renameAll" #-} renameAll $!! si2-  -- rnf si2 `seq` donePhase Loud "Uniqify"-  (s0, si4) <- {-# SCC "elim" #-} elim cfg $!! si3-  -- writeLoud $ "About to solve: \n" ++ render (toFixpoint cfg si4)-  res <- {-# SCC "Sol.solve" #-} Sol.solve cfg s0 $!! si4+  let si3  = {-# SCC "renameAll"  #-} renameAll  $!! si2+  rnf si3 `seq` donePhase Loud "Uniqify & Rename"+  loudDump 1 cfg si3+  let si4  = {-# SCC "defunction" #-} defunctionalize cfg $!! si3+  -- putStrLn $ "AXIOMS: " ++ showpp (asserts si4)+  loudDump 2 cfg si4+  let si5  = {-# SCC "elaborate"  #-} elaborate "solver" (symbolEnv cfg si4) si4+  loudDump 3 cfg si5+  res <- {-# SCC "Sol.solve" #-} Sol.solve cfg $!! si5   -- rnf soln `seq` donePhase Loud "Solve2"   --let stat = resStatus res   saveSolution cfg res@@ -193,58 +202,34 @@   -- colorStrLn (colorResult stat) (show stat)   return res --elim :: (Fixpoint a) => Config -> SInfo a -> IO (Solution, SInfo a)-elim cfg fi-  | eliminate cfg = do-      let (s0, fi') = E.eliminate fi-      writeLoud $ "fq file after eliminate: \n" ++ render (toFixpoint cfg fi')-      -- elimSolGraph cfg s0-      donePhase Loud "Eliminate"-      writeLoud $ "Solution after eliminate: \n" ++ showpp s0 -- toFixpoint cfg fi')-      -- donePhase Loud "DonePrint"-      return (s0, fi')-  | otherwise     =-      return (mempty, fi)--remakeQual :: Qualifier -> Qualifier-remakeQual q = {- traceShow msg $ -} mkQual (q_name q) (q_params q) (q_body q) (q_pos q)---   where---     msg      = "REMAKEQUAL: " ++ show q-------------------------------------------------------------------------------- | Extract ExitCode from Solver Result --------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | Extract ExitCode from Solver Result ---------------------------------------+-------------------------------------------------------------------------------- resultExit :: FixResult a -> ExitCode----------------------------------------------------------------------------+-------------------------------------------------------------------------------- resultExit Safe        = ExitSuccess resultExit (Unsafe _)  = ExitFailure 1 resultExit _           = ExitFailure 2 ------------------------------------------------------------------------------- | Parse External Qualifiers -------------------------------------------------------------------------------------------------------------------------parseFInfo :: [FilePath] -> IO (FInfo a) -- [Qualifier]----------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | Parse External Qualifiers -------------------------------------------------+--------------------------------------------------------------------------------+parseFInfo :: [FilePath] -> IO (FInfo a)+-------------------------------------------------------------------------------- parseFInfo fs = mconcat <$> mapM parseFI fs -parseFI :: FilePath -> IO (FInfo a) --[Qualifier]+parseFI :: FilePath -> IO (FInfo a) parseFI f = do   str   <- readFile f   let fi = rr' f str :: FInfo ()   return $ mempty { quals = quals  fi-                  , lits  = lits   fi }+                  , gLits = gLits  fi+                  , dLits = dLits  fi }  saveSolution :: Config -> Result a -> IO () saveSolution cfg res = when (save cfg) $ do   let f = queryFile Out cfg   putStrLn $ "Saving Solution: " ++ f ++ "\n"   ensurePath f-  writeFile f $ "\nSolution:\n"  ++ showpp (resSolution res)-------------------------------------------------------------------------------- | Initialize Progress Bar-----------------------------------------------------------------------------withProgressFI :: FInfo a -> IO b -> IO b-----------------------------------------------------------------------------withProgressFI = withProgress . fromIntegral . gSccs . cGraph+  writeFile f $ "\nSolution:\n" ++ showpp (resSolution  res)+                ++ (if (gradual cfg) then ("\n\n" ++ showpp (gresSolution res)) else mempty)
src/Language/Fixpoint/Solver/Eliminate.hs view
@@ -1,33 +1,65 @@ {-# LANGUAGE FlexibleContexts     #-}-{-# LANGUAGE BangPatterns         #-} -module Language.Fixpoint.Solver.Eliminate (eliminate) where+-- | This module exports a single function that computes the dependency+-- information needed to eliminate non-cut KVars, and then transitively+-- collapse the resulting constraint dependencies.+-- See the type of `SolverInfo` for details. +module Language.Fixpoint.Solver.Eliminate (solverInfo) where+ import qualified Data.HashSet        as S import qualified Data.HashMap.Strict as M +import           Language.Fixpoint.Types.Config    (Config)+import qualified Language.Fixpoint.Types.Solutions as Sol import           Language.Fixpoint.Types import           Language.Fixpoint.Types.Visitor   (kvars, isConcC)-import           Language.Fixpoint.Partition       (depCuts, depNonCuts, deps)+import           Language.Fixpoint.Graph import           Language.Fixpoint.Misc            (safeLookup, group, errorstar)+import           Language.Fixpoint.Solver.Sanitize  ---------------------------------------------------------------------------------eliminate :: SInfo a -> (Solution, SInfo a)+-- | `solverInfo` constructs a `SolverInfo` comprising the Solution and various+--   indices needed by the worklist-based refinement loop ---------------------------------------------------------------------------------eliminate si  = ( sHyp, si' )+solverInfo :: Config -> SInfo a -> SolverInfo a b+--------------------------------------------------------------------------------+solverInfo cfg sI = SI sHyp sI' cD cKs   where-    sHyp      = solFromList [] kHyps-    si'       = cutSInfo   kI cKs si-    kHyps     = nonCutHyps kI nKs si-    kI        = kIndex  si-    (cKs,nKs) = kutVars si+    cD             = elimDeps     sI es nKs+    sI'            = cutSInfo     sI kI cKs+    sHyp           = Sol.fromList sE mempty mempty kHyps kS+    kHyps          = nonCutHyps   sI kI nKs+    kI             = kIndex       sI+    (es, cKs, nKs) = kutVars cfg  sI+    kS             = kvScopes     sI es+    sE             = symbolEnv   cfg sI -kutVars :: SInfo a -> (S.HashSet KVar, S.HashSet KVar)-kutVars si   = (depCuts ds, depNonCuts ds)++--------------------------------------------------------------------------------+kvScopes :: SInfo a -> [CEdge] -> M.HashMap KVar IBindEnv+kvScopes sI es = is2env <$> kiM   where-    ds       = deps si+    is2env = foldr1 intersectionIBindEnv . fmap (senv . getSubC sI)+    kiM    = group $ [(k, i) | (Cstr i, KVar k) <- es ] +++                     [(k, i) | (KVar k, Cstr i) <- es ]  --------------------------------------------------------------------------------++cutSInfo :: SInfo a -> KIndex -> S.HashSet KVar -> SInfo a+cutSInfo si kI cKs = si { ws = ws', cm = cm' }+  where+    ws'   = M.filterWithKey (\k _ -> S.member k cKs) (ws si)+    cm'   = M.filterWithKey (\i c -> S.member i cs || isConcC c) (cm si)+    cs    = S.fromList      (concatMap kCs cKs)+    kCs k = M.lookupDefault [] k kI++kutVars :: Config -> SInfo a -> ([CEdge], S.HashSet KVar, S.HashSet KVar)+kutVars cfg si   = (es, depCuts ds, depNonCuts ds)+  where+    (es, ds)     = elimVars cfg si++-------------------------------------------------------------------------------- -- | Map each `KVar` to the list of constraints on which it appears on RHS -------------------------------------------------------------------------------- type KIndex = M.HashMap KVar [Integer]@@ -40,24 +72,17 @@     iCs    = M.toList (cm si)     rkvars = kvars . crhs -cutSInfo :: KIndex -> S.HashSet KVar -> SInfo a -> SInfo a-cutSInfo kI cKs si = si { ws = ws', cm = cm' }-  where-    ws'   = M.filterWithKey (\k _ -> S.member k cKs) (ws si)-    cm'   = M.filterWithKey (\i c -> S.member i cs || isConcC c) (cm si)-    cs    = S.fromList      (concatMap kCs cKs)-    kCs k = M.lookupDefault [] k kI+nonCutHyps :: SInfo a -> KIndex -> S.HashSet KVar -> [(KVar, Sol.Hyp)]+nonCutHyps si kI nKs = [ (k, nonCutHyp kI si k) | k <- S.toList nKs ] -nonCutHyps :: KIndex -> S.HashSet KVar -> SInfo a -> [(KVar, Hyp)]-nonCutHyps kI nKs si = [ (k, nonCutHyp kI si k) | k <- S.toList nKs ] -nonCutHyp  :: KIndex -> SInfo a -> KVar -> Hyp+nonCutHyp  :: KIndex -> SInfo a -> KVar -> Sol.Hyp nonCutHyp kI si k = nonCutCube <$> cs   where     cs            = getSubC   si <$> M.lookupDefault [] k kI -nonCutCube :: SimpC a -> Cube-nonCutCube c = Cube (senv c) (rhsSubst c)+nonCutCube :: SimpC a -> Sol.Cube+nonCutCube c = Sol.Cube (senv c) (rhsSubst c) (subcId c) (stag c)  rhsSubst :: SimpC a -> Subst rhsSubst             = rsu . crhs@@ -69,63 +94,3 @@ getSubC si i = safeLookup msg i (cm si)   where     msg = "getSubC: " ++ show i-----------------------------------------------------------------------------------{--eliminateAll :: SInfo a -> (Solution, SInfo a)-eliminateAll !si = foldl' eliminate (mempty, si) nonCuts-  where-    nonCuts      = depNonCuts $ deps si--eliminate :: (Solution, SInfo a) -> KVar -> (Solution, SInfo a)-eliminate (!s, !si) k = (solInsert k (mkJVar orPred) s, si')-  where-    si'    = si { cm = nokCs , ws = M.delete k $ ws si }-    kCs    = M.filter (   elem k . kvars . crhs) (cm si) -- with    k in RHS (SLOW!)-    nokCs  = M.filter (notElem k . kvars . crhs) (cm si) -- without k in RHS (SLOW!)-    kW     = (ws si) M.! k-    kDom   = domain (bs si) kW-    orPred = POr $!! extractPred kDom (bs si)  <$> M.elems kCs--extractPred :: [Symbol] -> BindEnv -> SimpC a -> Expr-extractPred kDom be sc = renameQuantified (subcId sc) kSol-  where-    kSol               = PExist xts $ PAnd (lhsPreds ++ suPreds)-    xts                = filter (nonFunction be . fst) yts-    yts                = second sr_sort <$> env-    env                = clhs be sc-    lhsPreds           = bindPred <$> env-    suPreds            = substPreds kDom $ crhs sc---- x:{v:int|v=10} -> (x=10)-bindPred :: (Symbol, SortedReft) -> Expr-bindPred (x, sr) = p `subst1`(v, eVar x)-  where-    v            = reftBind r-    r            = sr_reft sr-    p            = reftPred r---- k0[v:=e1][x:=e2] -> [v = e1, x = e2]-substPreds :: [Symbol] -> Expr -> [Expr]-substPreds dom (PKVar _ (Su subs)) = [PAtom Eq (eVar x) e | (x, e) <- M.toList subs , x `elem` dom]-substPreds _ _ = errorstar "Eliminate.substPreds called on bad input"---- SLOW!-nonFunction :: BindEnv -> Symbol -> Bool-nonFunction be sym = sym `notElem` funcs-  where-    funcs = [x | (_, x, sr) <- bindEnvToList be-               , isFunctionSortedReft sr]--renameQuantified :: Integer -> Expr -> Expr-renameQuantified i (PExist bs p) = PExist bs' p'-  where-    su  = substFromQBinds i bs-    bs' = first (subst su) <$> bs-    p'  = subst su p-renameQuantified _ _ = errorstar "Eliminate.renameQuantified called on bad input"--substFromQBinds :: Integer -> [(Symbol, Sort)] -> Subst-substFromQBinds i bs = Su $ M.fromList [(s, EVar $ existSymbol s i) | s <- fst <$> bs]---}
+ src/Language/Fixpoint/Solver/GradualSolution.hs view
@@ -0,0 +1,420 @@+{-# LANGUAGE FlexibleInstances  #-}+{-# LANGUAGE TupleSections      #-}++module Language.Fixpoint.Solver.GradualSolution+  ( -- * Create Initial Solution+    init++    -- * Update Solution+  , Sol.update++  -- * Lookup Solution+  , lhsPred+  ) where++import           Control.Parallel.Strategies+import           Control.Arrow (second)+import qualified Data.HashSet                   as S+import qualified Data.HashMap.Strict            as M+import qualified Data.List                      as L+import           Data.Maybe                     (fromMaybe, maybeToList, isNothing, catMaybes)+import           Data.Monoid                    ((<>))+import           Language.Fixpoint.Types.PrettyPrint ()+import           Language.Fixpoint.Types.Visitor      as V+import qualified Language.Fixpoint.SortCheck          as So+import           Language.Fixpoint.Misc+import qualified Language.Fixpoint.Smt.Theories       as Thy+import           Language.Fixpoint.Types.Config+import qualified Language.Fixpoint.Types              as F+import           Language.Fixpoint.Types                 ((&.&))+import qualified Language.Fixpoint.Types.Solutions    as Sol+import           Language.Fixpoint.Types.Constraints  hiding (ws, bs)+import           Prelude                              hiding (init, lookup)+import           Language.Fixpoint.Solver.Sanitize+++--------------------------------------------------------------------------------+-- | Initial Gradual Solution (from Qualifiers and WF constraints) -------------+--------------------------------------------------------------------------------+init :: Config -> F.SInfo a -> S.HashSet F.KVar -> Sol.GSolution+--------------------------------------------------------------------------------+init cfg si ks = Sol.fromList senv geqs keqs [] mempty+  where+    keqs       = map (refine si qs genv)  ws `using` parList rdeepseq+    geqs       = map (refineG si qs genv) gs `using` parList rdeepseq +    qs         = F.quals si+    ws         = [ w | (k, w) <- ws0, k `S.member` ks]+    gs         = snd <$> gs0+    genv       = instConstants si+    senv       = symbolEnv cfg si++    (gs0,ws0)  = L.partition (isGWfc . snd) $ M.toList (F.ws si)+++--------------------------------------------------------------------------------+refineG :: F.SInfo a -> [F.Qualifier] -> F.SEnv F.Sort -> F.WfC a -> (F.KVar, (((F.Symbol,F.Sort), F.Expr), Sol.GBind))+refineG fi qs genv w = (k, (((fst3 $ wrft w, snd3 $ wrft w), wexpr w), Sol.qbToGb qb))+  where +    (k, qb) = refine fi qs genv w ++refine :: F.SInfo a -> [F.Qualifier] -> F.SEnv F.Sort -> F.WfC a -> (F.KVar, Sol.QBind)+refine fi qs genv w = refineK (allowHOquals fi) env qs $ F.wrft w+  where+    env             = wenv <> genv+    wenv            = F.sr_sort <$> F.fromListSEnv (F.envCs (F.bs fi) (F.wenv w))++instConstants :: F.SInfo a -> F.SEnv F.Sort+instConstants = F.fromListSEnv . filter notLit . F.toListSEnv . F.gLits+  where+    notLit    = not . F.isLitSymbol . fst+++refineK :: Bool -> F.SEnv F.Sort -> [F.Qualifier] -> (F.Symbol, F.Sort, F.KVar) -> (F.KVar, Sol.QBind)+refineK ho env qs (v, t, k) = (k, eqs')+   where+    eqs                     = instK ho env v t qs+    eqs'                    = Sol.qbFilter (okInst env v t) eqs++--------------------------------------------------------------------------------+instK :: Bool+      -> F.SEnv F.Sort+      -> F.Symbol+      -> F.Sort+      -> [F.Qualifier]+      -> Sol.QBind+--------------------------------------------------------------------------------+instK ho env v t = Sol.qb . unique . concatMap (instKQ ho env v t)+  where+    unique       = L.nubBy ((. Sol.eqPred) . (==) . Sol.eqPred)++instKQ :: Bool+       -> F.SEnv F.Sort+       -> F.Symbol+       -> F.Sort+       -> F.Qualifier+       -> [Sol.EQual]+instKQ ho env v t q+  = do (su0, v0) <- candidates senv [(t, [v])] qt+       xs        <- match senv tyss [v0] (So.apply su0 <$> qts)+       return     $ Sol.eQual q (reverse xs)+    where+       qt : qts   = snd <$> F.qParams q+       tyss       = instCands ho env+       senv       = (`F.lookupSEnvWithDistance` env)++instCands :: Bool -> F.SEnv F.Sort -> [(F.Sort, [F.Symbol])]+instCands ho env = filter isOk tyss+  where+    tyss      = groupList [(t, x) | (x, t) <- xts]+    isOk      = if ho then const True else isNothing . F.functionSort . fst+    xts       = F.toListSEnv env++match :: So.Env -> [(F.Sort, [F.Symbol])] -> [F.Symbol] -> [F.Sort] -> [[F.Symbol]]+match env tyss xs (t : ts)+  = do (su, x) <- candidates env tyss t+       match env tyss (x : xs) (So.apply su <$> ts)+match _   _   xs []+  = return xs++--------------------------------------------------------------------------------+candidates :: So.Env -> [(F.Sort, [F.Symbol])] -> F.Sort -> [(So.TVSubst, F.Symbol)]+--------------------------------------------------------------------------------+candidates env tyss tx = +    [(su, y) | (t, ys) <- tyss+             , su      <- maybeToList $ So.unifyFast mono env tx t+             , y       <- ys                                   ]+  where+    mono = So.isMono tx++--------------------------------------------------------------------------------+okInst :: F.SEnv F.Sort -> F.Symbol -> F.Sort -> Sol.EQual -> Bool+--------------------------------------------------------------------------------+okInst env v t eq = isNothing tc+  where+    sr            = F.RR t (F.Reft (v, p))+    p             = Sol.eqPred eq+    tc            = So.checkSorted env sr +++--------------------------------------------------------------------------------+-- | Predicate corresponding to LHS of constraint in current solution+--------------------------------------------------------------------------------+lhsPred :: F.SolEnv -> Sol.GSolution -> F.SimpC a ->  [([(F.KVar, Sol.QBind)], F.Expr)]+lhsPred be s c = gSelectToList (fst <$> applyGradual g s bs)+  where+    g                 = (ci, be, bs)+    bs                = F.senv c+    ci                = sid c++type Cid         = Maybe Integer+type CombinedEnv = (Cid, F.SolEnv, F.IBindEnv)+type ExprInfo    = (F.Expr, KInfo)++applyGradual        :: CombinedEnv -> Sol.GSolution -> F.IBindEnv -> GSelect ExprInfo+applyGradual g s bs = mappendGSelect mappendExprInfo pks (applyKVarsGrad g s ks)+  where+    pgs           = allCombinations $ applyGVars g s gs+    pks           = if null gs +                        then GNone (F.pAnd ps, mempty) +                        else GOpt [(fst (unzip l) , (F.pAnd (ps++snd (unzip l)), mempty)) | l <- pgs ]+    (ps,  ks, gs) = envConcKVars g bs++    mappendExprInfo (e1, i1) (e2, i2) = (F.pAnd [e1, e2], mappend i1 i2)+++envConcKVars :: CombinedEnv -> F.IBindEnv -> ([F.Expr], [F.KVSub], [F.KVSub])+envConcKVars g bs = (concat pss, concat kss, L.nubBy (\x y -> F.ksuKVar x == F.ksuKVar y) $ concat gss)+  where+    (pss, kss, gss) = unzip3 [ F.sortedReftConcKVars x sr | (x, sr) <- xrs ]+    xrs             = (\i -> F.lookupBindEnv i be) <$> is+    is              = F.elemsIBindEnv bs+    be              = F.soeBinds (snd3 g)++applyGVars :: CombinedEnv -> Sol.GSolution -> [F.KVSub] -> [[((F.KVar, Sol.QBind), F.Expr)]]+applyGVars g s = map (applyGVar g s)+++applyGVar :: CombinedEnv -> Sol.GSolution -> F.KVSub -> [((F.KVar, Sol.QBind), F.Expr)]+applyGVar g s ksu = case Sol.glookup s (F.ksuKVar ksu) of+  Right (Right (e,eqss)) -> [((F.ksuKVar ksu, eqs), F.pAnd ((F.subst su (snd e)):(fst <$> Sol.qbPreds msg s su eqs))) | eqs <- Sol.gbToQbs eqss]+  _                      -> []+  where+    msg     = "applyGVar: " ++ show (fst3 g)+    su      = F.ksuSubst ksu++applyKVarsGrad :: CombinedEnv -> Sol.GSolution -> [F.KVSub] -> GSelect ExprInfo+applyKVarsGrad g s xs = (f <$> (collapseGSelect $ map (applyKVarGrad g s) xs))+  where+    f xs = let (es, is) = unzip xs  in (F.pAnd es, mconcat is)++applyKVarGrad :: CombinedEnv -> Sol.GSolution -> F.KVSub -> GSelect ExprInfo+applyKVarGrad g s ksu = case Sol.glookup s (F.ksuKVar ksu) of+  Left cs                -> hypPredGrad g s ksu cs+  Right (Left eqs)       -> GNone (F.pAnd $ fst <$> Sol.qbPreds msg s (F.ksuSubst ksu) eqs, mempty)+  Right (Right (e,eqss)) -> GOpt [([(F.ksuKVar ksu, eqs)]+                                  , (, mempty) $ F.pAnd ((F.subst su (snd e)):(fst <$> Sol.qbPreds msg s su eqs))) +                                  | eqs <- Sol.gbToQbs eqss]+  where+    msg     = "applyKVar: " ++ show (fst3 g) +    su      = F.ksuSubst ksu+++hypPredGrad :: CombinedEnv -> Sol.GSolution -> F.KVSub -> Sol.Hyp  -> GSelect ExprInfo+hypPredGrad g s ksu xs = f <$> (collapseGSelect $ map (cubePredGrad g s ksu) xs)+  where+    f xs = let (es, is) = unzip xs  in (F.pOr es, mconcatPlus is)+++{- | `cubePred g s k su c` returns the predicate for++        (k . su)++      defined by using cube++        c := [b1,...,bn] |- (k . su')++      in the binder environment `g`.++        bs' := the subset of "extra" binders in [b1...bn] that are *not* in `g`+        p'  := the predicate corresponding to the "extra" binders++ -}++elabExist :: Sol.Sol a Sol.QBind -> [(F.Symbol, F.Sort)] -> F.Expr -> F.Expr+elabExist s xts = F.pExist xts'+  where+    xts'        = [ (x, elab t) | (x, t) <- xts]+    elab        = So.elaborate "elabExist" env+    env         = Sol.sEnv s+++cubePredGrad :: CombinedEnv -> Sol.GSolution -> F.KVSub -> Sol.Cube -> GSelect ExprInfo+cubePredGrad g s ksu c  = ((\((xts,psu,p), kI) -> (elabExist s xts (psu &.& p) , kI)) <$> cubePredExcGrad g s ksu c bs')+  where+    bs'               = delCEnv s k bs+    bs                = Sol.cuBinds c+    k                 = F.ksuKVar ksu+++type Binders = [(F.Symbol, F.Sort)]++-- | @cubePredExc@ computes the predicate for the subset of binders bs'.+--   The output is a tuple, `(xts, psu, p, kI)` such that the actual predicate+--   we want is `Exists xts. (psu /\ p)`.+++cubePredExcGrad :: CombinedEnv -> Sol.GSolution -> F.KVSub -> Sol.Cube -> F.IBindEnv+            -> GSelect ((Binders, F.Pred, F.Pred), KInfo)+cubePredExcGrad g s ksu c bs' +  = f <$> (applyGradual g' s bs')+  where+    f (p', kI)      = ((xts, psu, elabExist s yts' (p' &.& psu') ), extendKInfo kI (Sol.cuTag c))+    yts'            = symSorts g bs'+    g'              = addCEnv  g bs+    +    (_  , psu')     = substElim sEnv g' k su'+    (xts, psu)      = substElim sEnv g  k su+    su'             = Sol.cuSubst c+    bs              = Sol.cuBinds c+    k               = F.ksuKVar   ksu+    su              = F.ksuSubst  ksu+    sEnv            = F.insertSEnv (F.ksuVV ksu) (F.ksuSort ksu) (Sol.sEnv s)+++-- TODO: SUPER SLOW! Decorate all substitutions with Sorts in a SINGLE pass.++{- | @substElim@ returns the binders that must be existentially quantified,+     and the equality predicate relating the kvar-"parameters" and their+     actual values. i.e. given++        K[x1 := e1]...[xn := en]++     where e1 ... en have types t1 ... tn+     we want to quantify out++       x1:t1 ... xn:tn++     and generate the equality predicate && [x1 ~~ e1, ... , xn ~~ en]+     we use ~~ because the param and value may have different sorts, see:++        tests/pos/kvar-param-poly-00.hs++     Finally, we filter out binders if they are++     1. "free" in e1...en i.e. in the outer environment.+        (Hmm, that shouldn't happen...?)++     2. are binders corresponding to sorts (e.g. `a : num`, currently used+        to hack typeclasses current.)+ -}+substElim :: F.SEnv F.Sort -> CombinedEnv -> F.KVar -> F.Subst -> ([(F.Symbol, F.Sort)], F.Pred)+substElim sEnv g _ (F.Su m) = (xts, p)+  where+    p      = F.pAnd [ mkSubst x (substSort sEnv frees x t) e t | (x, e, t) <- xets  ]+    xts    = [ (x, t)    | (x, _, t) <- xets, not (S.member x frees) ]+    xets   = [ (x, e, t) | (x, e)    <- xes, t <- sortOf e, not (isClass t)]+    xes    = M.toList m+    env    = combinedSEnv g+    frees  = S.fromList (concatMap (F.syms . snd) xes)+    sortOf = maybeToList . So.checkSortExpr env++substSort :: F.SEnv F.Sort -> S.HashSet F.Symbol -> F.Symbol -> F.Sort -> F.Sort+substSort sEnv _frees x _t = fromMaybe (err x) $ F.lookupSEnv x sEnv+  where+    err x            = error $ "Solution.mkSubst: unknown binder " ++ F.showpp x++mkSubst :: F.Symbol -> F.Sort -> F.Expr -> F.Sort -> F.Expr+mkSubst x tx ey ty+  | tx == ty    = F.EEq ex ey+  | otherwise   = F.notracepp msg (F.EEq ex' ey')+  where+    msg         = "mkSubst-DIFF:" ++ F.showpp (tx, ty) ++ F.showpp (ex', ey')+    ex          = F.expr x+    ex'         = Thy.toInt ex tx+    ey'         = Thy.toInt ey ty++isClass :: F.Sort -> Bool+isClass F.FNum  = True+isClass F.FFrac = True+isClass _       = False++--badExpr :: CombinedEnv -> F.KVar -> F.Expr -> a+--badExpr g@(i,_,_) k e+  -- = errorstar $ "substSorts has a badExpr: "+              -- ++ show e+              -- ++ " in cid = "+              -- ++ show i+              -- ++ " for kvar " ++ show k+              -- ++ " in env \n"+              -- ++ show (combinedSEnv g)++-- substPred :: F.Subst -> F.Pred+-- substPred (F.Su m) = F.pAnd [ F.PAtom F.Eq (F.eVar x) e | (x, e) <- M.toList m]++combinedSEnv :: CombinedEnv -> F.SEnv F.Sort+combinedSEnv (_, se, bs) = F.sr_sort <$> F.fromListSEnv (F.envCs be bs)+  where+    be                   = F.soeBinds se++addCEnv :: CombinedEnv -> F.IBindEnv -> CombinedEnv+addCEnv (x, be, bs) bs' = (x, be, F.unionIBindEnv bs bs')++-- delCEnv :: F.IBindEnv -> CombinedEnv -> F.IBindEnv+-- delCEnv bs (_, _, bs')  = F.diffIBindEnv bs bs'++delCEnv :: Sol.Sol a Sol.QBind -> F.KVar -> F.IBindEnv -> F.IBindEnv+delCEnv s k bs  = F.diffIBindEnv bs _kbs+                                                -- ORIG: bs'+  where+    _kbs = safeLookup "delCEnv" k (Sol.sScp s)++symSorts :: CombinedEnv -> F.IBindEnv -> [(F.Symbol, F.Sort)]+symSorts (_, se, _) bs = second F.sr_sort <$> F.envCs be  bs+  where+    be                 = F.soeBinds se++_noKvars :: F.Expr -> Bool+_noKvars = null . V.kvars++--------------------------------------------------------------------------------+-- | Information about size of formula corresponding to an "eliminated" KVar.+--------------------------------------------------------------------------------+data KInfo = KI { kiTags  :: [Tag]+                , kiDepth :: !Int+                , kiCubes :: !Integer+                } deriving (Eq, Ord, Show)++instance Monoid KInfo where+  mempty         = KI [] 0 1+  mappend ki ki' = KI ts d s+    where+      ts         = appendTags (kiTags  ki) (kiTags  ki')+      d          = max        (kiDepth ki) (kiDepth ki')+      s          = (*)        (kiCubes ki) (kiCubes ki')++mplus :: KInfo -> KInfo -> KInfo+mplus ki ki' = (mappend ki ki') { kiCubes = kiCubes ki + kiCubes ki'}++mconcatPlus :: [KInfo] -> KInfo+mconcatPlus = foldr mplus mempty++appendTags :: [Tag] -> [Tag] -> [Tag]+appendTags ts ts' = sortNub (ts ++ ts')++extendKInfo :: KInfo -> F.Tag -> KInfo+extendKInfo ki t = ki { kiTags  = appendTags [t] (kiTags  ki)+                      , kiDepth = 1  +            kiDepth ki }+++--------------------------------------------------------------------------------+-- | Gradual Selection Interface -----------------------------------------------+--------------------------------------------------------------------------------+data GSelect a = GNone a | GOpt [([(F.KVar, Sol.QBind)], a)] deriving (Show)+++gSelectToList :: GSelect a -> [([(F.KVar, Sol.QBind)], a)]+gSelectToList (GNone a) = [([], a)]+gSelectToList (GOpt xs) = xs +++instance Functor GSelect where+  fmap f (GNone a) = GNone  (f a)+  fmap f (GOpt xs) = GOpt [(p, f a) | (p, a) <- xs]++mappendGSelect :: (a -> a -> b) -> GSelect a -> GSelect a -> GSelect b +mappendGSelect f (GNone x) (GNone y) = GNone (f x y)+mappendGSelect f (GNone x) (GOpt ys) = GOpt [(i, f x y) | (i, y) <- ys] +mappendGSelect f (GOpt xs) (GNone y) = GOpt [(i, f x y) | (i, x) <- xs]+mappendGSelect f (GOpt xs) (GOpt ys) = GOpt $ concatMap (\y -> (catMaybes $ map (\x -> g x y) xs)) ys +  where+    g (xs, x) (ys, y)+      | null [ () | (k1, _) <- xs, (k2, _) <- ys, k1 == k2 ]  +      =  Just (xs ++ ys, f x y)+      | and [v1 == v2 | (k1, v1) <- xs, (k2, v2) <- ys, k1 == k2 ] +      = Just (xs ++ [(k, v) | (k, v) <- ys, not (k `elem` (fst <$> xs))], f x y)+      | otherwise+      = Nothing ++collapseGSelect :: [GSelect a] -> GSelect [a]+collapseGSelect = foldl (mappendGSelect (\x y -> (x ++ y))) (GNone []) . fmap (fmap (:[]))+
+ src/Language/Fixpoint/Solver/GradualSolve.hs view
@@ -0,0 +1,319 @@+{-# LANGUAGE PatternGuards     #-}+{-# LANGUAGE TupleSections     #-}+{-# LANGUAGE FlexibleContexts  #-}+{-# LANGUAGE OverloadedStrings #-}++--------------------------------------------------------------------------------+-- | Solve a system of horn-clause constraints ---------------------------------+--------------------------------------------------------------------------------++module Language.Fixpoint.Solver.GradualSolve (solveGradual) where++import           Control.Monad (when, filterM, foldM)+import           Control.Monad.State.Strict (lift)+import           Language.Fixpoint.Misc+import qualified Language.Fixpoint.Types           as F+import qualified Language.Fixpoint.Types.Solutions as Sol+import qualified Language.Fixpoint.SortCheck       as So+import           Language.Fixpoint.Types.PrettyPrint+import           Language.Fixpoint.Types.Config hiding (stats)+import qualified Language.Fixpoint.Solver.GradualSolution  as S+import qualified Language.Fixpoint.Solver.Worklist  as W+import qualified Language.Fixpoint.Solver.Eliminate as E+import           Language.Fixpoint.Solver.Monad+import           Language.Fixpoint.Utils.Progress+import           Language.Fixpoint.Graph+import           Text.PrettyPrint.HughesPJ+import           Text.Printf+import           System.Console.CmdArgs.Verbosity (whenNormal, whenLoud)+import           Control.DeepSeq+import qualified Data.HashMap.Strict as M+import qualified Data.HashSet        as S++--------------------------------------------------------------------------------+-- | Progress Bar+--------------------------------------------------------------------------------+withProgressFI :: SolverInfo a b -> IO b -> IO b+withProgressFI = withProgress . fromIntegral . cNumScc . siDeps+--------------------------------------------------------------------------------++printStats :: F.SInfo a ->  W.Worklist a -> Stats -> IO ()+printStats fi w s = putStrLn "\n" >> ppTs [ ptable fi, ptable s, ptable w ]+  where+    ppTs          = putStrLn . showpp . mconcat++--------------------------------------------------------------------------------+solverInfo :: Config -> F.SInfo a -> SolverInfo a b+--------------------------------------------------------------------------------+solverInfo cfg fI+  | useElim cfg = E.solverInfo cfg fI+  | otherwise   = SI mempty fI cD (siKvars fI)+  where+    cD          = elimDeps fI (kvEdges fI) mempty++siKvars :: F.SInfo a -> S.HashSet F.KVar+siKvars = S.fromList . M.keys . F.ws+++--------------------------------------------------------------------------------+-- | tidyResult ensures we replace the temporary kVarArg names introduced to+--   ensure uniqueness with the original names in the given WF constraints.+--------------------------------------------------------------------------------+tidyResult :: F.Result a -> F.Result a+tidyResult r = r { F.resSolution  =  tidySolution  (F.resSolution r)+                 , F.gresSolution =  gtidySolution (F.gresSolution r) +                 }++tidySolution :: F.FixSolution -> F.FixSolution+tidySolution = fmap tidyPred++gtidySolution :: F.GFixSolution -> F.GFixSolution+gtidySolution = fmap tidyPred --  (\(e, es) -> (tidyPred e, tidyPred <$> es))++tidyPred :: F.Expr -> F.Expr+tidyPred = F.substf (F.eVar . F.tidySymbol)+++predKs :: F.Expr -> [(F.KVar, F.Subst)]+predKs (F.PAnd ps)    = concatMap predKs ps+predKs (F.PKVar k su) = [(k, su)]+predKs _              = []++++--------------------------------------------------------------------------------+minimizeResult :: Config -> M.HashMap F.KVar F.Expr+               -> SolveM (M.HashMap F.KVar F.Expr)+--------------------------------------------------------------------------------+minimizeResult cfg s+  | minimalSol cfg = mapM minimizeConjuncts s+  | otherwise      = return s++minimizeConjuncts :: F.Expr -> SolveM F.Expr+minimizeConjuncts p = F.pAnd <$> go (F.conjuncts p) []+  where+    go []     acc   = return acc+    go (p:ps) acc   = do b <- isValid (F.pAnd (acc ++ ps)) p+                         if b then go ps acc+                              else go ps (p:acc)++++showUnsat :: Bool -> Integer -> F.Pred -> F.Pred -> IO ()+showUnsat u i lP rP = {- when u $ -} do+  putStrLn $ printf   "UNSAT id %s %s" (show i) (show u)+  putStrLn $ showpp $ "LHS:" <+> pprint lP+  putStrLn $ showpp $ "RHS:" <+> pprint rP++--------------------------------------------------------------------------------+-- | Predicate corresponding to RHS of constraint in current solution+--------------------------------------------------------------------------------+rhsPred :: F.SimpC a -> F.Expr+--------------------------------------------------------------------------------+rhsPred c+  | isTarget c = F.crhs c+  | otherwise  = errorstar $ "rhsPred on non-target: " ++ show (F.sid c)++isValid :: F.Expr -> F.Expr -> SolveM Bool+isValid p q = (not . null) <$> filterValid p [(q, ())]+++-------------------------------------------------------------------------------+-- | solve with edits to allow Gradual types ----------------------------------+-------------------------------------------------------------------------------++solveGradual :: (NFData a, F.Fixpoint a) => Config -> F.SInfo a -> IO (F.Result (Integer, a))++solveGradual cfg fi = do+    (res, stat) <- withProgressFI sI $ runSolverM cfg sI n act+    when (solverStats cfg) $ printStats fi wkl stat+    return res+  where+    act  = solveGradual_ cfg fi s0 ks  wkl+    sI   = solverInfo cfg fi+    wkl  = W.init sI+    n    = fromIntegral $ W.wRanks wkl+    s0   = siSol  sI+    ks   = siVars sI++--------------------------------------------------------------------------------+solveGradual_ :: (NFData a, F.Fixpoint a)+       => Config+       -> F.SInfo a+       -> Sol.GSolution +       -> S.HashSet F.KVar+       -> W.Worklist a+       -> SolveM (F.Result (Integer, a), Stats)+--------------------------------------------------------------------------------+solveGradual_ cfg fi s0 ks wkl = do+  let s1  = mappend s0 $ {-# SCC "sol-init" #-} S.init cfg fi ks+  s2      <- {-# SCC "sol-local"  #-} filterLocal s1+  s       <- {-# SCC "sol-refine" #-} refine s2 wkl+  res     <- {-# SCC "sol-result" #-} result cfg wkl s+  st      <- stats+  let res' = {-# SCC "sol-tidy"   #-} tidyResult res+  return $!! (res', st)++filterLocal :: Sol.GSolution -> SolveM Sol.GSolution +filterLocal sol = do +  gs' <- mapM (initGBind sol) gs +  return $ Sol.updateGMap sol $ M.fromList gs'+  where +    gs = M.toList $ Sol.gMap sol ++initGBind :: Sol.GSolution -> (F.KVar, (((F.Symbol, F.Sort), F.Expr), Sol.GBind)) -> SolveM (F.KVar, (((F.Symbol, F.Sort), F.Expr), Sol.GBind))+initGBind sol (k, (e, gb)) = do  +   elems0  <- filterM (isLocal e) (Sol.gbEquals gb)+   elems   <- sortEquals elems0 +   lattice <- makeLattice [] (map (:[]) elems) elems+   return $ ((k,) . (e,) . Sol.equalsGb) lattice+  where+    makeLattice acc new elems+      | null new+      = return acc +      | otherwise+      = do let cands = [e:es |e<-elems, es<-new]+           localCans <- filterM (isLocal e) cands+           newElems  <- filterM (notTrivial (new ++ acc)) localCans +           makeLattice (acc ++ new) newElems elems++    notTrivial [] _     = return True +    notTrivial (x:xs) p = do v <- isValid (mkPred x) (mkPred p)+                             if v then return False +                                  else notTrivial xs p ++    mkPred eq = So.elaborate "initBGind.mkPred" (Sol.sEnv sol) (F.pAnd (Sol.eqPred <$> eq))+    isLocal (v, e) eqs = do +      let pp = So.elaborate "filterLocal" (Sol.sEnv sol) $ F.PExist [v] $ F.pAnd (e:(Sol.eqPred <$> eqs)) +      isValid mempty pp++    root      = Sol.trueEqual+    sortEquals xs = (bfs [0]) <$> makeEdges vs [] vs +      where +       vs        = zip [0..] (root:(head <$> xs))++       bfs []     _  = [] +       bfs (i:is) es = (snd $ (vs!!i)) : bfs (is++map snd (filter (\(j,k) ->  (j==i && notElem k is)) es)) es++       makeEdges _   acc []    = return acc+       makeEdges vs acc (x:xs) = do ves  <- concat <$> mapM (makeEdgesOne x) vs+                                    if any (\(i,j) -> elem (j,i) acc) ves +                                      then makeEdges (filter ((/= fst x) . fst) vs) (filter (\(i,j) -> ((i /= fst x) && (j /= fst x))) acc) xs +                                      else makeEdges vs (mergeEdges (ves ++ acc)) xs ++    makeEdgesOne (i,_) (j,_) | i == j = return [] +    makeEdgesOne (i,x) (j,y) = do +      ij <- isValid (mkPred [x]) (mkPred [y])+      return (if ij then [(j,i)] else [])++    mergeEdges es = filter (\(i,j) -> (not (any (\k -> ((i,k) `elem` es && (k,j) `elem` es)) (fst <$> es)))) es+++--------------------------------------------------------------------------------+refine :: Sol.GSolution -> W.Worklist a -> SolveM Sol.GSolution+--------------------------------------------------------------------------------+refine s w+  | Just (c, w', newScc, rnk) <- W.pop w = do+     i       <- tickIter newScc+     (b, s') <- refineC i s c+     lift $ writeLoud $ refineMsg i c b rnk+     let w'' = if b then W.push c w' else w'+     refine s' w''+  | otherwise = return s+  where+    -- DEBUG+    refineMsg i c b rnk = printf "\niter=%d id=%d change=%s rank=%d\n"+                            i (F.subcId c) (show b) rnk++---------------------------------------------------------------------------+-- | Single Step Refinement -----------------------------------------------+---------------------------------------------------------------------------+refineC :: Int -> Sol.GSolution -> F.SimpC a -> SolveM (Bool, Sol.GSolution)+---------------------------------------------------------------------------+refineC _i s c+  | null rhs  = return (False, s)+  | otherwise = do be      <- getBinds+                   let lhss = snd <$> S.lhsPred be s c+                   kqs     <- filterValidGradual lhss rhs+                   return   $ S.update s ks kqs+  where+    _ci       = F.subcId c+    (ks, rhs) = rhsCands s c+    -- msg       = printf "refineC: iter = %d, sid = %s, soln = \n%s\n"+    --               _i (show (F.sid c)) (showpp s)+    _msg ks xs ys = printf "refineC: iter = %d, sid = %s, s = %s, rhs = %d, rhs' = %d \n"+                     _i (show _ci) (showpp ks) (length xs) (length ys)+++rhsCands :: Sol.GSolution -> F.SimpC a -> ([F.KVar], Sol.Cand (F.KVar, Sol.EQual))+rhsCands s c    = (fst <$> ks, kqs)+  where+    kqs         = [ (p, (k, q)) | (k, su) <- ks, (p, q)  <- cnd k su ]+    ks          = predKs . F.crhs $ c+    cnd k su    = Sol.qbPreds msg s su (Sol.lookupQBind s k)+    msg         = "rhsCands: " ++ show (F.sid c)++--------------------------------------------------------------------------------+-- | Gradual Convert Solution into Result ----------------------------------------------+--------------------------------------------------------------------------------+result :: (F.Fixpoint a) => Config -> W.Worklist a -> Sol.GSolution+       -> SolveM (F.Result (Integer, a))+--------------------------------------------------------------------------------+result cfg wkl s = do+  lift $ writeLoud "Computing Result"+  stat    <- result_ wkl s +  lift $ whenNormal $ putStrLn $ "RESULT: " ++ show (F.sid <$> stat)+  F.Result (ci <$> stat) <$> solResult cfg s <*> solResultGradual wkl cfg s +  where+    ci c = (F.subcId c, F.sinfo c)++result_ :: Fixpoint a =>  W.Worklist a -> Sol.GSolution -> SolveM (F.FixResult (F.SimpC a))+result_  w s = res <$> filterM (isUnsat s) cs+  where+    cs       = W.unsatCandidates w+    res []   = F.Safe+    res cs'  = F.Unsafe cs'++solResult :: Config -> Sol.GSolution -> SolveM (M.HashMap F.KVar F.Expr)+solResult cfg+  = minimizeResult cfg . Sol.result+++solResultGradual :: W.Worklist a -> Config -> Sol.GSolution -> SolveM F.GFixSolution+solResultGradual w _cfg sol +  = F.toGFixSol . Sol.resultGradual <$> updateGradualSolution (W.unsatCandidates w) sol++--------------------------------------------------------------------------------+updateGradualSolution :: [F.SimpC a] -> Sol.GSolution -> SolveM (Sol.GSolution)+--------------------------------------------------------------------------------+updateGradualSolution cs sol = foldM f (Sol.emptyGMap sol) cs+  where+   f s c = do+    be <- getBinds+    let lpi = S.lhsPred be sol c +    let rp  = rhsPred c +    gbs    <- firstValid rp lpi +    return $ Sol.updateGMapWithKey gbs s +++firstValid :: Monoid a =>  F.Expr -> [(a, F.Expr)] -> SolveM a +firstValid _   [] = return mempty +firstValid rhs ((y,lhs):xs) = do+  v <- isValid lhs rhs+  if v then return y else firstValid rhs xs +++--------------------------------------------------------------------------------+isUnsat :: Fixpoint a => Sol.GSolution -> F.SimpC a -> SolveM Bool+--------------------------------------------------------------------------------+isUnsat s c = do+  -- lift   $ printf "isUnsat %s" (show (F.subcId c))+  _     <- tickIter True -- newScc+  be    <- getBinds+  let lpi = S.lhsPred be s c+  let rp = rhsPred        c+  res   <- (not . or) <$> mapM (`isValid` rp) (snd <$> lpi)+  lift   $ whenLoud $ showUnsat res (F.subcId c) (F.pOr (snd <$> lpi)) rp+  return res++
− src/Language/Fixpoint/Solver/Graph.hs
@@ -1,162 +0,0 @@-{-# LANGUAGE PartialTypeSignatures #-}-{-# LANGUAGE TupleSections         #-}-{-# LANGUAGE OverloadedStrings     #-}--module Language.Fixpoint.Solver.Graph (-       -- * Remove Constraints that don't affect Targets-         slice--       -- * Predicate describing Targets-       , isTarget--       -- * Compute Ranks / SCCs-       , graphRanks--       -- * Compute Kvar dependencies-       , cGraph, gSccs--       -- * Kvars written and read by a constraint-       , kvWriteBy, kvReadBy-       ) where----- import           Debug.Trace (trace)-import           Prelude hiding (init)-import           Language.Fixpoint.Types.Visitor (rhsKVars, envKVars, kvars, isConcC)-import           Language.Fixpoint.Misc (errorstar, fst3, sortNub, group)-import qualified Language.Fixpoint.Types   as F-import           Language.Fixpoint.Solver.Types-import qualified Data.HashMap.Strict       as M-import qualified Data.List                 as L-import           Data.Maybe (fromMaybe)-import qualified Data.HashSet as S-import           Data.Graph (transposeG, graphFromEdges, dfs, scc, Graph, Vertex)-import           Data.Tree (flatten)-------------------------------------------------------------------------------- | Compute constraints that transitively affect target constraints,---   and delete everything else from F.SInfo a-----------------------------------------------------------------------------slice :: (F.TaggedC c a) => F.GInfo c a -> F.GInfo c a-----------------------------------------------------------------------------slice fi = fi { F.cm = cm'-              , F.ws = ws' }-  where-     cm' = M.filterWithKey inC (F.cm fi)-     ws' = M.filterWithKey inW (F.ws fi)-     ks  = sliceKVars fi sl-     is  = S.fromList (slKVarCs sl ++ slConcCs sl)-     sl  = mkSlice fi-     inC i _ = S.member i is-     inW k _ = S.member k ks--sliceKVars :: (F.TaggedC c a) => F.GInfo c a -> Slice -> S.HashSet F.KVar-sliceKVars fi sl = S.fromList $ concatMap (subcKVars be) cs-  where-    cs           = lookupCMap cm <$> slKVarCs sl ++ slConcCs sl-    be           = F.bs fi-    cm           = F.cm fi--subcKVars :: (F.TaggedC c a) => F.BindEnv -> c a -> [F.KVar]-subcKVars be c = envKVars be c ++ rhsKVars c------------------------------------------------------------------------------mkSlice :: (F.TaggedC c a) => F.GInfo c a -> Slice-----------------------------------------------------------------------------mkSlice fi        = mkSlice_ (F.cm fi) g' es v2i i2v-  where-    g'            = transposeG g  -- "inverse" of g (reverse the dep-edges)-    (g, vf, cf)   = graphFromEdges es-    es            = gEdges $ cGraph fi-    v2i           = fst3 . vf-    i2v i         = fromMaybe (errU i) $ cf i-    errU i        = errorstar $ "graphSlice: nknown constraint " ++ show i---mkSlice_ cm g' es v2i i2v = Slice { slKVarCs = kvarCs-                                  , slConcCs = concCs-                                  , slEdges  = sliceEdges kvarCs es-                                  }-  where-    -- n                  = length kvarCs-    concCs             = [ i | (i, c) <- M.toList cm, isTarget c ]-    kvarCs             = v2i <$> reachVs-    rootVs             = i2v <$> concCs-    reachVs            = concatMap flatten $ dfs g' rootVs--sliceEdges :: [CId] -> [DepEdge] -> [DepEdge]-sliceEdges is es = [ (i, i, filter inSlice js) | (i, _, js) <- es, inSlice i ]-  where-    inSlice i    = M.member i im-    im           = M.fromList $ (, ()) <$> is---- | DO NOT DELETE!--- sliceCSucc :: Slice -> CSucc--- sliceCSucc sl = \i -> M.lookupDefault [] i im-  -- where-    -- im        = M.fromList [(i, is) | (i,_,is) <- slEdges sl]-------------------------------------------------------------------------------- | Dependencies --------------------------------------------------------------------------------------------------------------------------------------kvSucc :: (F.TaggedC c a) => F.GInfo c a -> CSucc-----------------------------------------------------------------------------kvSucc fi = succs cm rdBy-  where-    rdBy  = kvReadBy fi-    cm    = F.cm     fi--succs :: (F.TaggedC c a) => CMap (c a) -> KVRead -> CSucc-succs cm rdBy i = sortNub $ concatMap kvReads iKs-  where-    iKs         = kvWriteBy cm i-    kvReads k   = M.lookupDefault [] k rdBy------------------------------------------------------------------------------kvWriteBy :: (F.TaggedC c a) => CMap (c a) -> CId -> [F.KVar]-----------------------------------------------------------------------------kvWriteBy cm = kvars . F.crhs . lookupCMap cm------------------------------------------------------------------------------kvReadBy :: (F.TaggedC c a) => F.GInfo c a -> KVRead-----------------------------------------------------------------------------kvReadBy fi = group [ (k, i) | (i, ci) <- M.toList cm-                             , k       <- envKVars bs ci]-  where-    cm      = F.cm fi-    bs      = F.bs fi------------------------------------------------------------------------------isTarget :: (F.TaggedC c a) => c a -> Bool-----------------------------------------------------------------------------isTarget c   = isConcC c && isNonTriv c-  where-   isNonTriv = not .  F.isTautoPred . F.crhs--------------------------------------------------------------------------------- | Constraint Graph ----------------------------------------------------------------------------------------------------------------------------------cGraph :: (F.TaggedC c a) => F.GInfo c a -> CGraph-----------------------------------------------------------------------------cGraph fi = CGraph { gEdges = es-                   , gRanks = outRs-                   , gSucc  = next-                   , gSccs  = length sccs }-  where-    es             = [(i, i, next i) | i <- M.keys $ F.cm fi]-    next           = kvSucc fi-    (g, vf, _)     = graphFromEdges es-    (outRs, sccs)  = graphRanks g vf-------------------------------------------------------------------------------- | Ranks from Graph ----------------------------------------------------------------------------------------------------------------------------------graphRanks :: Graph -> (Vertex -> DepEdge) -> (CMap Int, [[Vertex]])-----------------------------------------------------------------------------graphRanks g vf = (M.fromList irs, sccs)-  where-    irs        = [(v2i v, r) | (r, vs) <- rvss, v <- vs ]-    rvss       = zip [0..] sccs-    sccs       = L.reverse $ map flatten $ scc g-    v2i        = fst3 . vf
+ src/Language/Fixpoint/Solver/Instantiate.hs view
@@ -0,0 +1,533 @@+{-# LANGUAGE OverloadedStrings         #-}+{-# LANGUAGE PartialTypeSignatures     #-}+{-# LANGUAGE TupleSections             #-}+{-# LANGUAGE BangPatterns              #-}+{-# LANGUAGE FlexibleInstances         #-}+{-# LANGUAGE ViewPatterns              #-}+{-# LANGUAGE PatternGuards             #-}+{-# LANGUAGE ExistentialQuantification #-}++--------------------------------------------------------------------------------+-- | Axiom Instantiation  ------------------------------------------------------+--------------------------------------------------------------------------------++module Language.Fixpoint.Solver.Instantiate (++  instantiateAxioms,+  instantiateFInfo,++  ) where++import           Language.Fixpoint.Types+import           Language.Fixpoint.Types.Config as FC+import qualified Language.Fixpoint.Smt.Theories as FT+import           Language.Fixpoint.Types.Visitor (eapps, kvars, mapMExpr)+import           Language.Fixpoint.Misc          (mapFst)++import Language.Fixpoint.Smt.Interface          ( smtPop, smtPush+                                                , smtDecls, smtAssert+                                                , checkValid', Context(..) )+import Language.Fixpoint.Defunctionalize        (defuncAny, makeLamArg)+import Language.Fixpoint.SortCheck              (elaborate)++import Control.Monad.State++-- AT: I've inlined this, but we should have a more elegant solution+--     (track predicates instead of selectors!)+-- import           Language.Haskell.Liquid.GHC.Misc (dropModuleNames)+import qualified Data.Text            as T+import qualified Data.HashMap.Strict  as M+import qualified Data.List            as L+import           Data.Maybe           (catMaybes, fromMaybe)+import           Data.Char            (isUpper)+import           Data.Foldable        (foldlM)+-- import           Data.Monoid          ((<>))++(~>) :: (Expr, String) -> Expr -> EvalST Expr+(_e,_str) ~> e' = do+    modify (\st -> st{evId = evId st + 1})+    -- traceM $ showpp _str ++ " : " ++ showpp _e ++ showpp e'+    return (η e')++---------------------+-- Instantiate Axioms+---------------------+instantiateFInfo :: Config -> Context -> FInfo c -> IO (FInfo c)+instantiateFInfo cfg ctx fi = do+    cm' <- sequence $ M.mapWithKey instantiateOne (cm fi)+    return $ fi { cm = cm' }+  where instantiateOne = instantiateAxioms cfg ctx (bs fi) (gLits fi) (ae fi)++instantiateAxioms :: Config -> Context -> BindEnv -> SEnv Sort -> AxiomEnv+                     -> Integer -> SubC c+                     -> IO (SubC c)+instantiateAxioms _ _ _ _ aenv sid sub+  | not (M.lookupDefault False sid (aenvExpand aenv))+  = return sub+instantiateAxioms cfg ctx bds fenv aenv sid sub+  = flip strengthenLhs sub . pAnd . (is0 ++) .+    (if arithmeticAxioms cfg then (is ++) else id) <$>+    if rewriteAxioms cfg then evalEqs else return []+  where+    is0              = eqBody <$> L.filter (null . eqArgs) eqs+    is               = instances maxNumber aenv initOccurences+    evalEqs          =+       map (uncurry (PAtom Eq)) .+       filter (uncurry (/=)) <$>+       evaluate cfg ctx ((vv Nothing, slhs sub):binds) fenv aenv initExpressions+    initExpressions  = expr (slhs sub) : expr (srhs sub) : (expr <$> binds)+    binds            = envCs bds (senv sub)+    initOccurences   = concatMap (makeInitOccurences as eqs) initExpressions++    eqs = aenvEqs aenv++    -- fuel calculated and used only by `instances` arith rewrite method+    fuelNumber = M.lookupDefault 0 sid (aenvFuel aenv)+    as         = (,fuelNumber) . eqName <$> filter (not . null . eqArgs) eqs+    maxNumber  = (length (aenvSyms aenv) * length initOccurences) ^ fuelNumber+++------------------------------+-- Knowledge (SMT Interaction)+------------------------------+-- AT:@TODO: knSels and knEqs should reall just be the same thing. In this way,+-- we should also unify knSims and knAms, as well as their analogues in AxiomEnv+data Knowledge+  = KN { knSels    :: ![(Expr, Expr)]+       , knEqs     :: ![(Expr, Expr)]+       , knSims    :: ![Rewrite]+       , knAms     :: ![Equation]+       , knContext :: IO Context+       , knPreds   :: !([(Symbol, Sort)] -> Expr -> Context -> IO Bool)+       , knLams    :: [(Symbol, Sort)]+       }++emptyKnowledge :: IO Context -> Knowledge+emptyKnowledge cxt = KN [] [] [] [] cxt (\_ _ _ -> return False) []++lookupKnowledge :: Knowledge -> Expr -> Maybe Expr+lookupKnowledge γ e+  -- Zero argument axioms like `mempty = N`+  | Just e' <- L.lookup e (knEqs γ)+  = Just e'+  | Just e' <- L.lookup e (knSels γ)+  = Just e'+  | otherwise+  = Nothing++isValid :: Knowledge -> Expr -> IO Bool+isValid γ b = knPreds γ (knLams γ) b =<< knContext γ++makeKnowledge :: Config -> Context -> AxiomEnv -> SEnv Sort+                 -> [(Symbol, SortedReft)]+                 -> ([(Expr, Expr)], Knowledge)+makeKnowledge cfg ctx aenv fenv es = (simpleEqs,) $ (emptyKnowledge context)+                                     { knSels   = sels+                                     , knEqs    = eqs+                                     , knSims   = aenvSimpl aenv+                                     , knAms    = aenvEqs aenv+                                     , knPreds  = \bs e c -> askSMT c bs e+                                     }+  where+    (xv, sv) = (vv Nothing, sr_sort $ snd $ head es)+    fbinds = toListSEnv fenv ++ [(x, s) | (x, RR s _) <- es]+    senv = fromListSEnv fbinds++    context :: IO Context+    context = do+      smtPop ctx+      smtPush ctx+      smtDecls ctx $ L.nub [(x, toSMT [] s) | (x, s) <- fbinds+                                            , not (M.member x FT.theorySymbols)]+      smtAssert ctx (pAnd ([toSMT [] (PAtom Eq e1 e2) | (e1, e2) <- simpleEqs]+                           ++ filter (null.kvars) ((toSMT [] . expr) <$> es)+                          ))+      return ctx++    -- This creates the rewrite rule e1 -> e2+    -- when should I apply it?+    -- 1. when e2 is a data con and can lead to further reductions+    -- 2. when size e2 < size e1+    -- @TODO: Can this be generalized?+    atms = splitPAnd =<< (expr <$> filter isProof es)+    simpleEqs = makeSimplifications (aenvSimpl aenv) =<<+                L.nub (catMaybes [getDCEquality e1 e2 | PAtom Eq e1 e2 <- atms])+    sels = (go . expr) =<< es+    go e = let es   = splitPAnd e+               su   = mkSubst [(x, EVar y)  | PAtom Eq (EVar x) (EVar y) <- es ]+               sels = [(EApp (EVar s) x, e) | PAtom Eq (EApp (EVar s) x) e <- es+                                            , isSelector s ]+           in L.nub (sels ++ subst su sels)++    eqs = [(EVar x, ex) | Equ a _ bd <- filter (null . eqArgs) $ aenvEqs aenv+                        , PAtom Eq (EVar x) ex <- splitPAnd bd+                        , x == a+                        -- AT: no test needs this+                        --, EVar x /= ex+                        ]++    toSMT xs = defuncAny cfg (insertSEnv xv sv senv) .+               elaborate "symbolic evaluation"+               (foldl (\env (x,s) -> insertSEnv x s (deleteSEnv x env))+                      (insertSEnv xv sv senv)+                      xs)++    -- AT: Non-obvious needed invariant: askSMT True is always the+    -- totality-effecting one+    askSMT :: Context -> [(Symbol, Sort)] -> Expr -> IO Bool+    askSMT cxt xss e+      | isTautoPred  e = return True+      | isContraPred e = return False+      | null (kvars e) = do+          smtPush cxt+          b <- checkValid' cxt [] PTrue (toSMT xss e)+          smtPop cxt+          return b+      | otherwise      = return False++    -- TODO: Stringy hacks+    isSelector :: Symbol -> Bool+    isSelector  = L.isPrefixOf "select" . symbolString+    isProof (_, RR s _) =  showpp s == "Tuple"+++makeSimplifications :: [Rewrite] -> (Symbol, [Expr], Expr) -> [(Expr, Expr)]+makeSimplifications sis (dc, es, e)+ = go =<< sis+ where+   go (SMeasure f dc' xs bd)+     | dc == dc', length xs == length es+     = [(EApp (EVar f) e, subst (mkSubst $ zip xs es) bd)]+   go _+     = []++getDCEquality :: Expr -> Expr -> Maybe (Symbol, [Expr], Expr)+getDCEquality e1 e2+    | Just dc1 <- f1+    , Just dc2 <- f2+    = if dc1 == dc2+         then Nothing+         else error ("isDCEquality on" ++ showpp e1 ++ "\n" ++ showpp e2)+    | Just dc1 <- f1+    = Just (dc1, es1, e2)+    | Just dc2 <- f2+    = Just (dc2, es2, e1)+    | otherwise+    = Nothing+  where+    (f1, es1) = mapFst getDC $ splitEApp e1+    (f2, es2) = mapFst getDC $ splitEApp e2++    -- TODO: Stringy hacks+    getDC (EVar x)+      = if isUpper $ head $ symbolString $ dropModuleNames x+           then Just x+           else Nothing+    getDC _+      = Nothing++    dropModuleNames = mungeNames (symbol . last) "."++    mungeNames _ _ ""  = ""+    mungeNames f d s'@(symbolText -> s)+      | s' == tupConName = tupConName+      | otherwise        = f $ T.splitOn d $ stripParens s++    stripParens t = fromMaybe t ((T.stripPrefix "(" >=> T.stripSuffix ")") t)++splitPAnd :: Expr -> [Expr]+splitPAnd (PAnd es) = concatMap splitPAnd es+splitPAnd e         = [e]++------------------------+-- Creating Measure Info+------------------------+-- AT@TODO do this for all reflected functions, not just DataCons++-- Insert measure info for every constructor+-- that appears in the expression e+-- required by PMEquivalence.mconcatChunk+assertSelectors :: Knowledge -> Expr -> EvalST ()+assertSelectors γ e = do+   EvalEnv _ _ evaenv <- get+   let sims = aenvSimpl evaenv+   _ <- foldlM (\_ s -> mapMExpr (go s) e) e sims+   return ()+  where+    go :: Rewrite -> Expr -> EvalST Expr+    go (SMeasure f dc xs bd) e@(EApp _ _)+      | (EVar dc', es) <- splitEApp e+      , dc == dc', length xs == length es+      = addSMTEquality γ (EApp (EVar f) e) (subst (mkSubst $ zip xs es) bd)+      >> return e+    go _ e+      = return e++addSMTEquality :: Knowledge -> Expr -> Expr -> EvalST (IO ())+addSMTEquality γ e1 e2 =+  return $ do ctx <- knContext γ+              smtAssert ctx (PAtom Eq (makeLam γ e1) (makeLam γ e2))++-------------------------------+-- Symbolic Evaluation with SMT+-------------------------------+data EvalEnv = EvalEnv { evId        :: Int+                       , evSequence  :: [(Expr,Expr)]+                       , _evAEnv     :: AxiomEnv+                       }++type EvalST a = StateT EvalEnv IO a++evaluate :: Config -> Context -> [(Symbol, SortedReft)] -> SEnv Sort -> AxiomEnv+            -> [Expr]+            -> IO [(Expr, Expr)]+evaluate cfg ctx facts fenv aenv einit+  = (eqs ++) <$>+    (fmap join . sequence)+    (evalOne <$> L.nub (grepTopApps =<< einit))+  where+    (eqs, γ) = makeKnowledge cfg ctx aenv fenv facts+    initEvalSt = EvalEnv 0 [] aenv+    -- This adds all intermediate unfoldings into the assumptions+    -- no test needs it+    -- TODO: add a flag to enable it+    evalOne :: Expr -> IO [(Expr, Expr)]+    evalOne e = do+      (e', st) <- runStateT (eval γ e) initEvalSt+      if e' == e then return [] else return ((e, e'):evSequence st)++grepTopApps :: Expr -> [Expr]+grepTopApps (PAnd es) = concatMap grepTopApps es+grepTopApps (PAtom _ e1 e2) = grepTopApps e1 ++ grepTopApps e2+grepTopApps e@(EApp _ _) = [e]+grepTopApps _ = []+-- POr    ![Expr]+-- PNot   !Expr+-- PImp   !Expr !Expr+-- PIff   !Expr !Expr++-- AT: I think makeLam is the adjoint of splitEApp?+makeLam :: Knowledge -> Expr -> Expr+makeLam γ e = foldl (flip ELam) e (knLams γ)++eval :: Knowledge -> Expr -> EvalST Expr+eval γ e | Just e' <- lookupKnowledge γ e+   = (e, "Knowledge") ~> e'+eval γ (ELam (x,s) e)+  = do let x' = makeLamArg s (1+ length (knLams γ))+       e'    <- eval γ{knLams = (x',s):knLams γ} (subst1 e (x, EVar x'))+       return $ ELam (x,s) $ subst1 e' (x', EVar x)+eval γ e@(EIte b e1 e2)+  = do b' <- eval γ b+       evalIte γ e b' e1 e2+eval γ e@(EApp _ _)+  = evalArgs γ e >>= evalApp γ e+eval γ (PAtom r e1 e2)+  = PAtom r <$> eval γ e1 <*> eval γ e2+eval γ (ENeg e)+  = ENeg <$> eval γ e+eval γ (EBin o e1 e2)+  = EBin o <$> eval γ e1 <*> eval γ e2+eval γ (ETApp e t)+  = flip ETApp t <$> eval γ e+eval γ (ETAbs e s)+  = flip ETAbs s <$> eval γ e+eval γ (PNot e)+  = PNot <$> eval γ e+eval γ (PImp e1 e2)+  = PImp <$> eval γ e1 <*> eval γ e2+eval γ (PIff e1 e2)+  = PIff <$> eval γ e1 <*> eval γ e2+eval _ e = return e++evalArgs :: Knowledge -> Expr -> EvalST (Expr, [Expr])+evalArgs γ = go []+  where+    go acc (EApp f e)+      = do f' <- eval γ f+           e' <- eval γ e+           go (e':acc) f'+    go acc e+      = (,acc) <$> eval γ e++evalApp :: Knowledge -> Expr -> (Expr, [Expr]) -> EvalST Expr+evalApp γ e (EVar f, [ex])+  | (EVar dc, es) <- splitEApp ex+  , Just simp <- L.find (\simp -> (smName simp == f) && (smDC simp == dc))+                        (knSims γ)+  , length (smArgs simp) == length es+  = do e'    <- eval γ $ η $ substPopIf (zip (smArgs simp) es) (smBody simp)+       (e, "Rewrite -" ++ showpp f) ~> e'+evalApp γ _ (EVar f, es)+  | Just eq <- L.find ((==f) . eqName) (knAms γ)+  , Just bd <- getEqBody eq+  , length (eqArgs eq) == length es+  , f `notElem` syms bd -- not recursive+  = eval γ $ η $ substPopIf (zip (eqArgs eq) es) bd+evalApp γ _e (EVar f, es)+  | Just eq <- L.find ((==f) . eqName) (knAms γ)+  , Just bd <- getEqBody eq+  , length (eqArgs eq) == length es  --  recursive+  = evalRecApplication γ (eApps (EVar f) es) $+    subst (mkSubst $ zip (eqArgs eq) es) bd+evalApp _ _ (f, es)+  = return $ eApps f es++substPopIf :: [(Symbol, Expr)] -> Expr -> Expr+substPopIf xes e = η $ foldl go e xes+  where+    go e (x, EIte b e1 e2) = EIte b (subst1 e (x, e1)) (subst1 e (x, e2))+    go e (x, ex)           = subst1 e (x, ex)++evalRecApplication :: Knowledge ->  Expr -> Expr -> EvalST Expr+evalRecApplication γ e (EIte b e1 e2)+  = do b' <- eval γ b+       b'' <- liftIO (isValid γ b')+       if b''+          then addApplicationEq γ e e1 >>+               assertSelectors γ e1 >>+               eval γ e1 >>=+               ((e, "App") ~>)+          else do b''' <- liftIO (isValid γ (PNot b'))+                  if b'''+                     then addApplicationEq γ e e2 >>+                          assertSelectors γ e2 >>+                          eval γ e2 >>=+                          ((e, "App") ~>)+                     else return e+evalRecApplication _ _ e+  = return e++addApplicationEq :: Knowledge -> Expr -> Expr -> EvalST ()+addApplicationEq γ e1 e2 =+  modify (\st -> st{evSequence = (makeLam γ e1, makeLam γ e2):evSequence st})++evalIte :: Knowledge -> Expr -> Expr -> Expr -> Expr -> EvalST Expr+evalIte γ e b e1 e2 = join $+                      evalIte' γ e b e1 e2 <$>+                      liftIO (isValid γ b) <*>+                      liftIO (isValid γ (PNot b))++evalIte' :: Knowledge -> Expr -> Expr -> Expr -> Expr -> Bool -> Bool+            -> EvalST Expr+evalIte' γ e _ e1 _ b _+  | b+  = do e' <- eval γ e1+       (e, "If-True of:" ++ showpp b)  ~> e'+evalIte' γ e _ _ e2 _ b'+  | b'+  = do e' <- eval γ e2+       (e, "If-False") ~> e'+evalIte' γ _ b e1 e2 _ _+  = do e1' <- eval γ e1+       e2' <- eval γ e2+       return $ EIte b e1' e2'++-- normalization required by ApplicativeMaybe.composition+---------------------------------------------------------+η :: Expr -> Expr+η = snd . go+  where+    go (EIte b t f)+      | isTautoPred t && isFalse f+      = (True, b)+    go (EIte b e1 e2)+      = let (fb, b') = go b+            (f1, e1') = go e1+            (f2, e2') = go e2+            in+        (fb || f1 || f2, EIte b' e1' e2')+    go (EApp (EIte b f1 f2) e)+      = (True, EIte b (snd $ go $ EApp f1 e) (snd $ go $ EApp f2 e))+    go (EApp f (EIte b e1 e2))+      = (True, EIte b (snd $ go $ EApp f e1) (snd $ go $ EApp f e2))+    go (EApp e1 e2)+      = let (f1, e1') = go e1+            (f2, e2') = go e2+            in+        if f1 || f2+              then go $ EApp e1' e2'+              else (False, EApp e1' e2')+    go e = (False, e)+++-- Fuel+-------+type Fuel = Int+type FuelMap = [(Symbol, Fuel)]++goodFuelMap :: FuelMap -> Bool+goodFuelMap = any ((>0) . snd)++hasFuel :: FuelMap -> Symbol -> Bool+hasFuel fm x = maybe True (\x -> 0 < x) (L.lookup x fm)++makeFuelMap :: (Fuel -> Fuel) -> FuelMap -> Symbol -> FuelMap+makeFuelMap f ((x, fx):fs) y+  | x == y    = (x, f fx) : fs+  | otherwise = (x, fx)   : makeFuelMap f fs y+makeFuelMap _ _ _ = error "makeFuelMap"++----------------------------+-- Naive evaluation strategy+----------------------------+data Occurence = Occ {_ofun :: Symbol, _oargs :: [Expr], ofuel :: FuelMap}+ deriving (Show)++instances :: Int -> AxiomEnv -> [Occurence] -> [Expr]+instances maxIs aenv !occs+  = instancesLoop aenv maxIs eqs occs -- (eqBody <$> eqsZero) ++ is+  where+    eqs = filter (not . null . eqArgs) (aenvEqs  aenv)++-- Naively: Instantiation happens arbitrary times (in recursive functions it+-- diverges)+-- Step 1 [done] : Hack it so that instantiation of axiom A happens from an+-- occurences and its subsequent instances <= FUEL times+-- How? Hack expressions to contatin fuel info within eg Cst Step 2: Compute+-- fuel based on Ranjit's algorithm++instancesLoop :: AxiomEnv ->  Int -> [Equation] -> [Occurence] -> [Expr]+instancesLoop _ _ eqs = go 0 []+  where+    go :: Int -> [Expr] -> [Occurence] -> [Expr]+    go !i acc occs+       = let is      = concatMap (unfold eqs) occs+             newIs   = findNewEqs is acc+             newOccs = concatMap (grepOccurences eqs) newIs+             in+         if null newIs+            then acc+            else go (i + length newIs) ((fst <$> newIs) ++ acc) newOccs++findNewEqs :: [(Expr, FuelMap)] -> [Expr] -> [(Expr, FuelMap)]+findNewEqs [] _ = []+findNewEqs ((e, f):xss) es+  | e `elem` es = findNewEqs xss es+  | otherwise   = (e,f):findNewEqs xss es++makeInitOccurences :: [(Symbol, Fuel)] -> [Equation] -> Expr -> [Occurence]+makeInitOccurences xs eqs e+  = [Occ x es xs | (EVar x, es) <- splitEApp <$> eapps e+                 , Equ x' xs' _ <- eqs, x == x'+                 , length xs' == length es]++grepOccurences :: [Equation] -> (Expr, FuelMap) -> [Occurence]+grepOccurences eqs (e, fs)+  = filter (goodFuelMap . ofuel)+           [Occ x es fs | (EVar x, es) <- splitEApp <$> eapps e+                        , Equ x' xs' _ <- eqs, x == x'+                        , length xs' == length es]++unfold :: [Equation] -> Occurence -> [(Expr, FuelMap)]+unfold eqs (Occ x es fs)+  = catMaybes [if hasFuel fs x+                  then Just (subst (mkSubst $ zip  xs' es) e+                            , makeFuelMap (\x -> x-1) fs x)+                  else Nothing+              | Equ x' xs' e <- eqs+              , x == x'+              , length xs' == length es]++instance Expression (Symbol, SortedReft) where+  expr (x, RR _ (Reft (v, r))) = subst1 (expr r) (v, EVar x)
src/Language/Fixpoint/Solver/Monad.hs view
@@ -1,6 +1,5 @@ {-# LANGUAGE DeriveGeneric     #-} {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE BangPatterns      #-}  -- | This is a wrapper around IO that permits SMT queries @@ -15,8 +14,11 @@        , getBinds           -- * SMT Query+       , filterRequired        , filterValid-       , checkSat, smtEnablrmbqi+       , filterValidGradual+       , checkSat+       , smtEnablembqi           -- * Debug        , Stats@@ -29,33 +31,39 @@ import           Control.DeepSeq import           GHC.Generics import           Language.Fixpoint.Utils.Progress-import           Language.Fixpoint.Misc    (groupList)+import           Language.Fixpoint.Misc    (mapSnd, groupList) import qualified Language.Fixpoint.Types.Config  as C-import           Language.Fixpoint.Types.Config  (Config, solver, linear, SMTSolver(Z3))+import           Language.Fixpoint.Types.Config  (Config) import qualified Language.Fixpoint.Types   as F+import qualified Language.Fixpoint.Types.Solutions as F import           Language.Fixpoint.Types   (pprint)-import qualified Language.Fixpoint.Types.Errors  as E+-- import qualified Language.Fixpoint.Types.Errors  as E import qualified Language.Fixpoint.Smt.Theories as Thy-import           Language.Fixpoint.Smt.Serialize (initSMTEnv)+import           Language.Fixpoint.Smt.Types (tsInterp)+import           Language.Fixpoint.Smt.Serialize () import           Language.Fixpoint.Types.PrettyPrint () import           Language.Fixpoint.Smt.Interface-import           Language.Fixpoint.Solver.Validate+import           Language.Fixpoint.Solver.Sanitize+import           Language.Fixpoint.SortCheck+import           Language.Fixpoint.Graph.Types (SolverInfo (..)) -- import           Language.Fixpoint.Solver.Solution-import           Data.Maybe           (isJust, catMaybes)+-- import           Data.Maybe           (catMaybes)+import           Data.List            (partition)+-- import           Data.Char            (isUpper) import           Text.PrettyPrint.HughesPJ (text) import           Control.Monad.State.Strict import qualified Data.HashMap.Strict as M-+import           Data.Maybe (catMaybes) import           Control.Exception.Base (bracket) ------------------------------------------------------------------------------- | Solver Monadic API -------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | Solver Monadic API --------------------------------------------------------+--------------------------------------------------------------------------------  type SolveM = StateT SolverState IO  data SolverState = SS { ssCtx     :: !Context          -- ^ SMT Solver Context-                      , ssBinds   :: !F.BindEnv        -- ^ All variables and types+                      , ssBinds   :: !F.SolEnv         -- ^ All variables and types                       , ssStats   :: !Stats            -- ^ Solver Statistics                       } @@ -73,6 +81,7 @@   where     nCs   = M.size $ F.cm fi + instance F.PTable Stats where   ptable s = F.DocTable [ (text "# Constraints"         , pprint (numCstr s))                         , (text "# Refine Iterations"   , pprint (numIter s))@@ -81,45 +90,49 @@                         , (text "# SMT Queries (Total)" , pprint (numChck s))                         ] -----------------------------------------------------------------------------runSolverM :: Config -> F.GInfo c b -> Int -> SolveM a -> IO a-----------------------------------------------------------------------------runSolverM cfg fi' _ act = do+--------------------------------------------------------------------------------+runSolverM :: Config -> SolverInfo b c -> Int -> SolveM a -> IO a+--------------------------------------------------------------------------------+runSolverM cfg sI _ act =   bracket acquire release $ \ctx -> do-    res <- runStateT (declareInitEnv >> declare fi >> act) (SS ctx be $ stats0 fi)+    res <- runStateT act' (s0 ctx)     smtWrite ctx "(exit)"     return $ fst res-   where-    acquire = makeContextWithSEnv lar (solver cfg) file env-    release = cleanupContext-    be      = F.bs     fi-    file    = F.fileName fi -- (inFile cfg)-    env     = F.fromListSEnv ((F.toListSEnv $ F.lits fi) ++ binds)-    binds   = [(x, F.sr_sort t) | (_, x, t) <- F.bindEnvToList $ F.bs fi]+    s0 ctx   = SS ctx be (stats0 fi)+    act'     = declare initEnv lts {- ess -} >> assumesAxioms (F.asserts fi) >> act+    release  = cleanupContext+    acquire  = makeContextWithSEnv cfg file initEnv+    initEnv  = symbolEnv   cfg fi+    lts      = F.toListSEnv (F.dLits fi)+    -- ess   = distinctLiterals fi+    be       = F.SolEnv (F.bs fi)+    file     = C.srcFile cfg     -- only linear arithmentic when: linear flag is on or solver /= Z3-    lar     = linear cfg || Z3 /= solver cfg-    fi      = fi' {F.allowHO = C.allowHO cfg}+    -- lar     = linear cfg || Z3 /= solver cfg+    fi       = (siQuery sI) {F.hoInfo = F.HOI (C.allowHO cfg) (C.allowHOqs cfg)} -----------------------------------------------------------------------------getBinds :: SolveM F.BindEnv----------------------------------------------------------------------------+++--------------------------------------------------------------------------------+getBinds :: SolveM F.SolEnv+-------------------------------------------------------------------------------- getBinds = ssBinds <$> get ----------------------------------------------------------------------------+-------------------------------------------------------------------------------- getIter :: SolveM Int----------------------------------------------------------------------------+-------------------------------------------------------------------------------- getIter = numIter . ssStats <$> get ----------------------------------------------------------------------------+-------------------------------------------------------------------------------- incIter, incBrkt :: SolveM ()----------------------------------------------------------------------------+-------------------------------------------------------------------------------- incIter   = modifyStats $ \s -> s {numIter = 1 + numIter s} incBrkt   = modifyStats $ \s -> s {numBrkt = 1 + numBrkt s} ----------------------------------------------------------------------------+-------------------------------------------------------------------------------- incChck, incVald :: Int -> SolveM ()----------------------------------------------------------------------------+-------------------------------------------------------------------------------- incChck n = modifyStats $ \s -> s {numChck = n + numChck s} incVald n = modifyStats $ \s -> s {numVald = n + numVald s} @@ -132,14 +145,43 @@ modifyStats :: (Stats -> Stats) -> SolveM () modifyStats f = modify $ \s -> s { ssStats = f (ssStats s) } ------------------------------------------------------------------------------- | SMT Interface ------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | SMT Interface -------------------------------------------------------------+--------------------------------------------------------------------------------+-- | `filterRequired [(x1, p1),...,(xn, pn)] q` returns a minimal list [xi] s.t.+--   /\ [pi] => q+--------------------------------------------------------------------------------+filterRequired :: F.Cand a -> F.Expr -> SolveM [a]+--------------------------------------------------------------------------------+filterRequired = error "TBD:filterRequired"++{-+(set-option :produce-unsat-cores true)+(declare-fun x () Int)+(declare-fun y () Int)+(declare-fun z () Int)++; Z3 will only track assertions that are named.++(assert (< 0 x))+(assert (! (< 0 y)       :named b2))+(assert (! (< x 10)      :named b3))+(assert (! (< y 10)      :named b4))+(assert (! (< (+ x y) 0) :named bR))+(check-sat)+(get-unsat-core)++> unsat (b2 bR)+-}++--------------------------------------------------------------------------------+-- | `filterValid p [(x1, q1),...,(xn, qn)]` returns the list `[ xi | p => qi]`+-------------------------------------------------------------------------------- filterValid :: F.Expr -> F.Cand a -> SolveM [a]----------------------------------------------------------------------------+-------------------------------------------------------------------------------- filterValid p qs = do   qs' <- withContext $ \me ->-           smtBracket me $+           smtBracket me "filterValidLHS" $              filterValid_ p qs me   -- stats   incBrkt@@ -151,54 +193,105 @@ filterValid_ p qs me = catMaybes <$> do   smtAssert me p   forM qs $ \(q, x) ->-    smtBracket me $ do+    smtBracket me "filterValidRHS" $ do       smtAssert me (F.PNot q)       valid <- smtCheckUnsat me       return $ if valid then Just x else Nothing  -smtEnablrmbqi-  = withContext $ \me ->-            smtWrite me "(set-option :smt.mbqi true)" +--------------------------------------------------------------------------------+-- | `filterValidGradual ps [(x1, q1),...,(xn, qn)]` returns the list `[ xi | p => qi]`+-- | for some p in the list ps +--------------------------------------------------------------------------------+filterValidGradual :: [F.Expr] -> F.Cand a -> SolveM [a]+--------------------------------------------------------------------------------+filterValidGradual p qs = do+  qs' <- withContext $ \me ->+           smtBracket me "filterValidGradualLHS" $+             filterValidGradual_ p qs me+  -- stats+  incBrkt+  incChck (length qs)+  incVald (length qs')+  return qs' +filterValidGradual_ :: [F.Expr] -> F.Cand a -> Context -> IO [a]+filterValidGradual_ ps qs me +  = (map snd . fst) <$> foldM partitionCandidates ([], qs) ps+  where+    partitionCandidates :: (F.Cand a, F.Cand a) -> F.Expr -> IO (F.Cand a, F.Cand a)+    partitionCandidates (ok, candidates) p = do +      (valids', invalids')  <- partition snd <$> filterValidOne_ p candidates me +      let (valids, invalids) = (fst <$> valids', fst <$> invalids')+      return (ok ++ valids, invalids)++filterValidOne_ :: F.Expr -> F.Cand a -> Context -> IO [((F.Expr, a), Bool)]+filterValidOne_ p qs me = do+  smtAssert me p+  forM qs $ \(q, x) ->+    smtBracket me "filterValidRHS" $ do+      smtAssert me (F.PNot q)+      valid <- smtCheckUnsat me+      return $ ((q, x), valid)++smtEnablembqi :: SolveM ()+smtEnablembqi+  = withContext $ \me ->+      smtWrite me "(set-option :smt.mbqi true)"++-------------------------------------------------------------------------------- checkSat :: F.Expr -> SolveM  Bool+-------------------------------------------------------------------------------- checkSat p   = withContext $ \me ->-            smtBracket me $-             smtCheckSat me p+      smtBracket me "checkSat" $+        smtCheckSat me p -----------------------------------------------------------------------------declare :: F.GInfo c a -> SolveM ()-----------------------------------------------------------------------------declareInitEnv :: SolveM ()-declareInitEnv = withContext $ \me ->-                   forM_ (F.toListSEnv initSMTEnv) $ uncurry $ smtDecl me+--------------------------------------------------------------------------------+declare :: F.SEnv F.Sort -> [(F.Symbol, F.Sort)] -> SolveM ()+--------------------------------------------------------------------------------+declare env lts = withContext $ \me -> do+  forM_ thyXTs $ uncurry $ smtDecl     me+  forM_ qryXTs $ uncurry $ smtDecl     me+  forM_ ess    $           smtDistinct me+  forM_ axs    $           smtAssert   me+  return ()+  where+    ess        = distinctLiterals  lts+    axs        = Thy.axiomLiterals lts+    thyXTs     =               filter (isKind 1) xts+    qryXTs     = mapSnd tx <$> filter (isKind 2) xts+    isKind n   = (n ==)  . symKind . fst+    xts        = F.toListSEnv           env+    tx         = elaborate    "declare" env -declare fi  = withContext $ \me -> do-  xts      <- either E.die return $ declSymbols fi-  let ess   = declLiterals fi-  forM_ xts $ uncurry $ smtDecl     me-  forM_ ess $           smtDistinct me+-- | symKind returns {0, 1, 2} where:+--   0 = Theory-Definition,+--   1 = Theory-Declaration,+--   2 = Query-Binder -declLiterals :: F.GInfo c a -> [[F.Expr]]-declLiterals fi | F.allowHO fi-  = [es | (_, es) <- tess ]-  where-    tess        = groupList [(t, F.expr x) | (x, t) <- F.toListSEnv $ F.lits fi, not (isThy x)]-    isThy       = isJust . Thy.smt2Symbol+symKind :: F.Symbol -> Int+symKind x = case M.lookup x Thy.theorySymbols of+              Just t  -> if tsInterp t then 0 else 1+              Nothing -> 2 -declLiterals fi-  = [es | (_, es) <- tess ]-   where-    notFun      = not . F.isFunctionSortedReft . (`F.RR` F.trueReft)-    tess        = groupList [(t, F.expr x) | (x, t) <- F.toListSEnv $ F.lits fi, notFun t]+assumesAxioms :: [F.Triggered F.Expr] -> SolveM ()+assumesAxioms es = withContext $ \me -> forM_  es $ smtAssertAxiom me -declSymbols :: F.GInfo c a -> Either E.Error [(F.Symbol, F.Sort)]-declSymbols = fmap dropThy . symbolSorts-  where-    dropThy = filter (not . isThy . fst)-    isThy   = isJust . Thy.smt2Symbol+-- assumes :: [F.Expr] -> SolveM ()+-- assumes es = withContext $ \me -> forM_  es $ smtAssert me++-- | `distinctLiterals` is used solely to determine the set of literals+--   (of each sort) that are *disequal* to each other, e.g. EQ, LT, GT,+--   or string literals "cat", "dog", "mouse". These should only include+--   non-function sorted values.+distinctLiterals :: [(F.Symbol, F.Sort)] -> [[F.Expr]]+distinctLiterals xts = [ es | (_, es) <- tess ]+   where+    tess             = groupList [(t, F.expr x) | (x, t) <- xts, notFun t]+    notFun           = not . F.isFunctionSortedReft . (`F.RR` F.trueReft)+    -- _notStr          = not . (F.strSort ==) . F.sr_sort . (`F.RR` F.trueReft)  --------------------------------------------------------------------------- stats :: SolveM Stats
+ src/Language/Fixpoint/Solver/Sanitize.hs view
@@ -0,0 +1,425 @@+-- | Validate and Transform Constraints to Ensure various Invariants -------------------------+--   1. Each binder must be associated with a UNIQUE sort+{-# LANGUAGE TupleSections     #-}+{-# LANGUAGE OverloadedStrings #-}++module Language.Fixpoint.Solver.Sanitize+  ( -- * Transform FInfo to enforce invariants+    sanitize++    -- * Sorts for each Symbol (move elsewhere)+  , symbolEnv++    -- * Remove substitutions K[x := e] where `x` is not in dom(K)+  , dropDeadSubsts+  ) where++import           Language.Fixpoint.Types.PrettyPrint+import           Language.Fixpoint.Types.Visitor (symConsts, isConcC, isKvarC, mapKVars, mapKVarSubsts)+import           Language.Fixpoint.SortCheck     (isFirstOrder)+import qualified Language.Fixpoint.Misc                            as Misc+import qualified Language.Fixpoint.Types                           as F+import           Language.Fixpoint.Types.Config (Config, allowHO)+import qualified Language.Fixpoint.Types.Errors                    as E+import qualified Language.Fixpoint.Smt.Theories                    as Thy+import           Language.Fixpoint.Graph (kvEdges, CVertex (..))+import qualified Data.HashMap.Strict                               as M+import qualified Data.HashSet                                      as S+import qualified Data.List                                         as L+import qualified Data.Text                                         as T+import           Data.Maybe          (isNothing, mapMaybe)+import           Control.Monad       ((>=>))+import           Text.PrettyPrint.HughesPJ++type SanitizeM a = Either E.Error a++--------------------------------------------------------------------------------+sanitize :: F.SInfo a -> SanitizeM (F.SInfo a)+--------------------------------------------------------------------------------+sanitize =    -- banIllScopedKvars+             Misc.fM dropFuncSortedShadowedBinders+         >=> Misc.fM sanitizeWfC+         >=> Misc.fM replaceDeadKvars+         >=> Misc.fM (dropDeadSubsts . restrictKVarDomain)+         >=>         banMixedRhs+         >=>         banQualifFreeVars+         >=>         banConstraintFreeVars+         >=> Misc.fM addLiterals+++--------------------------------------------------------------------------------+-- | `addLiterals` traverses the constraints to find (string) literals that+--   are then added to the `dLits` field.+--------------------------------------------------------------------------------+addLiterals :: F.SInfo a -> F.SInfo a+--------------------------------------------------------------------------------+addLiterals si = si { F.dLits = F.unionSEnv (F.dLits si) lits'+                    , F.gLits = F.unionSEnv (F.gLits si) lits'+                    }+  where+    lits'      = M.fromList [ (F.symbol x, F.strSort) | x <- symConsts si ]++--------------------------------------------------------------------------------+-- | See issue liquid-fixpoint issue #230. This checks that whenever we have,+--      G1        |- K.su1+--      G2, K.su2 |- rhs+--   then+--      G1 \cap G2 \subseteq wenv(k)+--------------------------------------------------------------------------------+_banIllScopedKvars :: F.SInfo a ->  SanitizeM (F.SInfo a)+--------------------------------------------------------------------------------+_banIllScopedKvars si = Misc.applyNonNull (Right si) (Left . badKs) errs+  where+    errs              = concatMap (checkIllScope si kDs) ks+    kDs               = kvarDefUses si+    ks                = filter notKut $ M.keys (F.ws si)+    notKut            = not . (`F.ksMember` F.kuts si)++badKs :: [(F.KVar, F.SubcId, F.SubcId, F.IBindEnv)] -> F.Error+badKs = E.catErrors . map E.errIllScopedKVar++type KvConstrM = M.HashMap F.KVar [Integer]+type KvDefs    = (KvConstrM, KvConstrM)++checkIllScope :: F.SInfo a -> KvDefs -> F.KVar -> [(F.KVar, F.SubcId, F.SubcId, F.IBindEnv)]+checkIllScope si (inM, outM) k = mapMaybe (uncurry (isIllScope si k)) ios+  where+    ios                        = [(i, o) | i <- ins, o <- outs, i /= o ]+    ins                        = M.lookupDefault [] k inM+    outs                       = M.lookupDefault [] k outM++isIllScope :: F.SInfo a -> F.KVar -> F.SubcId -> F.SubcId -> Maybe (F.KVar, F.SubcId, F.SubcId, F.IBindEnv)+isIllScope si k inI outI+  | F.nullIBindEnv badXs = Nothing+  | otherwise            = Just (k, inI, outI, badXs)+  where+    badXs                = F.diffIBindEnv commonXs kXs+    kXs                  = {- F.tracepp ("kvarBinds " ++ show k) $ -} kvarBinds si k+    commonXs             = F.intersectionIBindEnv inXs outXs+    inXs                 = subcBinds si inI+    outXs                = subcBinds si outI++subcBinds :: F.SInfo a -> F.SubcId -> F.IBindEnv+subcBinds si i = F._cenv $ F.cm si M.! i++kvarBinds :: F.SInfo a -> F.KVar -> F.IBindEnv+kvarBinds si = F.wenv . (F.ws si M.!)++kvarDefUses :: F.SInfo a -> KvDefs+kvarDefUses si = (Misc.group ins, Misc.group outs)+  where+    es         = kvEdges si+    outs       = [(k, o) | (KVar k, Cstr o) <- es ]+    ins        = [(k, i) | (Cstr i, KVar k) <- es ]++--------------------------------------------------------------------------------+-- | `dropDeadSubsts` removes dead `K[x := e]` where `x` NOT in the domain of K.+--------------------------------------------------------------------------------+dropDeadSubsts :: F.SInfo a -> F.SInfo a+dropDeadSubsts si = mapKVarSubsts (F.filterSubst . f) si+  where+    kvsM          = M.mapWithKey (\k _ -> kvDom k) (F.ws si)+    kvDom         = S.fromList . F.kvarDomain si+    f k x _       = S.member x (M.lookupDefault mempty k kvsM)++--------------------------------------------------------------------------------+-- | `restrictKVarDomain` updates the kvar-domains in the wf constraints+--   to a subset of the original binders, where we DELETE the parameters+--   `x` which appear in substitutions of the form `K[x := y]` where `y`+--   is not in the env.+--------------------------------------------------------------------------------+restrictKVarDomain :: F.SInfo a -> F.SInfo a+restrictKVarDomain si = si { F.ws = M.mapWithKey (restrictWf kvm) (F.ws si) }+  where+    kvm               = safeKvarEnv si++-- | `restrictWf kve k w` restricts the env of `w` to the parameters in `kve k`.+restrictWf :: KvDom -> F.KVar -> F.WfC a -> F.WfC a+restrictWf kve k w = w { F.wenv = F.filterIBindEnv f (F.wenv w) }+  where+    f i            = S.member i kis+    kis            = S.fromList [ i | (_, i) <- F.toListSEnv kEnv ]+    kEnv           = M.lookupDefault mempty k kve++-- | `safeKvarEnv` computes the "real" domain of each kvar, which is+--   a SUBSET of the input domain, in which we KILL the parameters+--   `x` which appear in substitutions of the form `K[x := y]`+--   where `y` is not in the env.++type KvDom     = M.HashMap F.KVar (F.SEnv F.BindId)+type KvBads    = M.HashMap F.KVar [F.Symbol]++safeKvarEnv :: F.SInfo a -> KvDom+safeKvarEnv si = L.foldl' (dropKvarEnv si) env0 cs+  where+    cs         = M.elems  (F.cm si)+    env0       = initKvarEnv si++dropKvarEnv :: F.SInfo a -> KvDom -> F.SimpC a -> KvDom+dropKvarEnv si kve c = M.mapWithKey (dropBadParams kBads) kve+  where+    kBads            = badParams si c++dropBadParams :: KvBads -> F.KVar -> F.SEnv F.BindId -> F.SEnv F.BindId+dropBadParams kBads k kEnv = L.foldl' (flip F.deleteSEnv) kEnv xs+  where+    xs                     = M.lookupDefault mempty k kBads++badParams :: F.SInfo a -> F.SimpC a -> M.HashMap F.KVar [F.Symbol]+badParams si c = Misc.group bads+  where+    bads       = [ (k, x) | (v, k, F.Su su) <- subcKSubs xsrs c+                          , let vEnv = maybe sEnv (`S.insert` sEnv) v+                          , (x, e)          <- M.toList su+                          , badArg vEnv e+                 ]+    sEnv       = S.fromList (fst <$> xsrs)+    xsrs       = F.envCs (F.bs si) (F.senv c)++badArg :: S.HashSet F.Symbol -> F.Expr -> Bool+badArg sEnv (F.EVar y) = not (y `S.member` sEnv)+badArg _    _          = True++type KSub = (Maybe F.Symbol, F.KVar, F.Subst)++subcKSubs :: [(F.Symbol, F.SortedReft)] -> F.SimpC a -> [KSub]+subcKSubs xsrs c = rhs ++ lhs+  where+    lhs          = [ (Just v, k, su) | (_, sr) <- xsrs+                                     , let rs   = F.reftConjuncts (F.sr_reft sr)+                                     , F.Reft (v, F.PKVar k su) <- rs+                   ]+    rhs          = [(Nothing, k, su) | F.PKVar k su <- [F.crhs c]]+++initKvarEnv :: F.SInfo a -> KvDom+initKvarEnv si = initEnv si <$> F.ws si++initEnv :: F.SInfo a -> F.WfC a -> F.SEnv F.BindId+initEnv si w = F.fromListSEnv [ (bind i, i) | i <- is ]+  where+    is       = F.elemsIBindEnv $ F.wenv w+    bind i   = fst (F.lookupBindEnv i be)+    be       = F.bs si++--------------------------------------------------------------------------------+-- | check that no constraint has free variables (ignores kvars)+--------------------------------------------------------------------------------+banConstraintFreeVars :: F.SInfo a -> SanitizeM (F.SInfo a)+banConstraintFreeVars fi0 = Misc.applyNonNull (Right fi0) (Left . badCs) bads+  where+    fi = mapKVars (const $ Just F.PTrue) fi0+    bads = [(c, fs) | c <- M.elems $ F.cm fi, Just fs <- [cNoFreeVars fi c]]++cNoFreeVars :: F.SInfo a -> F.SimpC a -> Maybe [F.Symbol]+cNoFreeVars fi c = if S.null fv then Nothing else Just (S.toList fv)+  where+    be   = F.bs fi+    lits = fst <$> F.toListSEnv (F.gLits fi)+    ids  = F.elemsIBindEnv $ F.senv c+    cDom = [fst $ F.lookupBindEnv i be | i <- ids]+    cRng = concat [S.toList . F.reftFreeVars . F.sr_reft . snd $ F.lookupBindEnv i be | i <- ids]+    fv   = cRng `nubDiff` (lits ++ cDom ++ F.prims)++badCs :: Misc.ListNE (F.SimpC a, [F.Symbol]) -> E.Error+badCs = E.catErrors . map (E.errFreeVarInConstraint . Misc.mapFst F.subcId)+++--------------------------------------------------------------------------------+-- | check that no qualifier has free variables+--------------------------------------------------------------------------------+banQualifFreeVars :: F.SInfo a -> SanitizeM (F.SInfo a)+--------------------------------------------------------------------------------+banQualifFreeVars fi = Misc.applyNonNull (Right fi) (Left . badQuals) bads+  where+    bads   = [ (q, xs) | q <- F.quals fi, let xs = free q, not (null xs) ]+    lits   = fst <$> F.toListSEnv (F.gLits fi)+    free q = S.toList $ F.syms (F.qBody q) `nubDiff` (lits ++ F.prims ++ F.syms (fst <$> F.qParams q))+++badQuals     :: Misc.ListNE (F.Qualifier, Misc.ListNE F.Symbol) -> E.Error+badQuals bqs = E.catErrors [ E.errFreeVarInQual q xs | (q, xs) <- bqs]++-- Null if first is a subset of second+nubDiff :: [F.Symbol] -> [F.Symbol] -> S.HashSet F.Symbol+nubDiff a b = a' `S.difference` b'+  where+    a' = S.fromList a+    b' = S.fromList b++--------------------------------------------------------------------------------+-- | check that each constraint has RHS of form [k1,...,kn] or [p]+--------------------------------------------------------------------------------+banMixedRhs :: F.SInfo a -> SanitizeM (F.SInfo a)+--------------------------------------------------------------------------------+banMixedRhs fi = Misc.applyNonNull (Right fi) (Left . badRhs) bads+  where+    ics        = M.toList $ F.cm fi+    bads       = [(i, c) | (i, c) <- ics, not $ isOk c]+    isOk c     = isKvarC c || isConcC c++badRhs :: Misc.ListNE (Integer, F.SimpC a) -> E.Error+badRhs = E.catErrors . map badRhs1++badRhs1 :: (Integer, F.SimpC a) -> E.Error+badRhs1 (i, c) = E.err E.dummySpan $ vcat [ "Malformed RHS for constraint id" <+> pprint i+                                          , nest 4 (pprint (F.crhs c)) ]++--------------------------------------------------------------------------------+-- | symbol |-> sort for EVERY variable in the FInfo+--------------------------------------------------------------------------------+symbolEnv :: Config -> F.SInfo a -> F.SEnv F.Sort+symbolEnv cfg si = Thy.theorySEnv+                   `mappend`+                   F.fromListSEnv (symbolSorts cfg si)++symbolSorts :: Config -> F.GInfo c a -> [(F.Symbol, F.Sort)]+symbolSorts cfg fi = either E.die id $ symbolSorts' cfg fi++symbolSorts' :: Config -> F.GInfo c a -> SanitizeM [(F.Symbol, F.Sort)]+symbolSorts' cfg fi  = (normalize . compact . (defs ++)) =<< bindSorts fi+  where+    normalize       = fmap (map (unShadow txFun dm))+    dm              = M.fromList defs+    defs            = F.toListSEnv . F.gLits $ fi+    txFun+      | allowHO cfg = id+      | otherwise   = defuncSort++unShadow :: (F.Sort -> F.Sort) -> M.HashMap F.Symbol a -> (F.Symbol, F.Sort) -> (F.Symbol, F.Sort)+unShadow tx dm (x, t)+  | M.member x dm  = (x, t)+  | otherwise      = (x, tx t)++defuncSort :: F.Sort -> F.Sort+defuncSort (F.FFunc {}) = F.funcSort+defuncSort t            = t++compact :: [(F.Symbol, F.Sort)] -> Either E.Error [(F.Symbol, F.Sort)]+compact xts+  | null bad  = Right [(x, t) | (x, [t]) <- ok ]+  | otherwise = Left $ dupBindErrors bad'+  where+    bad'      = [(x, (, []) <$> ts) | (x, ts) <- bad]+    (bad, ok) = L.partition multiSorted . binds $ xts+    binds     = M.toList . M.map Misc.sortNub . Misc.group++--------------------------------------------------------------------------------+bindSorts  :: F.GInfo c a -> Either E.Error [(F.Symbol, F.Sort)]+--------------------------------------------------------------------------------+bindSorts fi+  | null bad   = Right [ (x, t) | (x, [(t, _)]) <- ok ]+  | otherwise  = Left $ dupBindErrors [ (x, ts) | (x, ts) <- bad]+  where+    (bad, ok)  = L.partition multiSorted . binds $ fi+    binds      = symBinds . F.bs+++multiSorted :: (x, [t]) -> Bool+multiSorted = (1 <) . length . snd++dupBindErrors :: [(F.Symbol, [(F.Sort, [F.BindId] )])] -> E.Error+dupBindErrors = foldr1 E.catError . map dbe+  where+   dbe (x, y) = E.err E.dummySpan $ vcat [ "Multiple sorts for" <+> pprint x+                                         , nest 4 (pprint y) ]++--------------------------------------------------------------------------------+symBinds  :: F.BindEnv -> [SymBinds]+--------------------------------------------------------------------------------+symBinds  = {- THIS KILLS ELEM: tracepp "symBinds" . -}+            M.toList+          . M.map Misc.groupList+          . Misc.group+          . binders++type SymBinds = (F.Symbol, [(F.Sort, [F.BindId])])++binders :: F.BindEnv -> [(F.Symbol, (F.Sort, F.BindId))]+binders be = [(x, (F.sr_sort t, i)) | (i, x, t) <- F.bindEnvToList be]+++--------------------------------------------------------------------------------+-- | Drop func-sorted `bind` that are shadowed by `constant` (if same type, else error)+--------------------------------------------------------------------------------+dropFuncSortedShadowedBinders :: F.SInfo a -> F.SInfo a+--------------------------------------------------------------------------------+dropFuncSortedShadowedBinders fi = dropBinders f (const True) fi+  where+    f x t  = not (M.member x defs) || F.allowHO fi || isFirstOrder t+    defs   = M.fromList $ F.toListSEnv $ F.gLits fi++--------------------------------------------------------------------------------+-- | Drop irrelevant binders from WfC Environments+--------------------------------------------------------------------------------+sanitizeWfC :: F.SInfo a -> F.SInfo a+sanitizeWfC si = si { F.ws = ws' }+  where+    ws'        = deleteWfCBinds drops <$> F.ws si+    (_,drops)  = filterBindEnv keepF   $  F.bs si+    keepF      = conjKF [nonConstantF si, nonFunctionF si, _nonDerivedLH]+    -- drops   = F.tracepp "sanitizeWfC: dropping" $ L.sort drops'++conjKF :: [KeepBindF] -> KeepBindF+conjKF fs x t = and [f x t | f <- fs]++-- | `nonDerivedLH` keeps a bind x if it does not start with `$` which is used+--   typically for names that are automatically "derived" by GHC (and which can)+--   blow up the environments thereby clogging instantiation, etc.+--   NOTE: This is an LH specific hack and should be moved there.++_nonDerivedLH :: KeepBindF+_nonDerivedLH x _ = not . T.isPrefixOf "$" . last . T.split ('.' ==) . F.symbolText $ x++nonConstantF :: F.SInfo a -> KeepBindF+nonConstantF si = \x _ -> not (x `F.memberSEnv` cEnv)+  where+    cEnv        = F.gLits si++nonFunctionF :: F.SInfo a -> KeepBindF+nonFunctionF si+  | F.allowHO si    = \_ _ -> True+  | otherwise       = \_ t -> isNothing (F.functionSort t)++--------------------------------------------------------------------------------+-- | Generic API for Deleting Binders from FInfo+--------------------------------------------------------------------------------+dropBinders :: KeepBindF -> KeepSortF -> F.SInfo a -> F.SInfo a+--------------------------------------------------------------------------------+dropBinders f g fi  = fi { F.bs    = bs'+                         , F.cm    = cm'+                         , F.ws    = ws'+                         , F.gLits = lits' }+  where+    discards        = diss+    (bs', diss)     = filterBindEnv f $ F.bs fi+    cm'             = deleteSubCBinds discards   <$> F.cm fi+    ws'             = deleteWfCBinds  discards   <$> F.ws fi+    lits'           = F.filterSEnv g (F.gLits fi)++type KeepBindF = F.Symbol -> F.Sort -> Bool+type KeepSortF = F.Sort -> Bool++deleteSubCBinds :: [F.BindId] -> F.SimpC a -> F.SimpC a+deleteSubCBinds bs sc = sc { F._cenv = foldr F.deleteIBindEnv (F.senv sc) bs }++deleteWfCBinds :: [F.BindId] -> F.WfC a -> F.WfC a+deleteWfCBinds bs wf = wf { F.wenv = foldr F.deleteIBindEnv (F.wenv wf) bs }++filterBindEnv :: KeepBindF -> F.BindEnv -> (F.BindEnv, [F.BindId])+filterBindEnv f be  = (F.bindEnvFromList keep, discard')+  where+    (keep, discard) = L.partition f' $ F.bindEnvToList be+    discard'        = Misc.fst3     <$> discard+    f' (_, x, t)    = f x (F.sr_sort t)+++---------------------------------------------------------------------------+-- | Replace KVars that do not have a WfC with PFalse+---------------------------------------------------------------------------+replaceDeadKvars :: F.SInfo a -> F.SInfo a+---------------------------------------------------------------------------+replaceDeadKvars fi = mapKVars go fi+  where+    go k | k `M.member` F.ws fi = Nothing+         | otherwise            = Just F.PFalse
src/Language/Fixpoint/Solver/Solution.hs view
@@ -1,139 +1,107 @@ {-# LANGUAGE FlexibleInstances  #-} {-# LANGUAGE TupleSections      #-}-{-# LANGUAGE PatternGuards      #-}  module Language.Fixpoint.Solver.Solution-        ( -- * Create and Update Solution-          init, update+  ( -- * Create Initial Solution+    init -          -- * Lookup Solution-        , lhsPred-        , noKvars+    -- * Update Solution+  , Sol.update -          -- * Debug-        , solutionGraph-        )-where+  -- * Lookup Solution+  , lhsPred+  ) where  import           Control.Parallel.Strategies import           Control.Arrow (second) import qualified Data.HashSet                   as S import qualified Data.HashMap.Strict            as M import qualified Data.List                      as L-import           Data.Maybe                     (maybeToList, isNothing)+import           Data.Maybe                     (fromMaybe, maybeToList, isNothing) import           Data.Monoid                    ((<>)) import           Language.Fixpoint.Types.PrettyPrint () import           Language.Fixpoint.Types.Visitor      as V import qualified Language.Fixpoint.SortCheck          as So import           Language.Fixpoint.Misc+import qualified Language.Fixpoint.Smt.Theories       as Thy+import           Language.Fixpoint.Types.Config import qualified Language.Fixpoint.Types              as F-import           Language.Fixpoint.Types.Constraints hiding (ws, bs)-import           Language.Fixpoint.Types.Graphs-import           Prelude                        hiding (init, lookup)+import           Language.Fixpoint.Types                 ((&.&))+import qualified Language.Fixpoint.Types.Solutions    as Sol+import           Language.Fixpoint.Types.Constraints  hiding (ws, bs)+import           Prelude                              hiding (init, lookup)+import           Language.Fixpoint.Solver.Sanitize  -- DEBUG -- import Text.Printf (printf) -- import           Debug.Trace (trace) ------------------------------------------------------------------------------------ | Expanded or Instantiated Qualifier ------------------------------------------------------------------------------------------------------------------------- --- mkJVar :: F.Expr -> QBind--- mkJVar p = [F.EQL dummyQual p []]---- dummyQual :: F.Qualifier--- dummyQual = F.Q F.nonSymbol [] F.PFalse (F.dummyPos "")- ----------------------------------------------------------------------------------- | Update Solution -----------------------------------------------------------+-- | Initial Solution (from Qualifiers and WF constraints) --------------------- ---------------------------------------------------------------------------------update :: Solution -> [F.KVar] -> [(F.KVar, F.EQual)] -> (Bool, Solution)---------------------------------------------------------------------------update s ks kqs = {- tracepp msg -} (or bs, s')+init :: Config -> F.SInfo a -> S.HashSet F.KVar -> Sol.Solution+--------------------------------------------------------------------------------+init cfg si ks = Sol.fromList senv mempty keqs [] mempty   where-    kqss        = groupKs ks kqs-    (bs, s')    = folds update1 s kqss-    -- msg         = printf "ks = %s, s = %s" (showpp ks) (showpp s)+    keqs       = map (refine si qs genv) ws `using` parList rdeepseq+    qs         = F.quals si+    ws         = [ w | (k, w) <- M.toList (F.ws si), not (isGWfc w) , k `S.member` ks]+    genv       = instConstants si+    senv       = symbolEnv cfg si -folds   :: (a -> b -> (c, a)) -> a -> [b] -> ([c], a)-folds f b = L.foldl' step ([], b)+--------------------------------------------------------------------------------+refine :: F.SInfo a -> [F.Qualifier] -> F.SEnv F.Sort -> F.WfC a -> (F.KVar, Sol.QBind)+refine fi qs genv w = refineK (allowHOquals fi) env qs $ F.wrft w   where-     step (cs, acc) x = (c:cs, x')-       where-         (c, x')      = f acc x+    env             = wenv <> genv+    wenv            = F.sr_sort <$> F.fromListSEnv (F.envCs (F.bs fi) (F.wenv w)) -groupKs :: [F.KVar] -> [(F.KVar, F.EQual)] -> [(F.KVar, QBind)]-groupKs ks kqs = M.toList $ groupBase m0 kqs+instConstants :: F.SInfo a -> F.SEnv F.Sort+instConstants = F.fromListSEnv . filter notLit . F.toListSEnv . F.gLits   where-    m0         = M.fromList $ (,[]) <$> ks+    notLit    = not . F.isLitSymbol . fst -update1 :: Solution -> (F.KVar, QBind) -> (Bool, Solution)-update1 s (k, qs) = (change, solInsert k qs s)-  where-    oldQs         = solLookup s k-    change        = length oldQs /= length qs ------------------------------------------------------------------------ | Initial Solution (from Qualifiers and WF constraints) -------------------------------------------------------------------------------init :: F.SInfo a -> Solution----------------------------------------------------------------------init si  = F.solFromList keqs [] -- (fromList keqs) M.empty-  where-    keqs = map (refine si qs) ws `using` parList rdeepseq-    qs   = F.quals si-    ws   = M.elems $ F.ws si-----------------------------------------------------------------------refine :: F.SInfo a-       -> [F.Qualifier]-       -> F.WfC a-       -> (F.KVar, QBind)----------------------------------------------------------------------refine fi qs w = refineK env qs $ F.wrft w-  where-    env        = wenv <> genv-    wenv       = F.sr_sort <$> F.fromListSEnv (F.envCs (F.bs fi) (F.wenv w))-    genv       = F.lits fi--refineK :: F.SEnv F.Sort -> [F.Qualifier] -> (F.Symbol, F.Sort, F.KVar) -> (F.KVar, QBind)-refineK env qs (v, t, k) = {- tracepp msg -} (k, eqs')+refineK :: Bool -> F.SEnv F.Sort -> [F.Qualifier] -> (F.Symbol, F.Sort, F.KVar) -> (F.KVar, Sol.QBind)+refineK ho env qs (v, t, k) = {- F.tracepp _msg -} (k, eqs')    where-    eqs                  = instK env v t qs-    eqs'                 = filter (okInst env v t) eqs-    -- msg                  = printf "refineK: k = %s, eqs = %s" (showpp k) (showpp eqs)+    eqs                     = instK ho env v t qs+    eqs'                    = Sol.qbFilter (okInst env v t) eqs+    -- _msg                    = printf "\n\nrefineK: k = %s, eqs = %s" (F.showpp k) (F.showpp eqs) ----------------------------------------------------------------------instK :: F.SEnv F.Sort+--------------------------------------------------------------------------------+instK :: Bool+      -> F.SEnv F.Sort       -> F.Symbol       -> F.Sort       -> [F.Qualifier]-      -> QBind----------------------------------------------------------------------instK env v t = unique . concatMap (instKQ env v t)+      -> Sol.QBind+--------------------------------------------------------------------------------+instK ho env v t = Sol.qb . unique . concatMap (instKQ ho env v t)   where-    unique = L.nubBy ((. F.eqPred) . (==) . F.eqPred)+    unique       = L.nubBy ((. Sol.eqPred) . (==) . Sol.eqPred) -instKQ :: F.SEnv F.Sort+instKQ :: Bool+       -> F.SEnv F.Sort        -> F.Symbol        -> F.Sort        -> F.Qualifier-       -> QBind-instKQ env v t q+       -> [Sol.EQual]+instKQ ho env v t q   = do (su0, v0) <- candidates senv [(t, [v])] qt        xs        <- match senv tyss [v0] (So.apply su0 <$> qts)-       return     $ F.eQual q (reverse xs)+       return     $ Sol.eQual q (reverse xs)     where-       qt : qts   = snd <$> F.q_params q-       tyss       = instCands env+       qt : qts   = snd <$> F.qParams q+       tyss       = instCands ho env        senv       = (`F.lookupSEnvWithDistance` env) -instCands :: F.SEnv F.Sort -> [(F.Sort, [F.Symbol])]-instCands env = filter isOk tyss+instCands :: Bool -> F.SEnv F.Sort -> [(F.Sort, [F.Symbol])]+instCands ho env = filter isOk tyss   where     tyss      = groupList [(t, x) | (x, t) <- xts]-    isOk      = isNothing . F.functionSort . fst+    isOk      = if ho then const True else isNothing . F.functionSort . fst     xts       = F.toListSEnv env  match :: So.Env -> [(F.Sort, [F.Symbol])] -> [F.Symbol] -> [F.Sort] -> [[F.Symbol]]@@ -146,95 +114,178 @@ -------------------------------------------------------------------------------- candidates :: So.Env -> [(F.Sort, [F.Symbol])] -> F.Sort -> [(So.TVSubst, F.Symbol)] ---------------------------------------------------------------------------------candidates env tyss tx-  = [(su, y) | (t, ys) <- tyss+candidates env tyss tx = -- traceShow _msg+    [(su, y) | (t, ys) <- tyss              , su      <- maybeToList $ So.unifyFast mono env tx t              , y       <- ys                                   ]   where     mono = So.isMono tx+    _msg  = "candidates tyss :=" ++ F.showpp tyss ++ "tx := " ++ F.showpp tx -------------------------------------------------------------------------okInst :: F.SEnv F.Sort -> F.Symbol -> F.Sort -> F.EQual -> Bool------------------------------------------------------------------------+--------------------------------------------------------------------------------+okInst :: F.SEnv F.Sort -> F.Symbol -> F.Sort -> Sol.EQual -> Bool+-------------------------------------------------------------------------------- okInst env v t eq = isNothing tc   where     sr            = F.RR t (F.Reft (v, p))-    p             = F.eqPred eq-    tc            = So.checkSorted env sr+    p             = Sol.eqPred eq+    tc            = So.checkSorted env sr -- (F.tracepp _msg sr)+    -- _msg          = printf "okInst: t = %s, eq = %s, env = %s" (F.showpp t) (F.showpp eq) (F.showpp env)   -------------------------------------------------------------------------------- -- | Predicate corresponding to LHS of constraint in current solution ---------------------------------------------------------------------------------lhsPred :: F.BindEnv -> F.Solution -> F.SimpC a -> F.Expr----------------------------------------------------------------------------------lhsPred be s c = {- F.tracepp msg $ -} apply g s bs+lhsPred :: F.SolEnv -> Sol.Solution -> F.SimpC a -> F.Expr+lhsPred be s c = F.notracepp _msg $ fst $ apply g s bs   where     g          = (ci, be, bs)     bs         = F.senv c     ci         = sid c-    -- msg        = "LhsPred for id = " ++ show (sid c)+    _msg       = "LhsPred for id = " ++ show (sid c) -type Cid = Maybe Integer-type CombinedEnv = (Cid, F.BindEnv, F.IBindEnv)+type Cid         = Maybe Integer+type CombinedEnv = (Cid, F.SolEnv, F.IBindEnv)+type ExprInfo    = (F.Expr, KInfo) -apply :: CombinedEnv -> Solution -> F.IBindEnv -> F.Expr-apply g s bs = F.pAnd (apply1 g s <$> F.elemsIBindEnv bs)+apply :: CombinedEnv -> Sol.Sol a Sol.QBind -> F.IBindEnv -> ExprInfo+apply g s bs      = (F.pAnd (pks:ps), kI)+  where+    (pks, kI)     = applyKVars g s ks  -- RJ: switch to applyKVars' to revert to old behavior+    (ps,  ks, _)  = envConcKVars g bs  -apply1 :: CombinedEnv -> Solution -> F.BindId -> F.Expr-apply1 g s i = {- F.tracepp msg $ -} F.pAnd $ applyExpr g s <$> bindExprs g i-   -- where-   --  msg   = "apply1 bind = " ++ show i+envConcKVars :: CombinedEnv -> F.IBindEnv -> ([F.Expr], [F.KVSub], [F.KVSub])+envConcKVars g bs = (concat pss, concat kss, L.nubBy (\x y -> F.ksuKVar x == F.ksuKVar y) $ concat gss)+  where+    (pss, kss, gss) = unzip3 [ F.notracepp ("sortedReftConcKVars" ++ F.showpp sr) $ F.sortedReftConcKVars x sr | (x, sr) <- xrs ]+    xrs             = (\i -> F.notracepp  ("lookupBE i := " ++ show i) $ F.lookupBindEnv i be) <$> is+    is              = F.elemsIBindEnv bs+    be              = F.soeBinds (snd3 g) -bindExprs :: CombinedEnv -> F.BindId -> [F.Expr]-bindExprs (_,be,_) i = [p `F.subst1` (v, F.eVar x) | F.Reft (v, p) <- rs ]+applyKVars :: CombinedEnv -> Sol.Sol a Sol.QBind -> [F.KVSub] -> ExprInfo+applyKVars g s = mrExprInfos (applyKVar g s) F.pAnd mconcat ++applyKVar :: CombinedEnv -> Sol.Sol a Sol.QBind -> F.KVSub -> ExprInfo+applyKVar g s ksu = case Sol.lookup s (F.ksuKVar ksu) of+  Left cs          -> hypPred g s ksu cs+  Right eqs -> (F.pAnd $ fst <$> Sol.qbPreds msg s (F.ksuSubst ksu) eqs, mempty) -- TODO: don't initialize kvars that have a hyp solution   where-    (x, sr)          = F.lookupBindEnv i be-    rs               = F.reftConjuncts $ F.sr_reft sr+    msg     = "applyKVar: " ++ show (fst3 g)  -applyExpr :: CombinedEnv -> Solution -> F.Expr -> F.Expr-applyExpr g s (F.PKVar k su) = applyKVar g s k su-applyExpr _ _ p              = p+hypPred :: CombinedEnv -> Sol.Sol a Sol.QBind -> F.KVSub -> Sol.Hyp  -> ExprInfo+hypPred g s ksu = mrExprInfos (cubePred g s ksu) F.pOr mconcatPlus -applyKVar :: CombinedEnv -> Solution -> F.KVar -> F.Subst -> F.Expr-applyKVar g s k su-  | Just eqs <- M.lookup k (F.sMap s)-  = qBindPred su eqs-  | Just cs  <- M.lookup k (F.sHyp s)-  = hypPred g s k su cs-  | otherwise-  = errorstar $ "Unknown kvar: " ++ show k+{- | `cubePred g s k su c` returns the predicate for -hypPred :: CombinedEnv -> Solution -> F.KVar -> F.Subst -> F.Hyp  -> F.Expr-hypPred g s k su = F.pOr . fmap (cubePred g s k su)+        (k . su) -cubePred :: CombinedEnv -> Solution -> F.KVar -> F.Subst -> F.Cube -> F.Expr-cubePred g s k su c = F.PExist xts-                       $ F.pAnd [ psu-                                , F.PExist yts' $ F.pAnd [p', psu'] ]+      defined by using cube++        c := [b1,...,bn] |- (k . su')++      in the binder environment `g`.++        bs' := the subset of "extra" binders in [b1...bn] that are *not* in `g`+        p'  := the predicate corresponding to the "extra" binders++ -}++elabExist :: Sol.Sol a Sol.QBind -> [(F.Symbol, F.Sort)] -> F.Expr -> F.Expr+elabExist s xts = F.pExist xts'   where-    yts'          = symSorts g bs'-    g'            = addCEnv g bs-    p'            = apply g' s bs'-    bs'           = delCEnv bs g-    F.Cube bs su' = c-    (_  , psu')   = substElim g' k su'-    (xts, psu)    = substElim g  k su+    xts'        = [ (x, elab t) | (x, t) <- xts]+    elab        = So.elaborate "elabExist" env+    env         = Sol.sEnv s +cubePred :: CombinedEnv -> Sol.Sol a Sol.QBind -> F.KVSub -> Sol.Cube -> ExprInfo+cubePred g s ksu c    = (elabExist s xts (psu &.& p), kI)+  where+    ((xts,psu,p), kI) = cubePredExc g s ksu c bs'+    bs'               = delCEnv s k bs+    bs                = Sol.cuBinds c+    k                 = F.ksuKVar ksu++type Binders = [(F.Symbol, F.Sort)]++-- | @cubePredExc@ computes the predicate for the subset of binders bs'.+--   The output is a tuple, `(xts, psu, p, kI)` such that the actual predicate+--   we want is `Exists xts. (psu /\ p)`.++cubePredExc :: CombinedEnv -> Sol.Sol a Sol.QBind -> F.KVSub -> Sol.Cube -> F.IBindEnv+            -> ((Binders, F.Pred, F.Pred), KInfo)++cubePredExc g s ksu c bs' = (cubeP, extendKInfo kI (Sol.cuTag c))+  where+    cubeP           = (xts, psu, elabExist s yts' (p' &.& psu') )+    yts'            = symSorts g bs'+    g'              = addCEnv  g bs+    (p', kI)        = apply g' s bs'+    (_  , psu')     = substElim sEnv g' k su'+    (xts, psu)      = substElim sEnv g  k su+    su'             = Sol.cuSubst c+    bs              = Sol.cuBinds c+    k               = F.ksuKVar   ksu+    su              = F.ksuSubst  ksu+    sEnv            = F.insertSEnv (F.ksuVV ksu) (F.ksuSort ksu) (Sol.sEnv s)+ -- TODO: SUPER SLOW! Decorate all substitutions with Sorts in a SINGLE pass.-substElim :: CombinedEnv -> F.KVar -> F.Subst -> ([(F.Symbol, F.Sort)], F.Pred)-substElim g _ (F.Su m) = (xts, p)++{- | @substElim@ returns the binders that must be existentially quantified,+     and the equality predicate relating the kvar-"parameters" and their+     actual values. i.e. given++        K[x1 := e1]...[xn := en]++     where e1 ... en have types t1 ... tn+     we want to quantify out++       x1:t1 ... xn:tn++     and generate the equality predicate && [x1 ~~ e1, ... , xn ~~ en]+     we use ~~ because the param and value may have different sorts, see:++        tests/pos/kvar-param-poly-00.hs++     Finally, we filter out binders if they are++     1. "free" in e1...en i.e. in the outer environment.+        (Hmm, that shouldn't happen...?)++     2. are binders corresponding to sorts (e.g. `a : num`, currently used+        to hack typeclasses current.)+ -}+substElim :: F.SEnv F.Sort -> CombinedEnv -> F.KVar -> F.Subst -> ([(F.Symbol, F.Sort)], F.Pred)+substElim sEnv g _ (F.Su m) = (xts, p)   where-    p      = F.pAnd [ F.PAtom F.Eq (F.eVar x) e | (x, e, _) <- xets  ]+    p      = F.pAnd [ mkSubst x (substSort sEnv frees x t) e t | (x, e, t) <- xets  ]     xts    = [ (x, t)    | (x, _, t) <- xets, not (S.member x frees) ]-    xets   = [ (x, e, t) | (x, e)    <- xes, t <- sortOf e ]+    xets   = [ (x, e, t) | (x, e)    <- xes, t <- sortOf e, not (isClass t)]     xes    = M.toList m     env    = combinedSEnv g     frees  = S.fromList (concatMap (F.syms . snd) xes)     sortOf = maybeToList . So.checkSortExpr env-    -- sortOf e = fromMaybe (badExpr g k e) $ So.checkSortExpr env e +substSort :: F.SEnv F.Sort -> S.HashSet F.Symbol -> F.Symbol -> F.Sort -> F.Sort+substSort sEnv _frees x _t = fromMaybe (err x) $ F.lookupSEnv x sEnv+  where+    err x            = error $ "Solution.mkSubst: unknown binder " ++ F.showpp x++mkSubst :: F.Symbol -> F.Sort -> F.Expr -> F.Sort -> F.Expr+mkSubst x tx ey ty+  | tx == ty    = F.EEq ex ey+  | otherwise   = F.notracepp msg (F.EEq ex' ey')+  where+    msg         = "mkSubst-DIFF:" ++ F.showpp (tx, ty) ++ F.showpp (ex', ey')+    ex          = F.expr x+    ex'         = Thy.toInt ex tx+    ey'         = Thy.toInt ey ty++isClass :: F.Sort -> Bool+isClass F.FNum  = True+isClass F.FFrac = True+isClass _       = False+ --badExpr :: CombinedEnv -> F.KVar -> F.Expr -> a --badExpr g@(i,_,_) k e   -- = errorstar $ "substSorts has a badExpr: "@@ -249,30 +300,61 @@ -- substPred (F.Su m) = F.pAnd [ F.PAtom F.Eq (F.eVar x) e | (x, e) <- M.toList m]  combinedSEnv :: CombinedEnv -> F.SEnv F.Sort-combinedSEnv (_, be, bs) = F.sr_sort <$> F.fromListSEnv (F.envCs be bs)+combinedSEnv (_, se, bs) = F.sr_sort <$> F.fromListSEnv (F.envCs be bs)+  where+    be                   = F.soeBinds se  addCEnv :: CombinedEnv -> F.IBindEnv -> CombinedEnv addCEnv (x, be, bs) bs' = (x, be, F.unionIBindEnv bs bs') -delCEnv :: F.IBindEnv -> CombinedEnv -> F.IBindEnv-delCEnv bs (_, _, bs')  = F.diffIBindEnv bs bs'+-- delCEnv :: F.IBindEnv -> CombinedEnv -> F.IBindEnv+-- delCEnv bs (_, _, bs')  = F.diffIBindEnv bs bs' +delCEnv :: Sol.Sol a Sol.QBind -> F.KVar -> F.IBindEnv -> F.IBindEnv+delCEnv s k bs  = F.diffIBindEnv bs _kbs+                                                -- ORIG: bs'+  where+    _kbs = safeLookup "delCEnv" k (Sol.sScp s)+ symSorts :: CombinedEnv -> F.IBindEnv -> [(F.Symbol, F.Sort)]-symSorts (_, be, _) bs = second F.sr_sort <$> F.envCs be bs+symSorts (_, se, _) bs = second F.sr_sort <$> F.envCs be  bs+  where+    be                 = F.soeBinds se -noKvars :: F.Expr -> Bool-noKvars = null . V.kvars+_noKvars :: F.Expr -> Bool+_noKvars = null . V.kvars  ---------------------------------------------------------------------------------qBindPred :: F.Subst -> QBind -> F.Expr+-- | Information about size of formula corresponding to an "eliminated" KVar. ---------------------------------------------------------------------------------qBindPred su eqs = F.subst su $ F.pAnd $ F.eqPred <$> eqs+data KInfo = KI { kiTags  :: [Tag]+                , kiDepth :: !Int+                , kiCubes :: !Integer+                } deriving (Eq, Ord, Show) +instance Monoid KInfo where+  mempty         = KI [] 0 1+  mappend ki ki' = KI ts d s+    where+      ts         = appendTags (kiTags  ki) (kiTags  ki')+      d          = max        (kiDepth ki) (kiDepth ki')+      s          = (*)        (kiCubes ki) (kiCubes ki') ----------------------------------------------------------------------------------solutionGraph :: Solution -> KVGraph----------------------------------------------------------------------------------solutionGraph s = [ (KVar k, KVar k, KVar <$> eqKvars eqs) | (k, eqs) <- kEqs ]+mplus :: KInfo -> KInfo -> KInfo+mplus ki ki' = (mappend ki ki') { kiCubes = kiCubes ki + kiCubes ki'}++mconcatPlus :: [KInfo] -> KInfo+mconcatPlus = foldr mplus mempty++appendTags :: [Tag] -> [Tag] -> [Tag]+appendTags ts ts' = sortNub (ts ++ ts')++extendKInfo :: KInfo -> F.Tag -> KInfo+extendKInfo ki t = ki { kiTags  = appendTags [t] (kiTags  ki)+                      , kiDepth = 1  +            kiDepth ki }++-- mrExprInfos :: (a -> ExprInfo) -> ([F.Expr] -> F.Expr) -> ([KInfo] -> KInfo) -> [a] -> ExprInfo+mrExprInfos :: (a -> (b, c)) -> ([b] -> b1) -> ([c] -> c1) -> [a] -> (b1, c1)+mrExprInfos mF erF irF xs = (erF es, irF is)   where-     eqKvars    = sortNub . concatMap (V.kvars . F.eqPred)-     kEqs       = M.toList (F.sMap s)+    (es, is)              = unzip $ map mF xs
src/Language/Fixpoint/Solver/Solve.hs view
@@ -1,72 +1,103 @@-{-# LANGUAGE PatternGuards    #-}-{-# LANGUAGE TupleSections    #-}-{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE PatternGuards     #-}+{-# LANGUAGE TupleSections     #-}+{-# LANGUAGE FlexibleContexts  #-} {-# LANGUAGE OverloadedStrings #-}  -------------------------------------------------------------------------------- -- | Solve a system of horn-clause constraints --------------------------------- -------------------------------------------------------------------------------- -module Language.Fixpoint.Solver.Solve (solve, gradualSolve ) where+module Language.Fixpoint.Solver.Solve (solve) where  import           Control.Monad (when, filterM) import           Control.Monad.State.Strict (lift) import           Language.Fixpoint.Misc-import qualified Language.Fixpoint.Types as F+import qualified Language.Fixpoint.Types           as F+import qualified Language.Fixpoint.Types.Solutions as Sol import           Language.Fixpoint.Types.PrettyPrint import           Language.Fixpoint.Types.Config hiding (stats)-import qualified Language.Fixpoint.Solver.Solution as S-import qualified Language.Fixpoint.Solver.Worklist as W+import qualified Language.Fixpoint.Solver.Solution  as S+import qualified Language.Fixpoint.Solver.Worklist  as W+import qualified Language.Fixpoint.Solver.Eliminate as E import           Language.Fixpoint.Solver.Monad-import           Language.Fixpoint.Solver.Graph (isTarget)+import           Language.Fixpoint.Solver.GradualSolve+import           Language.Fixpoint.Utils.Progress+import           Language.Fixpoint.Graph import           Text.PrettyPrint.HughesPJ---- DEBUG import           Text.Printf-import           System.Console.CmdArgs.Verbosity (whenLoud)+import           System.Console.CmdArgs.Verbosity (whenNormal, whenLoud) import           Control.DeepSeq+import qualified Data.HashMap.Strict as M+import qualified Data.HashSet        as S -import           Data.List  (sort)-import           Data.Maybe (catMaybes)+-- DEBUG -- import           Debug.Trace (trace)  ---------------------------------------------------------------------------------solve :: (NFData a, F.Fixpoint a) => Config -> F.Solution -> F.SInfo a -> IO (F.Result (Integer, a))+solve :: (NFData a, F.Fixpoint a) => Config -> F.SInfo a -> IO (F.Result (Integer, a)) ---------------------------------------------------------------------------------solve cfg s0 fi = do+solve cfg fi | gradual cfg +  = solveGradual cfg fi ++solve cfg fi = do     -- donePhase Loud "Worklist Initialize"-    (res, stat) <- runSolverM cfg fi n act+    (res, stat) <- withProgressFI sI $ runSolverM cfg sI n act     when (solverStats cfg) $ printStats fi wkl stat     -- print (numIter stat)     return res   where-    wkl  = W.init fi+    act  = solve_ cfg fi s0 ks  wkl+    sI   = solverInfo cfg fi+    wkl  = W.init sI     n    = fromIntegral $ W.wRanks wkl-    act  = solve_ cfg fi s0 wkl+    s0   = siSol  sI+    ks   = siVars sI +--------------------------------------------------------------------------------+-- | Progress Bar+--------------------------------------------------------------------------------+withProgressFI :: SolverInfo a b -> IO b -> IO b+withProgressFI = withProgress . fromIntegral . cNumScc . siDeps+--------------------------------------------------------------------------------+ printStats :: F.SInfo a ->  W.Worklist a -> Stats -> IO () printStats fi w s = putStrLn "\n" >> ppTs [ ptable fi, ptable s, ptable w ]   where     ppTs          = putStrLn . showpp . mconcat +--------------------------------------------------------------------------------+solverInfo :: Config -> F.SInfo a -> SolverInfo a b+--------------------------------------------------------------------------------+solverInfo cfg fI+  | useElim cfg = E.solverInfo cfg fI+  | otherwise   = SI mempty fI cD (siKvars fI)+  where+    cD          = elimDeps fI (kvEdges fI) mempty +siKvars :: F.SInfo a -> S.HashSet F.KVar+siKvars = S.fromList . M.keys . F.ws+ -------------------------------------------------------------------------------- solve_ :: (NFData a, F.Fixpoint a)-       => Config -> F.SInfo a -> F.Solution -> W.Worklist a+       => Config+       -> F.SInfo a+       -> Sol.Solution+       -> S.HashSet F.KVar+       -> W.Worklist a        -> SolveM (F.Result (Integer, a), Stats) ---------------------------------------------------------------------------------solve_ cfg fi s0 wkl = do-  let s0'  = mappend s0 $ {-# SCC "sol-init" #-} S.init fi-  s       <- {-# SCC "sol-refine" #-} refine s0' wkl+solve_ cfg fi s0 ks wkl = do +  let s1  = mappend s0 $ {-# SCC "sol-init" #-} S.init cfg fi ks+  s       <- {-# SCC "sol-refine" #-} refine s1 wkl   res     <- {-# SCC "sol-result" #-} result cfg wkl s   st      <- stats   let res' = {-# SCC "sol-tidy"   #-} tidyResult res   return $!! (res', st) --- | tidyResult ensures we replace the temporary kVarArg names---   introduced to ensure uniqueness with the original names---   appearing in the supplied WF constraints.-+--------------------------------------------------------------------------------+-- | tidyResult ensures we replace the temporary kVarArg names introduced to+--   ensure uniqueness with the original names in the given WF constraints.+-------------------------------------------------------------------------------- tidyResult :: F.Result a -> F.Result a tidyResult r = r { F.resSolution = tidySolution (F.resSolution r) } @@ -77,7 +108,7 @@ tidyPred = F.substf (F.eVar . F.tidySymbol)  ---------------------------------------------------------------------------------refine :: F.Solution -> W.Worklist a -> SolveM F.Solution+refine :: Sol.Solution -> W.Worklist a -> SolveM Sol.Solution -------------------------------------------------------------------------------- refine s w   | Just (c, w', newScc, rnk) <- W.pop w = do@@ -87,64 +118,98 @@      let w'' = if b then W.push c w' else w'      refine s' w''   | otherwise = return s---- DEBUG-refineMsg i c b rnk = printf "\niter=%d id=%d change=%s rank=%d\n"-                        i (F.subcId c) (show b) rnk+  where+    -- DEBUG+    refineMsg i c b rnk = printf "\niter=%d id=%d change=%s rank=%d\n"+                            i (F.subcId c) (show b) rnk  --------------------------------------------------------------------------- -- | Single Step Refinement ----------------------------------------------- ----------------------------------------------------------------------------refineC :: Int -> F.Solution -> F.SimpC a -> SolveM (Bool, F.Solution)+refineC :: Int -> Sol.Solution -> F.SimpC a -> SolveM (Bool, Sol.Solution) --------------------------------------------------------------------------- refineC _i s c   | null rhs  = return (False, s)   | otherwise = do be     <- getBinds                    let lhs = S.lhsPred be s c                    kqs    <- filterValid lhs rhs-                   return  $ S.update s ks {- tracepp (msg ks rhs kqs) -} kqs+                   return  $ S.update s ks kqs   where+    _ci       = F.subcId c     (ks, rhs) = rhsCands s c-    -- msg ks xs ys = printf "refineC: iter = %d, ks = %s, rhs = %d, rhs' = %d \n" _i (showpp ks) (length xs) (length ys)+    -- msg       = printf "refineC: iter = %d, sid = %s, soln = \n%s\n"+    --               _i (show (F.sid c)) (showpp s)+    _msg ks xs ys = printf "refineC: iter = %d, sid = %s, s = %s, rhs = %d, rhs' = %d \n"+                     _i (show _ci) (showpp ks) (length xs) (length ys) -rhsCands :: F.Solution -> F.SimpC a -> ([F.KVar], F.Cand (F.KVar, F.EQual))-rhsCands s c   = (fst <$> ks, kqs)+rhsCands :: Sol.Solution -> F.SimpC a -> ([F.KVar], Sol.Cand (F.KVar, Sol.EQual))+rhsCands s c    = (fst <$> ks, kqs)   where-    kqs        = [ cnd k su q | (k, su) <- ks, q <- F.solLookup s k]-    ks         = predKs . F.crhs $ c-    cnd k su q = (F.subst su (F.eqPred q), (k, q))+    kqs         = [ (p, (k, q)) | (k, su) <- ks, (p, q)  <- cnd k su ]+    ks          = predKs . F.crhs $ c+    cnd k su    = Sol.qbPreds msg s su (Sol.lookupQBind s k)+    msg         = "rhsCands: " ++ show (F.sid c)  predKs :: F.Expr -> [(F.KVar, F.Subst)] predKs (F.PAnd ps)    = concatMap predKs ps predKs (F.PKVar k su) = [(k, su)] predKs _              = [] ------------------------------------------------------------------------------- | Convert Solution into Result ----------------------------------------------------------------------------------------------------------------------result :: (F.Fixpoint a) => Config -> W.Worklist a -> F.Solution -> SolveM (F.Result (Integer, a))-----------------------------------------------------------------------------result _ wkl s = do+--------------------------------------------------------------------------------+-- | Convert Solution into Result ----------------------------------------------+--------------------------------------------------------------------------------+result :: (F.Fixpoint a) => Config -> W.Worklist a -> Sol.Solution+       -> SolveM (F.Result (Integer, a))+--------------------------------------------------------------------------------+result cfg wkl s = do   lift $ writeLoud "Computing Result"-  stat    <- result_ wkl s-  -- stat'   <- gradualSolve cfg stat-  lift $ print (F.sid <$> stat)-  return   $ F.Result (ci <$> stat) (F.solResult s)+  stat    <- result_ wkl s +  lift $ whenNormal $ putStrLn $ "RESULT: " ++ show (F.sid <$> stat)+  F.Result (ci <$> stat) <$> solResult cfg s <*> return mempty   where     ci c = (F.subcId c, F.sinfo c) +solResult :: Config -> Sol.Solution -> SolveM (M.HashMap F.KVar F.Expr)+solResult cfg = minimizeResult cfg . Sol.result  -result_ :: W.Worklist a -> F.Solution -> SolveM (F.FixResult (F.SimpC a))+result_ :: W.Worklist a -> Sol.Solution -> SolveM (F.FixResult (F.SimpC a)) result_  w s = res <$> filterM (isUnsat s) cs   where     cs       = W.unsatCandidates w     res []   = F.Safe     res cs'  = F.Unsafe cs' -----------------------------------------------------------------------------isUnsat :: F.Solution -> F.SimpC a -> SolveM Bool----------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | `minimizeResult` transforms each KVar's result by removing+--   conjuncts that are implied by others. That is,+--+--      minimizeConjuncts :: ps:[Pred] -> {qs:[Pred] | subset qs ps}+--+--   such that `minimizeConjuncts ps` is a minimal subset of ps where no+--   is implied by /\_{q' in qs \ qs}+--   see: tests/pos/min00.fq for an example. +--------------------------------------------------------------------------------+minimizeResult :: Config -> M.HashMap F.KVar F.Expr+               -> SolveM (M.HashMap F.KVar F.Expr)+--------------------------------------------------------------------------------+minimizeResult cfg s+  | minimalSol cfg = mapM minimizeConjuncts s+  | otherwise      = return s++minimizeConjuncts :: F.Expr -> SolveM F.Expr+minimizeConjuncts p = F.pAnd <$> go (F.conjuncts p) []+  where+    go []     acc   = return acc+    go (p:ps) acc   = do b <- isValid (F.pAnd (acc ++ ps)) p+                         if b then go ps acc+                              else go ps (p:acc)++--------------------------------------------------------------------------------+isUnsat :: Sol.Solution -> F.SimpC a -> SolveM Bool+-------------------------------------------------------------------------------- isUnsat s c = do+  -- lift   $ printf "isUnsat %s" (show (F.subcId c))+  _     <- tickIter True -- newScc   be    <- getBinds   let lp = S.lhsPred be s c   let rp = rhsPred        c@@ -158,8 +223,6 @@   putStrLn $ showpp $ "LHS:" <+> pprint lP   putStrLn $ showpp $ "RHS:" <+> pprint rP -- -------------------------------------------------------------------------------- -- | Predicate corresponding to RHS of constraint in current solution --------------------------------------------------------------------------------@@ -172,64 +235,6 @@ isValid :: F.Expr -> F.Expr -> SolveM Bool isValid p q = (not . null) <$> filterValid p [(q, ())] ------------------------------------------------------------------------------------- | RJ: @nikivazou please add some description here of what this does.----------------------------------------------------------------------------------gradualSolve :: (Fixpoint a)-             => Config-             -> F.FixResult (F.SimpC a)-             -> SolveM (F.FixResult (F.SimpC a))-gradualSolve cfg (F.Unsafe cs)-  | gradual cfg   = go cs-  where-    go cs         = smtEnablrmbqi >> (makeResult . catMaybes <$> mapM gradualSolveOne cs)-    makeResult    = applyNonNull F.Safe F.Unsafe-gradualSolve _  r = return r--gradualSolveOne :: (F.Fixpoint a) => F.SimpC a -> SolveM (Maybe (F.SimpC a))-gradualSolveOne c =-  do γ0 <- makeEnvironment c-     let (γ, γ', hasGradual) = splitLastGradual γ0-     if hasGradual-      then do let vc = makeGradualExpression γ γ' (F.crhs c)-              s <- checkSat vc-              return {- traceShow ("DEBUG" ++ show  (γ, γ', F.crhs c) ++ "\nVC = \n" ++ show (vc, s) ) -}-                 $ if s then Nothing else Just c-      else return $ Just c--makeGradualExpression γ γ' p-  = F.PAnd [F.PAll bs (F.PImp gs p), gs]-  where-    bs = [ (x, s) | (x, F.RR s _) <- γ']-    gs = F.pAnd (bindToLogic <$> (γ ++ γ'))-    bindToLogic (x, F.RR _ (F.Reft (v, e))) = e `F.subst1` (v, F.EVar x)--makeEnvironment  c-  = do lp <- getBinds-       return [ F.lookupBindEnv i lp | i <- bs ]-  where-    bs = sort $ F.elemsIBindEnv $ F.senv c--splitLastGradual = go [] . reverse-  where-    go acc (xe@(x, F.RR s (F.Reft (v, e))) : xss)-      | Just es <- removePGrads e-      = (reverse ((x, F.RR s (F.Reft (v, F.pAnd es))):xss), reverse acc, True)-      | otherwise-      = go (xe:acc) xss-    go acc []-      = ([], reverse acc, False)--removePGrads (F.PAnd es)-  | F.PGrad `elem` es-  = Just $ filter (/= F.PGrad) es-  | otherwise-  = Nothing-removePGrads F.PGrad-  = Just []-removePGrads _-  = Nothing  {- ---------------------------------------------------------------------------
src/Language/Fixpoint/Solver/TrivialSort.hs view
@@ -3,7 +3,6 @@ module Language.Fixpoint.Solver.TrivialSort (nontrivsorts) where  import           GHC.Generics        (Generic)-import           Control.Arrow       (second) import           Language.Fixpoint.Types.PrettyPrint import           Language.Fixpoint.Types.Visitor import           Language.Fixpoint.Types.Config@@ -24,7 +23,7 @@ ------------------------------------------------------------------------- nontrivsorts cfg fi = do   let fi' = simplify' cfg fi-  writeFInfo cfg fi' $ extFileName Out (inFile cfg)+  writeFInfo cfg fi' $ queryFile Out cfg   return mempty  simplify' :: Config -> FInfo a -> FInfo a@@ -42,8 +41,7 @@ -------------------------------------------------------------------- mkNonTrivSorts :: FInfo a -> NonTrivSorts ---------------------------------------------------------------------mkNonTrivSorts = tracepp "mkNonTrivSorts: "-               . nonTrivSorts . trivInfo+mkNonTrivSorts = {- tracepp "mkNonTrivSorts: " . -}  nonTrivSorts . trivInfo  -------------------------------------------------------------------- nonTrivSorts :: TrivInfo -> NonTrivSorts@@ -67,8 +65,8 @@ type NTG = [(NTV, NTV, [NTV])]  data NTV = NTV-         | K KVar-         | S Sort+         | K !KVar+         | S !Sort          deriving (Eq, Ord, Show, Generic)  instance Hashable NTV@@ -144,11 +142,13 @@ }  simplifyBindEnv :: NonTrivSorts -> BindEnv -> BindEnv-simplifyBindEnv = mapBindEnv . second . simplifySortedReft+simplifyBindEnv tm = mapBindEnv (\_ (x, sr) -> (x, simplifySortedReft tm sr))  simplifyWfCs :: NonTrivSorts -> M.HashMap KVar (WfC a) -> M.HashMap KVar (WfC a) simplifyWfCs tm = M.filter (isNonTrivialSort tm . snd3 . wrft) +simplifySubCs :: (Eq k, Hashable k)+              => NonTrivSorts -> M.HashMap k (SubC a) -> M.HashMap k (SubC a) simplifySubCs ti cm = trace msg cm'   where     cm' = tx cm
− src/Language/Fixpoint/Solver/Types.hs
@@ -1,39 +0,0 @@--{-# LANGUAGE ImplicitParams        #-}--module Language.Fixpoint.Solver.Types where---import           Language.Fixpoint.Misc (safeLookup)-import qualified Language.Fixpoint.Types   as F-import qualified Data.HashMap.Strict       as M-import GHC.Stack------------------------------------------------------------------------------- | Dramatis Personae------------------------------------------------------------------------------type CId     = Integer-type CSucc   = CId -> [CId]-type CMap a  = M.HashMap CId a-type KVRead  = M.HashMap F.KVar [CId]-type DepEdge = (CId, CId, [CId])--data Slice = Slice { slKVarCs :: [CId]     -- ^ CIds that transitively "reach" below-                   , slConcCs :: [CId]     -- ^ CIds with Concrete RHS-                   , slEdges  :: [DepEdge] -- ^ Dependencies between slKVarCs-                   } deriving (Eq, Show)--data CGraph = CGraph { gEdges :: [DepEdge]-                     , gRanks :: CMap Int-                     , gSucc  :: CSucc-                     , gSccs  :: Int-                     }-------------------------------------------------------------------------------- | CMap API -------------------------------------------------------------------------------------------------------------------------------------------lookupCMap :: (?callStack :: CallStack) => CMap a -> CId -> a-lookupCMap rm i = safeLookup err i rm-  where-    err      = "lookupCMap: cannot find info for " ++ show i
src/Language/Fixpoint/Solver/UniqifyBinds.hs view
@@ -6,7 +6,7 @@ module Language.Fixpoint.Solver.UniqifyBinds (renameAll) where  import           Language.Fixpoint.Types-import           Language.Fixpoint.Solver.Types  (CId)+import           Language.Fixpoint.Solver.Sanitize (dropDeadSubsts) import           Language.Fixpoint.Misc          (fst3, mlookup)  import qualified Data.HashMap.Strict as M@@ -18,58 +18,81 @@ import           GHC.Generics        (Generic) import           Control.Arrow       (second) import           Control.DeepSeq     (NFData, ($!!))+-- import Debug.Trace (trace) ---------------------------------------------------------------+-------------------------------------------------------------------------------- renameAll    :: SInfo a -> SInfo a-renameAll fi2 = fi4+--------------------------------------------------------------------------------+renameAll fi2 = fi6   where-    fi4      = {-# SCC "renameBinds" #-} renameBinds fi3 $!! rnm-    fi3      = {-# SCC "renameVars"  #-} renameVars fi2 rnm $!! idm-    rnm      = {-# SCC "mkRenameMap" #-} mkRenameMap $!! bs fi2-    idm      = {-# SCC "mkIdMap"     #-} mkIdMap fi2---------------------------------------------------------------+    fi6       = {-# SCC "dropDead"    #-} dropDeadSubsts  fi5+    fi5       = {-# SCC "dropUnused"  #-} dropUnusedBinds fi4+    fi4       = {-# SCC "renameBinds" #-} renameBinds fi3 $!! rnm+    fi3       = {-# SCC "renameVars"  #-} renameVars fi2 rnm $!! idm+    rnm       = {-# SCC "mkRenameMap" #-} mkRenameMap $!! bs fi2+    idm       = {-# SCC "mkIdMap"     #-} mkIdMap fi2 -data Ref = RB BindId | RI CId deriving (Eq, Generic) +--------------------------------------------------------------------------------+-- | `dropUnusedBinds` replaces the refinements of "unused" binders with "true".+--   see tests/pos/unused.fq for an example of why this phase is needed.+--------------------------------------------------------------------------------+dropUnusedBinds :: SInfo a -> SInfo a+dropUnusedBinds fi = fi {bs = filterBindEnv isUsed (bs fi)}-- { bs = mapBindEnv tx (bs fi) }+  where+    -- _tx i (x, r)+    -- | isUsed i    = (x, r)+    -- | otherwise   = (x, top r)+    isUsed i _x r  = {- tracepp (unwords ["isUsed", show i, showpp _x]) $ -} memberIBindEnv i usedBinds || isTauto r+    usedBinds      = L.foldl' unionIBindEnv emptyIBindEnv (cEnvs ++ wEnvs)+    wEnvs          = wenv <$> M.elems (ws fi)+    cEnvs          = senv <$> M.elems (cm fi)++data Ref+  = RB !BindId    -- ^ Bind identifier+  | RI !Integer   -- ^ Constraint identifier?+    deriving (Eq, Generic)+ instance NFData   Ref instance Hashable Ref --- stores for each constraint and BindId the set of other BindIds that it--- references, i.e. those where it needs to know when their names gets changed+-- | An `IdMap` stores for each constraint and BindId the+--   set of other BindIds that it references, i.e. those+--   where it needs to know when their names gets changed type IdMap = M.HashMap Ref (S.HashSet BindId) --- map from old name and sort to new name, represented by a hashmap containing--- association lists. Nothing as new name means same as old+-- | A `RenameMap` maps an old name and sort to new name,+--   represented by a hashmap containing association lists.+--   `Nothing` as new name means the name is the same as the old. type RenameMap = M.HashMap Symbol [(Sort, Maybe Symbol)] ---------------------------------------------------------------+-------------------------------------------------------------------------------- mkIdMap :: SInfo a -> IdMap---------------------------------------------------------------+-------------------------------------------------------------------------------- mkIdMap fi = M.foldlWithKey' (updateIdMap $ bs fi) M.empty $ cm fi -updateIdMap :: BindEnv -> IdMap -> CId -> SimpC a -> IdMap+updateIdMap :: BindEnv -> IdMap -> Integer -> SimpC a -> IdMap updateIdMap be m scId s = M.insertWith S.union (RI scId) refSet m'   where-    ids = elemsIBindEnv $ senv s-    nameMap = M.fromList [(fst $ lookupBindEnv i be, i) | i <- ids]-    m' = foldl' (insertIdIdLinks be nameMap) m ids--    symSet = S.fromList $ syms $ crhs s-    refSet = namesToIds symSet nameMap+    ids                 = elemsIBindEnv (senv s)+    nameMap             = M.fromList [(fst $ lookupBindEnv i be, i) | i <- ids]+    m'                  = foldl' (insertIdIdLinks be nameMap) m ids+    symSet              = S.fromList $ syms $ crhs s+    refSet              = namesToIds symSet nameMap  insertIdIdLinks :: BindEnv -> M.HashMap Symbol BindId -> IdMap -> BindId -> IdMap insertIdIdLinks be nameMap m i = M.insertWith S.union (RB i) refSet m   where-    sr = snd $ lookupBindEnv i be+    sr     = snd $ lookupBindEnv i be     symSet = reftFreeVars $ sr_reft sr     refSet = namesToIds symSet nameMap  namesToIds :: S.HashSet Symbol -> M.HashMap Symbol BindId -> S.HashSet BindId namesToIds xs m = S.fromList $ catMaybes [M.lookup x m | x <- S.toList xs] --TODO why any Nothings? ---------------------------------------------------------------+-------------------------------------------------------------------------------- mkRenameMap :: BindEnv -> RenameMap---------------------------------------------------------------+-------------------------------------------------------------------------------- mkRenameMap be = foldl' (addId be) M.empty ids   where     ids = fst3 <$> bindEnvToList be@@ -87,18 +110,20 @@   | otherwise                   = M.insert sym ((t, Just $ renameSymbol sym i) : mapping) m   where     mapping = fromJust $ M.lookup sym m--------------------------------------------------------------- ---------------------------------------------------------------+--------------------------------------------------------------------------------+-- | `renameVars` seems to do the actual work of renaming all the binders+--   to use their sort-specific names.+-------------------------------------------------------------------------------- renameVars :: SInfo a -> RenameMap -> IdMap -> SInfo a---------------------------------------------------------------+-------------------------------------------------------------------------------- renameVars fi rnMap idMap = M.foldlWithKey' (updateRef rnMap) fi idMap  updateRef :: RenameMap -> SInfo a -> Ref -> S.HashSet BindId -> SInfo a updateRef rnMap fi rf bset = applySub (mkSubst subs) fi rf   where     symTList = [second sr_sort $ lookupBindEnv i $ bs fi | i <- S.toList bset]-    subs = catMaybes $ mkSubUsing rnMap <$> symTList+    subs     = catMaybes $ mkSubUsing rnMap <$> symTList  mkSubUsing :: RenameMap -> (Symbol, Sort) -> Maybe (Symbol, Expr) mkSubUsing m (sym, t) = do@@ -108,25 +133,23 @@ applySub :: Subst -> SInfo a -> Ref -> SInfo a applySub sub fi (RB i) = fi { bs = adjustBindEnv go i (bs fi) }   where-    go (sym, sr)        = (sym, subst sub sr)+    go (sym, sr)       = (sym, subst sub sr)  applySub sub fi (RI i) = fi { cm = M.adjust go i (cm fi) }   where-    go c                = c { _crhs = subst sub (_crhs c) }---------------------------------------------------------------+    go c               = c { _crhs = subst sub (_crhs c) } ---------------------------------------------------------------+-------------------------------------------------------------------------------- renameBinds :: SInfo a -> RenameMap -> SInfo a---------------------------------------------------------------+-------------------------------------------------------------------------------- renameBinds fi m = fi { bs = bindEnvFromList $ renameBind m <$> beList }   where-    beList = bindEnvToList $ bs fi+    beList       = bindEnvToList $ bs fi  renameBind :: RenameMap -> (BindId, Symbol, SortedReft) -> (BindId, Symbol, SortedReft) renameBind m (i, sym, sr)-  | (Just newSym) <- mnewSym = (i, newSym, sr)-  | otherwise                = (i, sym,    sr)+  | Just newSym <- mnewSym = (i, newSym, sr)+  | otherwise              = (i, sym,    sr)   where-    t       = sr_sort sr-    mnewSym = fromJust $ L.lookup t $ mlookup m sym---------------------------------------------------------------+    t                      = sr_sort sr+    mnewSym                = fromJust $ L.lookup t $ mlookup m sym
src/Language/Fixpoint/Solver/UniqifyKVars.hs view
@@ -1,9 +1,9 @@-{--This module creates new bindings for each argument of each kvar.-It also makes sure that all arguments to each kvar are explicit.-For example,+{- | This module creates new bindings for each argument of each kvar.+     It also makes sure that all arguments to each kvar are explicit. -'''+     For example,++``` bind 0 x bind 1 v constraint:@@ -12,11 +12,11 @@ wf:   env [0]   reft {v : int | [$k_42]}-'''+```  becomes -'''+``` bind 0 x bind 1 v bind 2 lq_karg$x$k_42@@ -27,68 +27,80 @@ wf:   env [2]   reft {lq_karg$v$k_42 : int | [$k_42]}-'''+```+ -}  module Language.Fixpoint.Solver.UniqifyKVars (wfcUniqify) where  import           Language.Fixpoint.Types import           Language.Fixpoint.Types.Visitor (mapKVarSubsts)--- import           Language.Fixpoint.Solver.Validate (getDomain) import qualified Data.HashMap.Strict as M import           Data.Foldable       (foldl') ---------------------------------------------------------------+-------------------------------------------------------------------------------- wfcUniqify    :: SInfo a -> SInfo a wfcUniqify fi = updateWfcs $ remakeSubsts fi--------------------------------------------------------------- ---------------------------------------------------------------+++-- mapKVarSubsts (\k su -> restrict table k su xs)+-------------------------------------------------------------------------------- remakeSubsts :: SInfo a -> SInfo a---------------------------------------------------------------+-------------------------------------------------------------------------------- remakeSubsts fi = mapKVarSubsts (remakeSubst fi) fi  remakeSubst :: SInfo a -> KVar -> Subst -> Subst-remakeSubst fi k su = foldl' (updateSubst k) su kDom-  where-    kDom = kvarDomain fi k+remakeSubst fi k su = foldl' (updateSubst k) su (kvarDomain fi k)  updateSubst :: KVar -> Subst -> Symbol -> Subst updateSubst k (Su su) sym-  | sym `M.member` su = Su $ M.delete sym $ M.insert (kArgSymbol sym kx) (su M.! sym) su-  | otherwise         = Su $ M.insert (kArgSymbol sym kx) (eVar sym) su-  where-    kx                = kv k+  = case M.lookup sym su of+      Just z  -> Su $ M.delete sym $ M.insert ksym z          su+      Nothing -> Su $                M.insert ksym (eVar sym) su+    where+      kx      = kv k+      ksym    = kArgSymbol sym kx ---------------------------------------------------------------+-- / | sym `M.member` su = Su $ M.delete sym $ M.insert ksym (su M.! sym) su+-- /  | otherwise         = Su $                M.insert ksym (eVar sym)   su++-------------------------------------------------------------------------------- updateWfcs :: SInfo a -> SInfo a---------------------------------------------------------------+-------------------------------------------------------------------------------- updateWfcs fi = M.foldl' updateWfc fi (ws fi)  updateWfc :: SInfo a -> WfC a -> SInfo a-updateWfc fi w    = fi' { ws = M.insert k w' (ws fi) }+updateWfc fi w    = fi'' { ws = M.insert k w' (ws fi) }   where+    w'            = updateWfCExpr (subst su) w'' +    w''           = w { wenv = insertsIBindEnv newIds mempty, wrft = (v', t, k) }+    (_, fi'')     = newTopBind v' (trueSortedReft t) fi'+    (fi', newIds) = foldl' (accumBindsIfValid k) (fi, []) (elemsIBindEnv $ wenv w)     (v, t, k)     = wrft w-    (fi', newIds) = insertNewBinds w fi k-    env'          = insertsIBindEnv newIds emptyIBindEnv-    w'            = w { wenv = env', wrft = (kArgSymbol v (kv k), t, k) }--insertNewBinds :: WfC a -> SInfo a -> KVar -> (SInfo a, [BindId])-insertNewBinds w fi k = foldl' (accumBindsIfValid k) (fi, []) (elemsIBindEnv $ wenv w)+    v'            = kArgSymbol v (kv k)+    su            = mkSubst ((v, EVar v'):[(x, eVar $ kArgSymbol x (kv k)) | x <- kvarDomain fi k])  accumBindsIfValid :: KVar -> (SInfo a, [BindId]) -> BindId -> (SInfo a, [BindId]) accumBindsIfValid k (fi, ids) i = if renamable then accumBinds k (fi, ids) i else (fi, i : ids)   where-    (_, sr) = lookupBindEnv i (bs fi)-    renamable = isValidInRefinements $ sr_sort sr+    (_, sr)                     = lookupBindEnv i      (bs fi)+    renamable                   = isValidInRefinements (sr_sort sr)  accumBinds :: KVar -> (SInfo a, [BindId]) -> BindId -> (SInfo a, [BindId])-accumBinds k (fi, ids) i = (fi {bs = be'}, i' : ids)+accumBinds k (fi, ids) i = (fi', i' : ids)   where-    --TODO: could we ignore the old SortedReft? what would it mean if it were non-trivial in a wf environment?     (oldSym, sr) = lookupBindEnv i (bs fi)     newSym       = {- tracepp "kArgSymbol" $ -}  kArgSymbol oldSym (kv k)-    (i', be')    = insertBindEnv newSym sr (bs fi)+    (i', fi')    = newTopBind newSym sr fi++-- | `newTopBind` ignores the actual refinements as they are not relevant+--   in the kvar parameters (as suggested by BLC.)+newTopBind :: Symbol -> SortedReft -> SInfo a -> (BindId, SInfo a)+newTopBind x sr fi = (i', fi {bs = be'})+  where+    (i', be')   = insertBindEnv x (top sr) (bs fi)+ --------------------------------------------------------------  isValidInRefinements :: Sort -> Bool
− src/Language/Fixpoint/Solver/Validate.hs
@@ -1,276 +0,0 @@--- | Validate and Transform Constraints to Ensure various Invariants ----------------------------   1. Each binder must be associated with a UNIQUE sort-{-# LANGUAGE TupleSections     #-}-{-# LANGUAGE OverloadedStrings #-}--module Language.Fixpoint.Solver.Validate-       ( -- * Transform FInfo to enforce invariants-         sanitize--         -- * Sorts for each Symbol-       , symbolSorts--       )-       where--import           Language.Fixpoint.Types.PrettyPrint-import           Language.Fixpoint.Types.Visitor (isConcC, isKvarC, mapKVars, mapKVarSubsts)-import           Language.Fixpoint.SortCheck     (isFirstOrder)-import qualified Language.Fixpoint.Misc   as Misc-import           Language.Fixpoint.Misc          (fM)-import qualified Language.Fixpoint.Types  as F-import qualified Language.Fixpoint.Types.Errors as E-import qualified Data.HashMap.Strict      as M-import qualified Data.HashSet             as S-import qualified Data.List as L-import           Data.Maybe          (isNothing)-import           Control.Monad       ((>=>))-import           Text.PrettyPrint.HughesPJ-type ValidateM a = Either E.Error a-----------------------------------------------------------------------------------sanitize :: F.SInfo a -> ValidateM (F.SInfo a)----------------------------------------------------------------------------------sanitize   = fM dropFuncSortedShadowedBinders-         >=> fM dropWfcFunctions-         >=> fM replaceDeadKvars-         >=> fM dropBogusSubstitutions-         >=>    banMixedRhs-         >=>    banQualifFreeVars-         >=>    banConstraintFreeVars------------------------------------------------------------------------------------- | remove substitutions `K[x := e]` where `x` is not in the domain of K----------------------------------------------------------------------------------dropBogusSubstitutions :: F.SInfo a -> F.SInfo a-dropBogusSubstitutions si0 = mapKVarSubsts (F.filterSubst . keepSubst) si0-  where-    kvM                    = kvarDomainM si0-    kvXs k                 = M.lookupDefault S.empty k kvM-    keepSubst k x _        = x `S.member` kvXs k--kvarDomainM :: F.SInfo a -> M.HashMap F.KVar (S.HashSet F.Symbol)-kvarDomainM si = M.fromList [ (k, dom k) | k <- ks ]-  where-    ks         = M.keys (F.ws si)-    dom        = S.fromList . F.kvarDomain si-------------------------------------------------------------------------------- filterBogusSubstitutions :: F.SInfo a -> F.SInfo a--- ------------------------------------------------------------------------------ filterBogusSubstitutions fi = mapKVarSubsts (filterByDomain fi) fi------ filterByDomain :: F.SInfo a -> F.KVar -> F.Subst -> F.Subst--- filterByDomain si k su = F.filterSubst (go kDom) su-  -- where-    -- kDom = getDomain si k-    -- go dom sym _ = sym `elem` dom------------------------------------------------------------------------------------- | check that no constraint has free variables (ignores kvars)----------------------------------------------------------------------------------banConstraintFreeVars :: F.SInfo a -> ValidateM (F.SInfo a)-banConstraintFreeVars fi0 = Misc.applyNonNull (Right fi0) (Left . badCs) bads-  where-    fi = mapKVars (const $ Just F.PTrue) fi0-    bads = [c | c <- M.elems $ F.cm fi, not $ cNoFreeVars fi c]--cNoFreeVars :: F.SInfo a -> F.SimpC a -> Bool-cNoFreeVars fi c = S.null $ cRng `nubDiff` (lits ++ cDom ++ F.prims)-  where-    be = F.bs fi-    lits = fst <$> F.toListSEnv (F.lits fi)-    ids  = F.elemsIBindEnv $ F.senv c-    cDom = [fst $ F.lookupBindEnv i be | i <- ids]-    cRng = concat [S.toList . F.reftFreeVars . F.sr_reft . snd $ F.lookupBindEnv i be | i <- ids]--badCs :: Misc.ListNE (F.SimpC a) -> E.Error-badCs = E.catErrors . map (E.errFreeVarInConstraint . F.subcId)-------------------------------------------------------------------------------------- | check that no qualifier has free variables----------------------------------------------------------------------------------banQualifFreeVars :: F.SInfo a -> ValidateM (F.SInfo a)----------------------------------------------------------------------------------banQualifFreeVars fi = Misc.applyNonNull (Right fi) (Left . badQuals) bads-  where-    bads   = [ (q, xs) | q <- F.quals fi, let xs = free q, not (null xs) ]-    lits   = fst <$> F.toListSEnv (F.lits fi)-    free q = S.toList $ F.syms (F.q_body q) `nubDiff` (lits ++ F.prims ++ F.syms (fst <$> F.q_params q))---badQuals     :: Misc.ListNE (F.Qualifier, Misc.ListNE F.Symbol) -> E.Error-badQuals bqs = E.catErrors [ E.errFreeVarInQual q xs | (q, xs) <- bqs]---- Null if first is a subset of second-nubDiff :: [F.Symbol] -> [F.Symbol] -> S.HashSet F.Symbol-nubDiff a b = a' `S.difference` b'-  where-    a' = S.fromList a-    b' = S.fromList b------------------------------------------------------------------------------------- | check that each constraint has RHS of form [k1,...,kn] or [p]----------------------------------------------------------------------------------banMixedRhs :: F.SInfo a -> ValidateM (F.SInfo a)----------------------------------------------------------------------------------banMixedRhs fi = Misc.applyNonNull (Right fi) (Left . badRhs) bads-  where-    ics        = M.toList $ F.cm fi-    bads       = [(i, c) | (i, c) <- ics, not $ isOk c]-    isOk c     = isKvarC c || isConcC c--badRhs :: Misc.ListNE (Integer, F.SimpC a) -> E.Error-badRhs = E.catErrors . map badRhs1--badRhs1 :: (Integer, F.SimpC a) -> E.Error-badRhs1 (i, c) = E.err E.dummySpan $ vcat [ "Malformed RHS for constraint id" <+> pprint i-                                          , nest 4 (pprint (F.crhs c)) ]---- | Conservative check that KVars appear at "top-level" in pred--- isOkRhs :: F.Pred -> Bool--- isOkRhs p = all isKvar ps  || all isConc ps---  where---     ps    = F.conjuncts p------------------------------------------------------------------------------------ | symbol |-> sort for EVERY variable in the FInfo----------------------------------------------------------------------------------symbolSorts :: F.GInfo c a -> ValidateM [(F.Symbol, F.Sort)]----------------------------------------------------------------------------------symbolSorts fi = (normalize . compact . (defs ++)) =<< bindSorts fi-  where-    normalize  = fmap (map (unShadow dm))-    dm         = M.fromList defs-    defs       = F.toListSEnv $ F.lits fi--unShadow :: M.HashMap F.Symbol a -> (F.Symbol, F.Sort) -> (F.Symbol, F.Sort)-unShadow dm (x, t)-  | M.member x dm  = (x, t)-  | otherwise      = (x, defuncSort t)--defuncSort :: F.Sort -> F.Sort-defuncSort (F.FFunc {}) = F.funcSort-defuncSort t            = t--compact :: [(F.Symbol, F.Sort)] -> Either E.Error [(F.Symbol, F.Sort)]-compact xts-  | null bad  = Right [(x, t) | (x, [t]) <- ok ]-  | otherwise = Left $ dupBindErrors bad'-  where-    bad'      = [(x, (, []) <$> ts) | (x, ts) <- bad]-    (bad, ok) = L.partition multiSorted . binds $ xts-    binds     = M.toList . M.map Misc.sortNub . Misc.group-----------------------------------------------------------------------------------bindSorts  :: F.GInfo c a -> Either E.Error [(F.Symbol, F.Sort)]----------------------------------------------------------------------------------bindSorts fi-  | null bad   = Right [ (x, t) | (x, [(t, _)]) <- ok ]-  | otherwise  = Left $ dupBindErrors [ (x, ts) | (x, ts) <- bad]-  where-    (bad, ok)  = L.partition multiSorted . binds $ fi-    binds      = symBinds . F.bs---multiSorted :: (x, [t]) -> Bool-multiSorted = (1 <) . length . snd--dupBindErrors :: [(F.Symbol, [(F.Sort, [F.BindId] )])] -> E.Error-dupBindErrors = foldr1 E.catError . map dbe-  where-   dbe (x, y) = E.err E.dummySpan $ vcat [ "Multiple sorts for" <+> pprint x-                                         , nest 4 (pprint y) ]-----------------------------------------------------------------------------------symBinds  :: F.BindEnv -> [SymBinds]----------------------------------------------------------------------------------symBinds  = {- THIS KILLS ELEM: tracepp "symBinds" . -}-            M.toList-          . M.map Misc.groupList-          . Misc.group-          . binders--type SymBinds = (F.Symbol, [(F.Sort, [F.BindId])])--binders :: F.BindEnv -> [(F.Symbol, (F.Sort, F.BindId))]-binders be = [(x, (F.sr_sort t, i)) | (i, x, t) <- F.bindEnvToList be]-------------------------------------------------------------------------------------- | Drop func-sorted `bind` that are shadowed by `constant` (if same type, else error)----------------------------------------------------------------------------------dropFuncSortedShadowedBinders :: F.SInfo a -> F.SInfo a----------------------------------------------------------------------------------dropFuncSortedShadowedBinders fi = dropBinders f (const True) fi-  where-    f x t  = not (M.member x defs) || F.allowHO fi || isFirstOrder t-    defs   = M.fromList $ F.toListSEnv $ F.lits fi------------------------------------------------------------------------------------- | Drop functions from WfC environments----------------------------------------------------------------------------------dropWfcFunctions :: F.SInfo a -> F.SInfo a----------------------------------------------------------------------------------dropWfcFunctions fi | F.allowHO fi = fi-dropWfcFunctions fi = fi { F.ws = ws' }-  where-    nonFunction   = isNothing . F.functionSort-    (_, discards) = filterBindEnv (const nonFunction) $  F.bs fi-    ws'           = deleteWfCBinds discards          <$> F.ws fi-------------------------------------------------------------------------------------- | Generic API for Deleting Binders from FInfo----------------------------------------------------------------------------------dropBinders :: KeepBindF -> KeepSortF -> F.SInfo a -> F.SInfo a----------------------------------------------------------------------------------dropBinders f g fi  = fi { F.bs = bs' , F.cm = cm' , F.ws = ws' , F.lits = lits' }-  where-    discards        = {- tracepp "DISCARDING" -} diss-    (bs', diss)     = filterBindEnv f $ F.bs fi-    cm'             = deleteSubCBinds discards   <$> F.cm fi-    ws'             = deleteWfCBinds  discards   <$> F.ws fi-    lits'           = F.filterSEnv g (F.lits fi)--type KeepBindF = F.Symbol -> F.Sort -> Bool-type KeepSortF = F.Sort -> Bool--deleteSubCBinds :: [F.BindId] -> F.SimpC a -> F.SimpC a-deleteSubCBinds bs sc = sc { F._cenv = foldr F.deleteIBindEnv (F.senv sc) bs }--deleteWfCBinds :: [F.BindId] -> F.WfC a -> F.WfC a-deleteWfCBinds bs wf = wf { F.wenv = foldr F.deleteIBindEnv (F.wenv wf) bs }--filterBindEnv :: KeepBindF -> F.BindEnv -> (F.BindEnv, [F.BindId])-filterBindEnv f be  = (F.bindEnvFromList keep, discard')-  where-    (keep, discard) = L.partition f' $ F.bindEnvToList be-    discard'        = Misc.fst3     <$> discard-    f' (_, x, t)    = f x (F.sr_sort t)--------------------------------------------------------------------------------- | Replace KVars that do not have a WfC with PFalse-----------------------------------------------------------------------------replaceDeadKvars :: F.SInfo a -> F.SInfo a-----------------------------------------------------------------------------replaceDeadKvars fi = mapKVars go fi-  where-    go k | k `M.member` F.ws fi = Nothing-         | otherwise            = Just F.PFalse-------------------------------------------------------------------------------- | General helper functions------------------------------------------------------------------------------- domain :: F.BindEnv -> F.WfC a -> [F.Symbol]--- domain be wfc = Misc.fst3 (F.wrft wfc) : map fst (F.envCs be $ F.wenv wfc)------ getDomain :: F.SInfo a -> F.KVar -> [F.Symbol]--- getDomain si k = domain (F.bs si) (getWfC si k)------ getWfC :: F.SInfo a -> F.KVar -> F.WfC a--- getWfC si k = Misc.mlookup (F.ws si) k------ freeVars :: F.Reft -> S.HashSet F.Symbol--- freeVars rft@(F.Reft (v, _)) = S.delete v $ S.fromList $ F.syms rft
src/Language/Fixpoint/Solver/Worklist.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE PartialTypeSignatures #-} {-# LANGUAGE BangPatterns          #-} {-# LANGUAGE TupleSections         #-} @@ -24,28 +23,28 @@        where  import           Prelude hiding (init)-import           Language.Fixpoint.Types.PrettyPrint -- (PTable (..), PPrint (..))+import           Language.Fixpoint.Types.PrettyPrint import qualified Language.Fixpoint.Types   as F-import           Language.Fixpoint.Solver.Types-import           Language.Fixpoint.Solver.Graph+import           Language.Fixpoint.Graph.Types+import           Language.Fixpoint.Graph   (isTarget)+ import           Control.Arrow             (first) import qualified Data.HashMap.Strict       as M import qualified Data.Set                  as S import qualified Data.List                 as L-import           Data.Graph (graphFromEdges) import           Text.PrettyPrint.HughesPJ (text) --- | Worklist -------------------------------------------------------------+-- | Worklist ------------------------------------------------------------------  data Worklist a = WL { wCs     :: !WorkSet                      , wPend   :: !(CMap ())-                     , wDeps   :: CSucc+                     , wDeps   :: !(CMap [F.SubcId])                      , wCm     :: !(CMap (F.SimpC a))                      , wRankm  :: !(CMap Rank)-                     , wLast   :: !(Maybe CId)+                     , wLast   :: !(Maybe F.SubcId)                      , wRanks  :: !Int                      , wTime   :: !Int-                     , wConcCs :: ![CId]+                     , wConcCs :: ![F.SubcId]                      }  data Stats = Stats { numKvarCs  :: !Int@@ -53,7 +52,6 @@                    , _numSccs   :: !Int                    } deriving (Eq, Show) - instance PPrint (Worklist a) where   pprintTidy k = pprintTidy k . S.toList . wCs @@ -70,7 +68,7 @@  type WorkSet  = S.Set WorkItem -data WorkItem = WorkItem { wiCId  :: !CId   -- ^ Constraint Id+data WorkItem = WorkItem { wiCId  :: !F.SubcId   -- ^ Constraint Id                          , wiTime :: !Int   -- ^ Time at which inserted                          , wiRank :: !Rank  -- ^ Rank of constraint                          } deriving (Eq, Show)@@ -87,31 +85,24 @@               , compare i1         i2         -- Otherwise Set drops items               ] --- | Ranks -----------------------------------------------------------------------data Rank = Rank { rScc  :: !Int    -- ^ SCC number with ALL dependencies-                 , rIcc  :: !Int    -- ^ SCC number without CUT dependencies-                 , rTag  :: !F.Tag  -- ^ The constraint's Tag-                 } deriving (Eq, Show)- -------------------------------------------------------------------------------- -- | Initialize worklist and slice out irrelevant constraints ------------------ ---------------------------------------------------------------------------------init :: F.SInfo a -> Worklist a+init :: SolverInfo a b -> Worklist a ---------------------------------------------------------------------------------init fi    = WL { wCs     = items+init sI    = WL { wCs     = items                 , wPend   = addPends M.empty kvarCs                 , wDeps   = cSucc cd                 , wCm     = cm-                , wRankm  = rankm+                , wRankm  = {- F.tracepp "W.init ranks" -} rankm                 , wLast   = Nothing                 , wRanks  = cNumScc cd                 , wTime   = 0                 , wConcCs = concCs                 }   where-    cm        = F.cm  fi-    cd        = cDeps fi+    cm        = F.cm  (siQuery sI)+    cd        = siDeps sI     rankm     = cRank cd     items     = S.fromList $ workItemsAt rankm 0 <$> kvarCs     concCs    = fst <$> ics@@ -137,20 +128,20 @@        , rank w i        ) -popW :: Worklist a -> CId -> WorkSet -> Worklist a+popW :: Worklist a -> F.SubcId -> WorkSet -> Worklist a popW w i is = w { wCs   = is                 , wLast = Just i                 , wPend = remPend (wPend w) i }  -newSCC :: Worklist a -> CId -> Bool+newSCC :: Worklist a -> F.SubcId -> Bool newSCC oldW i = (rScc <$> oldRank) /= (rScc <$> newRank)   where     oldRank   = lookupCMap rankm <$> wLast oldW     newRank   = Just              $  lookupCMap rankm i     rankm     = wRankm oldW -rank :: Worklist a -> CId -> Int+rank :: Worklist a -> F.SubcId -> Int rank w i = rScc $ lookupCMap (wRankm w) i  ---------------------------------------------------------------------------@@ -162,68 +153,19 @@              }   where     i    = F.subcId c-    is'  = filter (not . isPend wp) $ wDeps w i+    is'  = filter (not . isPend wp) $ M.lookupDefault [] i (wDeps w)     wis' = workItemsAt (wRankm w) t <$> is'     t    = wTime w     wp   = wPend w -workItemsAt :: CMap Rank -> Int -> CId -> WorkItem+workItemsAt :: CMap Rank -> Int -> F.SubcId -> WorkItem workItemsAt !r !t !i = WorkItem { wiCId  = i                                 , wiTime = t                                 , wiRank = lookupCMap r i } ------------------------------------------------------------------------------- | Constraint Dependencies -------------------------------------------------------------------------------------------------------------------------- -data CDeps = CDs { cSucc   :: CSucc-                 , cRank   :: CMap Rank-                 , cNumScc :: Int-                 }  ----------------------------------------------------------------------------cDeps :: F.SInfo a -> CDeps-----------------------------------------------------------------------------cDeps fi  = CDs { cSucc   = gSucc cg-                , cNumScc = gSccs cg-                , cRank   = M.fromList [(i, rf i) | i <- is ]-                }-  where-    rf    = rankF (F.cm fi) outRs inRs-    inRs  = inRanks fi es outRs-    outRs = gRanks cg-    es    = gEdges cg-    cg    = cGraph fi-    cm    = F.cm fi-    is    = M.keys cm--rankF :: CMap (F.SimpC a) -> CMap Int -> CMap Int -> CId -> Rank-rankF cm outR inR = \i -> Rank (outScc i) (inScc i) (tag i)-  where-    outScc        = lookupCMap outR-    inScc         = lookupCMap inR-    tag           = F._ctag . lookupCMap cm--------------------------------------------------------------------------------inRanks :: F.SInfo a -> [DepEdge] -> CMap Int -> CMap Int-----------------------------------------------------------------------------inRanks fi es outR-  | ks == mempty      = outR-  | otherwise         = fst $ graphRanks g' vf'-  where-    ks                = F.kuts fi-    cm                = F.cm fi-    (g', vf', _)      = graphFromEdges es'-    es'               = [(i, i, filter (not . isCut i) js) | (i,_,js) <- es ]-    isCut i j         = S.member i cutCIds && isEqOutRank i j-    isEqOutRank i j   = lookupCMap outR i == lookupCMap outR j-    cutCIds           = S.fromList [i | i <- M.keys cm, isKutWrite i ]-    isKutWrite        = any (`F.ksMember` ks) . kvWriteBy cm------------------------------------------------------------------------------ stats :: Worklist a -> Stats --------------------------------------------------------------------------- stats w = Stats (kn w) (cn w) (wRanks w)@@ -235,16 +177,16 @@ -- | Pending API --------------------------------------------------------------------------- -addPends :: CMap () -> [CId] -> CMap ()+addPends :: CMap () -> [F.SubcId] -> CMap () addPends = L.foldl' addPend -addPend :: CMap () -> CId -> CMap ()+addPend :: CMap () -> F.SubcId -> CMap () addPend m i = M.insert i () m -remPend :: CMap () -> CId -> CMap ()+remPend :: CMap () -> F.SubcId -> CMap () remPend m i = M.delete i m -isPend :: CMap () -> CId -> Bool+isPend :: CMap () -> F.SubcId -> Bool isPend w i = M.member i w  ---------------------------------------------------------------------------@@ -254,5 +196,5 @@ sAdds :: WorkSet -> [WorkItem] -> WorkSet sAdds = L.foldl' (flip S.insert) -sPop :: WorkSet -> Maybe (CId, WorkSet)+sPop :: WorkSet -> Maybe (F.SubcId, WorkSet) sPop = fmap (first wiCId) . S.minView
src/Language/Fixpoint/SortCheck.hs view
@@ -4,6 +4,7 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TupleSections         #-} {-# LANGUAGE OverloadedStrings     #-}+{-# LANGUAGE PatternGuards         #-}  -- | This module has the functions that perform sort-checking, and related -- operations on Fixpoint expressions and predicates.@@ -21,11 +22,13 @@   , pruneUnsortedReft    -- * Sort inference-  , sortExpr, checkSortExpr+  , sortExpr+  , checkSortExpr+  , exprSort    -- * Unify   , unifyFast-  , unify+  , unifySorts    -- * Apply Substitution   , apply@@ -33,8 +36,10 @@   -- * Exported Sorts   , boolSort   , strSort-  , elaborate +  -- * Sort-Directed Transformations+  , Elaborate (..)+   -- * Predicates on Sorts   , isFirstOrder   , isMono@@ -49,41 +54,147 @@  import           Language.Fixpoint.Types.PrettyPrint import           Language.Fixpoint.Misc-import           Language.Fixpoint.Types hiding (subst)-import           Language.Fixpoint.Types.Visitor (foldSort)-import           Language.Fixpoint.Smt.Theories (theoryEnv)+import           Language.Fixpoint.Types hiding   (subst)+import           Language.Fixpoint.Types.Visitor  (mapExpr, stripCasts, foldSort)+import qualified Language.Fixpoint.Smt.Theories   as Thy import           Text.PrettyPrint.HughesPJ import           Text.Printf  -- import Debug.Trace ----------------------------------------------------------------------------- | Predicates on Sorts ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------isFirstOrder :: Sort -> Bool---------------------------------------------------------------------------isFirstOrder (FAbs _ t)    = isFirstOrder t-isFirstOrder (FFunc s1 s2) = noFun s1 && isFirstOrder s2-isFirstOrder _             = True--noFun (FFunc _ _) = False-noFun (FAbs _ _)  = False-noFun _           = True---------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | Predicates on Sorts -------------------------------------------------------+-------------------------------------------------------------------------------- isMono :: Sort -> Bool--------------------------------------------------------------------------+-------------------------------------------------------------------------------- isMono             = null . foldSort fv []   where     fv vs (FVar i) = i : vs     fv vs _        = vs ----------------------------------------------------------------------------- | Sort Inference       ------------------------------------------------------------------------------------------------------------------------- +--------------------------------------------------------------------------------+-- | Elaborate: make polymorphic instantiation explicit via casts,+--   make applications monomorphic for SMTLIB. This deals with+--   polymorphism by `elaborate`-ing all refinements except for+--   KVars. THIS IS NOW MANDATORY as sort-variables can be instantiated+--   to `int` and `bool`.+--------------------------------------------------------------------------------+class Elaborate a where+  elaborate :: String -> SEnv Sort -> a -> a++instance Elaborate (SInfo a) where+  elaborate x senv si = si+    { cm      = elaborate x senv <$> cm      si+    , bs      = elaborate x senv  $  bs      si+    , asserts = elaborate x senv <$> asserts si+    }++instance (Elaborate e) => (Elaborate (Triggered e)) where+  elaborate x env t = fmap (elaborate x env) t++instance Elaborate Sort where+  elaborate _ _ = go+   where+      go s | isString s = strSort+      go (FAbs i s)    = FAbs i $ go s+      go (FFunc s1 s2) = funSort (go s1) (go s2)+      go (FApp s1 s2)  = FApp    (go s1) (go s2)+      go s             = s+      funSort :: Sort -> Sort -> Sort+      funSort = FApp . FApp funcSort++instance Elaborate Expr where+  elaborate msg env = elabNumeric . elabApply . elabExpr msg env++instance Elaborate (Symbol, Sort) where+  elaborate msg env (x, s) = (x,) (elaborate msg env s)++instance Elaborate a => Elaborate [a]  where+  elaborate msg env xs = elaborate msg env <$> xs++elabNumeric :: Expr -> Expr+elabNumeric = mapExpr go+  where+    go (ETimes e1 e2)+      | exprSort "txn1" e1 == FReal+      , exprSort "txn2" e2 == FReal+      = ERTimes e1 e2+    go (EDiv   e1 e2)+      | exprSort ("txn3: " ++ showpp e1) e1 == FReal+      , exprSort "txn4" e2 == FReal+      = ERDiv   e1 e2+    go e+      = e++instance Elaborate SortedReft where+  elaborate x env (RR s (Reft (v, e))) = RR s (Reft (v, e'))+    where+      e'   = elaborate x env' e+      env' = insertSEnv v s env++instance Elaborate BindEnv where+  elaborate z env = mapBindEnv (\i (x, sr) -> (x, elaborate (z ++ msg i x sr) env sr))+    where+      msg i x sr  = unwords [" elabBE",  show i, show x, show sr]++instance Elaborate (SimpC a) where+  elaborate x env c = c {_crhs = elaborate x env (_crhs c) }++-- instance Elaborate Qualifier where+  -- elaborate env q = q { qParams = elaborate env (qParams q)+                      -- , qBody   = elaborate [env ++ qParams] (qBody q)+                      -- }++elabExpr :: String -> SEnv Sort -> Expr -> Expr+elabExpr msg γ e+  = case runCM0 $ elab f e of+      Left msg -> die $ err dummySpan (d msg)+      Right s  -> fst s+    where+      f   = (`lookupSEnvWithDistance` γ')+      γ'  = γ `mappend` Thy.theorySEnv+      d m = vcat [ "elaborate" <+> text msg <+> "failed on:"+                 , nest 4 (pprint e)+                 , "with error"+                 , nest 4 (text m)+                 , "in environment"+                 , nest 4 (pprint $ subEnv γ' e)+                 ]++elabApply :: Expr -> Expr+elabApply = go+  where+    go e                  = case splitArgs e of+                             (e', []) -> step e'+                             (f , es) -> defuncEApp (go f) (mapFst go <$> es)+    step (PAnd [])        = PTrue+    step (POr [])         = PFalse+    step (ENeg e)         = ENeg (go  e)+    step (EBin o e1 e2)   = EBin o (go e1) (go e2)+    step (EIte e1 e2 e3)  = EIte (go e1) (go e2) (go e3)+    step (ECst e t)       = ECst (go e) t+    step (PAnd ps)        = PAnd (go <$> ps)+    step (POr ps)         = POr  (go <$> ps)+    step (PNot p)         = PNot (go p)+    step (PImp p q)       = PImp (go p) (go q)+    step (PIff p q)       = PIff (go p) (go q)+    step (PExist bs p)    = PExist bs (go p)+    step (PAll   bs p)    = PAll   bs (go p)+    step (PAtom r e1 e2)  = PAtom r (go e1) (go e2)+    step e@(EApp {})      = go e+    step (ELam b e)       = ELam b (go e)+    step (PGrad k su e)   = PGrad k su (go e)+    step e@(PKVar {})     = e+    step e@(ESym {})      = e+    step e@(ECon {})      = e+    step e@(EVar {})      = e+    -- ELam, ETApp, ETAbs, PAll, PExist+    step e                = error $ "TODO elabApply: " ++ showpp e++--------------------------------------------------------------------------------+-- | Sort Inference ------------------------------------------------------------+-------------------------------------------------------------------------------- sortExpr :: SrcSpan -> SEnv Sort -> Expr -> Sort sortExpr l γ e = case runCM0 $ checkExpr f e of     Left msg -> die $ err l (d msg)@@ -93,7 +204,10 @@     d m = vcat [ "sortExpr failed on expression:"                , nest 4 (pprint e)                , "with error:"-               , nest 4 (text m)]+               , nest 4 (text m)+               , "in environment"+               , nest 4 (pprint γ)+               ]  checkSortExpr :: SEnv Sort -> Expr -> Maybe Sort checkSortExpr γ e = case runCM0 $ checkExpr f e of@@ -104,24 +218,16 @@             Just z  -> Found z             Nothing -> Alts [] --elaborate :: SEnv Sort -> Expr -> Expr-elaborate γ e-  = case runCM0 $ elab f e of-      Left msg -> die $ err dummySpan (d msg)-      Right s  -> fst s+subEnv :: (Subable e) => SEnv a -> e -> SEnv a+subEnv g e = intersectWithSEnv (\t _ -> t) g g'   where-    f   = (`lookupSEnvWithDistance` γ')-    γ'  = unionSEnv γ theoryEnv-    d m = vcat [ "elaborate failed on:"-               , nest 4 (pprint e)-               , "with error"-               , nest 4 (text m)    ]+    g' = fromListSEnv $ (, ()) <$> syms e ----------------------------------------------------------------------------- | Checking Refinements ------------------------------------------------------------------------------------------------------------------------- +--------------------------------------------------------------------------------+-- | Checking Refinements ------------------------------------------------------+--------------------------------------------------------------------------------+ -- | Types used throughout checker  type StateM = Int@@ -130,6 +236,7 @@  type Env      = Symbol -> SESearch Sort + instance Monad CheckM where   return x     = CM $ \i -> (i, Right x)   (CM m) >>= f = CM $ \i -> case m i of@@ -143,6 +250,9 @@                                       (j, Left s) -> runCM (f s) j                                       (j, Right x) -> (j, Right x) +withError :: CheckM a -> String -> CheckM a+act `withError` e' = act `catchError` (\e -> throwError (e ++ "\n  because\n" ++ e'))+ instance Functor CheckM where   fmap f (CM m) = CM $ \i -> case m i of {(j, Left s) -> (j, Left s); (j, Right x) -> (j, Right $ f x)} @@ -154,7 +264,10 @@                                  (k, Left s)  -> (k, Left s)                                  (k, Right g) -> (k, Right $ g x) +initCM :: StateM initCM = 42++runCM0 :: CheckM a -> Either String a runCM0 act = snd $ runCM act initCM  class Freshable a where@@ -169,10 +282,9 @@   fresh   = mapM (const fresh) [0..]   refresh = mapM refresh ----------------------------------------------------------------------------- | Checking Refinements --------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | Checking Refinements ------------------------------------------------------+-------------------------------------------------------------------------------- checkSortedReft :: SEnv SortedReft -> [Symbol] -> SortedReft -> Maybe Doc checkSortedReft env xs sr = applyNonNull Nothing oops unknowns   where@@ -210,6 +322,7 @@     γ'   = insertSEnv v s γ     -- wmsg t r = "WARNING: prune unsorted reft:\n" ++ showFix r ++ "\n" ++ t +checkPred' :: Env -> Expr -> Maybe Expr checkPred' f p = res -- traceFix ("checkPred: p = " ++ showFix p) $ res   where     res        = case runCM0 $ checkPred f p of@@ -235,12 +348,10 @@    where      γ' = insertSEnv v s γ ----------------------------------------------------------------------------- | Checking Expressions --------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | Checking Expressions ------------------------------------------------------+-------------------------------------------------------------------------------- checkExpr                  :: Env -> Expr -> CheckM Sort- checkExpr _ (ESym _)       = return strSort checkExpr _ (ECon (I _))   = return FInt checkExpr _ (ECon (R _))   = return FReal@@ -258,7 +369,7 @@ checkExpr f (POr ps)       = mapM_ (checkPred f) ps >> return boolSort checkExpr f (PAtom r e e') = checkRel f r e e' >> return boolSort checkExpr _ (PKVar {})     = return boolSort-checkExpr _ PGrad          = return boolSort+checkExpr f (PGrad _ _ e)  = checkPred f e >> return boolSort  checkExpr f (PAll  bs e )  = checkExpr (addEnv f bs) e checkExpr f (PExist bs e)  = checkExpr (addEnv f bs) e@@ -285,11 +396,11 @@  elab f (EApp e1@(EApp _ _) e2) = do   (e1', _, e2', s2, s) <- elabEApp f e1 e2-  return (EApp e1' (ECst e2' s2), s)+  return (eAppC s e1' (ECst e2' s2), s)  elab f (EApp e1 e2) = do   (e1', s1, e2', s2, s) <- elabEApp f e1 e2-  return (EApp (ECst e1' s1) (ECst e2' s2), s)+  return (eAppC s (ECst e1' s1) (ECst e2' s2), s)  elab _ e@(ESym _) =   return (e, strSort)@@ -306,8 +417,8 @@ elab _ e@(PKVar _ _) =   return (e, boolSort) -elab _ e@PGrad =-  return (e, boolSort)+elab f (PGrad k su e) = +  ((, boolSort) . PGrad k su . fst) <$> elab f e   elab f e@(EVar x) =   (e,) <$> checkSym f x@@ -349,70 +460,145 @@   ps' <- mapM (elab f) ps   return (POr (fst <$> ps'), boolSort) -elab f (PAtom Eq e1 e2) = do+elab f e@(PAtom Eq e1 e2) = do   t1        <- checkExpr f e1   t2        <- checkExpr f e2-  (t1',t2') <- unite f  t1 t2+  (t1',t2') <- unite f e  t1 t2 `withError` (errElabExpr e)   e1'       <- elabAs f t1' e1   e2'       <- elabAs f t2' e2-  return (PAtom Eq e1' e2', boolSort)+  return (PAtom Eq (ECst e1' t1') (ECst e2' t2'), boolSort) -elab f (PAtom r e1 e2) = do+elab f (PAtom r e1 e2)+  | r == Ueq || r == Une = do   (e1', _) <- elab f e1   (e2', _) <- elab f e2   return (PAtom r e1' e2', boolSort) +elab f (PAtom r e1 e2) = do+  e1' <- uncurry Thy.toInt <$> elab f e1+  e2' <- uncurry Thy.toInt <$> elab f e2+  return (PAtom r e1' e2', boolSort)+ elab f (PExist bs e) = do   (e', s) <- elab (addEnv f bs) e-  return (PExist bs e', s)+  let bs' = elaborate "PExist Args" mempty bs+  return (PExist bs' e', s)  elab f (PAll bs e) = do   (e', s) <- elab (addEnv f bs) e-  return (PAll bs e', s)+  let bs' = elaborate "PAll Args" mempty bs+  return (PAll bs' e', s)  elab f (ELam (x,t) e) = do   (e', s) <- elab (addEnv f [(x,t)]) e-  return (ELam (x,t) (ECst e' s), FFunc t s)+  let t' = elaborate "ELam Arg" mempty t+  return (ELam (x,t') (ECst e' s), FFunc t s)  elab _ (ETApp _ _) =   error "SortCheck.elab: TODO: implement ETApp" elab _ (ETAbs _ _) =   error "SortCheck.elab: TODO: implement ETAbs" +-- elabAs :: Env -> Sort -> Expr -> CheckM Expr+-- elabAs f t e = tracepp msg <$> elabAs' f t e+--  where+--    msg  = "elabAs: t = " ++ show t ++ " e = " ++ show e+ elabAs :: Env -> Sort -> Expr -> CheckM Expr-elabAs f t e@(EApp {}) = elabAppAs f t g es where (g, es) = splitEApp e-elabAs f _ e           = fst <$> elab f e+elabAs f t (EApp e1 e2) = elabAppAs f t e1 e2+elabAs f _ e            = fst <$> elab f e -elabAppAs :: Env -> Sort -> Expr -> [Expr] -> CheckM Expr-elabAppAs f t g es = do-  gT    <- generalize =<< checkExpr f g-  eTs   <- mapM (checkExpr f) es-  gTios <- sortFunction (length es) gT-  su    <- unifys f (snd gTios:fst gTios) (t:eTs)-  let tg = apply su gT -  g'    <- elabAs f tg g-  let ts = apply su <$> eTs-  es'   <- zipWithM (elabAs f) ts es-  return $ eApps (ECst g' tg) (zipWith ECst es' ts)+elabAppAs :: Env -> Sort -> Expr -> Expr -> CheckM Expr+elabAppAs f t g e = do+  gT       <- generalize =<< checkExpr f g+  eT       <- checkExpr f e+  (iT, oT, isu) <- checkFunSort gT+  let ge    = Just (EApp g e)+  su       <- unifyMany f ge isu [oT, iT] [t, eT]+  let tg    = apply su gT+  g'       <- elabAs f tg g+  let te    = apply su eT+  e'       <- elabAs f te e+  return    $ EApp (ECst g' tg) (ECst e' te)  elabEApp  :: Env -> Expr -> Expr -> CheckM (Expr, Sort, Expr, Sort, Sort) elabEApp f e1 e2 = do   (e1', s1) <- elab f e1   (e2', s2) <- elab f e2-  s         <- elabAppSort f s1 s2-  return (e1', s1, e2', s2, s)+  s         <- elabAppSort f e1 e2 s1 s2+  return      (e1', s1, e2', s2, s) -unite :: Env -> Sort -> Sort -> CheckM (Sort, Sort)--- unite' f t1@(FObj l) t2@FInt = do-  -- checkNumeric f l-  -- return (t1, t2)--- unite' f t1@FInt t2@(FObj l) = do-  -- checkNumeric f l-  -- return (t1, t2)-unite f t1 t2 = do-  su <- unifys f [t1] [t2]+--------------------------------------------------------------------------------+-- | defuncEApp monomorphizes function applications.+--------------------------------------------------------------------------------+defuncEApp :: Expr -> [(Expr, Sort)] -> Expr+defuncEApp e es+  | Thy.isSmt2App (stripCasts e) es+  = eApps e (fst <$> es)+  | otherwise+  = L.foldl' makeApplication e es++-- e1 e2 => App (App runFun e1) (toInt e2)+makeApplication :: Expr -> (Expr, Sort) -> Expr+makeApplication e1 (e2, s) = ECst (EApp (EApp (EVar f) e1) e2') s+  where+    f                      = makeFunSymbol (spec s)+    e2'                    = Thy.toInt e2 (exprSort "makeApplication" e2)+    -- s                      = fromMaybe (resultType e1 e2) sO+    spec                 :: Sort -> Sort+    spec (FAbs _ s)      = spec s+    spec s               = s++makeFunSymbol :: Sort -> Symbol+makeFunSymbol s+  | (FApp (FTC c) _) <- s+  , Thy.isConName setConName c+  = setApplyName 1+  | (FApp (FApp (FTC c) _) _) <- s+  , Thy.isConName mapConName c+  = mapApplyName 1+  | (FApp (FTC bv) (FTC s))   <- s+  , Thy.isConName bitVecName bv+  , Just _ <- Thy.sizeBv s+  = bitVecApplyName 1+  | FTC c <- s, c == boolFTyCon+  = boolApplyName 1+  | s == FReal+  = realApplyName 1+  | otherwise+  = intApplyName 1++splitArgs :: Expr -> (Expr, [(Expr, Sort)])+splitArgs = go []+  where+    go acc (ECst (EApp e1 e) s) = go ((e, s) : acc) e1+    go _   e@EApp{}             = errorstar $ "UNEXPECTED: splitArgs: EApp without output type: " ++ showpp e+    -- go acc (ECst e _)           = go acc e+    go acc e                    = (e, acc)++--------------------------------------------------------------------------------+-- | Expressions sort  ---------------------------------------------------------+--------------------------------------------------------------------------------+exprSort :: String -> Expr -> Sort+exprSort msg = go+  where+    go (ECst _ s) = s+    go (ELam (_, sx) e) = FFunc sx (go e)+    go (EApp e ex)+      | FFunc sx s <- genSort (go e)+      = maybe s (`apply` s) $ unifySorts (go ex) sx+    go e = errorstar ("\nexprSort [" ++ msg ++ "] on unexpected expressions " ++ show e)++genSort :: Sort -> Sort+genSort (FAbs _ t) = genSort t+genSort t          = t++unite :: Env -> Expr -> Sort -> Sort -> CheckM (Sort, Sort)+unite f e t1 t2 = do+  su <- unifys f (Just e) [t1] [t2]   return (apply su t1, apply su t2) + -- | Helper for checking symbol occurrences checkSym :: Env -> Symbol -> CheckM Sort checkSym f x@@ -422,11 +608,13 @@  -- | Helper for checking if-then-else expressions checkIte :: Env -> Expr -> Expr -> Expr -> CheckM Sort-checkIte f p e1 e2-  = do checkPred f p-       t1 <- checkExpr f e1-       t2 <- checkExpr f e2-       ((`apply` t1) <$> unifys f [t1] [t2]) `catchError` (\_ -> throwError $ errIte e1 e2 t1 t2)+checkIte f p e1 e2 = do+  checkPred f p+  t1 <- checkExpr f e1+  t2 <- checkExpr f e2+  ((`apply` t1) <$> unifys f e' [t1] [t2]) `withError` (errIte e1 e2 t1 t2)+  where+    e' = Just (EIte  p e1 e2)  -- | Helper for checking cast expressions checkCst :: Env -> Sort -> Expr -> CheckM Sort@@ -434,15 +622,18 @@   = checkApp f (Just t) g e checkCst f t e   = do t' <- checkExpr f e-       ((`apply` t) <$> unifys f [t] [t']) `catchError` (\_ -> throwError $ errCast e t' t)+       ((`apply` t) <$> unifys f (Just e) [t] [t']) `withError` (errCast e t' t) -elabAppSort :: Env -> Sort -> Sort -> CheckM Sort-elabAppSort f s1 s2 =-  do s1' <- generalize s1-     case s1' of-        FFunc sx s -> do θ <- unifys f [sx] [s2]-                         return $ apply θ s-        _ -> errorstar "Foo"+elabAppSort :: Env -> Expr -> Expr -> Sort -> Sort -> CheckM Sort+elabAppSort f e1 e2 s1 s2 = do+  s1'  <- generalize s1+  let e = Just (EApp e1 e2)+  case s1' of+    FFunc sx s -> (`apply` s) <$> unifys f e [sx] [s2]+    FVar i     -> do j <- refresh 0 +                     k <- refresh 0 +                     (`apply` (FVar k)) <$> unifyMany f e (updateVar i (FFunc (FVar j) (FVar j)) emptySubst) [FVar j] [s2]+    _          -> errorstar ("elabAppSort for expr" ++ showpp (EApp e1 e2) ++ " with sorts" ++ showpp s1  ++ " and " ++ showpp s2 )  checkApp :: Env -> Maybe Sort -> Expr -> Expr -> CheckM Sort checkApp f to g es@@ -451,13 +642,32 @@ checkExprAs :: Env -> Sort -> Expr -> CheckM Sort checkExprAs f t (EApp g e)   = checkApp f (Just t) g e-checkExprAs f t e -  = do t' <- checkExpr f e -       θ  <- unifys f [t'] [t]+checkExprAs f t e+  = do t' <- checkExpr f e+       θ  <- unifys f (Just e) [t'] [t]        return $ apply θ t  -- | Helper for checking uninterpreted function applications+-- | Checking function application should be curried,+-- | consider checking+-- | fromJust :: Maybe a -> a, f :: Maybe (b -> b), x: c |- fromJust f x+ checkApp' :: Env -> Maybe Sort -> Expr -> Expr -> CheckM (TVSubst, Sort)+checkApp' f to g e = do+  gt       <- checkExpr f g >>= generalize+  et       <- checkExpr f e+  (it, ot, isu) <- checkFunSort gt+  let ge    = Just (EApp g e)+  θ        <- unifyMany f ge isu [it] [et]+  let t     = apply θ ot+  case to of+    Nothing    -> return (θ, t)+    Just t'    -> do θ' <- unifyMany f ge θ [t] [t']+                     let ti = apply θ' et+                     _ <- checkExprAs f ti e+                     return (θ', apply θ' t)++{- checkApp' f to g' e   = do gt           <- checkExpr f g        gt'          <- generalize gt@@ -468,22 +678,18 @@        case to of          Nothing    -> return (θ, t)          Just t'    -> do θ' <- unifyMany f θ [t] [t']-                          let ts = apply θ' <$> ets -                          _ <- zipWithM (checkExprAs f) ts es +                          let ts = apply θ' <$> ets+                          _ <- zipWithM (checkExprAs f) ts es                           return (θ', apply θ' t)   where     (g, es) = splitEApp $ EApp g' e+-}  -- | Helper for checking binary (numeric) operations checkNeg :: Env -> Expr -> CheckM Sort checkNeg f e = do   t <- checkExpr f e-  case t of-   FReal    -> return FReal-   FInt     -> return FInt-   (FObj l) -> checkNumeric f l >> return t-   _        -> throwError $ printf "Operand has non-numeric type %s in %s"-                            (showFix t) (showFix e)+  checkNumeric f t >> return t  checkOp :: Env -> Expr -> Bop -> Expr -> CheckM Sort checkOp f e1 o e2@@ -491,7 +697,8 @@        t2 <- checkExpr f e2        checkOpTy f (EBin o e1 e2) t1 t2 -checkOpTy :: PPrint a => Env -> a -> Sort -> Sort -> CheckM Sort++checkOpTy :: Env -> Expr -> Sort -> Sort -> CheckM Sort checkOpTy _ _ FInt FInt   = return FInt @@ -504,28 +711,30 @@ checkOpTy _ _ FReal FInt   = return FReal -checkOpTy f _ t@(FObj l) (FObj l')-  | l == l'-  = checkNumeric f l >> return t+checkOpTy f _ t t'+  | t == t'+  = checkNumeric f t >> return t  checkOpTy _ e t t'   = throwError $ errOp e t t' -checkFractional :: Env -> Symbol -> CheckM ()-checkFractional f l+checkFractional :: Env -> Sort -> CheckM ()+checkFractional f s@(FObj l)   = do t <- checkSym f l-       unless (t == FFrac) (throwError $ errNonFractional l)-       return ()+       unless (t == FFrac) (throwError $ errNonFractional s)+checkFractional _ s+  = unless (isReal s) (throwError $ errNonFractional s) -checkNumeric :: Env -> Symbol -> CheckM ()-checkNumeric f l+checkNumeric :: Env -> Sort -> CheckM ()+checkNumeric f s@(FObj l)   = do t <- checkSym f l-       unless (t == FNum || t == FFrac) (throwError $ errNonNumeric l)-       return ()+       unless (t == FNum || t == FFrac) (throwError $ errNonNumeric s)+checkNumeric _ s+  = unless (isNumeric s) (throwError $ errNonNumeric s) ----------------------------------------------------------------------------- | Checking Predicates --------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | Checking Predicates -------------------------------------------------------+--------------------------------------------------------------------------------  checkPred                  :: Env -> Expr -> CheckM () checkPred f e = checkExpr f e >>= checkBoolSort e@@ -535,112 +744,128 @@  | s == boolSort = return ()  | otherwise     = throwError $ errBoolSort e s + -- | Checking Relations checkRel :: Env -> Brel -> Expr -> Expr -> CheckM ()-checkRel f Eq e1 e2                = do t1 <- checkExpr f e1-                                        t2 <- checkExpr f e2-                                        su <- unifys f [t1] [t2]-                                        checkExprAs f (apply su t1) e1 -                                        checkExprAs f (apply su t2) e2-                                        checkRelTy f (PAtom Eq e1 e2) Eq t1 t2-checkRel f r  e1 e2                = do t1 <- checkExpr f e1-                                        t2 <- checkExpr f e2-                                        checkRelTy f (PAtom r e1 e2) r t1 t2--checkRelTy :: (Fixpoint a, PPrint a) => Env -> a -> Brel -> Sort -> Sort -> CheckM ()-checkRelTy f _ _ (FObj l) (FObj l') | l /= l'-  = (checkNumeric f l >> checkNumeric f l') `catchError` (\_ -> throwError $ errNonNumerics l l')-checkRelTy f _ _ FInt (FObj l)     = checkNumeric f l `catchError` (\_ -> throwError $ errNonNumeric l)-checkRelTy f _ _ (FObj l) FInt     = checkNumeric f l `catchError` (\_ -> throwError $ errNonNumeric l)-checkRelTy _ _ _ FReal FReal       = return ()-checkRelTy _ _ _ FInt  FReal       = return ()-checkRelTy _ _ _ FReal FInt        = return ()-checkRelTy f _ _ FReal (FObj l)    = checkFractional f l `catchError` (\_ -> throwError $ errNonFractional l)-checkRelTy f _ _ (FObj l) FReal    = checkFractional f l `catchError` (\_ -> throwError $ errNonFractional l)+checkRel f Eq e1 e2 = do+  t1 <- checkExpr f e1+  t2 <- checkExpr f e2+  su <- (unifys f (Just e) [t1] [t2]) `withError` (errRel e t1 t2)+  _  <- checkExprAs f (apply su t1) e1+  _  <- checkExprAs f (apply su t2) e2+  checkRelTy f e Eq t1 t2+  where+    e = PAtom Eq e1 e2 -checkRelTy _ e Eq t1 t2-  | t1 == boolSort ||-    t2 == boolSort                 = throwError $ errRel e t1 t2-checkRelTy _ e Ne t1 t2-  | t1 == boolSort ||-    t2 == boolSort                 = throwError $ errRel e t1 t2-checkRelTy f _ Eq t1 t2            = void $ unifys f [t1] [t2]-checkRelTy f _ Ne t1 t2            = void $ unifys f [t1] [t2]+checkRel f r  e1 e2 = do+  t1 <- checkExpr f e1+  t2 <- checkExpr f e2+  checkRelTy f (PAtom r e1 e2) r t1 t2 +checkRelTy :: Env -> Expr -> Brel -> Sort -> Sort -> CheckM () checkRelTy _ _ Ueq _ _             = return () checkRelTy _ _ Une _ _             = return ()-checkRelTy _ e _  t1 t2            = unless (t1 == t2)                 (throwError $ errRel e t1 t2)+checkRelTy f _ _ s1@(FObj l) s2@(FObj l') | l /= l'+  = (checkNumeric f s1 >> checkNumeric f s2) `withError` (errNonNumerics l l')+checkRelTy _ _ _ FReal FReal = return ()+checkRelTy _ _ _ FInt  FReal = return ()+checkRelTy _ _ _ FReal FInt  = return ()+checkRelTy f _ _ FInt  s2    = checkNumeric    f s2 `withError` (errNonNumeric s2)+checkRelTy f _ _ s1    FInt  = checkNumeric    f s1 `withError` (errNonNumeric s1)+checkRelTy f _ _ FReal s2    = checkFractional f s2 `withError` (errNonFractional s2)+checkRelTy f _ _ s1    FReal = checkFractional f s1 `withError` (errNonFractional s1) --------------------------------------------------------------------------+-- checkRelTy _ e Eq t1 t2+--   | t1 == boolSort || t2 == boolSort = throwError $ errRel e t1 t2+-- checkRelTy _ e Ne t1 t2+--   | t1 == boolSort || t2 == boolSort = throwError $ errRel e t1 t2++checkRelTy f e Eq t1 t2            = void (unifys f (Just e) [t1] [t2] `withError` (errRel e t1 t2))+checkRelTy f e Ne t1 t2            = void (unifys f (Just e) [t1] [t2] `withError` (errRel e t1 t2))++checkRelTy _ e _  t1 t2            = unless (t1 == t2) (throwError $ errRel e t1 t2)++-------------------------------------------------------------------------------- -- | Sort Unification---------------------------------------------------------------------------unify :: Env -> Sort -> Sort -> Maybe TVSubst---------------------------------------------------------------------------unify f t1 t2-  = case runCM0 $ unify1 f emptySubst t1 t2 of+--------------------------------------------------------------------------------+unify :: Env -> Maybe Expr -> Sort -> Sort -> Maybe TVSubst+--------------------------------------------------------------------------------+unify f e t1 t2+  = case runCM0 $ unify1 f e emptySubst t1 t2 of       Left _   -> Nothing       Right su -> Just su +--------------------------------------------------------------------------------+unifySorts :: Sort -> Sort -> Maybe TVSubst+--------------------------------------------------------------------------------+unifySorts   = unifyFast False emptyEnv+  where+    emptyEnv = const $ die $ err dummySpan "SortChecl: lookup in Empty Env " --------------------------------------------------------------------------+-------------------------------------------------------------------------------- -- | Fast Unification; `unifyFast True` is just equality--------------------------------------------------------------------------+-------------------------------------------------------------------------------- unifyFast :: Bool -> Env -> Sort -> Sort -> Maybe TVSubst---------------------------------------------------------------------------unifyFast False f = unify f+--------------------------------------------------------------------------------+unifyFast False f = unify f Nothing unifyFast True  _ = uMono   where     uMono t1 t2      | t1 == t2   = Just emptySubst      | otherwise  = Nothing ---------------------------------------------------------------------------unifys :: Env -> [Sort] -> [Sort] -> CheckM TVSubst---------------------------------------------------------------------------unifys f = unifyMany f emptySubst -unifyMany :: Env -> TVSubst -> [Sort] -> [Sort] -> CheckM TVSubst-unifyMany f θ ts ts'-  | length ts == length ts' = foldM (uncurry . unify1 f) θ $ zip ts ts'+--------------------------------------------------------------------------------+unifys :: Env -> Maybe Expr -> [Sort] -> [Sort] -> CheckM TVSubst+--------------------------------------------------------------------------------+unifys f e = unifyMany f e emptySubst++unifyMany :: Env -> Maybe Expr -> TVSubst -> [Sort] -> [Sort] -> CheckM TVSubst+unifyMany f e θ ts ts'+  | length ts == length ts' = foldM (uncurry . unify1 f e) θ $ zip ts ts'   | otherwise               = throwError $ errUnifyMany ts ts'  -unify1 :: Env -> TVSubst -> Sort -> Sort -> CheckM TVSubst-unify1 f θ (FVar i) t-  = unifyVar f θ i t-unify1 f θ t (FVar i)-  = unifyVar f θ i t-unify1 f θ (FApp t1 t2) (FApp t1' t2')-  = unifyMany f θ [t1, t2] [t1', t2']-unify1 _ θ (FTC l1) (FTC l2)+unify1 :: Env -> Maybe Expr -> TVSubst -> Sort -> Sort -> CheckM TVSubst+unify1 f e θ (FVar i) t+  = unifyVar f e θ i t+unify1 f e θ t (FVar i)+  = unifyVar f e θ i t+unify1 f e θ (FApp t1 t2) (FApp t1' t2')+  = unifyMany f e θ [t1, t2] [t1', t2']+unify1 _ _ θ (FTC l1) (FTC l2)   | isListTC l1 && isListTC l2   = return θ-unify1 f θ t1@(FAbs _ _) t2 = do+unify1 f e θ t1@(FAbs _ _) t2 = do   t1'<- generalize t1-  unifyMany f θ [t1'] [t2]-unify1 f θ t1 t2@(FAbs _ _) = do+  unifyMany f e θ [t1'] [t2]+unify1 f e θ t1 t2@(FAbs _ _) = do   t2' <- generalize t2-  unifyMany f θ [t1] [t2']+  unifyMany f e θ [t1] [t2']+unify1 _ _ θ s1 s2+  | isString s1, isString s2+  = return θ -unify1 f θ (FObj l) FInt = do-  checkNumeric f l-  return θ+unify1 _ _ θ FInt  FReal = return θ -unify1 f θ FInt (FObj l) = do-  checkNumeric f l+unify1 _ _ θ FReal FInt  = return θ++unify1 f e θ t FInt = do+  checkNumeric f t `withError` (errUnify e t FInt)   return θ -unify1 _ θ FInt  FReal = return θ-unify1 _ θ FReal FInt  = return θ+unify1 f e θ FInt t = do+  checkNumeric f t `withError` (errUnify e FInt t)+  return θ -unify1 f θ (FFunc t1 t2) (FFunc t1' t2') = do -  unifyMany f θ [t1, t2] [t1', t2']+unify1 f e θ (FFunc t1 t2) (FFunc t1' t2') = do+  unifyMany f e θ [t1, t2] [t1', t2'] -unify1 _ θ t1 t2+unify1 _ e θ t1 t2   | t1 == t2   = return θ   | otherwise-  = throwError $ errUnify t1 t2+  = throwError $ errUnify e t1 t2  subst :: (Int, Sort) -> Sort -> Sort subst (j,tj) t@(FVar i)@@ -663,52 +888,62 @@ generalize t =   return t -unifyVar :: Env -> TVSubst -> Int -> Sort -> CheckM TVSubst-unifyVar _ θ i t@(FVar j)+unifyVar :: Env -> Maybe Expr -> TVSubst -> Int -> Sort -> CheckM TVSubst+unifyVar _ _ θ i t@(FVar j)   = case lookupVar i θ of       Just t'       -> if t == t' then return θ else return $ updateVar j t' θ       Nothing       -> return $ updateVar i t θ -unifyVar f θ i t+unifyVar f e θ i t   = case lookupVar i θ of       Just (FVar j) -> return $ updateVar i t $ updateVar j t θ-      Just t'       -> if t == t' then return θ else unify1 f θ t t'+      Just t'       -> if t == t' then return θ else unify1 f e θ t t'       Nothing       -> return $ updateVar i t θ ----------------------------------------------------------------------------- | Applying a Type Substitution -----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | Applying a Type Substitution ----------------------------------------------+-------------------------------------------------------------------------------- apply :: TVSubst -> Sort -> Sort--------------------------------------------------------------------------+-------------------------------------------------------------------------------- apply θ          = sortMap f   where     f t@(FVar i) = fromMaybe t (lookupVar i θ)     f t          = t --------------------------------------------------------------------------+-------------------------------------------------------------------------------- sortMap :: (Sort -> Sort) -> Sort -> Sort--------------------------------------------------------------------------+-------------------------------------------------------------------------------- sortMap f (FAbs i t)    = FAbs i (sortMap f t) sortMap f (FFunc t1 t2) = FFunc (sortMap f t1) (sortMap f t2) sortMap f (FApp t1 t2)  = FApp  (sortMap f t1) (sortMap f t2) sortMap f t             = f t ---------------------------------------------------------------------------- | Deconstruct a function-sort ----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | Deconstruct a function-sort -----------------------------------------------+-------------------------------------------------------------------------------- +checkFunSort :: Sort -> CheckM (Sort, Sort, TVSubst)+checkFunSort (FAbs _ t)    = checkFunSort t+checkFunSort (FFunc t1 t2) = return (t1, t2, emptySubst)+checkFunSort (FVar i)      = do j <- refresh 0 +                                k <- refresh 0 +                                return (FVar j, FVar k, updateVar i (FFunc (FVar j) (FVar k)) emptySubst)+checkFunSort t             = throwError $ errNonFunction 1 t++{- sortFunction :: Int -> Sort -> CheckM ([Sort], Sort) sortFunction i t   = case functionSort t of      Nothing          -> throwError $ errNonFunction i t-     Just (_, ts, t') -> if length ts < i +     Just (_, ts, t') -> if length ts < i                           then throwError $ errNonFunction i t-                          else let (its, ots) = splitAt i ts +                          else let (its, ots) = splitAt i ts                                in return (its, foldl FFunc t' ots)+-} ---------------------------------------------------------------------------- | API for manipulating Sort Substitutions ----------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | API for manipulating Sort Substitutions -----------------------------------+--------------------------------------------------------------------------------  newtype TVSubst = Th (M.HashMap Int Sort) deriving (Show) @@ -721,30 +956,60 @@ emptySubst :: TVSubst emptySubst = Th M.empty ----------------------------------------------------------------------------- | Error messages -------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | Error messages ------------------------------------------------------------+-------------------------------------------------------------------------------- -errUnify t1 t2       = printf "Cannot unify %s with %s" (showpp t1) (showpp t2)+errElabExpr    :: Expr -> String+errElabExpr e  = printf "Elaborate fails on %s" (showpp e) +errUnify :: Maybe Expr -> Sort -> Sort -> String+errUnify eo t1 t2 = printf "Cannot unify %s with %s %s"+                      (showpp t1) (showpp t2) (unifyExpr eo)++unifyExpr :: Maybe Expr -> String+unifyExpr Nothing  = ""+unifyExpr (Just e) = "in expression: " ++ showpp e++errUnifyMany :: [Sort] -> [Sort] -> String errUnifyMany ts ts'  = printf "Cannot unify types with different cardinalities %s and %s"                          (showpp ts) (showpp ts')++errRel :: Expr -> Sort -> Sort -> String errRel e t1 t2       = printf "Invalid Relation %s with operand types %s and %s"                          (showpp e) (showpp t1) (showpp t2)++errOp :: Expr -> Sort -> Sort -> String errOp e t t'   | t == t'          = printf "Operands have non-numeric types %s in %s"                          (showpp t) (showpp e)   | otherwise        = printf "Operands have different types %s and %s in %s"                          (showpp t) (showpp t') (showpp e)++errIte :: Expr -> Expr -> Sort -> Sort -> String errIte e1 e2 t1 t2   = printf "Mismatched branches in Ite: then %s : %s, else %s : %s"                          (showpp e1) (showpp t1) (showpp e2) (showpp t2)++errCast :: Expr -> Sort -> Sort -> String errCast e t' t       = printf "Cannot cast %s of sort %s to incompatible sort %s"                          (showpp e) (showpp t') (showpp t)++errUnboundAlts :: Symbol -> [Symbol] -> String errUnboundAlts x xs  = printf "Unbound Symbol %s\n Perhaps you meant: %s"                         (showpp x)                         (foldr1 (\w s -> w ++ ", " ++ s) (showpp <$> xs))-errNonFunction i t   = printf "Sort %s is not a function with at least %s arguments" (showpp t) (showpp i)-errNonNumeric  l     = printf "FObj sort %s is not numeric" (showpp l)++errNonFunction :: Int -> Sort -> String+errNonFunction i t   = printf "The sort %s is not a function with at least %s arguments\n" (showpp t) (showpp i)++errNonNumeric :: Sort -> String+errNonNumeric  l     = printf "The sort %s is not numeric" (showpp l)++errNonNumerics :: Symbol -> Symbol -> String errNonNumerics l l'  = printf "FObj sort %s and %s are different and not numeric" (showpp l) (showpp l')-errNonFractional  l  = printf "FObj sort %s is not fractional" (showpp l)++errNonFractional :: Sort -> String+errNonFractional  l  = printf "The sort %s is not fractional" (showpp l)++errBoolSort :: Expr -> Sort -> String errBoolSort     e s  = printf "Expressions %s should have bool sort, but has %s" (showpp e) (showpp s)
src/Language/Fixpoint/Types.hs view
@@ -3,28 +3,16 @@ --   implication (i.e. subtyping) and well-formedness --   constraints. -module Language.Fixpoint.Types (-    module Language.Fixpoint.Types.PrettyPrint-  , module Language.Fixpoint.Types.Spans-  , module Language.Fixpoint.Types.Errors-  , module Language.Fixpoint.Types.Names-  , module Language.Fixpoint.Types.Sorts-  , module Language.Fixpoint.Types.Refinements-  , module Language.Fixpoint.Types.Substitutions-  , module Language.Fixpoint.Types.Environments-  , module Language.Fixpoint.Types.Constraints-  , module Language.Fixpoint.Types.Graphs-  , module Language.Fixpoint.Types.Utils-  ) where+module Language.Fixpoint.Types (module X) where -import           Language.Fixpoint.Types.PrettyPrint-import           Language.Fixpoint.Types.Names-import           Language.Fixpoint.Types.Errors-import           Language.Fixpoint.Types.Spans-import           Language.Fixpoint.Types.Sorts-import           Language.Fixpoint.Types.Refinements-import           Language.Fixpoint.Types.Substitutions-import           Language.Fixpoint.Types.Environments-import           Language.Fixpoint.Types.Constraints-import           Language.Fixpoint.Types.Graphs-import           Language.Fixpoint.Types.Utils+import Language.Fixpoint.Types.PrettyPrint      as X+import Language.Fixpoint.Types.Names            as X+import Language.Fixpoint.Types.Errors           as X+import Language.Fixpoint.Types.Spans            as X+import Language.Fixpoint.Types.Sorts            as X+import Language.Fixpoint.Types.Refinements      as X+import Language.Fixpoint.Types.Substitutions    as X+import Language.Fixpoint.Types.Environments     as X+import Language.Fixpoint.Types.Constraints      as X+import Language.Fixpoint.Types.Utils            as X+import Language.Fixpoint.Types.Triggers         as X
src/Language/Fixpoint/Types/Config.hs view
@@ -6,132 +6,100 @@  module Language.Fixpoint.Types.Config (     Config  (..)+  , defConfig+  , withPragmas+   , getOpts-  , Command (..)++  -- * SMT Solver options   , SMTSolver (..)-  , GenQualifierSort (..)-  , UeqAllSorts (..)-  , withTarget++  -- * Eliminate options+  , Eliminate (..)+  , useElim++  -- * parallel solving options   , defaultMinPartSize   , defaultMaxPartSize   , multicore+   , queryFile ) where -import Data.Maybe   (fromMaybe)-import Data.List    (find)+import Data.Serialize                (Serialize (..))+import Control.Monad import GHC.Generics import System.Console.CmdArgs+import System.Console.CmdArgs.Explicit+import System.Environment+ import Language.Fixpoint.Utils.Files -class Command a  where-  command :: a -> String ---------------------------------------------------------------------------- Configuration Options ------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+withPragmas :: Config -> [String] -> IO Config+--------------------------------------------------------------------------------+withPragmas = foldM withPragma -withTarget        :: Config -> FilePath -> Config-withTarget cfg fq = cfg { inFile = fq } { outFile = fq `withExt` Out }+withPragma :: Config -> String -> IO Config+withPragma c s = withArgs [s] $ cmdArgsRun+          config { modeValue = (modeValue config) { cmdArgsValue = c } } +--------------------------------------------------------------------------------+-- | Configuration Options -----------------------------------------------------+--------------------------------------------------------------------------------+ defaultMinPartSize :: Int defaultMinPartSize = 500  defaultMaxPartSize :: Int defaultMaxPartSize = 700 + data Config   = Config {-      inFile      :: FilePath            -- ^ target fq-file-    , outFile     :: FilePath            -- ^ output file-    , srcFile     :: FilePath            -- ^ src file (*.hs, *.ts, *.c)+      srcFile     :: FilePath            -- ^ src file (*.hs, *.ts, *.c, or even *.fq or *.bfq)     , cores       :: Maybe Int           -- ^ number of cores used to solve constraints     , minPartSize :: Int                 -- ^ Minimum size of a partition     , maxPartSize :: Int                 -- ^ Maximum size of a partition. Overrides minPartSize     , solver      :: SMTSolver           -- ^ which SMT solver to use-    , genSorts    :: GenQualifierSort    -- ^ generalize qualifier sorts-    , ueqAllSorts :: UeqAllSorts         -- ^ use UEq on all sorts     , linear      :: Bool                -- ^ not interpret div and mul in SMT-    , allowHO     :: Bool                -- ^ not interpret div and mul in SMT-    , newcheck    :: Bool                -- ^ new fixpoint sort check-    , eliminate   :: Bool                -- ^ eliminate non-cut KVars+    , stringTheory :: Bool               -- ^ interpretation of string theory by SMT+    , defunction  :: Bool                -- ^ defunctionalize (use 'apply' for all uninterpreted applications)+    , allowHO     :: Bool                -- ^ allow higher order binders in the logic environment+    , allowHOqs   :: Bool                -- ^ allow higher order qualifiers+    , eliminate   :: Eliminate           -- ^ eliminate non-cut KVars+    , elimBound   :: Maybe Int           -- ^ maximum length of KVar chain to eliminate     , elimStats   :: Bool                -- ^ print eliminate stats     , solverStats :: Bool                -- ^ print solver stats     , metadata    :: Bool                -- ^ print meta-data associated with constraints     , stats       :: Bool                -- ^ compute constraint statistics     , parts       :: Bool                -- ^ partition FInfo into separate fq files     , save        :: Bool                -- ^ save FInfo as .bfq and .fq file-    , minimize    :: Bool                -- ^ use delta debug to min fq file-    -- , nontriv     :: Bool             -- ^ simplify using non-trivial sorts+    , minimize    :: Bool                -- ^ min .fq by delta debug (unsat with min constraints)+    , minimizeQs  :: Bool                -- ^ min .fq by delta debug (sat with min qualifiers)+    , minimizeKs  :: Bool                -- ^ min .fq by delta debug (sat with min kvars)+    , minimalSol  :: Bool                -- ^ shrink final solution by pruning redundant qualfiers from fixpoint     , gradual     :: Bool                -- ^ solve "gradual" constraints-    } deriving (Eq,Data,Typeable,Show)-+    , extensionality   :: Bool           -- ^ allow function extensionality+    , alphaEquivalence :: Bool           -- ^ allow lambda alpha equivalence axioms+    , betaEquivalence  :: Bool           -- ^ allow lambda beta equivalence axioms+    , normalForm       :: Bool           -- ^ allow lambda normal-form equivalence axioms+    , autoKuts         :: Bool           -- ^ ignore given kut variables+    , nonLinCuts       :: Bool           -- ^ Treat non-linear vars as cuts+    , noslice          :: Bool           -- ^ Disable non-concrete KVar slicing+    , rewriteAxioms    :: Bool           -- ^ allow axiom instantiation via rewriting+    , arithmeticAxioms :: Bool           -- ^ allow axiom instantiation on arithmetic expressions+    } deriving (Eq,Data,Typeable,Show,Generic)  instance Default Config where-  def = Config { inFile      = ""-               , outFile     = def-               , srcFile     = def-               , cores       = def-               , minPartSize = defaultMinPartSize-               , maxPartSize = defaultMaxPartSize-               , solver      = def-               , genSorts    = def-               , ueqAllSorts = def-               , linear      = def-               , allowHO     = False-               , newcheck    = False-               , eliminate   = def-               , elimStats   = def-               , solverStats = False-               , metadata    = def-               , stats       = def-               , parts       = def-               , save        = def-               , minimize    = def-               , gradual     = False-               }--instance Command Config where-  command c =  command (genSorts c)-            ++ command (ueqAllSorts c)-            ++ command (solver c)-            ++ " -out "-            ++ outFile c ++ " "-            ++ inFile c------------------------------------------------------------------------------------------newtype GenQualifierSort = GQS Bool-    deriving (Eq, Data,Typeable,Show)--instance Default GenQualifierSort where-  def = GQS False--instance Command GenQualifierSort where-  command (GQS True)  = ""-  command (GQS False) = "-no-gen-qual-sorts"--newtype UeqAllSorts = UAS Bool-    deriving (Eq, Data,Typeable,Show)--instance Default UeqAllSorts where-  def = UAS False--instance Command UeqAllSorts where-  command (UAS True)  = " -ueq-all-sorts "-  command (UAS False) = ""---- instance Command Cores where---   command (C n) = " --cores=" ++ show n-+  def = defConfig  ---------------------------------------------------------------------------------------  data SMTSolver = Z3 | Cvc4 | Mathsat                  deriving (Eq, Data, Typeable, Generic) -instance Command SMTSolver where-  command s = " -smtsolver " ++ show s- instance Default SMTSolver where   def = Z3 @@ -141,30 +109,67 @@   show Mathsat = "mathsat"  ---------------------------------------------------------------------------------------+-- | Eliminate describes the number of KVars to eliminate:+--   None = use PA/Quals for ALL k-vars, i.e. no eliminate+--   Some = use PA/Quals for CUT k-vars, i.e. eliminate non-cuts+--   All  = eliminate ALL k-vars, solve cut-vars to TRUE+---------------------------------------------------------------------------------------+data Eliminate+  = None+  | Some+  | All+  deriving (Eq, Data, Typeable, Generic) -config :: Config-config = Config {-    inFile      = def   &= typ "TARGET"       &= args    &= typFile-  , outFile     = "out" &= help "Output file"-  , srcFile     = def   &= help "Source File from which FQ is generated"-  , solver      = def   &= help "Name of SMT Solver"-  , genSorts    = def   &= help "Generalize qualifier sorts"-  , ueqAllSorts = def   &= help "Use UEq on all sorts"-  , newcheck    = False &= help "(alpha) New liquid-fixpoint sort checking "-  , linear      = False &= help "Use uninterpreted integer multiplication and division"-  , allowHO     = False &= help "Allow higher order binders into fixpoint environment"-  , eliminate   = False &= help "(alpha) Eliminate non-cut KVars"-  , elimStats   = False &= help "(alpha) Print eliminate stats"-  , solverStats = False &= help "Print solver stats"-  , save        = False &= help "Save Query as .fq and .bfq files"-  , metadata    = False &= help "Print meta-data associated with constraints"-  , stats       = False &= help "Compute constraint statistics"-  , parts       = False &= help "Partition constraints into indepdendent .fq files"-  , cores       = def   &= help "(numeric) Number of threads to use"-  , minPartSize = defaultMinPartSize &= help "(numeric) Minimum partition size when solving in parallel"-  , maxPartSize = defaultMaxPartSize &= help "(numeric) Maximum partiton size when solving in parallel."-  , minimize    = False &= help "Use delta debug to minimize fq file"-  , gradual     = False &= help "Solve gradual-refinement typing constraints"+instance Serialize Eliminate++instance Default Eliminate where+  def = None++instance Show Eliminate where+  show None = "none"+  show Some = "some"+  show All  = "all"+++useElim :: Config -> Bool+useElim cfg = eliminate cfg /= None++---------------------------------------------------------------------------------------++defConfig :: Config+defConfig = Config {+    srcFile          = "out"   &= args    &= typFile+  , defunction       = False   &= help "Allow higher order binders into fixpoint environment"+  , solver           = def     &= help "Name of SMT Solver"+  , linear           = False   &= help "Use uninterpreted integer multiplication and division"+  , stringTheory     = False   &= help "Interpretation of String Theory by SMT"+  , allowHO          = False   &= help "Allow higher order binders into fixpoint environment"+  , allowHOqs        = False   &= help "Allow higher order qualifiers"+  , eliminate        = None    &= help "Eliminate KVars [none = quals for all-kvars, cuts = quals for cut-kvars, all = eliminate all-kvars (TRUE for cuts)]"+  , elimBound        = Nothing &= name "elimBound"  &= help "(alpha) Maximum eliminate-chain depth"+  , elimStats        = False   &= help "(alpha) Print eliminate stats"+  , solverStats      = False   &= help "Print solver stats"+  , save             = False   &= help "Save Query as .fq and .bfq files"+  , metadata         = False   &= help "Print meta-data associated with constraints"+  , stats            = False   &= help "Compute constraint statistics"+  , parts            = False   &= help "Partition constraints into indepdendent .fq files"+  , cores            = def     &= help "(numeric) Number of threads to use"+  , minPartSize      = defaultMinPartSize &= help "(numeric) Minimum partition size when solving in parallel"+  , maxPartSize      = defaultMaxPartSize &= help "(numeric) Maximum partiton size when solving in parallel."+  , minimize         = False &= help "Delta debug to minimize fq file (unsat with min constraints)"+  , minimizeQs       = False &= help "Delta debug to minimize fq file (sat with min qualifiers)"+  , minimizeKs       = False &= help "Delta debug to minimize fq file (sat with max kvars replaced by True)"+  , minimalSol       = False &= help "Shrink fixpoint by removing implied qualifiers"+  , gradual          = False &= help "Solve gradual-refinement typing constraints"+  , extensionality   = False &= help "Allow function extensionality axioms"+  , alphaEquivalence = False &= help "Allow lambda alpha equivalence axioms"+  , betaEquivalence  = False &= help "Allow lambda alpha equivalence axioms"+  , normalForm       = False  &= help "Allow lambda normal-form equivalence axioms"+  , autoKuts         = False &= help "Ignore given Kut vars, compute from scratch"+  , nonLinCuts       = False &= help "Treat non-linear kvars as cuts"+  , noslice          = False &= help "Disable non-concrete KVar slicing"+  , rewriteAxioms    = False &= help "allow axiom instantiation via rewriting"+  , arithmeticAxioms = False &= help "Disable non-concrete KVar slicing"   }   &= verbosity   &= program "fixpoint"@@ -176,8 +181,11 @@              , "  fixpoint foo.fq"              ] +config :: Mode (CmdArgs Config)+config = cmdArgsMode defConfig+ getOpts :: IO Config-getOpts = do md <- cmdArgs config+getOpts = do md <- cmdArgs defConfig              putStrLn banner              return md @@ -189,6 +197,4 @@ multicore cfg = cores cfg /= Just 1  queryFile :: Ext -> Config -> FilePath-queryFile e cfg = extFileName e f-  where-    f           = fromMaybe "out" $ find (not . null) [srcFile cfg, inFile cfg]+queryFile e = extFileName e . srcFile
src/Language/Fixpoint/Types/Constraints.hs view
@@ -11,13 +11,13 @@ {-# LANGUAGE GADTs                      #-} {-# LANGUAGE PatternGuards              #-} --- | This module contains the top-level query data types and elements,+-- | This module contains the top-level QUERY data types and elements, --   including (Horn) implication & well-formedness constraints and sets.  module Language.Fixpoint.Types.Constraints (     -- * Top-level Queries-    FInfo, SInfo, GInfo (..)+    FInfo, SInfo, GInfo (..), FInfoWithOpts(..)   , convertFormat   , Solver @@ -30,11 +30,13 @@   , fi    -- * Constraints-  , WfC (..)-  , SubC, mkSubC, subcId, sid, senv, slhs, srhs, stag, subC, wfC+  , WfC (..), isGWfc, updateWfCExpr+  , SubC, SubcId+  , mkSubC, subcId, sid, senv, slhs, srhs, stag, subC, wfC   , SimpC (..)   , Tag   , TaggedC, clhs, crhs+  , strengthenLhs    -- * Accessing Constraints   , addIds@@ -43,41 +45,42 @@    -- * Qualifiers   , Qualifier (..)+  , trueQual   , qualifier-  , EQual (..)-  , eQual+  , mkQual, remakeQual    -- * Results   , FixSolution+  , GFixSolution, toGFixSol   , Result (..) -  -- * Solutions-  , Hyp-  , Cube (..)-  , QBind-  , Cand-  , Sol (..)-  , Solution-  , solFromList, solInsert, solLookup, solResult-   -- * Cut KVars   , Kuts (..)   , ksMember -+  -- * Higher Order Logic+  , HOInfo (..)+  , allowHO+  , allowHOquals +  -- * Axioms+  , AxiomEnv (..)+  , Equation (..)+  , Rewrite  (..)+  , getEqBody   ) where  import qualified Data.Binary as B import           Data.Generics             (Data) import           Data.Typeable             (Typeable) import           GHC.Generics              (Generic)-import           Data.List                 (sort, nub, delete)+import qualified Data.List                 as L -- (sort, nub, delete) import           Data.Maybe                (catMaybes) import           Control.DeepSeq import           Control.Monad             (void) import           Language.Fixpoint.Types.PrettyPrint import           Language.Fixpoint.Types.Config hiding (allowHO)+import           Language.Fixpoint.Types.Triggers import           Language.Fixpoint.Types.Names import           Language.Fixpoint.Types.Errors import           Language.Fixpoint.Types.Spans@@ -96,19 +99,36 @@ -- | Constraints --------------------------------------------------------------- -------------------------------------------------------------------------------- -{-@ type Tag = { v : [Int] | len(v) = 1 } @-}+{-@ type Tag = { v : [Int] | len v == 1 } @-}+ type Tag           = [Int] -data WfC a  = WfC  { wenv  :: !IBindEnv-                   , wrft  :: (Symbol, Sort, KVar)-                   , winfo :: !a-                   }+data WfC a  =  WfC  { wenv  :: !IBindEnv+                    , wrft  :: (Symbol, Sort, KVar)+                    , winfo :: !a+                    }+             | GWfC { wenv  :: !IBindEnv+                    , wrft  :: !(Symbol, Sort, KVar)+                    , winfo :: !a+                    , wexpr :: !Expr+                    }               deriving (Eq, Generic, Functor) ++updateWfCExpr :: (Expr -> Expr) -> WfC a -> WfC a+updateWfCExpr _ w@(WfC {})  = w+updateWfCExpr f w@(GWfC {}) = w{wexpr = f (wexpr w)}++isGWfc :: WfC a -> Bool+isGWfc (GWfC _ _ _ _) = True+isGWfc (WfC _ _ _)    = False++type SubcId = Integer+ data SubC a = SubC { _senv  :: !IBindEnv-                   , slhs  :: !SortedReft-                   , srhs  :: !SortedReft-                   , _sid   :: !(Maybe Integer)+                   , slhs   :: !SortedReft+                   , srhs   :: !SortedReft+                   , _sid   :: !(Maybe SubcId)                    , _stag  :: !Tag                    , _sinfo :: !a                    }@@ -122,6 +142,11 @@                      }               deriving (Generic, Functor) +strengthenLhs :: Expr -> SubC a -> SubC a+strengthenLhs e subc = subc {slhs = go (slhs subc)}+  where+    go (RR s (Reft(v, r))) = RR s (Reft (v, pAnd [r, e]))+ class TaggedC c a where   senv  :: c a -> IBindEnv   sid   :: c a -> Maybe Integer@@ -151,25 +176,35 @@   where     Reft (x, _)   = sr_reft sr -subcId :: (TaggedC c a) => c a -> Integer+subcId :: (TaggedC c a) => c a -> SubcId subcId = mfromJust "subCId" . sid  --------------------------------------------------------------------------- -- | Solutions and Results --------------------------------------------------------------------------- -type FixSolution = M.HashMap KVar Expr+type GFixSolution = GFixSol Expr -data Result a = Result { resStatus   :: FixResult a-                       , resSolution :: FixSolution }+type FixSolution  = M.HashMap KVar Expr+newtype GFixSol e = GSol (M.HashMap KVar (e, [e]))+  deriving (Generic, Monoid, Functor)++toGFixSol :: M.HashMap KVar (e, [e]) -> GFixSol e+toGFixSol = GSol+++data Result a = Result { resStatus    :: !(FixResult a)+                       , resSolution  :: !FixSolution+                       , gresSolution :: !GFixSolution }                 deriving (Generic, Show)  instance Monoid (Result a) where-  mempty        = Result mempty mempty-  mappend r1 r2 = Result stat soln+  mempty        = Result mempty mempty mempty+  mappend r1 r2 = Result stat soln gsoln     where-      stat      = mappend (resStatus r1)   (resStatus r2)-      soln      = mappend (resSolution r1) (resSolution r2)+      stat      = mappend (resStatus r1)    (resStatus r2)+      soln      = mappend (resSolution r1)  (resSolution r2)+      gsoln     = mappend (gresSolution r1) (gresSolution r2)  instance (Ord a, Fixpoint a) => Fixpoint (FixResult (SubC a)) where   toFix Safe             = text "Safe"@@ -178,7 +213,7 @@   toFix (Unsafe xs)      = vcat $ text "Unsafe:" : pprSinfos "WARNING: " xs  pprSinfos :: (Ord a, Fixpoint a) => String -> [SubC a] -> [Doc]-pprSinfos msg = map ((text msg <>) . toFix) . sort . fmap sinfo+pprSinfos msg = map ((text msg <>) . toFix) . L.sort . fmap sinfo  instance Fixpoint a => Show (WfC a) where   show = showFix@@ -219,17 +254,38 @@               -- NOTE: this next line is printed this way for compatability with the OCAML solver               $+$ text "reft" <+> toFix (RR t (Reft (v, PKVar k mempty)))               $+$ toFixMeta (text "wf") (toFix (winfo w))+              $+$ if (isGWfc w) then (toFixMeta (text "expr") (toFix (wexpr w))) else mempty           (v, t, k) = wrft w  toFixMeta :: Doc -> Doc -> Doc toFixMeta k v = text "// META" <+> k <+> text ":" <+> v -pprId (Just i)  = text "id" <+> tshow i-pprId _         = text ""+pprId :: Show a => Maybe a -> Doc+pprId (Just i)  = "id" <+> tshow i+pprId _         = "" +instance PPrint GFixSolution where+  pprintTidy k (GSol xs) = vcat $ punctuate "\n\n" (pprintTidyGradual k <$> M.toList xs)++pprintTidyGradual :: Tidy -> (KVar, (Expr, [Expr])) -> Doc+pprintTidyGradual _ (x, (e, es)) = ppLocOfKVar x <+> text ":=" <+> (ppNonTauto " && " e <> pprint es)++ppLocOfKVar :: KVar -> Doc+ppLocOfKVar = text. dropWhile (/='(') . symbolString .kv++ppNonTauto :: Doc -> Expr -> Doc+ppNonTauto d e+  | isTautoPred e = mempty+  | otherwise     = pprint e <> d++instance Show   GFixSolution where+  show = showpp+ ---------------------------------------------------------------- instance B.Binary Qualifier instance B.Binary Kuts+instance B.Binary HOInfo+instance B.Binary GFixSolution instance (B.Binary a) => B.Binary (SubC a) instance (B.Binary a) => B.Binary (WfC a) instance (B.Binary a) => B.Binary (SimpC a)@@ -237,6 +293,8 @@  instance NFData Qualifier instance NFData Kuts+instance NFData HOInfo+instance NFData GFixSolution  instance (NFData a) => NFData (SubC a) instance (NFData a) => NFData (WfC a)@@ -249,18 +307,24 @@ ---------------------------------------------------------------------------  wfC :: (Fixpoint a) => IBindEnv -> SortedReft -> a -> [WfC a]-wfC be sr x = if all isEmptySubst sus-                then [WfC be (v, sr_sort sr, k) x | k <- ks]+wfC be sr x = if all isEmptySubst (sus ++ gsus)+                then [WfC be (v, sr_sort sr, k) x | k <- ks] ++ [GWfC be (v, sr_sort sr, k) x e | (k, e) <- gs ]                 else errorstar msg   where     msg             = "wfKvar: malformed wfC " ++ show sr     Reft (v, ras)   = sr_reft sr     (ks, sus)       = unzip $ go ras+    (gs, gsus)      = unzip $ go' ras      go (PKVar k su) = [(k, su)]     go (PAnd es)    = [(k, su) | PKVar k su <- es]     go _            = [] +    go' (PGrad k su e) = [((k, e), su)]+    go' (PAnd es)      = concatMap go' es+    go' _              = []++mkSubC :: IBindEnv -> SortedReft -> SortedReft -> Maybe Integer -> Tag -> a -> SubC a mkSubC = SubC  subC :: IBindEnv -> SortedReft -> SortedReft -> Maybe Integer -> Tag -> a -> [SubC a]@@ -281,6 +345,7 @@    | v == v'   = r    | otherwise = Reft (v', subst1 ras (v, EVar v')) +addIds :: [SubC a] -> [(Integer, SubC a)] addIds = zipWith (\i c -> (i, shiftId i $ c {_sid = Just i})) [1..]   where -- Adding shiftId to have distinct VV for SMT conversion     shiftId i c = c { slhs = shiftSR i $ slhs c }@@ -292,27 +357,28 @@ -- | Qualifiers ---------------------------------------------------------------- -------------------------------------------------------------------------------- -data Qualifier = Q { q_name   :: Symbol           -- ^ Name-                   , q_params :: [(Symbol, Sort)] -- ^ Parameters-                   , q_body   :: Expr             -- ^ Predicate-                   , q_pos    :: !SourcePos       -- ^ Source Location+data Qualifier = Q { qName   :: !Symbol          -- ^ Name+                   , qParams :: [(Symbol, Sort)] -- ^ Parameters+                   , qBody   :: !Expr            -- ^ Predicate+                   , qPos    :: !SourcePos       -- ^ Source Location                    }                deriving (Eq, Show, Data, Typeable, Generic) +trueQual :: Qualifier+trueQual = Q (symbol ("QTrue" :: String)) [] mempty (dummyPos "trueQual")+ instance Loc Qualifier where   srcSpan q = SS l l     where-      l     = q_pos q+      l     = qPos q  instance Fixpoint Qualifier where   toFix = pprQual  instance PPrint Qualifier where-  pprintTidy k q = hcat [ "qualif"-                        , pprintTidy k (q_name q)-                        , "defined at"-                        , pprintTidy k (q_pos q) ]+  pprintTidy k q = "qualif" <+> pprintTidy k (qName q) <+> "defined at" <+> pprintTidy k (qPos q) +pprQual :: Qualifier -> Doc pprQual (Q n xts p l) = text "qualif" <+> text (symbolString n) <> parens args <> colon <+> parens (toFix p) <+> text "//" <+> toFix l   where     args              = intersperse comma (toFix <$> xts)@@ -320,7 +386,7 @@ qualifier :: SEnv Sort -> SourcePos -> SEnv Sort -> Symbol -> Sort -> Expr -> Qualifier qualifier lEnv l γ v so p   = Q "Auto" ((v, so) : xts) p l   where-    xs  = delete v $ nub $ syms p+    xs  = L.delete v $ L.nub $ syms p     xts = catMaybes $ zipWith (envSort l lEnv γ) xs [0..]  envSort :: SourcePos -> SEnv Sort -> SEnv Sort -> Symbol -> Integer -> Maybe (Symbol, Sort)@@ -332,6 +398,57 @@     ai  = {- trace msg $ -} fObj $ Loc l l $ tempSymbol "LHTV" i     -- msg = "unknown symbol in qualifier: " ++ show x +remakeQual :: Qualifier -> Qualifier+remakeQual q = {- traceShow msg $ -} mkQual (qName q) (qParams q) (qBody q) (qPos q)++-- | constructing qualifiers+mkQual :: Symbol -> [(Symbol, Sort)] -> Expr -> SourcePos -> Qualifier+mkQual n xts p = Q n ((v, t) : yts) (subst su p)+  where+    (v, t):zts = gSorts xts+    -- yts        = first mkParam <$> zts+    yts        = zts+    su         = mkSubst $ zipWith (\(z,_) (y,_) -> (z, eVar y)) zts yts++gSorts :: [(a, Sort)] -> [(a, Sort)]+gSorts xts     = [(x, substVars su t) | (x, t) <- xts]+  where+    su         = (`zip` [0..]) . sortNub . concatMap (sortVars . snd) $ xts++substVars :: [(Symbol, Int)] -> Sort -> Sort+substVars su = mapSort' tx+  where+    tx (FObj x)+      | Just i <- lookup x su = FVar i+    tx t                      = t++sortVars :: Sort -> [Symbol]+sortVars = foldSort' go []+  where+    go b (FObj x) = x : b+    go b _        = b++-- COPIED from Visitor due to cyclic deps+mapSort' :: (Sort -> Sort) -> Sort -> Sort+mapSort' f = step+  where+    step             = go . f+    go (FFunc t1 t2) = FFunc (step t1) (step t2)+    go (FApp t1 t2)  = FApp (step t1) (step t2)+    go (FAbs i t)    = FAbs i (step t)+    go t             = t++-- COPIED from Visitor due to cyclic deps+foldSort' :: (a -> Sort -> a) -> a -> Sort -> a+foldSort' f = step+  where+    step b t           = go (f b t) t+    go b (FFunc t1 t2) = L.foldl' step b [t1, t2]+    go b (FApp t1 t2)  = L.foldl' step b [t1, t2]+    go b (FAbs _ t)    = go b t+    go b _             = b++ -------------------------------------------------------------------------------- -- | Constraint Cut Sets ------------------------------------------------------- --------------------------------------------------------------------------------@@ -352,16 +469,31 @@ ------------------------------------------------------------------------ -- | Constructing Queries -------------------------------------------------------------------------fi cs ws binds ls ks qs bi fn aHO+fi :: [SubC a]+   -> [WfC a]+   -> BindEnv+   -> SEnv Sort+   -> SEnv Sort+   -> Kuts+   -> [Qualifier]+   -> M.HashMap BindId a+   -> Bool+   -> Bool+   -> [Triggered Expr]+   -> AxiomEnv+   -> GInfo SubC a+fi cs ws binds ls ds ks qs bi aHO aHOq es axe   = FI { cm       = M.fromList $ addIds cs        , ws       = M.fromListWith err [(k, w) | w <- ws, let (_, _, k) = wrft w]        , bs       = binds-       , lits     = ls+       , gLits    = ls+       , dLits    = ds        , kuts     = ks        , quals    = qs        , bindInfo = bi-       , fileName = fn-       , allowHO  = aHO+       , hoInfo   = HOI aHO aHOq+       , asserts  = es+       , ae       = axe        }   where     --TODO handle duplicates gracefully instead (merge envs by intersect?)@@ -371,33 +503,57 @@ -- | Top-level Queries ------------------------------------------------------------------------ +data FInfoWithOpts a = FIO {fioFI :: FInfo a, fioOpts :: [String]}+ type FInfo a   = GInfo SubC a type SInfo a   = GInfo SimpC a++data HOInfo = HOI { hoBinds :: Bool          -- ^ Allow higher order binds in the environemnt+                  , hoQuals :: Bool          -- ^ Allow higher order quals+                  }+  deriving (Eq, Show, Generic)++allowHO, allowHOquals :: GInfo c a -> Bool+allowHO      = hoBinds . hoInfo+allowHOquals = hoQuals . hoInfo+ data GInfo c a =-  FI { cm       :: M.HashMap Integer (c a)-     , ws       :: M.HashMap KVar (WfC a)-     , bs       :: !BindEnv-     , lits     :: !(SEnv Sort)-     , kuts     :: Kuts-     , quals    :: ![Qualifier]-     , bindInfo :: M.HashMap BindId a-     , fileName :: FilePath-     , allowHO  :: !Bool+  FI { cm       :: !(M.HashMap SubcId (c a)) -- ^ cst id |-> Horn Constraint+     , ws       :: !(M.HashMap KVar (WfC a))  -- ^ Kvar  |-> WfC defining its scope/args+     , bs       :: !BindEnv                   -- ^ Bind  |-> (Symbol, SortedReft)+     , gLits    :: !(SEnv Sort)               -- ^ Global Constant symbols+     , dLits    :: !(SEnv Sort)               -- ^ Distinct Constant symbols+     , kuts     :: !Kuts                      -- ^ Set of KVars *not* to eliminate+  --    , packs    :: !Packs                     -- ^ Pack-sets of related KVars+     , quals    :: ![Qualifier]               -- ^ Abstract domain+     , bindInfo :: !(M.HashMap BindId a)      -- ^ Metadata about binders+     , hoInfo   :: !HOInfo                    -- ^ Higher Order info+     , asserts  :: ![Triggered Expr]+     , ae       :: AxiomEnv      }   deriving (Eq, Show, Functor, Generic)  +instance Monoid HOInfo where+  mempty        = HOI False False+  mappend i1 i2 = HOI { hoBinds = hoBinds i1 || hoBinds i2+                      , hoQuals = hoQuals i1 || hoQuals i2+                      }+ instance Monoid (GInfo c a) where-  mempty        = FI M.empty mempty mempty mempty mempty mempty mempty mempty False+  mempty        = FI M.empty mempty mempty mempty mempty mempty mempty mempty mempty mempty mempty   mappend i1 i2 = FI { cm       = mappend (cm i1)       (cm i2)                      , ws       = mappend (ws i1)       (ws i2)                      , bs       = mappend (bs i1)       (bs i2)-                     , lits     = mappend (lits i1)     (lits i2)+                     , gLits    = mappend (gLits i1)    (gLits i2)+                     , dLits    = mappend (dLits i1)    (dLits i2)                      , kuts     = mappend (kuts i1)     (kuts i2)+                     -- , packs    = mappend (packs i1)    (packs i2)                      , quals    = mappend (quals i1)    (quals i2)                      , bindInfo = mappend (bindInfo i1) (bindInfo i2)-                     , fileName = fileName i1-                     , allowHO  = allowHO i1 || allowHO i2+                     , hoInfo   = mappend (hoInfo i1)   (hoInfo i2)+                     , asserts  = mappend (asserts i1)  (asserts i2)+                     , ae  = mappend (ae i1)  (ae i2)                      }  instance PTable (SInfo a) where@@ -410,19 +566,25 @@ -------------------------------------------------------------------------- toFixpoint :: (Fixpoint a, Fixpoint (c a)) => Config -> GInfo c a -> Doc ---------------------------------------------------------------------------toFixpoint cfg x' =    qualsDoc x'+toFixpoint cfg x' =    cfgDoc   cfg+                  $++$ qualsDoc x'                   $++$ kutsDoc  x'-                  $++$ conDoc   x'+                --   $++$ packsDoc x'+                  $++$ gConDoc   x'+                  $++$ dConDoc   x'                   $++$ bindsDoc x'                   $++$ csDoc    x'                   $++$ wsDoc    x'                   $++$ binfoDoc x'                   $++$ text "\n"   where-    conDoc        = vcat     . map toFixConstant . toListSEnv . lits+    cfgDoc cfg    = text ("// " ++ show cfg)+    gConDoc       = sEnvDoc "constant"             . gLits+    dConDoc       = sEnvDoc "distinct"             . dLits     csDoc         = vcat     . map toFix . M.elems . cm     wsDoc         = vcat     . map toFix . M.elems . ws     kutsDoc       = toFix    . kuts+    -- packsDoc      = toFix    . packs     bindsDoc      = toFix    . bs     qualsDoc      = vcat     . map toFix . quals     metaDoc (i,d) = toFixMeta (text "bind" <+> toFix i) (toFix d)@@ -434,8 +596,10 @@ ($++$) :: Doc -> Doc -> Doc x $++$ y = x $+$ text "\n" $+$ y -toFixConstant (c, so)-  = text "constant" <+> toFix c <+> text ":" <+> parens (toFix so)+sEnvDoc :: Doc -> SEnv Sort -> Doc+sEnvDoc d       = vcat . map kvD . toListSEnv+  where+    kvD (c, so) = d <+> toFix c <+> ":" <+> parens (toFix so)  writeFInfo :: (Fixpoint a, Fixpoint (c a)) => Config -> GInfo c a -> FilePath -> IO () writeFInfo cfg fq f = writeFile f (render $ toFixpoint cfg fq)@@ -468,89 +632,6 @@     cm'           = M.insert i subc' $ cm fi  ------------------------------------------------------------------------------------- | Solutions (Instantiated Qualfiers )---------------------------------------------------------------------------------------------------------------------------data EQual = EQL { eqQual :: !Qualifier-                 , eqPred :: !Expr-                 , eqArgs :: ![Expr]-                 }-             deriving (Eq, Show, Data, Typeable, Generic)--instance PPrint EQual where-  pprintTidy k = pprintTidy k . eqPred--instance NFData EQual--{- EQL :: q:_ -> p:_ -> ListX F.Expr {q_params q} -> _ @-}-eQual :: Qualifier -> [Symbol] -> EQual-eQual q xs = EQL q p es-  where-    p      = subst su $  q_body q-    su     = mkSubst  $  safeZip "eQual" qxs es-    es     = eVar    <$> xs-    qxs    = fst     <$> q_params q-------------------------------------------------------------------------------------- | Types --------------------------------------------------------------------------------------------------------------------------------------------------------type Solution = Sol QBind--data Sol a = Sol { sMap :: M.HashMap KVar a-                 , sHyp :: M.HashMap KVar Hyp-                 }--data Cube = Cube-  { cuBinds :: IBindEnv-  , cuSubst :: Subst-  }--type Hyp  = ListNE Cube--type QBind    = [EQual]--type Cand a   = [(Expr, a)]--instance Monoid (Sol a) where-  mempty        = Sol mempty mempty-  mappend s1 s2 = Sol { sMap = mappend (sMap s1) (sMap s2)-                      , sHyp = mappend (sHyp s1) (sHyp s2)-                      }--instance Functor Sol where-  fmap f (Sol s h) = Sol (f <$> s) h--instance PPrint a => PPrint (Sol a) where-  pprintTidy k = pprintTidy k . sMap-----------------------------------------------------------------------------------solResult :: Solution -> M.HashMap KVar Expr----------------------------------------------------------------------------------solResult s = sMap $ (pAnd . fmap eqPred) <$> s-------------------------------------------------------------------------------------- | Create a Solution -------------------------------------------------------------------------------------------------------------------------------------------solFromList :: [(KVar, a)] -> [(KVar, Hyp)] -> Sol a-solFromList kXs kYs = Sol (M.fromList kXs) (M.fromList kYs)------------------------------------------------------------------------------------- | Read / Write Solution at KVar -------------------------------------------------------------------------------------------------------------------------------solLookup :: Solution -> KVar -> QBind----------------------------------------------------------------------------------solLookup s k = M.lookupDefault [] k (sMap s)-----------------------------------------------------------------------------------solInsert :: KVar -> a -> Sol a -> Sol a----------------------------------------------------------------------------------solInsert k qs s = s { sMap = M.insert k qs (sMap s) }- --------------------------------------------------------------------------- -- | Top level Solvers ---------------------------------------------------- ---------------------------------------------------------------------------@@ -564,14 +645,71 @@   saveBinaryQuery cfg fi'   saveTextQuery cfg   fi' +saveBinaryQuery :: Config -> FInfo () -> IO () saveBinaryQuery cfg fi = do   let bfq  = queryFile Files.BinFq cfg   putStrLn $ "Saving Binary Query: " ++ bfq ++ "\n"   ensurePath bfq   B.encodeFile bfq fi +saveTextQuery :: Config -> FInfo () -> IO () saveTextQuery cfg fi = do   let fq   = queryFile Files.Fq cfg   putStrLn $ "Saving Text Query: "   ++ fq ++ "\n"   ensurePath fq   writeFile fq $ render (toFixpoint cfg fi)++---------------------------------------------------------------------------+-- | Axiom Instantiation Information --------------------------------------+---------------------------------------------------------------------------+data AxiomEnv = AEnv { aenvSyms    :: ![Symbol]+                     , aenvEqs     :: ![Equation]+                     , aenvSimpl   :: ![Rewrite]+                     , aenvFuel    :: M.HashMap SubcId Int+                     , aenvExpand  :: M.HashMap SubcId Bool+                     }+  deriving (Eq, Show, Generic)++instance B.Binary AxiomEnv+instance B.Binary Rewrite+instance B.Binary Equation+instance B.Binary SMTSolver+instance B.Binary Eliminate+instance NFData AxiomEnv+instance NFData Rewrite+instance NFData Equation+instance NFData SMTSolver+instance NFData Eliminate++instance Monoid AxiomEnv where+  mempty = AEnv [] [] [] (M.fromList []) (M.fromList [])+  mappend a1 a2 = AEnv aenvSyms' aenvEqs' aenvSimpl' aenvFuel' aenvExpand'+    where aenvSyms'    = mappend (aenvSyms a1) (aenvSyms a2)+          aenvEqs'     = mappend (aenvEqs a1) (aenvEqs a2)+          aenvSimpl'   = mappend (aenvSimpl a1) (aenvSimpl a2)+          aenvFuel'    = mappend (aenvFuel a1) (aenvFuel a2)+          aenvExpand'  = mappend (aenvExpand a1) (aenvExpand a2)++data Equation = Equ { eqName :: Symbol+                    , eqArgs :: [Symbol]+                    , eqBody :: Expr+                    }+  deriving (Eq, Show, Generic)++-- eg  SMeasure (f D [x1..xn] e)+-- for f (D x1 .. xn) = e+data Rewrite  = SMeasure  { smName  :: Symbol         -- eg. f+                          , smDC    :: Symbol         -- eg. D+                          , smArgs  :: [Symbol]       -- eg. xs+                          , smBody  :: Expr           -- eg. e[xs]+                          }+  deriving (Eq, Show, Generic)++getEqBody :: Equation -> Maybe Expr+getEqBody (Equ  x xs (PAnd ((PAtom Eq fxs e):_)))+  | (EVar f, es) <- splitEApp fxs+  , f == x+  , es == (EVar <$> xs)+  = Just e+getEqBody _+  = Nothing
src/Language/Fixpoint/Types/Environments.hs view
@@ -11,32 +11,52 @@ {-# LANGUAGE UndecidableInstances       #-} {-# LANGUAGE MultiParamTypeClasses      #-} {-# LANGUAGE GADTs                      #-}-{-# LANGUAGE PatternGuards              #-}  module Language.Fixpoint.Types.Environments (    -- * Environments     SEnv, SESearch(..)-  , emptySEnv, toListSEnv, fromListSEnv-  , mapSEnvWithKey, mapSEnv-  , insertSEnv, deleteSEnv, memberSEnv, lookupSEnv, unionSEnv+  , emptySEnv, toListSEnv, fromListSEnv, fromMapSEnv+  , mapSEnvWithKey, mapSEnv, mapMSEnv+  , insertSEnv, deleteSEnv, memberSEnv, lookupSEnv, unionSEnv, unionSEnv'   , intersectWithSEnv   , differenceSEnv   , filterSEnv   , lookupSEnvWithDistance   , envCs +  -- * Local Constraint Environments   , IBindEnv, BindId, BindMap-  , emptyIBindEnv, insertsIBindEnv, deleteIBindEnv, elemsIBindEnv+  , emptyIBindEnv+  , insertsIBindEnv+  , deleteIBindEnv+  , elemsIBindEnv+  , memberIBindEnv+  , unionIBindEnv+  , diffIBindEnv+  , intersectionIBindEnv+  , nullIBindEnv+  , filterIBindEnv +  -- * Global Binder Environments   , BindEnv, beBinds-  , insertBindEnv, emptyBindEnv, lookupBindEnv, mapBindEnv, adjustBindEnv-  , bindEnvFromList, bindEnvToList-  , unionIBindEnv, diffIBindEnv+  , emptyBindEnv+  , insertBindEnv, lookupBindEnv+  , filterBindEnv, mapBindEnv, mapWithKeyMBindEnv, adjustBindEnv+  , bindEnvFromList, bindEnvToList, elemsBindEnv++  -- * Information needed to lookup and update Solutions+  , SolEnv (..)++  -- * Groups of KVars (needed by eliminate)+  , Packs (..)+  , getPack+  , makePack   ) where  -- import qualified Data.Binary as B import qualified Data.Binary as B+import qualified Data.List   as L import           Data.Generics             (Data) import           Data.Typeable             (Typeable) import           GHC.Generics              (Generic)@@ -44,6 +64,7 @@ import qualified Data.HashMap.Strict       as M import qualified Data.HashSet              as S import           Data.Maybe+import           Data.Function             (on) import           Text.PrettyPrint.HughesPJ import           Control.DeepSeq @@ -58,35 +79,78 @@  newtype IBindEnv   = FB (S.HashSet BindId) deriving (Eq, Data, Typeable, Generic) +instance PPrint IBindEnv where+  pprintTidy _ = pprint . L.sort . elemsIBindEnv+ newtype SEnv a     = SE { seBinds :: M.HashMap Symbol a }                      deriving (Eq, Data, Typeable, Generic, Foldable, Traversable) -data SizedEnv a    = BE { _beSize  :: Int-                        , beBinds :: BindMap a+data SizedEnv a    = BE { _beSize  :: !Int+                        , beBinds :: !(BindMap a)                         } deriving (Eq, Show, Functor, Foldable, Generic, Traversable) +instance PPrint a => PPrint (SizedEnv a) where+  pprintTidy k (BE _ m) = pprintTidy k m+ type BindEnv       = SizedEnv (Symbol, SortedReft) -- Invariant: All BindIds in the map are less than beSize +data SolEnv        = SolEnv { soeBinds :: !BindEnv+                            -- , soePacks :: !Packs+                            } deriving (Eq, Show, Generic) +instance PPrint a => PPrint (SEnv a) where+  pprintTidy k = pprintKVs k . L.sortBy (compare `on` fst) . toListSEnv+ toListSEnv              ::  SEnv a -> [(Symbol, a)] toListSEnv (SE env)     = M.toList env  fromListSEnv            ::  [(Symbol, a)] -> SEnv a fromListSEnv            = SE . M.fromList +fromMapSEnv             ::  M.HashMap Symbol a -> SEnv a+fromMapSEnv             = SE++mapSEnv                 :: (a -> b) -> SEnv a -> SEnv b mapSEnv f (SE env)      = SE (fmap f env)++mapMSEnv                :: (Monad m) => (a -> m b) -> SEnv a -> m (SEnv b)+mapMSEnv f env          = fromListSEnv <$> mapM (secondM f) (toListSEnv env)++mapSEnvWithKey          :: ((Symbol, a) -> (Symbol, b)) -> SEnv a -> SEnv b mapSEnvWithKey f        = fromListSEnv . fmap f . toListSEnv++deleteSEnv :: Symbol -> SEnv a -> SEnv a deleteSEnv x (SE env)   = SE (M.delete x env)-insertSEnv x y (SE env) = SE (M.insert x y env)++insertSEnv :: Symbol -> a -> SEnv a -> SEnv a+insertSEnv x v (SE env) = SE (M.insert x v env)++lookupSEnv :: Symbol -> SEnv a -> Maybe a lookupSEnv x (SE env)   = M.lookup x env++emptySEnv :: SEnv a emptySEnv               = SE M.empty++memberSEnv :: Symbol -> SEnv a -> Bool memberSEnv x (SE env)   = M.member x env++intersectWithSEnv :: (v1 -> v2 -> a) -> SEnv v1 -> SEnv v2 -> SEnv a intersectWithSEnv f (SE m1) (SE m2) = SE (M.intersectionWith f m1 m2)-differenceSEnv      (SE m1) (SE m2) = SE (M.difference m1 m2)++differenceSEnv :: SEnv a -> SEnv w -> SEnv a+differenceSEnv (SE m1) (SE m2) = SE (M.difference m1 m2)++filterSEnv :: (a -> Bool) -> SEnv a -> SEnv a filterSEnv f (SE m)     = SE (M.filter f m)++unionSEnv :: SEnv a -> M.HashMap Symbol a -> SEnv a unionSEnv (SE m1) m2    = SE (M.union m1 m2) +unionSEnv' :: SEnv a -> SEnv a -> SEnv a+unionSEnv' (SE m1) (SE m2)    = SE (M.union m1 m2)++lookupSEnvWithDistance :: Symbol -> SEnv a -> SESearch a lookupSEnvWithDistance x (SE env)   = case M.lookup x env of      Just z  -> Found z@@ -103,12 +167,20 @@  -- | Functions for Indexed Bind Environment ++instance Monoid IBindEnv where+  mempty                  = emptyIBindEnv+  mappend (FB e1) (FB e2) = FB (e1 `mappend` e2)+ emptyIBindEnv :: IBindEnv emptyIBindEnv = FB S.empty  deleteIBindEnv :: BindId -> IBindEnv -> IBindEnv deleteIBindEnv i (FB s) = FB (S.delete i s) +memberIBindEnv :: BindId -> IBindEnv -> Bool+memberIBindEnv i (FB s) = S.member i s+ insertsIBindEnv :: [BindId] -> IBindEnv -> IBindEnv insertsIBindEnv is (FB s) = FB (foldr S.insert s is) @@ -123,6 +195,9 @@ emptyBindEnv :: BindEnv emptyBindEnv = BE 0 M.empty +filterBindEnv   :: (BindId -> Symbol -> SortedReft -> Bool) -> BindEnv -> BindEnv+filterBindEnv f (BE n be) = BE n (M.filterWithKey (\ n (x, r) -> f n x r) be)+ bindEnvFromList :: [(BindId, Symbol, SortedReft)] -> BindEnv bindEnvFromList [] = emptyBindEnv bindEnvFromList bs = BE (1 + maxId) be@@ -130,24 +205,41 @@     maxId          = maximum $ fst3 <$> bs     be             = M.fromList [(n, (x, r)) | (n, x, r) <- bs] +elemsBindEnv :: BindEnv -> [BindId]+elemsBindEnv be = fst3 <$> bindEnvToList be+ bindEnvToList :: BindEnv -> [(BindId, Symbol, SortedReft)] bindEnvToList (BE _ be) = [(n, x, r) | (n, (x, r)) <- M.toList be] -mapBindEnv :: ((Symbol, SortedReft) -> (Symbol, SortedReft)) -> BindEnv -> BindEnv-mapBindEnv f (BE n m) = BE n $ M.map f m+mapBindEnv :: (BindId -> (Symbol, SortedReft) -> (Symbol, SortedReft)) -> BindEnv -> BindEnv+mapBindEnv f (BE n m) = BE n $ M.mapWithKey f m+-- (\i z -> tracepp (msg i z) $ f z) m+--  where+--    msg i z = "beMap " ++ show i ++ " " ++ show z +mapWithKeyMBindEnv :: (Monad m) => ((BindId, (Symbol, SortedReft)) -> m (BindId, (Symbol, SortedReft))) -> BindEnv -> m BindEnv+mapWithKeyMBindEnv f (BE n m) = (BE n . M.fromList) <$> mapM f (M.toList m)+ lookupBindEnv :: BindId -> BindEnv -> (Symbol, SortedReft) lookupBindEnv k (BE _ m) = fromMaybe err (M.lookup k m)   where     err                  = errorstar $ "lookupBindEnv: cannot find binder" ++ show k +filterIBindEnv :: (BindId -> Bool) -> IBindEnv -> IBindEnv+filterIBindEnv f (FB m) = FB (S.filter f m)+ unionIBindEnv :: IBindEnv -> IBindEnv -> IBindEnv unionIBindEnv (FB m1) (FB m2) = FB $ m1 `S.union` m2 +intersectionIBindEnv :: IBindEnv -> IBindEnv -> IBindEnv+intersectionIBindEnv (FB m1) (FB m2) = FB $ m1 `S.intersection` m2++nullIBindEnv :: IBindEnv -> Bool+nullIBindEnv (FB m) = S.null m+ diffIBindEnv :: IBindEnv -> IBindEnv -> IBindEnv diffIBindEnv (FB m1) (FB m2) = FB $ m1 `S.difference` m2 - adjustBindEnv :: ((Symbol, SortedReft) -> (Symbol, SortedReft)) -> BindId -> BindEnv -> BindEnv adjustBindEnv f i (BE n m) = BE n $ M.adjust f i m @@ -156,8 +248,8 @@  instance Fixpoint BindEnv where   toFix (BE _ m) = vcat $ map toFixBind $ hashMapToAscList m--toFixBind (i, (x, r)) = text "bind" <+> toFix i <+> toFix x <+> text ":" <+> toFix r+    where+      toFixBind (i, (x, r)) = "bind" <+> toFix i <+> toFix x <+> ":" <+> toFix r  instance (Fixpoint a) => Fixpoint (SEnv a) where    toFix (SE m)   = toFix (hashMapToAscList m)@@ -183,13 +275,43 @@  -------------------------------------------------------------------------------- +instance NFData Packs instance NFData IBindEnv instance NFData BindEnv instance (NFData a) => NFData (SEnv a) +instance B.Binary Packs instance B.Binary IBindEnv instance B.Binary BindEnv instance (B.Binary a) => B.Binary (SEnv a) instance (Hashable a, Eq a, B.Binary a) => B.Binary (S.HashSet a) where   put = B.put . S.toList   get = S.fromList <$> B.get++--------------------------------------------------------------------------------+-- | Constraint Pack Sets ------------------------------------------------------+--------------------------------------------------------------------------------++newtype Packs = Packs { packm :: M.HashMap KVar Int }+               deriving (Eq, Show, Generic)++instance Fixpoint Packs where+  toFix (Packs m) = vcat $ (("pack" <+>) . toFix) <$> kIs+    where+      kIs = L.sortBy (compare `on` snd) . M.toList $ m++instance PPrint Packs where+  pprintTidy _ = toFix++instance Monoid Packs where+  mempty        = Packs mempty+  mappend m1 m2 = Packs $ M.union (packm m1) (packm m2)++getPack :: KVar -> Packs -> Maybe Int+getPack k (Packs m) = M.lookup k m++makePack :: [S.HashSet KVar] -> Packs+makePack kvss = Packs (M.fromList kIs)+  where+    kIs       = [ (k, i) | (i, ks) <- kPacks, k <- ks ]+    kPacks    = zip [0..] . coalesce . fmap S.toList $ kvss
src/Language/Fixpoint/Types/Errors.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                       #-} {-# LANGUAGE DeriveDataTypeable        #-} {-# LANGUAGE DeriveGeneric             #-} {-# LANGUAGE DeriveFoldable            #-}@@ -5,6 +6,7 @@ {-# LANGUAGE FlexibleInstances         #-} {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE ScopedTypeVariables       #-}+{-# LANGUAGE StandaloneDeriving        #-} {-# LANGUAGE OverloadedStrings         #-}  {-# OPTIONS_GHC -fno-warn-orphans #-}@@ -42,6 +44,7 @@   -- * Some popular errors   , errFreeVarInQual   , errFreeVarInConstraint+  , errIllScopedKVar   ) where  import           Control.Exception@@ -62,8 +65,18 @@  -- import           Debug.Trace +#if MIN_VERSION_pretty(1,1,3)+import qualified Text.PrettyPrint.Annotated.HughesPJ as Ann++deriving instance Generic (Ann.AnnotDetails a)+instance Serialize a => Serialize (Ann.AnnotDetails a)+instance Serialize a => Serialize (Ann.Doc a)+#endif+ instance Serialize Error1+-- FIXME: orphans are bad... instance Serialize TextDetails+ instance Serialize Doc instance Serialize Error instance Serialize (FixResult Error)@@ -179,6 +192,17 @@   where     sp               = srcSpan q -errFreeVarInConstraint :: Integer -> Error-errFreeVarInConstraint i = err dummySpan $ vcat [ "Constraint with free vars"-                                                , pprint i ]+errFreeVarInConstraint :: (PPrint a) => (Integer, a) -> Error+errFreeVarInConstraint (i, ss) = err dummySpan $+  vcat [ "Constraint with free vars"+       , pprint i+       , pprint ss+       , "Try using the --prune-unsorted flag"+       ]++errIllScopedKVar :: (PPrint k, PPrint bs) => (k, Integer, Integer, bs) -> Error+errIllScopedKVar (k, inId, outId, xs) = err dummySpan $+  vcat [ "Ill-scoped KVar" <+> pprint k+       , "Missing common binders at def" <+> pprint inId <+> "and use" <+> pprint outId+       , pprint xs+       ]
− src/Language/Fixpoint/Types/Graphs.hs
@@ -1,70 +0,0 @@---- | This module contains the types for representing dependency---   graphs between kvars and constraints.--{-# LANGUAGE DeriveGeneric     #-}-{-# LANGUAGE OverloadedStrings #-}--module Language.Fixpoint.Types.Graphs (-  -- * Graphs-    CVertex (..)-  , CEdge-  , KVGraph--  -- * Components-  , Comps-  , KVComps--  -- * Printing-  , writeGraph-  )-  where--import           GHC.Generics              (Generic)-import           Data.Hashable-import           Text.PrettyPrint.HughesPJ--import           Language.Fixpoint.Misc         -- hiding (group)-import           Language.Fixpoint.Types.PrettyPrint-import           Language.Fixpoint.Types.Refinements -- Constraints------------------------------------------------------------------------------------data CVertex = KVar  KVar    -- ^ real kvar vertex-             | DKVar KVar    -- ^ dummy to ensure each kvar has a successor-             | Cstr  Integer -- ^ constraint-id which creates a dependency-               deriving (Eq, Ord, Show, Generic)--instance PPrint CVertex where-  pprintTidy _ (KVar k)  = doubleQuotes $ pprint $ kv k-  pprintTidy _ (Cstr i)  = text "id_" <> pprint i-  pprintTidy _ (DKVar k) = pprint k   <> text "*"---instance Hashable CVertex--type CEdge    = (CVertex, CVertex)-type KVGraph  = [(CVertex, CVertex, [CVertex])]-type Comps a  = [[a]]-type KVComps  = Comps CVertex-----------------------------------------------------------------------------------writeGraph :: FilePath -> KVGraph -> IO ()----------------------------------------------------------------------------------writeGraph f = writeFile f . render . ppGraph--ppGraph :: KVGraph -> Doc-ppGraph g = ppEdges [ (v, v') | (v,_,vs) <- g, v' <- vs]--ppEdges :: [CEdge] -> Doc-ppEdges             = vcat . wrap ["digraph Deps {"] ["}"]-                           . map ppE-                           . filter (not . isJunkEdge)-  where-    ppE (v, v')     = pprint v <+> "->" <+> pprint v'--isJunkEdge :: CEdge -> Bool-isJunkEdge (DKVar _, _)     = True-isJunkEdge (_, DKVar _)     = True-isJunkEdge (Cstr _, Cstr _) = True-isJunkEdge _                = False
src/Language/Fixpoint/Types/Names.hs view
@@ -23,6 +23,7 @@   , Symbolic (..)   , LocSymbol   , LocText+  , symbolicString    -- * Conversion to/from Text   , symbolSafeText@@ -34,6 +35,7 @@   , isPrefixOfSym   , isSuffixOfSym   , isNonSymbol+  , isLitSymbol   , isNontrivialVV   , isDummy @@ -79,8 +81,10 @@   , listConName   , listLConName   , tupConName-  , propConName-  , hpropConName+  , setConName+  , mapConName+  -- , propConName+  -- , hpropConName   , strConName   , nilName   , consName@@ -98,6 +102,9 @@   , setToIntName, bitVecToIntName, mapToIntName, boolToIntName, realToIntName   , setApplyName, bitVecApplyName, mapApplyName, boolApplyName, realApplyName, intApplyName +  , lambdaName+  , intArgName+ ) where  import           Control.DeepSeq             (NFData (..))@@ -140,8 +147,6 @@ -- --   where i is a unique integer (for each text) -- data Symbol   = S { _symbolId      :: !Id       , symbolRaw     :: !T.Text@@ -168,7 +173,8 @@   hashWithSalt s (DT t) = hashWithSalt s t  instance Hashable Symbol where-  hashWithSalt _ (S i _ _) = i+  -- NOTE: hash based on original text rather than id+  hashWithSalt s (S _ t _) = hashWithSalt s t  instance NFData Symbol where   rnf (S {}) = ()@@ -329,11 +335,11 @@ safeChars :: S.HashSet Char safeChars = alphaChars `mappend`             numChars   `mappend`-            S.fromList ['_', '.'  ]+            S.fromList ['_', '.']  symChars :: S.HashSet Char symChars =  safeChars `mappend`-            S.fromList ['%', '#', '$']+            S.fromList ['%', '#', '$', '\'']  okSymChars :: S.HashSet Char okSymChars = safeChars@@ -388,6 +394,9 @@ litSymbol :: Symbol -> Symbol litSymbol s = litPrefix `mappendSym` s +isLitSymbol :: Symbol -> Bool+isLitSymbol = isPrefixOfSym litPrefix+ unLitSymbol :: Symbol -> Maybe Symbol unLitSymbol = stripPrefix litPrefix @@ -406,11 +415,14 @@ existSymbol :: Symbol -> Integer -> Symbol existSymbol prefix = intSymbol (existPrefix `mappendSym` prefix) -tempPrefix, anfPrefix, renamePrefix, litPrefix, kArgPrefix, existPrefix :: Symbol++tempPrefix, anfPrefix, renamePrefix, litPrefix  :: Symbol tempPrefix   = "lq_tmp$" anfPrefix    = "lq_anf$" renamePrefix = "lq_rnm$" litPrefix    = "lit$"++kArgPrefix, existPrefix :: Symbol kArgPrefix   = "lq_karg$" existPrefix  = "lq_ext$" @@ -443,6 +455,9 @@ class Symbolic a where   symbol :: a -> Symbol +symbolicString :: (Symbolic a) => a -> String+symbolicString = symbolString . symbol+ instance Symbolic T.Text where   symbol = textSymbol @@ -456,13 +471,20 @@ --------------- Global Name Definitions ------------------------------------ ---------------------------------------------------------------------------- -setToIntName, bitVecToIntName, mapToIntName, boolToIntName , realToIntName:: Symbol+lambdaName :: Symbol+lambdaName = "smt_lambda"++intArgName :: Int -> Symbol+intArgName = intSymbol "lam_int_arg"++setToIntName, bitVecToIntName, mapToIntName, realToIntName :: Symbol setToIntName    = "set_to_int" bitVecToIntName = "bitvec_to_int" mapToIntName    = "map_to_int"-boolToIntName   = "bool_to_int" realToIntName   = "real_to_int" +boolToIntName :: (IsString a) => a+boolToIntName   = "bool_to_int"  setApplyName, bitVecApplyName, mapApplyName, boolApplyName, realApplyName, intApplyName :: Int -> Symbol setApplyName    = intSymbol "set_apply_"@@ -479,19 +501,22 @@ boolConName  = "Bool" funConName   = "->" -listConName, listLConName, tupConName, propConName, hpropConName, strConName, vvName :: Symbol+listConName, listLConName, tupConName, _propConName, _hpropConName, vvName, setConName, mapConName :: Symbol listConName  = "[]" listLConName = "List" tupConName   = "Tuple"-propConName  = "Prop"-hpropConName = "HProp"-strConName   = "Str"+setConName   = "Set_Set"+mapConName   = "Map_t" vvName       = "VV"+_propConName  = "Prop"+_hpropConName = "HProp" +strConName  :: (IsString a) => a+strConName   = "Str" -- symSepName   :: Char -- symSepName   = '#' -- DO NOT EVER CHANGE THIS -symSepName   :: (IsString a) => a -- Symbol+symSepName   :: (IsString a) => a symSepName   = "##"  nilName, consName, size32Name, size64Name, bitVecName, bvOrName, bvAndName :: Symbol@@ -508,13 +533,13 @@ divFuncName  = "Z3_OP_DIV"  prims :: [Symbol]-prims = [ propConName-        , hpropConName+prims = [ _propConName+        , _hpropConName         , vvName         , "Pred"         , "List"         , "[]"-        , "Set_Set"+        , setConName         , "Set_sng"         , "Set_cup"         , "Set_cap"@@ -523,7 +548,7 @@         , "Set_empty"         , "Set_mem"         , "Set_sub"-        , "Map_t"+        , mapConName         , "Map_select"         , "Map_store"         , size32Name
src/Language/Fixpoint/Types/PrettyPrint.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                #-} {-# LANGUAGE FlexibleContexts   #-} {-# LANGUAGE FlexibleInstances  #-} {-# LANGUAGE OverloadedStrings  #-}@@ -28,31 +29,31 @@ showFix =  render . toFix  instance (Ord a, Hashable a, Fixpoint a) => Fixpoint (S.HashSet a) where-  toFix xs = brackets $ sep $ punctuate (text ";") (toFix <$> L.sort (S.toList xs))+  toFix xs = brackets $ sep $ punctuate ";" (toFix <$> L.sort (S.toList xs))   simplify = S.fromList . map simplify . S.toList  instance Fixpoint () where-  toFix _ = text "()"+  toFix _ = "()"  instance Fixpoint a => Fixpoint (Maybe a) where-  toFix    = maybe (text "Nothing") ((text "Just" <+>) . toFix)+  toFix    = maybe "Nothing" (("Just" <+>) . toFix)   simplify = fmap simplify  instance Fixpoint a => Fixpoint [a] where-  toFix xs = brackets $ sep $ punctuate (text ";") (fmap toFix xs)+  toFix xs = brackets $ sep $ punctuate ";" (fmap toFix xs)   simplify = map simplify  instance (Fixpoint a, Fixpoint b) => Fixpoint (a,b) where-  toFix   (x,y)  = toFix x <+> text ":" <+> toFix y+  toFix   (x,y)  = toFix x <+> ":" <+> toFix y   simplify (x,y) = (simplify x, simplify y)  instance (Fixpoint a, Fixpoint b, Fixpoint c) => Fixpoint (a,b,c) where-  toFix   (x,y,z)  = toFix x <+> text ":" <+> toFix y <+> text ":" <+> toFix  z+  toFix   (x,y,z)  = toFix x <+> ":" <+> toFix y <+> ":" <+> toFix  z   simplify (x,y,z) = (simplify x, simplify y,simplify z)  instance Fixpoint Bool where-  toFix True  = text "True"-  toFix False = text "False"+  toFix True  = "True"+  toFix False = "False"   simplify z  = z  instance Fixpoint Int where@@ -84,17 +85,23 @@ showpp :: (PPrint a) => a -> String showpp = render . pprint +showTable :: (PPrint k, PPrint v) => Tidy -> [(k, v)] -> String+showTable k = render . pprintKVs k+ tracepp :: (PPrint a) => String -> a -> a tracepp s x = trace ("\nTrace: [" ++ s ++ "] : " ++ showpp x) x +notracepp :: (PPrint a) => String -> a -> a+notracepp _ x = x+ instance PPrint Doc where   pprintTidy _ = id  instance PPrint a => PPrint (Maybe a) where-  pprintTidy k = maybe (text "Nothing") ((text "Just" <+>) . pprintTidy k)+  pprintTidy k = maybe "Nothing" (("Just" <+>) . pprintTidy k)  instance PPrint a => PPrint [a] where-  pprintTidy k = brackets . intersperse comma . map (pprintTidy k)+  pprintTidy k = brackets . sep . punctuate comma . map (pprintTidy k)  instance PPrint a => PPrint (S.HashSet a) where   pprintTidy k = pprintTidy k . S.toList@@ -102,21 +109,10 @@ instance (PPrint a, PPrint b) => PPrint (M.HashMap a b) where   pprintTidy k = pprintKVs k . M.toList --- pprintKVs :: (PPrint k, PPrint v) => [(k, v)] -> Doc--- pprintKVs = pprintKVsTidy Full---- vcat . punctuate (text "\n") . map pp1---   where---     pp1 (x,y) = pprint x <+> text ":=" <+> pprint y- pprintKVs   :: (PPrint k, PPrint v) => Tidy -> [(k, v)] -> Doc-pprintKVs t = vcat . punctuate (text "\n") . map pp1+pprintKVs t = vcat . punctuate "\n" . map pp1   where-    pp1 (x,y) = pprintTidy t x <+> text ":=" <+> pprintTidy t y----+    pp1 (x,y) = pprintTidy t x <+> ":=" <+> pprintTidy t y  instance (PPrint a, PPrint b, PPrint c) => PPrint (a, b, c) where   pprintTidy k (x, y, z)  = parens $ pprintTidy k x <> "," <+>@@ -136,8 +132,10 @@ instance PPrint () where   pprintTidy _ = text . show +#if !(defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,0,1,1))) instance PPrint String where   pprintTidy _ = text+#endif  instance PPrint Int where   pprintTidy _ = tshow
src/Language/Fixpoint/Types/Refinements.hs view
@@ -14,9 +14,7 @@ {-# LANGUAGE PatternGuards              #-} {-# LANGUAGE PatternSynonyms            #-} --- | This module contains the data types for representing terms in the---   refinement logic; currently split into @Expr@ and @Pred@ but which---   will be unified.+-- | This module has the types for representing terms in the refinement logic.  module Language.Fixpoint.Types.Refinements ( @@ -27,8 +25,11 @@   , Brel (..)   , Expr (..), Pred   , pattern PTrue, pattern PTop, pattern PFalse, pattern EBot+  , pattern ETimes, pattern ERTimes, pattern EDiv, pattern ERDiv+  , pattern EEq   , KVar (..)   , Subst (..)+  , KVSub (..)   , Reft (..)   , SortedReft (..) @@ -36,7 +37,10 @@   , eVar, elit   , eProp   , pAnd, pOr, pIte+  , (&.&), (|.|)+  , pExist   , mkEApp+  , mkProp   , intKvar   , vv_ @@ -55,7 +59,7 @@   , uexprReft               -- singleton: v ~~ e   , symbolReft              -- singleton: v == x   , usymbolReft             -- singleton: v ~~ x-  , propReft                -- singleton: Prop(v) <=> p+  , propReft                -- singleton: v <=> p   , predReft                -- any pred : p   , reftPred   , reftBind@@ -63,21 +67,29 @@   -- * Predicates   , isFunctionSortedReft, functionSort   , isNonTrivial+  , isContraPred   , isTautoPred   , isSingletonReft-  , isEVar   , isFalse    -- * Destructing   , flattenRefas   , conjuncts   , eApps+  , eAppC   , splitEApp   , reftConjuncts    -- * Transforming   , mapPredReft   , pprintReft++  , debruijnIndex++  -- * Gradual Type Manipulation+  , pGAnds, pGAnd+  , isGradual+   ) where  import qualified Data.Binary as B@@ -85,7 +97,7 @@ import           Data.Typeable             (Typeable) import           Data.Hashable import           GHC.Generics              (Generic)-import           Data.List                 (partition) -- , foldl', sort, sortBy)+import           Data.List                 (foldl', partition) -- , sort, sortBy) import           Data.String import           Data.Text                 (Text) import qualified Data.Text                 as T@@ -129,17 +141,20 @@ instance B.Binary Reft instance B.Binary SortedReft - reftConjuncts :: Reft -> [Reft] reftConjuncts (Reft (v, ra)) = [Reft (v, ra') | ra' <- ras']   where     ras'                     = if null ps then ks else ((pAnd ps) : ks)-    (ks, ps)                 = partition isKvar $ refaConjuncts ra+    (ks, ps)                 = partition (\p -> isKvar p || isGradual p) $ refaConjuncts ra  isKvar :: Expr -> Bool isKvar (PKVar _ _) = True isKvar _           = False +isGradual :: Expr -> Bool+isGradual (PGrad _ _ _) = True+isGradual _             = False+ refaConjuncts :: Expr -> [Expr] refaConjuncts p = [p' | p' <- conjuncts p, not $ isTautoPred p'] @@ -151,7 +166,6 @@ newtype KVar = KV { kv :: Symbol }                deriving (Eq, Ord, Data, Typeable, Generic, IsString) - intKvar :: Integer -> KVar intKvar = KV . intSymbol "k_" @@ -167,7 +181,6 @@ -------------------------------------------------------------------------------- -- | Substitutions ------------------------------------------------------------- --------------------------------------------------------------------------------- newtype Subst = Su (M.HashMap Symbol Expr)                 deriving (Eq, Data, Typeable, Generic) @@ -179,6 +192,19 @@                    []  -> empty                    xys -> hcat $ map (\(x,y) -> brackets $ toFix x <> text ":=" <> toFix y) xys +instance PPrint Subst where+  pprintTidy _ = toFix++data KVSub = KVS+  { ksuVV    :: Symbol+  , ksuSort  :: Sort+  , ksuKVar  :: KVar+  , ksuSubst :: Subst+  } deriving (Eq, Data, Typeable, Generic, Show)++instance PPrint KVSub where+  pprintTidy k ksu = pprintTidy k (ksuVV ksu, ksuKVar ksu, ksuSubst ksu)+ -------------------------------------------------------------------------------- -- | Expressions --------------------------------------------------------------- --------------------------------------------------------------------------------@@ -203,7 +229,6 @@ data Expr = ESym !SymConst           | ECon !Constant           | EVar !Symbol-          -- NV TODO: change this to `EApp !Expr !Expr`           | EApp !Expr !Expr           | ENeg !Expr           | EBin !Bop !Expr !Expr@@ -212,8 +237,6 @@           | ELam !(Symbol, Sort)   !Expr           | ETApp !Expr !Sort           | ETAbs !Expr !Symbol----- Used to be predicates           | PAnd   ![Expr]           | POr    ![Expr]           | PNot   !Expr@@ -223,21 +246,27 @@           | PKVar  !KVar !Subst           | PAll   ![(Symbol, Sort)] !Expr           | PExist ![(Symbol, Sort)] !Expr-          | PGrad+          | PGrad  !KVar !Subst !Expr           deriving (Eq, Show, Data, Typeable, Generic)  type Pred = Expr -pattern PTrue  = PAnd []-pattern PTop   = PAnd []-pattern PFalse = POr []-pattern EBot   = POr []+pattern PTrue         = PAnd []+pattern PTop          = PAnd []+pattern PFalse        = POr  []+pattern EBot          = POr  []+pattern EEq e1 e2     = PAtom Eq    e1 e2+pattern ETimes e1 e2  = EBin Times  e1 e2+pattern ERTimes e1 e2 = EBin RTimes e1 e2+pattern EDiv e1 e2    = EBin Div    e1 e2+pattern ERDiv e1 e2   = EBin RDiv   e1 e2 + mkEApp :: LocSymbol -> [Expr] -> Expr-mkEApp f = eApps (EVar $ val f)+mkEApp = eApps . EVar . val  eApps :: Expr -> [Expr] -> Expr-eApps f es  = foldl EApp f es+eApps f es  = foldl' EApp f es  splitEApp :: Expr -> (Expr, [Expr]) splitEApp = go []@@ -245,7 +274,39 @@     go acc (EApp f e) = go (e:acc) f     go acc e          = (e, acc) +eAppC :: Sort -> Expr -> Expr -> Expr+eAppC s e1 e2 = ECst (EApp e1 e2) s +++debruijnIndex :: Expr -> Int+debruijnIndex = go+  where+    go (ELam _ e)      = 1 + go e+    go (ECst e _)      = go e+    go (EApp e1 e2)    = go e1 + go e2+    go (ESym _)        = 1+    go (ECon _)        = 1+    go (EVar _)        = 1+    go (ENeg e)        = go e+    go (EBin _ e1 e2)  = go e1 + go e2+    go (EIte e e1 e2)  = go e + go e1 + go e2+    go (ETAbs e _)     = go e+    go (ETApp e _)     = go e+    go (PAnd es)       = foldl (\n e -> n + go e) 0 es+    go (POr es)        = foldl (\n e -> n + go e) 0 es+    go (PNot e)        = go e+    go (PImp e1 e2)    = go e1 + go e2+    go (PIff e1 e2)    = go e1 + go e2+    go (PAtom _ e1 e2) = go e1 + go e2+    go (PAll _ e)      = go e+    go (PExist _ e)    = go e+    go (PKVar _ _)     = 1+    go (PGrad _ _ e)   = go e+++-- | Parsed refinement of @Symbol@ as @Expr@+--   e.g. in '{v: _ | e }' v is the @Symbol@ and e the @Expr@ newtype Reft = Reft (Symbol, Expr)                deriving (Eq, Data, Typeable, Generic) @@ -260,9 +321,9 @@   toFix (R i)   = toFix i   toFix (L s t) = parens $ text "lit" <+> text "\"" <> toFix s <> text "\"" <+> toFix t ------------------------------------------------------------------- | String Constants ---------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+-- | String Constants ----------------------------------------------------------+--------------------------------------------------------------------------------  -- | Replace all symbol-representations-of-string-literals with string-literal --   Used to transform parsed output from fixpoint back into fq.@@ -273,8 +334,8 @@ encodeSymConst        :: SymConst -> Symbol encodeSymConst (SL s) = litSymbol $ symbol s -decodeSymConst :: Symbol -> Maybe SymConst-decodeSymConst = fmap (SL . symbolText) . unLitSymbol+_decodeSymConst :: Symbol -> Maybe SymConst+_decodeSymConst = fmap (SL . symbolText) . unLitSymbol  instance Fixpoint SymConst where   toFix  = toFix . encodeSymConst@@ -327,7 +388,7 @@                                         $+$ ("." <+> toFix p))   toFix (ETApp e s)      = text "tapp" <+> toFix e <+> toFix s   toFix (ETAbs e s)      = text "tabs" <+> toFix e <+> toFix s-  toFix PGrad            = text "??"+  toFix (PGrad _ _ e)    = toFix e <+> text "&&" <+> text "??" -- <+> toFix k <+> toFix su   toFix (ELam (x,s) e)   = text "lam" <+> toFix x <+> ":" <+> toFix s <+> "." <+> toFix e    simplify (PAnd [])     = PTrue@@ -335,6 +396,10 @@   simplify (PAnd [p])    = simplify p   simplify (POr  [p])    = simplify p +  simplify (PGrad k su e)+    | isContraPred e      = PFalse+    | otherwise           = PGrad k su (simplify e)+   simplify (PAnd ps)     | any isContraPred ps = PFalse     | otherwise           = PAnd $ filter (not . isTautoPred) $ map simplify ps@@ -382,10 +447,6 @@                = x /= y     eqT _      = False -isEVar :: Expr -> Bool-isEVar (EVar _) = True-isEVar _        = False- isEq  :: Brel -> Bool isEq r          = r == Eq || r == Ueq @@ -410,6 +471,7 @@   pprintTidy _ (SL x) = doubleQuotes $ text $ T.unpack x  -- | Wrap the enclosed 'Doc' in parentheses only if the condition holds.+parensIf :: Bool -> Doc -> Doc parensIf True  = parens parensIf False = id @@ -432,6 +494,7 @@ -- sets the contextual precedence for recursive printer invocations to -- (prec p + 1). +opPrec :: Bop -> Int opPrec Mod    = 5 opPrec Plus   = 6 opPrec Minus  = 6@@ -461,8 +524,9 @@                                    "then" <+> pprintPrec (zi+1) k e1 <+>                                    "else" <+> pprintPrec (zi+1) k e2     where zi = 1-  pprintPrec _ k (ECst e so)     = parens $ pprint e <+> ":" <+> pprintTidy k so +  -- pprintPrec _ k (ECst e so)     = parens $ pprint e <+> ":" <+> const (text "...") (pprintTidy k so)+  pprintPrec z k (ECst e _)      = pprintPrec z k e   pprintPrec _ _ PTrue           = trueD   pprintPrec _ _ PFalse          = falseD   pprintPrec z k (PNot p)        = parensIf (z > zn) $@@ -495,20 +559,24 @@   pprintPrec _ _ p@(PKVar {})    = toFix p   pprintPrec _ _ (ETApp e s)     = "ETApp" <+> toFix e <+> toFix s   pprintPrec _ _ (ETAbs e s)     = "ETAbs" <+> toFix e <+> toFix s-  pprintPrec _ _ PGrad           = "?"+  pprintPrec z k (PGrad _ _ e)   = pprintPrec z k e <+> "&&" <+> "??" +pprintQuant :: Tidy -> Doc -> [(Symbol, Sort)] -> Expr -> Doc pprintQuant k d xts p = (d <+> toFix xts)                         $+$                         ("  ." <+> pprintTidy k p) +trueD, falseD, andD, orD :: Doc trueD  = "true" falseD = "false" andD   = "&&" orD    = "||" +pprintBin :: (PPrint a) => Int -> Tidy -> Doc -> Doc -> [a] -> Doc pprintBin _ _ b _ [] = b pprintBin z k _ o xs = vIntersperse o $ pprintPrec z k <$> xs +vIntersperse :: Doc -> [Doc] -> Doc vIntersperse _ []     = empty vIntersperse _ [d]    = d vIntersperse s (d:ds) = vcat (d : ((s <+>) <$> ds))@@ -535,14 +603,19 @@ class Predicate a where   prop   :: a -> Expr +instance Expression SortedReft where+  expr (RR _ r) = expr r++instance Expression Reft where+  expr (Reft(_, e)) = e+ instance Expression Expr where   expr = id  -- | The symbol may be an encoding of a SymConst.  instance Expression Symbol where-  expr s = maybe (eVar s) ESym (decodeSymConst s)-  -- expr = eVar+  expr s = eVar s  instance Expression Text where   expr = ESym . SL@@ -578,13 +651,26 @@   | e2 == EVar v && isEq r = Just e1 isSingletonExpr _ _        = Nothing -pAnd, pOr     :: ListNE Expr -> Expr+pAnd, pOr     :: ListNE Pred -> Pred pAnd          = simplify . PAnd pOr           = simplify . POr++(&.&) :: Pred -> Pred -> Pred+(&.&) p q = pAnd [p, q]++(|.|) :: Pred -> Pred -> Pred+(|.|) p q = pOr [p, q]++pIte :: Pred -> Expr -> Expr -> Expr pIte p1 p2 p3 = pAnd [p1 `PImp` p2, (PNot p1) `PImp` p3]-mkProp        = EApp (EVar propConName) +pExist :: [(Symbol, Sort)] -> Pred -> Pred+pExist []  p = p+pExist xts p = PExist xts p +mkProp :: Expr -> Pred+mkProp = id -- EApp (EVar propConName)+ -------------------------------------------------------------------------------- -- | Predicates ---------------------------------------------------------------- --------------------------------------------------------------------------------@@ -629,6 +715,17 @@ reftBind (Reft (x, _)) = x  ------------------------------------------------------------+-- | Gradual Type Manipulation  ----------------------------+------------------------------------------------------------+pGAnds :: [Expr] -> Expr+pGAnds = foldl pGAnd PTrue++pGAnd :: Expr -> Expr -> Expr+pGAnd (PGrad k su p) q = PGrad k su (pAnd [p, q])+pGAnd p (PGrad k su q) = PGrad k su (pAnd [p, q])+pGAnd p q              = pAnd [p,q]++------------------------------------------------------------ -- | Generally Useful Refinements -------------------------- ------------------------------------------------------------ @@ -659,6 +756,7 @@ conjuncts p   | isTautoPred p   = []   | otherwise       = [p]+  ------------------------------------------------------------------------- -- | TODO: This doesn't seem to merit a TC ------------------------------
+ src/Language/Fixpoint/Types/Solutions.hs view
@@ -0,0 +1,387 @@+{-# LANGUAGE FlexibleContexts           #-}+{-# LANGUAGE FlexibleInstances          #-}+{-# LANGUAGE NoMonomorphismRestriction  #-}+{-# LANGUAGE OverloadedStrings          #-}+{-# LANGUAGE UndecidableInstances       #-}+{-# LANGUAGE MultiParamTypeClasses      #-}+{-# LANGUAGE TypeOperators              #-}+{-# LANGUAGE GADTs                      #-}+{-# LANGUAGE PatternGuards              #-}+{-# LANGUAGE DeriveGeneric              #-}+{-# LANGUAGE DeriveDataTypeable         #-}+{-# LANGUAGE TupleSections              #-}++-- | This module contains the top-level SOLUTION data types,+--   including various indices used for solving.++module Language.Fixpoint.Types.Solutions (++  -- * Solution tables+    Solution, GSolution+  , Sol (gMap, sEnv), updateGMap, updateGMapWithKey+  , sScp+  , CMap++  -- * Solution elements+  , Hyp, Cube (..), QBind, GBind+  , EQual (..)++  -- * Equal elements+  , eQual+  , trueEqual++  -- * Gradual Solution elements   +  , qbToGb, gbToQbs, gbEquals, equalsGb, emptyGMap   ++  -- * Solution Candidates (move to SolverMonad?)+  , Cand++  -- * Constructor+  , fromList++  -- * Update+  , update++  -- * Lookup+  , lookupQBind+  , lookup, glookup++  -- * Manipulating QBind+  , qb+  , qbPreds+  , qbFilter++  , gbFilterM++  -- * Conversion for client+  , result, resultGradual++  -- * "Fast" Solver (DEPRECATED as unsound)+  , Index  (..)+  , KIndex (..)+  , BindPred (..)+  , BIndex (..)+  ) where++import           Prelude hiding (lookup)+import           GHC.Generics+import           Control.DeepSeq+import           Data.Maybe (fromMaybe)+import           Data.Hashable+import qualified Data.HashMap.Strict       as M+import qualified Data.List as L+import           Data.Generics             (Data)+import           Data.Typeable             (Typeable)+import           Control.Monad (filterM)+-- import qualified Data.HashSet              as S+import           Language.Fixpoint.Misc+import           Language.Fixpoint.Types.PrettyPrint+import           Language.Fixpoint.Types.Names+import           Language.Fixpoint.Types.Sorts+import           Language.Fixpoint.Types.Refinements+import           Language.Fixpoint.Types.Environments+import           Language.Fixpoint.Types.Constraints+import           Language.Fixpoint.Types.Substitutions+import           Language.Fixpoint.SortCheck (elaborate)+import           Text.PrettyPrint.HughesPJ++--------------------------------------------------------------------------------+-- | Update Solution -----------------------------------------------------------+--------------------------------------------------------------------------------+update :: Sol a QBind -> [KVar] -> [(KVar, EQual)] -> (Bool, Sol a QBind)+--------------------------------------------------------------------------------+update s ks kqs = {- tracepp msg -} (or bs, s')+  where+    kqss        = groupKs ks kqs+    (bs, s')    = folds update1 s kqss+    -- msg      = printf "ks = %s, s = %s" (showpp ks) (showpp s)++folds   :: (a -> b -> (c, a)) -> a -> [b] -> ([c], a)+folds f b = L.foldl' step ([], b)+  where+     step (cs, acc) x = (c:cs, x')+       where+         (c, x')      = f acc x++groupKs :: [KVar] -> [(KVar, EQual)] -> [(KVar, QBind)]+groupKs ks kqs = [ (k, QB eqs) | (k, eqs) <- M.toList $ groupBase m0 kqs ]+  where+    m0         = M.fromList $ (,[]) <$> ks++update1 :: Sol a QBind -> (KVar, QBind) -> (Bool, Sol a QBind)+update1 s (k, qs) = (change, updateK k qs s)+  where+    oldQs         = lookupQBind s k+    change        = qbSize oldQs /= qbSize qs++--------------------------------------------------------------------------------+-- | The `Solution` data type --------------------------------------------------+--------------------------------------------------------------------------------+type Solution  = Sol () QBind+type GSolution = Sol (((Symbol, Sort), Expr), GBind) QBind+newtype QBind = QB [EQual]   deriving (Show, Data, Typeable, Generic, Eq)+newtype GBind = GB [[EQual]] deriving (Show, Data, Typeable, Generic)++emptyGMap :: GSolution -> GSolution +emptyGMap sol = mapGMap sol (\(x,_) -> (x, GB []))++updateGMapWithKey :: [(KVar, QBind)] -> GSolution -> GSolution+updateGMapWithKey kqs sol = sol {gMap =  foldl (\m (k, (QB eq)) -> M.adjust (\(x, GB eqs) -> (x, GB (if eq `elem` eqs then eqs else eq:eqs))) k m) (gMap sol) kqs } ++qb :: [EQual] -> QBind+qb = QB++qbEQuals :: QBind -> [EQual]+qbEQuals (QB xs) = xs++qbToGb :: QBind -> GBind+qbToGb (QB xs) = GB $ map (:[]) xs++gbToQbs :: GBind -> [QBind]+gbToQbs (GB [])  = [QB [trueEqual]] +gbToQbs (GB ess) = QB <$> ess++gbEquals :: GBind -> [[EQual]]+gbEquals (GB eqs) = eqs ++equalsGb :: [[EQual]] -> GBind+equalsGb = GB ++gbFilterM :: Monad m => ([EQual] -> m Bool) -> GBind -> m GBind+gbFilterM f (GB eqs) = GB <$> filterM f eqs ++qbSize :: QBind -> Int+qbSize = length . qbEQuals++qbFilter :: (EQual -> Bool) -> QBind -> QBind+qbFilter f (QB eqs) = QB (filter f eqs)++instance NFData QBind+instance NFData GBind++instance PPrint QBind where+  pprintTidy k = pprintTidy k . qbEQuals++--------------------------------------------------------------------------------+-- | A `Sol` contains the various indices needed to compute a solution,+--   in particular, to compute `lhsPred` for any given constraint.+--------------------------------------------------------------------------------+data Sol b a = Sol+  { sEnv  :: !(SEnv Sort)                -- ^ Environment used to elaborate solutions+  , sMap  :: !(M.HashMap KVar a)         -- ^ Actual solution (for cut kvar)+  , gMap  :: !(M.HashMap KVar b)         -- ^ Solution for gradual variables +  , sHyp  :: !(M.HashMap KVar Hyp)       -- ^ Defining cubes  (for non-cut kvar)+  -- , sBot  :: !(M.HashMap KVar ())        -- ^ set of BOT (cut kvars)+  , sScp  :: !(M.HashMap KVar IBindEnv)  -- ^ set of allowed binders for kvar+  }++updateGMap :: Sol b a -> M.HashMap KVar b -> Sol b a +updateGMap sol gmap = sol {gMap = gmap}+++mapGMap :: Sol b a -> (b -> b) -> Sol b a +mapGMap sol f = sol {gMap = M.map f (gMap sol)}+++instance Monoid (Sol a b) where+  mempty        = Sol mempty mempty mempty mempty mempty+  mappend s1 s2 = Sol { sEnv  = mappend (sEnv s1) (sEnv s2)+                      , sMap  = mappend (sMap s1) (sMap s2)+                      , gMap  = mappend (gMap s1) (gMap s2)+                      , sHyp  = mappend (sHyp s1) (sHyp s2)+    --                , sBot  = mappend (sBot s1) (sBot s2)+                      , sScp  = mappend (sScp s1) (sScp s2)+                      }++instance Functor (Sol a) where+  fmap f (Sol e s m1 m2 m3) = Sol e (f <$> s) m1 m2 m3 ++instance (PPrint a, PPrint b) => PPrint (Sol a b) where+  pprintTidy k = pprintTidy k . sMap+++--------------------------------------------------------------------------------+-- | A `Cube` is a single constraint defining a KVar ---------------------------+--------------------------------------------------------------------------------+type Hyp      = ListNE Cube++data Cube = Cube+  { cuBinds :: IBindEnv  -- ^ Binders       from defining Env+  , cuSubst :: Subst     -- ^ Substitutions from cstrs    Rhs+  , cuId    :: SubcId    -- ^ Id            of   defining Cstr+  , cuTag   :: Tag       -- ^ Tag           of   defining Cstr (DEBUG)+  }++instance PPrint Cube where+  pprintTidy _ c = "Cube" <+> pprint (cuId c)++instance Show Cube where+  show = showpp+--------------------------------------------------------------------------------+result :: Sol a QBind -> M.HashMap KVar Expr+--------------------------------------------------------------------------------+result s = sMap $ (pAnd . fmap eqPred . qbEQuals) <$> s+++--------------------------------------------------------------------------------+resultGradual :: GSolution -> M.HashMap KVar (Expr, [Expr])+--------------------------------------------------------------------------------+resultGradual s = fmap go' (gMap s)+  where +    go' ((_,e), GB eqss) +     = (e, [PAnd $ fmap eqPred eqs | eqs <- eqss])+++--------------------------------------------------------------------------------+-- | Create a Solution ---------------------------------------------------------+--------------------------------------------------------------------------------+fromList :: SEnv Sort -> [(KVar, a)] -> [(KVar, b)] -> [(KVar, Hyp)] -> M.HashMap KVar IBindEnv -> Sol a b+fromList env kGs kXs kYs = Sol env kXm kGm kYm -- kBm+  where+    kXm              = M.fromList   kXs+    kYm              = M.fromList   kYs+    kGm              = M.fromList   kGs+ -- kBm              = const () <$> kXm++--------------------------------------------------------------------------------+qbPreds :: String -> Sol a QBind -> Subst -> QBind -> [(Pred, EQual)]+--------------------------------------------------------------------------------+qbPreds msg s su (QB eqs) = [ (elabPred eq, eq) | eq <- eqs ]+  where+    elabPred          = elaborate ("qbPreds:" ++ msg) env . subst su . eqPred+    env               = sEnv s++--------------------------------------------------------------------------------+-- | Read / Write Solution at KVar ---------------------------------------------+--------------------------------------------------------------------------------+lookupQBind :: Sol a QBind -> KVar -> QBind+--------------------------------------------------------------------------------+lookupQBind s k = {- tracepp _msg $ -} fromMaybe (QB []) (lookupElab s k)+  where+    _msg        = "lookupQB: k = " ++ show k++--------------------------------------------------------------------------------+glookup :: GSolution -> KVar -> Either Hyp (Either QBind (((Symbol, Sort), Expr), GBind))+--------------------------------------------------------------------------------+glookup s k+  | Just gbs <- M.lookup k (gMap s)+  = Right (Right gbs)+  | Just cs  <- M.lookup k (sHyp s) -- non-cut variable, return its cubes+  = Left cs+  | Just eqs <- lookupElab s k+  = Right (Left eqs)                 -- TODO: don't initialize kvars that have a hyp solution+  | otherwise+  = errorstar $ "solLookup: Unknown kvar " ++ show k++++--------------------------------------------------------------------------------+lookup :: Sol a QBind -> KVar -> Either Hyp QBind+--------------------------------------------------------------------------------+lookup s k+  | Just cs  <- M.lookup k (sHyp s) -- non-cut variable, return its cubes+  = Left cs+  | Just eqs <- lookupElab s k+  = Right eqs                 -- TODO: don't initialize kvars that have a hyp solution+  | otherwise+  = errorstar $ "solLookup: Unknown kvar " ++ show k++lookupElab :: Sol b QBind -> KVar -> Maybe QBind+lookupElab s k = M.lookup k (sMap s)++--------------------------------------------------------------------------------+updateK :: KVar -> a -> Sol b a -> Sol b a+--------------------------------------------------------------------------------+updateK k qs s = s { sMap = M.insert k qs (sMap s)+--                 , sBot = M.delete k    (sBot s)+                   }+++--------------------------------------------------------------------------------+-- | A `Cand` is an association list indexed by predicates+--------------------------------------------------------------------------------+type Cand a   = [(Expr, a)]+++--------------------------------------------------------------------------------+-- | Instantiated Qualifiers ---------------------------------------------------+--------------------------------------------------------------------------------+data EQual = EQL+  { _eqQual :: !Qualifier+  , eqPred  :: !Expr+  , _eqArgs :: ![Expr]+  } deriving (Eq, Show, Data, Typeable, Generic)++trueEqual :: EQual+trueEqual = EQL trueQual mempty [] ++instance PPrint EQual where+  pprintTidy k = pprintTidy k . eqPred++instance NFData EQual++{- EQL :: q:_ -> p:_ -> ListX F.Expr {q_params q} -> _ @-}+eQual :: Qualifier -> [Symbol] -> EQual+eQual q xs = {- tracepp "eQual" $ -} EQL q p es+  where+    p      = subst su $  qBody q+    su     = mkSubst  $  safeZip "eQual" qxs es+    es     = eVar    <$> xs+    qxs    = fst     <$> qParams q++--------------------------------------------------------------------------------+-- | A KIndex uniquely identifies each *use* of a KVar in an (LHS) binder+--------------------------------------------------------------------------------+data KIndex = KIndex { kiBIndex :: !BindId+                     , kiPos    :: !Int+                     , kiKVar   :: !KVar+                     }+              deriving (Eq, Ord, Show, Generic)++instance Hashable KIndex++instance PPrint KIndex where+  pprintTidy _ = tshow++--------------------------------------------------------------------------------+-- | A BIndex is created for each LHS Bind or RHS constraint+--------------------------------------------------------------------------------+data BIndex    = Root+               | Bind !BindId+               | Cstr !SubcId+                 deriving (Eq, Ord, Show, Generic)++instance Hashable BIndex++instance PPrint BIndex where+  pprintTidy _ = tshow++--------------------------------------------------------------------------------+-- | Each `Bind` corresponds to a conjunction of a `bpConc` and `bpKVars`+--------------------------------------------------------------------------------+data BindPred  = BP+  { bpConc :: !Pred                  -- ^ Concrete predicate (PTrue o)+  , bpKVar :: ![KIndex]              -- ^ KVar-Subst pairs+  } deriving (Show)++instance PPrint BindPred where+  pprintTidy _ = tshow+++--------------------------------------------------------------------------------+-- | A Index is a suitably indexed version of the cosntraints that lets us+--   1. CREATE a monolithic "background formula" representing all constraints,+--   2. ASSERT each lhs via bits for the subc-id and formulas for dependent cut KVars+--------------------------------------------------------------------------------+data Index = FastIdx+  { bindExpr   :: !(BindId |-> BindPred) -- ^ BindPred for each BindId+  , kvUse      :: !(KIndex |-> KVSub)    -- ^ Definition of each `KIndex`+  , kvDef      :: !(KVar   |-> Hyp)      -- ^ Constraints defining each `KVar`+  , envBinds   :: !(CMap IBindEnv)       -- ^ Binders of each Subc+  , envTx      :: !(CMap [SubcId])       -- ^ Transitive closure oof all dependent binders+  , envSorts   :: !(SEnv Sort)           -- ^ Sorts for all symbols+  -- , bindPrev   :: !(BIndex |-> BIndex)   -- ^ "parent" (immediately dominating) binder+  -- , kvDeps     :: !(CMap [KIndex])       -- ^ List of (Cut) KVars on which a SubC depends+  }++type CMap a  = M.HashMap SubcId a
src/Language/Fixpoint/Types/Sorts.hs view
@@ -1,9 +1,6 @@ {-# LANGUAGE TupleSections              #-} {-# LANGUAGE DeriveDataTypeable         #-}-{-# LANGUAGE DeriveFoldable             #-}-{-# LANGUAGE DeriveFunctor              #-} {-# LANGUAGE DeriveGeneric              #-}-{-# LANGUAGE DeriveTraversable          #-} {-# LANGUAGE FlexibleContexts           #-} {-# LANGUAGE FlexibleInstances          #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}@@ -12,7 +9,6 @@ {-# LANGUAGE UndecidableInstances       #-} {-# LANGUAGE MultiParamTypeClasses      #-} {-# LANGUAGE GADTs                      #-}-{-# LANGUAGE PatternGuards              #-}  -- | This module contains the data types, operations and --   serialization functions for representing Fixpoint's@@ -28,13 +24,15 @@   , Sub (..)   , FTycon, TCEmb   , sortFTycon-  , intFTyCon, boolFTyCon, realFTyCon, numFTyCon  -- TODO: hide these+  , intFTyCon, boolFTyCon, realFTyCon, numFTyCon, strFTyCon, setFTyCon  -- TODO: hide these    , intSort, realSort, boolSort, strSort, funcSort   , setSort, bitVecSort, mapSort   , listFTyCon   , isListTC-  , fTyconSymbol, symbolFTycon, fTyconSort+  , isFirstOrder+  , mappendFTC+  , fTyconSymbol, symbolFTycon, fTyconSort, symbolNumInfoFTyCon   , fApp, fApp', fAppTC   , fObj @@ -42,6 +40,8 @@   , functionSort   , mkFFunc   , bkFFunc++  , isNumeric, isReal, isString   ) where  import qualified Data.Binary as B@@ -49,6 +49,7 @@ import           Data.Typeable             (Typeable) import           GHC.Generics              (Generic) +import           Data.Monoid               () import           Data.Hashable import           Data.List                 (foldl') import           Control.DeepSeq@@ -61,36 +62,70 @@ import qualified Data.HashMap.Strict       as M  -newtype FTycon = TC LocSymbol deriving (Eq, Ord, Show, Data, Typeable, Generic)-type TCEmb a   = M.HashMap a FTycon+data FTycon   = TC LocSymbol TCInfo deriving (Ord, Show, Data, Typeable, Generic)+type TCEmb a  = M.HashMap a FTycon -intFTyCon, boolFTyCon, realFTyCon, funcFTyCon, numFTyCon, strFTyCon, listFTyCon :: FTycon-intFTyCon  = TC $ dummyLoc "int"-boolFTyCon = TC $ dummyLoc "bool"-realFTyCon = TC $ dummyLoc "real"-numFTyCon  = TC $ dummyLoc "num"-funcFTyCon = TC $ dummyLoc "function"-strFTyCon  = TC $ dummyLoc strConName-listFTyCon = TC $ dummyLoc listConName +instance Eq FTycon where+  (TC s _) == (TC s' _) = val s == val s'++data TCInfo = TCInfo { tc_isNum :: Bool, tc_isReal :: Bool, tc_isString :: Bool }+  deriving (Eq, Ord, Show, Data, Typeable, Generic)++mappendFTC :: FTycon -> FTycon -> FTycon+mappendFTC (TC x i1) (TC _ i2) = TC x (mappend i1 i2)++instance Monoid TCInfo where+  mempty                                          = TCInfo defNumInfo defRealInfo defStrInfo+  mappend (TCInfo i1 i2 i3)  (TCInfo i1' i2' i3') = TCInfo (i1 || i1') (i2 || i2') (i3 || i3')++defTcInfo, numTcInfo, realTcInfo, strTcInfo :: TCInfo+defTcInfo  = TCInfo defNumInfo defRealInfo defStrInfo+numTcInfo  = TCInfo True       defRealInfo defStrInfo+realTcInfo = TCInfo True       True        defStrInfo+strTcInfo  = TCInfo defNumInfo defRealInfo True++defNumInfo, defRealInfo, defStrInfo :: Bool+defNumInfo  = False+defRealInfo = False+defStrInfo  = False++charFTyCon, intFTyCon, boolFTyCon, realFTyCon, funcFTyCon, numFTyCon, strFTyCon, listFTyCon, setFTyCon :: FTycon+intFTyCon  = TC (dummyLoc "int"      ) numTcInfo+boolFTyCon = TC (dummyLoc "bool"     ) defTcInfo+realFTyCon = TC (dummyLoc "real"     ) realTcInfo+numFTyCon  = TC (dummyLoc "num"      ) numTcInfo+funcFTyCon = TC (dummyLoc "function" ) defTcInfo+strFTyCon  = TC (dummyLoc strConName ) strTcInfo+listFTyCon = TC (dummyLoc listConName) defTcInfo+charFTyCon = TC (dummyLoc "Char"     ) defTcInfo+setFTyCon  = TC (dummyLoc setConName ) defTcInfo+ isListConName :: LocSymbol -> Bool isListConName x = c == listConName || c == listLConName --"List"   where     c           = val x  isListTC :: FTycon -> Bool-isListTC (TC z) = isListConName z+isListTC (TC z _) = isListConName z  fTyconSymbol :: FTycon -> Located Symbol-fTyconSymbol (TC s) = s+fTyconSymbol (TC s _) = s -symbolFTycon :: LocSymbol -> FTycon-symbolFTycon c+symbolNumInfoFTyCon :: LocSymbol -> Bool -> Bool -> FTycon+symbolNumInfoFTyCon c isNum isReal   | isListConName c-  = TC $ fmap (const listConName) c+  = TC (fmap (const listConName) c) tcinfo   | otherwise-  = TC c+  = TC c tcinfo+  where+    tcinfo = defTcInfo{tc_isNum = isNum, tc_isReal = isReal} +++symbolFTycon :: LocSymbol -> FTycon+symbolFTycon c = symbolNumInfoFTyCon c defNumInfo defRealInfo+ fApp :: Sort -> [Sort] -> Sort fApp = foldl' FApp @@ -104,7 +139,7 @@     go acc t            = t : acc  fObj :: LocSymbol -> Sort-fObj = fTyconSort . TC+fObj = fTyconSort . (`TC` defTcInfo)  sortFTycon :: Sort -> Maybe FTycon sortFTycon FInt    = Just intFTyCon@@ -113,6 +148,7 @@ sortFTycon (FTC c) = Just c sortFTycon _       = Nothing + functionSort :: Sort -> Maybe ([Int], [Sort], Sort) functionSort s   | null is && null ss@@ -133,14 +169,55 @@           | FReal           | FNum                 -- ^ numeric kind for Num tyvars           | FFrac                -- ^ numeric kind for Fractional tyvars-          | FObj  Symbol         -- ^ uninterpreted type+          | FObj  !Symbol        -- ^ uninterpreted type           | FVar  !Int           -- ^ fixpoint type variable           | FFunc !Sort !Sort    -- ^ function           | FAbs  !Int !Sort     -- ^ type-abstraction-          | FTC   FTycon-          | FApp  Sort Sort      -- ^ constructed type+          | FTC   !FTycon+          | FApp  !Sort !Sort    -- ^ constructed type               deriving (Eq, Ord, Show, Data, Typeable, Generic) ++isFirstOrder, isFunction :: Sort -> Bool++isFirstOrder (FFunc sx s) = not (isFunction sx) && isFirstOrder s+isFirstOrder (FAbs _ s)   = isFirstOrder s+isFirstOrder (FApp s1 s2) = (not $ isFunction s1) && (not $ isFunction s2)+isFirstOrder _            = True++isFunction (FAbs _ s)  = isFunction s+isFunction (FFunc _ _) = True+isFunction _           = False++isNumeric :: Sort -> Bool+isNumeric FInt           = True+isNumeric (FApp s _)     = isNumeric s+isNumeric (FTC (TC _ i)) = tc_isNum i+isNumeric (FAbs _ s)     = isNumeric s+isNumeric _              = False++isReal :: Sort -> Bool+isReal FReal          = True+isReal (FApp s _)     = isReal s+isReal (FTC (TC _ i)) = tc_isReal i+isReal (FAbs _ s)     = isReal s+isReal _              = False+++isString :: Sort -> Bool+isString (FApp l c)     = (isList l && isChar c) || isString l+isString (FTC (TC c i)) = (val c == strConName || tc_isString i)+isString (FAbs _ s)     = isString s+isString _              = False++isList :: Sort -> Bool+isList (FTC c) = isListTC c+isList _       = False++isChar :: Sort -> Bool+isChar (FTC c) = c == charFTyCon+isChar _       = False+ {-@ FFunc :: Nat -> ListNE Sort -> Sort @-}  mkFFunc :: Int -> [Sort] -> Sort@@ -154,9 +231,9 @@    -- foldl (flip FAbs) (foldl1 (flip FFunc) ss) [0..i-1]  bkFFunc :: Sort -> Maybe (Int, [Sort])-bkFFunc t    = (maximum (0 : as),) <$> bkFun t' -  where -    (as, t') = bkAbs t +bkFFunc t    = (maximum (0 : as),) <$> bkFun t'+  where+    (as, t') = bkAbs t  bkAbs :: Sort -> ([Int], Sort) bkAbs (FAbs i t) = (i:is, t') where (is, t') = bkAbs t@@ -171,7 +248,7 @@   instance Hashable FTycon where-  hashWithSalt i (TC s) = hashWithSalt i s+  hashWithSalt i (TC s _) = hashWithSalt i s  instance Hashable Sort @@ -192,7 +269,7 @@ toFixSort (FTC c)      = toFix c toFixSort t@(FApp _ _) = toFixFApp (fApp' t) -+toFixAbsApp :: Sort -> Doc toFixAbsApp t = text "func" <> parens (toFix n <> text ", " <> toFix ts)   where     Just (vs, ss, s) = functionSort t@@ -206,7 +283,7 @@ toFixFApp ts         = parens $ intersperse space (toFixSort <$> ts)  instance Fixpoint FTycon where-  toFix (TC s)       = toFix s+  toFix (TC s _)       = toFix s  ------------------------------------------------------------------------- -- | Exported Basic Sorts -----------------------------------------------@@ -219,17 +296,17 @@ realSort = fTyconSort realFTyCon funcSort = fTyconSort funcFTyCon -bitVecSort :: Sort -mapSort :: Sort -> Sort -> Sort--setSort :: Sort -> Sort -setSort    = FApp (FTC $ symbolFTycon' "Set_Set")+setSort :: Sort -> Sort+setSort    = FApp (FTC setFTyCon) +bitVecSort :: Sort bitVecSort = FApp (FTC $ symbolFTycon' bitVecName) (FTC $ symbolFTycon' size32Name)-mapSort k v = FApp (FApp (FTC $ symbolFTycon' "Map_t") k) v -symbolFTycon' = symbolFTycon . dummyLoc+mapSort :: Sort -> Sort -> Sort+mapSort = FApp . FApp (FTC (symbolFTycon' mapConName)) +symbolFTycon' :: Symbol -> FTycon+symbolFTycon' = symbolFTycon . dummyLoc  fTyconSort :: FTycon -> Sort fTyconSort c@@ -249,10 +326,12 @@   instance B.Binary FTycon+instance B.Binary TCInfo instance B.Binary Sort instance B.Binary Sub  instance NFData FTycon+instance NFData TCInfo instance NFData Sort instance NFData Sub 
src/Language/Fixpoint/Types/Spans.hs view
@@ -80,6 +80,7 @@ toSourcePos :: (SourceName, Line, Column) -> SourcePos toSourcePos (f, l, c) = newPos f l c +sourcePosElts :: SourcePos -> (SourceName, Line, Column) sourcePosElts s = (src, line, col)   where     src         = sourceName   s@@ -92,7 +93,7 @@  data Located a = Loc { loc  :: !SourcePos -- ^ Start Position                      , locE :: !SourcePos -- ^ End Position-                     , val  :: a+                     , val  :: !a                      } deriving (Data, Typeable, Generic)  instance Loc (Located a) where@@ -115,7 +116,9 @@   traverse f (Loc l l' x) = Loc l l' <$> f x  instance Show a => Show (Located a) where-  show (Loc l l' x) = show x ++ " defined from: " ++ show l ++ " to: " ++ show l'+  show (Loc l l' x)+    | l == l' && l == dummyPos "Fixpoint.Types.dummyLoc" = show x ++ " (dummyLoc)"+    | otherwise  = show x ++ " defined from: " ++ show l ++ " to: " ++ show l'  instance PPrint a => PPrint (Located a) where   pprintTidy k (Loc _ _ x) = pprintTidy k x@@ -154,7 +157,7 @@ --     (f,l ,c )     = sourcePosElts $ sp_start z --     (_,l',c')     = sourcePosElts $ sp_stop  z -+ppSrcSpan :: SrcSpan -> Doc ppSrcSpan z       = text (printf "%s:%d:%d-%d:%d" f l c l' c')                 -- parens $ text (printf "file %s: (%d, %d) - (%d, %d)" (takeFileName f) l c l' c')   where@@ -165,6 +168,7 @@ instance Hashable SrcSpan where   hashWithSalt i z = hashWithSalt i (sp_start z, sp_stop z) +dummySpan :: SrcSpan dummySpan = SS l l   where l = initialPos "" 
src/Language/Fixpoint/Types/Substitutions.hs view
@@ -1,7 +1,6 @@ -- | This module contains the various instances for Subable, --   which (should) depend on the visitors, and hence cannot --   be in the same place as the @Term@ definitions.- module Language.Fixpoint.Types.Substitutions (     mkSubst   , isEmptySubst@@ -39,8 +38,12 @@     s1'                     = subst θ2 <$> s1  mkSubst :: [(Symbol, Expr)] -> Subst-mkSubst = Su . M.fromList . reverse +mkSubst = Su . M.fromList . reverse . filter notTrivial +  where+    notTrivial (x, EVar y) = x /= y+    notTrivial _           = True  + isEmptySubst :: Subst -> Bool isEmptySubst (Su xes) = M.null xes @@ -92,14 +95,19 @@ appSubst :: Subst -> Symbol -> Expr appSubst (Su s) x = fromMaybe (EVar x) (M.lookup x s) +subSymbol :: Maybe Expr -> Symbol -> Symbol subSymbol (Just (EVar y)) _ = y subSymbol Nothing         x = x subSymbol a               b = errorstar (printf "Cannot substitute symbol %s with expression %s" (showFix b) (showFix a)) +substfLam :: (Symbol -> Expr) -> (Symbol, Sort) -> Expr -> Expr+substfLam f s@(x, _) e =  ELam s (substf (\y -> if y == x then EVar x else f y) e)+ instance Subable Expr where   syms                     = exprSymbols   substa f                 = substf (EVar . f)   substf f (EApp s e)      = EApp (substf f s) (substf f e)+  substf f (ELam x e)      = substfLam f x e   substf f (ENeg e)        = ENeg (substf f e)   substf f (EBin op e1 e2) = EBin op (substf f e1) (substf f e2)   substf f (EIte p e1 e2)  = EIte (substf f p) (substf f e1) (substf f e2)@@ -113,10 +121,12 @@   substf f (PAtom r e1 e2) = PAtom r (substf f e1) (substf f e2)   substf _ p@(PKVar _ _)   = p   substf _  (PAll _ _)     = errorstar "substf: FORALL"+  substf f (PGrad k su e)  = PGrad k su (substf f e)   substf _  p              = p     subst su (EApp f e)      = EApp (subst su f) (subst su e)+  subst su (ELam x e)      = ELam x (subst (removeSubst su (fst x)) e)   subst su (ENeg e)        = ENeg (subst su e)   subst su (EBin op e1 e2) = EBin op (subst su e1) (subst su e2)   subst su (EIte p e1 e2)  = EIte (subst su p) (subst su e1) (subst su e2)@@ -129,12 +139,18 @@   subst su (PIff p1 p2)    = PIff (subst su p1) (subst su p2)   subst su (PAtom r e1 e2) = PAtom r (subst su e1) (subst su e2)   subst su (PKVar k su')   = PKVar k $ su' `catSubst` su-  subst _  (PAll _ _)      = errorstar "subst: FORALL"+  subst su (PGrad k su' e) = PGrad k (su' `catSubst` su)  (subst su e)+  subst su (PAll bs p)+          | disjoint su bs = PAll bs $ subst su p --(substExcept su (fst <$> bs)) p+          | otherwise      = errorstar "subst: PAll (without disjoint binds)"   subst su (PExist bs p)           | disjoint su bs = PExist bs $ subst su p --(substExcept su (fst <$> bs)) p-          | otherwise      = errorstar "subst: EXISTS (without disjoint binds)"+          | otherwise      = errorstar ("subst: EXISTS (without disjoint binds)" ++ show (bs, su))   subst _  p               = p +removeSubst :: Subst -> Symbol -> Subst+removeSubst (Su su) x = Su $ M.delete x su+ disjoint :: Subst -> [(Symbol, Sort)] -> Bool disjoint (Su su) bs = S.null $ suSyms `S.intersection` bsSyms   where@@ -192,6 +208,7 @@   bot    _        = falseReft   top (Reft(v,_)) = Reft (v, mempty) +pprReft :: Reft -> Doc -> Doc pprReft (Reft (v, p)) d   | isTautoPred p   = d@@ -205,6 +222,7 @@   ofReft   = errorstar "No instance of ofReft for SortedReft"   params _ = []   bot s    = s { sr_reft = falseReft }+  top s    = s { sr_reft = trueReft }  -- RJ: this depends on `isTauto` hence, here. instance PPrint Reft where@@ -231,23 +249,25 @@ instance Show SortedReft where   show  = showFix +pprReftPred :: Reft -> Doc pprReftPred (Reft (_, p))   | isTautoPred p   = text "true"   | otherwise   = ppRas [p] +ppRas :: [Expr] -> Doc ppRas = cat . punctuate comma . map toFix . flattenRefas  -------------------------------------------------------------------------------- -- | TODO: Rewrite using visitor ----------------------------------------------- --------------------------------------------------------------------------------- exprSymbols :: Expr -> [Symbol] exprSymbols = go   where     go (EVar x)           = [x]     go (EApp f e)         = go f ++ go e+    go (ELam (x,_) e)     = filter (/= x) (go e)     go (ENeg e)           = go e     go (EBin _ e1 e2)     = go e1 ++ go e2     go (EIte p e1 e2)     = exprSymbols p ++ go e1 ++ go e2
+ src/Language/Fixpoint/Types/Triggers.hs view
@@ -0,0 +1,64 @@+{-# LANGUAGE DeriveDataTypeable         #-}+{-# LANGUAGE DeriveFunctor              #-}+{-# LANGUAGE DeriveGeneric              #-}++module Language.Fixpoint.Types.Triggers (++    Triggered (..), Trigger(..),++    noTrigger, defaultTrigger,++    makeTriggers++    ) where++import qualified Data.Binary as B+import           Control.DeepSeq+import           GHC.Generics              (Generic)++import Language.Fixpoint.Types.Refinements+import Language.Fixpoint.Misc              (errorstar)+++data Triggered a = TR Trigger a+  deriving (Eq, Show, Functor, Generic)++data Trigger = NoTrigger | LeftHandSide+  deriving (Eq, Show, Generic)+++noTrigger :: e -> Triggered e+noTrigger = TR NoTrigger++defaultTrigger :: e -> Triggered e+defaultTrigger = TR LeftHandSide++makeTriggers :: Triggered Expr -> [Expr]+makeTriggers (TR LeftHandSide e) = [getLeftHandSide e]+makeTriggers (TR NoTrigger    _) = errorstar "makeTriggers on NoTrigger"+++getLeftHandSide :: Expr -> Expr+getLeftHandSide (ECst e _)+  = getLeftHandSide e+getLeftHandSide (PAll _ e)+  = getLeftHandSide e+getLeftHandSide (PExist _ e)+  = getLeftHandSide e+getLeftHandSide (PAtom eq lhs _)+  | eq == Eq || eq == Ueq+  = lhs+getLeftHandSide (PIff lhs _)+  = lhs+getLeftHandSide _+ = defaltPatter++-- NV TODO find out a valid, default pattern that does not instantiate the axiom+defaltPatter :: Expr+defaltPatter = PFalse++instance B.Binary Trigger+instance NFData   Trigger++instance (B.Binary a) => B.Binary (Triggered a)+instance (NFData a)   => NFData   (Triggered a)
src/Language/Fixpoint/Types/Utils.hs view
@@ -7,24 +7,20 @@    -- * Free variables in a refinement   , reftFreeVars++  -- * Deconstruct a SortedReft+  , sortedReftConcKVars   ) where --- import           Language.Fixpoint.Types.PrettyPrint+import qualified Data.HashMap.Strict                  as M+import qualified Data.HashSet                         as S++import           Language.Fixpoint.Misc import           Language.Fixpoint.Types.Names--- import           Language.Fixpoint.Types.Errors--- import           Language.Fixpoint.Types.Spans--- import           Language.Fixpoint.Types.Sorts import           Language.Fixpoint.Types.Refinements--- import           Language.Fixpoint.Types.Substitutions import           Language.Fixpoint.Types.Environments import           Language.Fixpoint.Types.Constraints--- import           Language.Fixpoint.Types.Graphs -import           Language.Fixpoint.Misc (fst3)-import qualified Data.HashMap.Strict as M-import qualified Data.HashSet as S-- -------------------------------------------------------------------------------- -- | Compute the domain of a kvar --------------------------------------------------------------------------------@@ -44,3 +40,18 @@ --TODO deduplicate (also in Solver/UniqifyBinds) reftFreeVars :: Reft -> S.HashSet Symbol reftFreeVars r@(Reft (v, _)) = S.delete v $ S.fromList $ syms r++--------------------------------------------------------------------------------+-- | Split a SortedReft into its concrete and KVar components+--------------------------------------------------------------------------------+sortedReftConcKVars :: Symbol -> SortedReft -> ([Pred], [KVSub], [KVSub])+sortedReftConcKVars x sr = go [] [] [] ves+  where+    ves                  = [(v, p `subst1` (v, eVar x)) | Reft (v, p) <- rs ]+    rs                   = reftConjuncts (sr_reft sr)+    t                    = sr_sort sr++    go ps ks gs ((v, PKVar k su  ):xs) = go ps (KVS v t k su:ks) gs xs +    go ps ks gs ((v, PGrad k su _):xs) = go ps ks (KVS v t k su:gs) xs +    go ps ks gs ((_, p):xs)            = go (p:ps) ks gs xs +    go ps ks gs []                     = (ps, ks, gs)
src/Language/Fixpoint/Types/Visitor.hs view
@@ -2,10 +2,12 @@ {-# LANGUAGE PatternGuards #-} {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FlexibleContexts #-}  module Language.Fixpoint.Types.Visitor (   -- * Visitor      Visitor (..)+  ,  Visitable (..)    -- * Extracting Symbolic Constants (String Literals)   ,  SymConsts (..)@@ -20,12 +22,14 @@   , fold    -- * Clients-  , kvars-  , size+  , stripCasts+  , kvars, eapps+  , size, lamSize   , envKVars   , envKVarsN   , rhsKVars   , mapKVars, mapKVars', mapKVarSubsts+  , mapExpr, mapMExpr    -- * Predicates on Constraints   , isConcC , isKvarC@@ -36,7 +40,7 @@    ) where -import           Control.Monad.Trans.State (State, modify, runState)+import           Control.Monad.Trans.State.Strict (State, modify, runState) import qualified Data.HashSet        as S import qualified Data.HashMap.Strict as M import qualified Data.List           as L@@ -57,12 +61,13 @@ --------------------------------------------------------------------------------- defaultVisitor :: Monoid acc => Visitor acc ctx ----------------------------------------------------------------------------------defaultVisitor = Visitor {-    ctxExpr    = const -- \c _ -> c+defaultVisitor = Visitor+  { ctxExpr    = const -- \c _ -> c   , txExpr     = \_ x -> x   , accExpr    = \_ _ -> mempty   } + ------------------------------------------------------------------------  fold         :: (Visitable t, Monoid a) => Visitor a ctx -> ctx -> a -> t -> a@@ -102,47 +107,57 @@   visit v c = mapM (visit v c)  ------------------------------------------------------------------------------------ Warning: these instances were written for mapKVars over SInfos only;---  check that they behave as expected before using with other clients.+-- WARNING: these instances were written for mapKVars over GInfos only;+-- check that they behave as expected before using with other clients. instance Visitable (SimpC a) where   visit v c x = do     rhs' <- visit v c (_crhs x)     return x { _crhs = rhs' } -instance Visitable (SInfo a) where+instance Visitable (SubC a) where   visit v c x = do+    lhs' <- visit v c (slhs x)+    rhs' <- visit v c (srhs x)+    return x { slhs = lhs', srhs = rhs' }++instance (Visitable (c a)) => Visitable (GInfo c a) where+  visit v c x = do     cm' <- mapM (visit v c) (cm x)     bs' <- visit v c (bs x)     return x { cm = cm', bs = bs' }---------------------------------------------------------------------------------- +++--------------------------------------------------------------------------------- visitExpr :: (Monoid a) => Visitor a ctx -> ctx -> Expr -> VisitM a Expr visitExpr v = vE   where-    vE c e = accum acc >> step c' e' where c'  = ctxExpr v c e-                                           e'  = txExpr v c' e-                                           acc = accExpr v c' e+    vE c e = do {-# SCC "visitExpr.vE.accum" #-} accum acc+                {-# SCC "visitExpr.vE.step" #-} step c' e'+      where c'  = ctxExpr v c e+            e'  = txExpr v c' e+            acc = accExpr v c' e     step _ e@(ESym _)      = return e     step _ e@(ECon _)      = return e     step _ e@(EVar _)      = return e-    step c (EApp f e)      = EApp       <$> vE c f  <*> vE c e-    step c (ENeg e)        = ENeg       <$> vE c e-    step c (EBin o e1 e2)  = EBin o     <$> vE c e1 <*> vE c e2-    step c (EIte p e1 e2)  = EIte       <$> vE c p  <*> vE c e1 <*> vE c e2-    step c (ECst e t)      = (`ECst` t) <$> vE c e-    step c (PAnd  ps)      = PAnd       <$> (vE c <$$> ps)-    step c (POr  ps)       = POr        <$> (vE c <$$> ps)-    step c (PNot p)        = PNot       <$> vE c p-    step c (PImp p1 p2)    = PImp       <$> vE c p1 <*> vE c p2-    step c (PIff p1 p2)    = PIff       <$> vE c p1 <*> vE c p2-    step c (PAtom r e1 e2) = PAtom r    <$> vE c e1 <*> vE c e2-    step c (PAll xts p)    = PAll   xts <$> vE c p-    step c (ELam (x,t) e)  = ELam (x,t) <$> vE c e-    step c (PExist xts p)  = PExist xts <$> vE c p+    step c (EApp f e)      = EApp        <$> vE c f  <*> vE c e+    step c (ENeg e)        = ENeg        <$> vE c e+    step c (EBin o e1 e2)  = EBin o      <$> vE c e1 <*> vE c e2+    step c (EIte p e1 e2)  = EIte        <$> vE c p  <*> vE c e1 <*> vE c e2+    step c (ECst e t)      = (`ECst` t)  <$> vE c e+    step c (PAnd  ps)      = PAnd        <$> (vE c <$$> ps)+    step c (POr  ps)       = POr         <$> (vE c <$$> ps)+    step c (PNot p)        = PNot        <$> vE c p+    step c (PImp p1 p2)    = PImp        <$> vE c p1 <*> vE c p2+    step c (PIff p1 p2)    = PIff        <$> vE c p1 <*> vE c p2+    step c (PAtom r e1 e2) = PAtom r     <$> vE c e1 <*> vE c e2+    step c (PAll xts p)    = PAll   xts  <$> vE c p+    step c (ELam (x,t) e)  = ELam (x,t)  <$> vE c e+    step c (PExist xts p)  = PExist xts  <$> vE c p     step c (ETApp e s)     = (`ETApp` s) <$> vE c e     step c (ETAbs e s)     = (`ETAbs` s) <$> vE c e     step _ p@(PKVar _ _)   = return p-    step _ PGrad           = return PGrad+    step c (PGrad k su e)  = PGrad k su <$> vE c e   mapKVars :: Visitable t => (KVar -> Maybe Expr) -> t -> t mapKVars f = mapKVars' f'@@ -155,15 +170,47 @@     kvVis              = defaultVisitor { txExpr = txK }     txK _ (PKVar k su)       | Just p' <- f (k, su) = subst su p'+    txK _ (PGrad k su _)+      | Just p' <- f (k, su) = subst su p'     txK _ p            = p -mapKVarSubsts :: Visitable t => (KVar -> Subst -> Subst) -> t -> t-mapKVarSubsts f        = trans kvVis () []+mapExpr :: (Expr -> Expr) -> Expr -> Expr+mapExpr f = trans (defaultVisitor {txExpr = const f}) () []+++mapMExpr :: (Monad m) => (Expr -> m Expr) -> Expr -> m Expr+mapMExpr f = go   where-    kvVis              = defaultVisitor { txExpr = txK }-    txK _ (PKVar k su) = PKVar k $ f k su-    txK _ p            = p+    go e@(ESym _)      = f e+    go e@(ECon _)      = f e+    go e@(EVar _)      = f e+    go e@(PKVar _ _)   = f e+    go (PGrad k su e)  = f =<< (PGrad k su  <$>  go e                     )+    go (ENeg e)        = f =<< (ENeg        <$>  go e                     )+    go (PNot p)        = f =<< (PNot        <$>  go p                     )+    go (ECst e t)      = f =<< ((`ECst` t)  <$>  go e                     )+    go (PAll xts p)    = f =<< (PAll   xts  <$>  go p                     )+    go (ELam (x,t) e)  = f =<< (ELam (x,t)  <$>  go e                     )+    go (PExist xts p)  = f =<< (PExist xts  <$>  go p                     )+    go (ETApp e s)     = f =<< ((`ETApp` s) <$>  go e                     )+    go (ETAbs e s)     = f =<< ((`ETAbs` s) <$>  go e                     )+    go (EApp g e)      = f =<< (EApp        <$>  go g  <*> go e           )+    go (EBin o e1 e2)  = f =<< (EBin o      <$>  go e1 <*> go e2          )+    go (PImp p1 p2)    = f =<< (PImp        <$>  go p1 <*> go p2          )+    go (PIff p1 p2)    = f =<< (PIff        <$>  go p1 <*> go p2          )+    go (PAtom r e1 e2) = f =<< (PAtom r     <$>  go e1 <*> go e2          )+    go (EIte p e1 e2)  = f =<< (EIte        <$>  go p  <*> go e1 <*> go e2)+    go (PAnd  ps)      = f =<< (PAnd        <$> (go <$$> ps)              )+    go (POr  ps)       = f =<< (POr         <$> (go <$$> ps)              ) +mapKVarSubsts :: Visitable t => (KVar -> Subst -> Subst) -> t -> t+mapKVarSubsts f          = trans kvVis () []+  where+    kvVis                = defaultVisitor { txExpr = txK }+    txK _ (PKVar k su)   = PKVar k (f k su)+    txK _ (PGrad k su e) = PGrad k (f k su) e+    txK _ p              = p+   newtype MInt = MInt Integer  instance Monoid MInt where@@ -176,12 +223,29 @@     MInt n = fold szV () mempty t     szV    = (defaultVisitor :: Visitor MInt t) { accExpr = \ _ _ -> MInt 1 } ++lamSize :: Visitable t => t -> Integer+lamSize t    = n+  where+    MInt n = fold szV () mempty t+    szV    = (defaultVisitor :: Visitor MInt t) { accExpr = accum }+    accum _ (ELam _ _) = MInt 1+    accum _ _          = MInt 0++eapps :: Visitable t => t -> [Expr]+eapps                 = fold eappVis () []+  where+    eappVis              = (defaultVisitor :: Visitor [KVar] t) { accExpr = eapp' }+    eapp' _ e@(EApp _ _) = [e]+    eapp' _ _            = []+ kvars :: Visitable t => t -> [KVar]-kvars                = fold kvVis () []+kvars                 = fold kvVis () []   where-    kvVis            = (defaultVisitor :: Visitor [KVar] t) { accExpr = kv' }-    kv' _ (PKVar k _) = [k]-    kv' _ _           = []+    kvVis             = (defaultVisitor :: Visitor [KVar] t) { accExpr = kv' }+    kv' _ (PKVar k _)   = [k]+    kv' _ (PGrad k _ _) = [k]+    kv' _ _             = []  envKVars :: (TaggedC c a) => BindEnv -> c a -> [KVar] envKVars be c = squish [ kvs sr |  (_, sr) <- clhs be c]@@ -206,11 +270,18 @@  isKvar :: Expr -> Bool isKvar (PKVar {}) = True+isKvar (PGrad {}) = True  isKvar _          = False  isConc :: Expr -> Bool isConc = null . kvars +stripCasts :: Expr -> Expr+stripCasts = mapExpr go+  where+    go (ECst e _) = e+    go e          = e+ --------------------------------------------------------------------------------- -- | Visitors over @Sort@ ---------------------------------------------------------------------------------@@ -242,12 +313,13 @@ class SymConsts a where   symConsts :: a -> [SymConst] -instance  SymConsts (FInfo a) where+-- instance  SymConsts (FInfo a) where+instance (SymConsts (c a)) => SymConsts (GInfo c a) where   symConsts fi = sortNub $ csLits ++ bsLits ++ qsLits     where       csLits   = concatMap symConsts $ M.elems  $  cm    fi       bsLits   = symConsts           $ bs                fi-      qsLits   = concatMap symConsts $ q_body  <$> quals fi+      qsLits   = concatMap symConsts $ qBody   <$> quals fi  instance SymConsts BindEnv where   symConsts    = concatMap (symConsts . snd) . M.elems . beBinds@@ -256,6 +328,9 @@   symConsts c  = symConsts (slhs c) ++                  symConsts (srhs c) +instance SymConsts (SimpC a) where+  symConsts c  = symConsts (crhs c)+ instance SymConsts SortedReft where   symConsts = symConsts . sr_reft @@ -272,11 +347,3 @@     scVis            = (defaultVisitor :: Visitor [SymConst] t)  { accExpr = sc }     sc _ (ESym c)    = [c]     sc _ _           = []---{---instance SymConsts (SimpC a) where-  symConsts c  = symConsts (crhs c)---}
src/Language/Fixpoint/Utils/Files.hs view
@@ -41,6 +41,7 @@ -- | Hardwired Paths and Files ----------------------------- ------------------------------------------------------------ +getFixpointPath :: IO FilePath getFixpointPath = fromMaybe msg . msum <$>                   sequence [ findExecutable "fixpoint.native"                            , findExecutable "fixpoint.native.exe"@@ -50,6 +51,7 @@   where     msg = errorstar "Cannot find fixpoint binary [fixpoint.native]" +getZ3LibPath :: IO FilePath getZ3LibPath    = dropFileName <$> getFixpointPath  @@ -72,6 +74,7 @@          | Js       -- ^ JavaScript source          | Ts       -- ^ Typescript source          | Spec     -- ^ Spec file (e.g. include/Prelude.spec)+         | BinSpec  -- ^ Lifted-Spec file, containing automatically generated specifications           | Hquals   -- ^ Qualifiers file (e.g. include/Prelude.hquals)          | Result   -- ^ Final result: SAFE/UNSAFE          | Cst      -- ^ HTML file with templates?@@ -88,8 +91,11 @@          | BinFq    -- ^ Binary representation of .fq / FInfo          | Smt2     -- ^ SMTLIB2 query file          | Min      -- ^ filter constraints with delta debug+         | MinQuals -- ^ filter qualifiers with delta debug+         | MinKVars -- ^ filter kvars with delta debug          deriving (Eq, Ord, Show) +extMap :: Ext -> FilePath extMap          = go   where     go Cgi      = ".cgi"@@ -110,6 +116,7 @@     go Mkdn     = ".markdown"     go Json     = ".json"     go Spec     = ".spec"+    go BinSpec  = ".bspec"     go Hquals   = ".hquals"     go Result   = ".out"     go Saved    = ".bak"@@ -120,6 +127,8 @@     go BinFq    = ".bfq"     go (Part n) = "." ++ show n     go Min      = ".minfq"+    go MinQuals = ".minquals"+    go MinKVars = ".minkvars"     -- go _      = errorstar $ "extMap: Unknown extension " ++ show e  withExt         :: FilePath -> Ext -> FilePath@@ -140,6 +149,7 @@     dir         = takeDirectory f     isTmp       = (tmpDirName `isSuffixOf`) +tmpDirName :: FilePath tmpDirName      = ".liquid"  extFileNameR     :: Ext -> FilePath -> FilePath@@ -180,8 +190,9 @@ getFileInDirs :: FilePath -> [FilePath] -> IO (Maybe FilePath) getFileInDirs name = findFirst (testM doesFileExist . (</> name)) +testM :: (Monad m) => (a -> m Bool) -> a -> m [a] testM f x = do b <- f x-               return $ if b then [x] else []+               return [ x | b ]  findFirst ::  Monad m => (t -> m [a]) -> [t] -> m (Maybe a) findFirst _ []     = return Nothing
src/Language/Fixpoint/Utils/Statistics.hs view
@@ -12,7 +12,7 @@ import           Language.Fixpoint.Misc                (donePhase, Moods(..), applyNonNull) import           Language.Fixpoint.Types.Config import           Language.Fixpoint.Types.PrettyPrint-import           Language.Fixpoint.Partition           (partition')+import           Language.Fixpoint.Graph (partition') import qualified Language.Fixpoint.Types        as F import qualified Data.HashMap.Strict            as M import           Data.List (sort,group)@@ -20,7 +20,7 @@  statistics :: Config -> F.FInfo a -> IO (F.Result (Integer, a)) statistics _ fi = do-  let (_, fis) = partition' Nothing fi+  let fis = partition' Nothing fi   putStrLn $ render $ pprint $ partitionStats fis   donePhase Loud "Statistics"   return mempty@@ -38,10 +38,10 @@  data Stats = Stats { cSizes  :: [Float]                    , cFreq   :: [(Float, Int)]-                   , cTotal  :: Float-                   , cMean   :: Float-                   , cMax    :: Float-                   , cSpeed  :: Float+                   , cTotal  :: !Float+                   , cMean   :: !Float+                   , cMax    :: !Float+                   , cSpeed  :: !Float                    } deriving (Show, Generic)  instance NFData Stats
+ stack.yaml view
@@ -0,0 +1,12 @@+flags:+ liquid-fixpoint:+  devel: True+packages:+- '.'+extra-deps:+- dotgen-0.4.2+- fgl-visualize-0.1.0.1+- intern-0.9.1.4+- located-base-0.1.1.0++resolver: nightly-2016-05-21
+ tests/crash/num00.fq view
@@ -0,0 +1,29 @@+// This qualifier saves the day; solve constraints WITHOUT IT++qualif Zog(v:a) : (0 <= v)+qualif Bog(v:a) : (0 <= 1)+++bind 0 zog : {v : int | true}++constraint:+  env [0]+  lhs {v : alpha | (v = 10)}+  rhs {v : alpha | $k0}+  id 1 tag []++constraint:+  env [0]+  lhs {v : alpha | $k0}+  rhs {v : alpha | $k0}+  id 2 tag []++constraint:+  env [0]+  lhs {v : alpha | $k0}+  rhs {v : alpha | 0 <= v}+  id 3 tag []++wf:+  env [0]+  reft {v: alpha | $k0}
+ tests/crash/sort00.fq view
@@ -0,0 +1,12 @@+// for LH Issue 773++constant foo : (func(0, [int; int]))++bind 0 x     : {v: Str | true}++constraint:+  env [ 0 ]+  lhs {v : int | (foo x = 0)}+  rhs {v : int | (3 = 1 + 2) }+  id 1 tag []+
+ tests/crash/sort01.fq view
@@ -0,0 +1,13 @@+// for LH Issue 774++constant foo : (func(0, [int; int]))++bind 0 x     : {v: Str | true}+bind 1 y     : {v: Str | true}++constraint:+  env [ 0; 1 ]+  lhs {v : int | (foo x = foo y)}+  rhs {v : int | (3 = 1 + 2) }+  id 1 tag []+
+ tests/cut/test00-tx.fq view
@@ -0,0 +1,12 @@+++// This qualifier saves the day; solve constraints WITHOUT IT+// qualif Zog(v:a) : (10 <= v)++bind 0 a : {v:int | (v = 10 || v = 20) }++constraint:+  env [ 0 ]+  lhs {v : int | v = a}+  rhs {v : int | 10 <= v}+  id 3 
+ tests/cut/test00.fq view
@@ -0,0 +1,28 @@+++// This qualifier saves the day; solve constraints WITHOUT IT+// qualif Zog(v:a) : (10 <= v)++bind 0 a : {v: int | $k0}++constraint:+  env [ ]+  lhs {v : int | (v = 10)}+  rhs {v : int | $k0}+  id 1 ++constraint:+  env [ ]+  lhs {v : int | v = 20}+  rhs {v : int | $k0}+  id 2 ++constraint:+  env [ 0 ]+  lhs {v : int | v = a}+  rhs {v : int | 10 <= v}+  id 3 ++wf:+  env [ ]+  reft {v: int | $k0}
+ tests/cut/test00a-tx.fq view
@@ -0,0 +1,43 @@+// This qualifier saves the day; solve constraints WITHOUT IT+// qualif Zog(v:a) : (10 <= v)++constraint:+  env [z : {v : int | true}]+  lhs {v : int | (z=10) \/ (z=20)}+  rhs {v : int | 10 <= z}+  id 3 ++/*++Rewriting constraints as:++    id 1+    x:int, v:int |- x=10 /\ v=x => k0+    +    id 2+    y:int, v:int |- y=20 /\ v=y => k0++Projecting out all variables NOT in the WF of k0++    id 1+    v:int |- (exists x:int. x=10 /\ v=x) => k0+           +    id 2+    v:int |- (exists y:int. y=20 /\ v=y) => k0++Take the \/ of all constraints on k0++     k0 = (exists x:int. x=10 /\ v=x) \/ (exists y:int. y=20 /\ v=y)+     +     k0[z/v]+       = (\x. x=10 /\ v=x) \/ (\y. y=20 /\ v=y)[z/v]+         = (\x. x=10 /\ z=x) \/ (\y. y=20 /\ z=y)++So you get:++     env [2]+        lhs {v : int | (\x. x=10 /\ z=x) \/ (\y. y=20 /\ z=y)}+     rhs {v : int | 10 <= z}+     id 3 ++*/
+ tests/cut/test00a.fq view
@@ -0,0 +1,29 @@+// This qualifier saves the day; solve constraints WITHOUT IT+// qualif Zog(v:a) : (10 <= v)++bind 0 x : {v : int | true}+bind 1 y : {v : int | true}+bind 2 z : {v : int | true}++constraint:+  env [0]+  lhs {v : int | (x = 10)}+  rhs {v : int | $k0[v:=x]}+  id 1 ++constraint:+  env [1]+  lhs {v : int | y = 20}+  rhs {v : int | $k0[v:=y]}+  id 2 ++constraint:+  env [2]+  lhs {v : int | $k0[v:=z]}+  rhs {v : int | 10 <= z}+  id 3 ++wf:+  env [ ]+  reft {v: int | $k0}+
+ tests/cut/test1-tx.fq view
@@ -0,0 +1,43 @@++// This qualifier saves the day; solve constraints WITHOUT IT+// qualif Zog(v:a) : (10 <= v)++constraint:+  env [a : {v : int | (exists x:int. x=10 /\ v=x) +                   \/ (exists y:int. y=20 /\ v=y) }]+  lhs {v : int | v = a  }+  rhs {v : int | 10 <= v}+  id 3 ++/*++Rewriting constraints as:++    id 1+    x:int, v:int |- (v=10)[x/v] /\ (v=x) => k0+    x:int, v:int |- (x=10) /\ (v=x) => k0++    id 2+    y:int, v:int |- (v=20)[y/v] /\ (v=y) => k0+    y:int, v:int |- (y=20) /\ (v=y) => k0++Projecting out all variables NOT in the WF of k0++    id 1+    v:int |- (exists x:int. x=10 /\ v=x) => k0++    id 2+    v:int |- (exists y:int. y=20 /\ v=y) => k0++Take the \/ of all constraints on k0++    k0 = (exists x:int. x=10 /\ v=x) \/ (exists y:int. y=20 /\ v=y)+     +So you get:++    env [a : {v : int | (exists x:int. x=10 /\ v=x) \/ (exists y:int. y=20 /\ v=y) }]+      lhs {v : int | v = a  }+    rhs {v : int | 10 <= v}+    id 3++*/
+ tests/cut/test1.fq view
@@ -0,0 +1,29 @@++// This qualifier saves the day; solve constraints WITHOUT IT+// qualif Zog(v:a) : (10 <= v)++bind 0 x : {v : int | v = 10}+bind 1 y : {v : int | v = 20}+bind 2 a : {v : int | $k0    }+      +constraint:+  env [0]+  lhs {v : int | v = x}+  rhs {v : int | $k0   }+  id 1 ++constraint:+  env [1]+  lhs {v : int | v = y}+  rhs {v : int | $k0   }+  id 2 ++constraint:+  env [2]+  lhs {v : int | v = a  }+  rhs {v : int | 10 <= v}+  id 3 ++wf:+  env [ ]+  reft {v : int | $k0}
+ tests/cut/test2-tx.fq view
@@ -0,0 +1,112 @@++// This qualifier saves the day; solve constraints WITHOUT IT+// qualif Zog(v:a): (10 <= v)++// But you may use this one+qualif Pog(v:a): (0 <= v)+++++/* ++-- Version 1 (eliminate k1) --++Rewriting constraints as:++    id 0+    v:int |- (v=0) => k1++    id 3+    v:int |- k0 => k1++Projecting out all variables NOT in the WF of k1++    N/A++Take the \/ of all constraints on k1++    k1 = (v=0) \/ k0++So you get:++  bind 0 x: {v: int | v = 10      }+  bind 1 a: {v: int | (v=0) \/ k0 }+  bind 2 y: {v: int | v = 20      }+  bind 3 b: {v: int | (v=0) \/ k0 }+  bind 4 c: {v: int | k0          }++  constraint:+    env [ 0; 1]+      lhs {v : int | v = x + a}+    rhs {v : int | k0}+    id 1 ++  constraint:+    env [2; 3]+      lhs {v : int | v = y + b}+    rhs {v : int | k0}+    id 2 ++  constraint:+    env [4]+      lhs {v : int | v = c  }+    rhs {v : int | 10 <= v}+    id 4 ++  wf:+    env [ ]+    reft {v: int | k1}+++++-- Version 2 (eliminate k0) --++Rewriting constraints as:++    id 1+    x:int, a:int, v:int |- (v=10)[x/v] /\ k1[a/v] /\ (v=x+a) => k0+    x:int, a:int, v:int |- (x=10) /\ k1[a/v] /\ (v=x+a) => k0++    id 2+    y:int, b:int, v:int |- (v=20)[y/v] /\ k1[b/v] /\ (v=y+b) => k0+    y:int, b:int, v:int |- (y=20) /\ k1[b/v] /\ (v=y+b) => k0++Projecting out all variables NOT in the WF of k0++    id 1+    v:int |- (exists x:int a:int. (x=10) /\ k1[a/v] /\ (v=x+a)) => k0+    +    id 2+    v:int |- (exists y:int b:int. (y=20) /\ k1[b/v] /\ (v=y+b)) => k0++Take the \/ of all constraints on k0++    k0 = (exists x:int a:int. (x=10) /\ k1[a/v] /\ (v=x+a))+      \/ (exists y:int b:int. (y=20) /\ k1[b/v] /\ (v=y+b))++So you get:++  bind 4 c: {v: int | (exists x:int a:int. (x=10) /\ k1[a/v] /\ (v=x+a))+                   \/ (exists y:int b:int. (y=20) /\ k1[b/v] /\ (v=y+b))    }++  constraint:+    env [ ]+      lhs {v : int | v = 0}+    rhs {v : int | k1 }+    id 0 +++  constraint:+    env [ ]+      lhs {v : int | (exists x:int a:int. (x=10) /\ k1[a/v] /\ (v=x+a))+                \/ (exists y:int b:int. (y=20) /\ k1[b/v] /\ (v=y+b))}+    rhs {v : int | k1}+    id 3++  constraint:+    env [4]+      lhs {v : int | v = c  }+    rhs {v : int | 10 <= v}+    id 4 
+ tests/cut/test2.fq view
@@ -0,0 +1,51 @@++// This qualifier saves the day; solve constraints WITHOUT IT+// qualif Zog(v:a): (10 <= v)++// But you may use this one+qualif Pog(v:a): (0 <= v)++bind 0 x: {v: int | v = 10}+bind 1 a: {v: int | $k1    }+bind 2 y: {v: int | v = 20}+bind 3 b: {v: int | $k1    }+bind 4 c: {v: int | $k0    }++constraint:+  env [ ]+  lhs {v : int | v = 0}+  rhs {v : int | $k1 }+  id 0 +++constraint:+  env [ 0; 1]+  lhs {v : int | v = x + a}+  rhs {v : int | $k0}+  id 1 ++constraint:+  env [2; 3]+  lhs {v : int | v = y + b}+  rhs {v : int | $k0}+  id 2 ++constraint:+  env [ ]+  lhs {v : int | $k0}+  rhs {v : int | $k1}+  id 3++constraint:+  env [4]+  lhs {v : int | v = c  }+  rhs {v : int | 10 <= v}+  id 4 ++wf:+  env [ ]+  reft {v: int | $k0}++wf:+  env [ ]+  reft {v: int | $k1}
+ tests/elim/div00.fq view
@@ -0,0 +1,23 @@++// --eliminate should be able to solve this WITHOUT the qualifier+// qualif Zog(v:int) : (v /= 0)++bind 0 n : {v: int | true }+bind 1 m : {v: int | true }+bind 2 z : {v: int | $k0[n := m] }++constraint:+  env [ ]+  lhs {v : int | v = 12 }+  rhs {v : int | $k0    }+  id 1 tag []++constraint:+  env [ 1; 2 ]+  lhs {v : int | v  = z}+  rhs {v : int | v /= 0}+  id 2 tag []++wf:+  env [ 0 ]+  reft {v: int | $k0 }
+ tests/elim/elim00.fq view
@@ -0,0 +1,1494 @@+fixpoint "--defunct"++// qualif Cmp(v : @(0), x : @(0)): ((v > x)) // "tests/todo/elim00.hs.fq" (line 1, column 8)+// qualif Cmp(v : @(0), x : @(0)): ((v = x)) // "tests/todo/elim00.hs.fq" (line 2, column 8)+++constant Control.Exception.Base.irrefutPatError##09 : (func(1, [int;+                                                                @(0)]))+constant GHC.Base..##r2C : (func(3, [func(0, [@(0); @(1)]);+                                     func(0, [@(2); @(0)]);+                                     @(2);+                                     @(1)]))+constant runFun : (func(2, [(Arrow  @(0)  @(1)); @(0); @(1)]))+constant GHC.Tuple.$40$$44$$44$$41$$35$$35$76 : (func(3, [@(0);+                                                          @(1);+                                                          @(2);+                                                          (Tuple  @(0)  @(1)  @(2))]))+constant GHC.Real.D$58$Integral$35$$35$rWH : (func(1, [func(0, [@(0);+                                                                @(0);+                                                                @(0)]);+                                                       func(0, [@(0); @(0); @(0)]);+                                                       func(0, [@(0); @(0); @(0)]);+                                                       func(0, [@(0); @(0); @(0)]);+                                                       func(0, [@(0); @(0); (Tuple  @(0)  @(0))]);+                                                       func(0, [@(0); @(0); (Tuple  @(0)  @(0))]);+                                                       func(0, [@(0); int]);+                                                       (GHC.Real.Integral  @(0))]))+constant addrLen : (func(0, [int; int]))+constant papp5 : (func(10, [(Pred  @(0)  @(1)  @(2)  @(3)  @(4));+                            @(5);+                            @(6);+                            @(7);+                            @(8);+                            @(9);+                            bool]))+constant xsListSelector : (func(1, [[@(0)]; [@(0)]]))+constant x_Tuple21 : (func(2, [(Tuple  @(0)  @(1)); @(0)]))+constant x_Tuple65 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(4)]))+constant Elim.foo##rlD : (func(0, [Elim.Foo; Elim.Foo]))+constant x_Tuple55 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(4)]))+constant GHC.Integer.Type.smallInteger##0Z : (func(0, [int; int]))+constant x_Tuple33 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(2)]))+constant x_Tuple77 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(6)]))+constant GHC.Base.Just##r1e : (func(1, [@(0);+                                        (GHC.Base.Maybe  @(0))]))+constant Elim.xx##rlB : (func(0, [Elim.Foo; int]))+constant papp3 : (func(6, [(Pred  @(0)  @(1)  @(2));+                           @(3);+                           @(4);+                           @(5);+                           bool]))+constant GHC.Prim.$43$$35$$35$$35$98 : (func(0, [int; int; int]))+constant x_Tuple63 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(2)]))+constant x_Tuple41 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(0)]))+constant GHC.Types.LT##6S : (GHC.Types.Ordering)+constant GHC.Prim.$60$$35$$35$$35$9q : (func(0, [int; int; int]))+constant papp4 : (func(8, [(Pred  @(0)  @(1)  @(2)  @(3));+                           @(4);+                           @(5);+                           @(6);+                           @(7);+                           bool]))+constant Elim.PP##rlx : (func(2, [@(0);+                                  @(1);+                                  (Elim.Pair  @(0)  @(1))]))+constant x_Tuple64 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(3)]))+constant GHC.Types.GT##6W : (GHC.Types.Ordering)+constant GHC.Prim.$45$$35$$35$$35$99 : (func(0, [int; int; int]))+constant GHC.Types.$58$$35$$35$64 : (func(1, [@(0);+                                              [@(0)];+                                              [@(0)]]))+constant autolen : (func(1, [@(0); int]))+constant GHC.Types.I###6c : (func(0, [int; int]))+constant x_Tuple52 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(1)]))+constant xx : (func(0, [Elim.Foo; int]))+constant null : (func(1, [[@(0)]; bool]))+constant GHC.Num.$43$$35$$35$rt : (func(1, [@(0); @(0); @(0)]))+constant GHC.Tuple.$40$$44$$44$$44$$44$$41$$35$$35$7a : (func(5, [@(0);+                                                                  @(1);+                                                                  @(2);+                                                                  @(3);+                                                                  @(4);+                                                                  (Tuple  @(0)  @(1)  @(2)  @(3)  @(4))]))+constant papp2 : (func(4, [(Pred  @(0)  @(1)); @(2); @(3); bool]))+constant x_Tuple62 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(1)]))+constant GHC.Tuple.$40$$44$$41$$35$$35$74 : (func(2, [@(0);+                                                      @(1);+                                                      (Tuple  @(0)  @(1))]))+constant Elim.yy##rlC : (func(0, [Elim.Foo; int]))+constant fromJust : (func(1, [(GHC.Base.Maybe  @(0)); @(0)]))+constant papp7 : (func(14, [(Pred  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                            @(7);+                            @(8);+                            @(9);+                            @(10);+                            @(11);+                            @(12);+                            @(13);+                            bool]))+constant x_Tuple53 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(2)]))+constant x_Tuple71 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(0)]))+constant GHC.Prim.$62$$35$$35$$35$9m : (func(0, [int; int; int]))+constant x_Tuple74 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(3)]))+constant Elim.Emp##rly : (func(2, [(Elim.Pair  @(0)  @(1))]))+constant len : (func(2, [(@(0)  @(1)); int]))+constant GHC.Tuple.$40$$44$$44$$44$$44$$44$$44$$41$$35$$35$7e : (func(7, [@(0);+                                                                          @(1);+                                                                          @(2);+                                                                          @(3);+                                                                          @(4);+                                                                          @(5);+                                                                          @(6);+                                                                          (Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6))]))+constant papp6 : (func(12, [(Pred  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                            @(6);+                            @(7);+                            @(8);+                            @(9);+                            @(10);+                            @(11);+                            bool]))+constant x_Tuple22 : (func(2, [(Tuple  @(0)  @(1)); @(1)]))+constant Data.Foldable.length##r1s : (func(2, [(@(0)  @(0)); int]))+constant x_Tuple66 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(5)]))+constant x_Tuple44 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(3)]))+constant xListSelector : (func(1, [[@(0)]; @(0)]))+constant strLen : (func(0, [int; int]))+constant x_Tuple72 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(1)]))+constant GHC.Tuple.$40$$44$$44$$44$$41$$35$$35$78 : (func(4, [@(0);+                                                              @(1);+                                                              @(2);+                                                              @(3);+                                                              (Tuple  @(0)  @(1)  @(2)  @(3))]))+constant isJust : (func(1, [(GHC.Base.Maybe  @(0)); bool]))+constant GHC.Prim.$61$$61$$35$$35$$35$9o : (func(0, [int;+                                                     int;+                                                     int]))+constant Elim.Foo##rlA : (func(0, [int; int; Elim.Foo]))+constant Prop : (func(0, [GHC.Types.Bool; bool]))+constant x_Tuple31 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(0)]))+constant x_Tuple75 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(4)]))+constant papp1 : (func(2, [(Pred  @(0)); @(1); bool]))+constant yy : (func(0, [Elim.Foo; int]))+constant x_Tuple61 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(0)]))+constant GHC.Prim.$62$$61$$35$$35$$35$9n : (func(0, [int;+                                                     int;+                                                     int]))+constant lit$36$tests$47$pos$47$elim00.hs$58$14$58$5$45$30$124$PP$32$wink$32$cow : (Str)+constant x_Tuple43 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(2)]))+constant GHC.Types.EQ##6U : (GHC.Types.Ordering)+constant x_Tuple51 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(0)]))+constant GHC.Base.Nothing##r1d : (func(1, [(GHC.Base.Maybe  @(0))]))+constant GHC.Num.$45$$35$$35$02B : (func(1, [@(0); @(0); @(0)]))+constant GHC.Num.$42$$35$$35$ru : (func(1, [@(0); @(0); @(0)]))+constant x_Tuple73 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(2)]))+constant GHC.Types.$91$$93$$35$$35$6m : (func(1, [[@(0)]]))+constant x_Tuple54 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(3)]))+constant cmp : (func(0, [GHC.Types.Ordering; GHC.Types.Ordering]))+constant x_Tuple32 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(1)]))+constant x_Tuple76 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(5)]))+constant GHC.Prim.$60$$61$$35$$35$$35$9r : (func(0, [int;+                                                     int;+                                                     int]))+constant GHC.Real.D$58$Fractional$35$$35$rVU : (func(1, [func(0, [@(0);+                                                                  @(0);+                                                                  @(0)]);+                                                         func(0, [@(0); @(0)]);+                                                         func(0, [(GHC.Real.Ratio  int); @(0)]);+                                                         (GHC.Real.Fractional  @(0))]))+constant fst : (func(2, [(Tuple  @(0)  @(1)); @(0)]))+constant snd : (func(2, [(Tuple  @(0)  @(1)); @(1)]))+constant GHC.Tuple.$40$$44$$44$$44$$44$$44$$41$$35$$35$7c : (func(6, [@(0);+                                                                      @(1);+                                                                      @(2);+                                                                      @(3);+                                                                      @(4);+                                                                      @(5);+                                                                      (Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5))]))+constant x_Tuple42 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(1)]))+constant GHC.Prim.void###0l : (GHC.Prim.Void#)+++bind 0 GHC.Prim.void###0l : {VV##180 : GHC.Prim.Void# | []}+bind 1 Elim.Emp##rly : {VV : func(2, [(Elim.Pair  @(0)  @(1))]) | []}+bind 2 GHC.Types.EQ##6U : {VV##185 : GHC.Types.Ordering | [(VV##185 = GHC.Types.EQ##6U)]}+bind 3 GHC.Types.LT##6S : {VV##186 : GHC.Types.Ordering | [(VV##186 = GHC.Types.LT##6S)]}+bind 4 GHC.Types.GT##6W : {VV##187 : GHC.Types.Ordering | [(VV##187 = GHC.Types.GT##6W)]}+bind 5 Elim.Emp##rly : {VV : func(2, [(Elim.Pair  @(0)  @(1))]) | []}+bind 6 GHC.Types.$91$$93$$35$$35$6m : {VV : func(1, [[@(0)]]) | []}+bind 7 GHC.Types.GT##6W : {VV##213 : GHC.Types.Ordering | [((cmp VV##213) = GHC.Types.GT##6W)]}+bind 8 GHC.Types.LT##6S : {VV##214 : GHC.Types.Ordering | [((cmp VV##214) = GHC.Types.LT##6S)]}+bind 9 GHC.Types.EQ##6U : {VV##215 : GHC.Types.Ordering | [((cmp VV##215) = GHC.Types.EQ##6U)]}+bind 10 GHC.Base.Nothing##r1d : {VV : func(1, [(GHC.Base.Maybe  @(0))]) | []}+bind 11 ds_dxd : {VV##222 : Elim.Foo | []}+bind 12 lq_anf$##dxr : {lq_tmp$x##223 : Elim.Foo | [(lq_tmp$x##223 = ds_dxd)]}+bind 13 lq_anf$##dxr : {lq_tmp$x##225 : Elim.Foo | [(lq_tmp$x##225 = ds_dxd)]}+bind 14 xig##awy : {lq_tmp$x##233 : int | []}+bind 15 yog##awz : {lq_tmp$x##234 : int | [(xig##awy < lq_tmp$x##234)]}+bind 16 lq_anf$##dxr : {lq_tmp$x##225 : Elim.Foo | [(lq_tmp$x##225 = ds_dxd);+                                                    ((yy lq_tmp$x##225) = yog##awz);+                                                    ((xx lq_tmp$x##225) = xig##awy);+                                                    (lq_tmp$x##225 = (Elim.Foo##rlA xig##awy yog##awz));+                                                    ((yy lq_tmp$x##225) = yog##awz);+                                                    ((xx lq_tmp$x##225) = xig##awy)]}+bind 17 lq_anf$##dxs : {lq_tmp$x##242 : (Elim.Pair  int  int) | [(lq_tmp$x##242 = (Elim.PP##rlx xig##awy yog##awz))]}+bind 18 lq_anf$##dxt : {lq_tmp$x##273 : (Elim.Pair  int  int) | [(lq_tmp$x##273 = lq_anf$##dxs)]}+bind 19 lq_anf$##dxt : {lq_tmp$x##277 : (Elim.Pair  int  int) | [(lq_tmp$x##277 = lq_anf$##dxs)]}+bind 20 wink##ax3 : {lq_tmp$x##275 : int | [$k_##248[lq_tmp$x##277:=lq_anf$##dxt][VV##247:=lq_tmp$x##275][lq_tmp$x##242:=lq_anf$##dxt][lq_tmp$x##271:=lq_tmp$x##275][lq_tmp$x##273:=lq_anf$##dxt][lq_tmp$x##245:=xig##awy][lq_tmp$x##246:=yog##awz][lq_tmp$x##250:=lq_tmp$x##275]]}+bind 21 cow##ax4 : {lq_tmp$x##276 : int | [$k_##252[lq_tmp$x##277:=lq_anf$##dxt][lq_tmp$x##281:=wink##ax3][VV##251:=lq_tmp$x##276][lq_tmp$x##242:=lq_anf$##dxt][lq_tmp$x##254:=lq_tmp$x##276][lq_tmp$x##273:=lq_anf$##dxt][lq_tmp$x##245:=xig##awy][lq_tmp$x##246:=yog##awz][lq_tmp$x##272:=lq_tmp$x##276]]}+bind 22 lq_anf$##dxt : {lq_tmp$x##277 : (Elim.Pair  int  int) | [(lq_tmp$x##277 = lq_anf$##dxs);+                                                                 (lq_tmp$x##277 = (Elim.PP##rlx wink##ax3 cow##ax4));+                                                                 (lq_tmp$x##277 = (Elim.PP##rlx wink##ax3 cow##ax4));+                                                                 (lq_tmp$x##277 = (Elim.PP##rlx wink##ax3 cow##ax4))]}+bind 23 lq_tmp$x##307 : {VV##308 : int | []}+bind 24 lq_anf$##dxt : {lq_tmp$x##313 : (Elim.Pair  int  int) | [(lq_tmp$x##313 = lq_anf$##dxs)]}+bind 25 lq_anf$##dxt : {lq_tmp$x##313 : (Elim.Pair  int  int) | [(lq_tmp$x##313 = lq_anf$##dxs);+                                                                 (lq_tmp$x##313 = Elim.Emp##rly);+                                                                 (lq_tmp$x##313 = Elim.Emp##rly);+                                                                 (lq_tmp$x##313 = Elim.Emp##rly)]}+bind 26 ds_dxg : {VV##318 : GHC.Prim.Void# | [$k_##319]}+bind 27 lq_anf$##dxu : {lq_tmp$x##335 : int | [(lq_tmp$x##335 ~~ lit$36$tests$47$pos$47$elim00.hs$58$14$58$5$45$30$124$PP$32$wink$32$cow);+                                               ((strLen lq_tmp$x##335) = 39)]}+bind 28 ds_dxh : {VV##268 : (Tuple  int  int) | [$k_##269]}+bind 29 lq_anf$##dxw : {lq_tmp$x##368 : (Tuple  int  int) | [(lq_tmp$x##368 = ds_dxh)]}+bind 30 lq_anf$##dxw : {lq_tmp$x##374 : (Tuple  int  int) | [(lq_tmp$x##374 = ds_dxh)]}+bind 31 wink##ax3 : {lq_tmp$x##370 : int | [$k_##259[lq_tmp$x##368:=lq_anf$##dxw][VV##268:=lq_anf$##dxw][lq_tmp$x##364:=lq_tmp$x##370][VV##258:=lq_tmp$x##370][lq_tmp$x##374:=lq_anf$##dxw]]}+bind 32 cow##Xxd : {lq_tmp$x##371 : int | [$k_##262[lq_tmp$x##368:=lq_anf$##dxw][VV##268:=lq_anf$##dxw][VV##261:=lq_tmp$x##371][lq_tmp$x##365:=lq_tmp$x##371][lq_tmp$x##379:=wink##ax3][lq_tmp$x##374:=lq_anf$##dxw];+                                           $k_##266[lq_tmp$x##368:=lq_anf$##dxw][lq_tmp$x##373:=lq_tmp$x##371][VV##265:=lq_tmp$x##371][lq_tmp$x##264:=wink##ax3][lq_tmp$x##367:=lq_tmp$x##371][VV##268:=lq_anf$##dxw][lq_tmp$x##372:=wink##ax3][lq_tmp$x##366:=wink##ax3][lq_tmp$x##379:=wink##ax3][lq_tmp$x##374:=lq_anf$##dxw]]}+bind 33 lq_anf$##dxw : {lq_tmp$x##374 : (Tuple  int  int) | [(lq_tmp$x##374 = ds_dxh);+                                                             ((snd lq_tmp$x##374) = cow##Xxd);+                                                             ((fst lq_tmp$x##374) = wink##ax3);+                                                             ((x_Tuple22 lq_tmp$x##374) = cow##Xxd);+                                                             ((x_Tuple21 lq_tmp$x##374) = wink##ax3);+                                                             (lq_tmp$x##374 = (GHC.Tuple.$40$$44$$41$$35$$35$74 wink##ax3 cow##Xxd));+                                                             ((snd lq_tmp$x##374) = cow##Xxd);+                                                             ((fst lq_tmp$x##374) = wink##ax3);+                                                             ((x_Tuple22 lq_tmp$x##374) = cow##Xxd);+                                                             ((x_Tuple21 lq_tmp$x##374) = wink##ax3)]}+bind 34 wink##ax3 : {VV##361 : int | [$k_##362]}+// bind 45 wink##ax3 : {lq_tmp$x##452 : int | [$k_##428[lq_tmp$x##425:=wink##ax3][lq_tmp$x##456:=lq_anf$##dxy][VV##427:=lq_tmp$x##452][lq_tmp$x##426:=cow##ax4][lq_tmp$x##450:=lq_anf$##dxy][lq_tmp$x##430:=lq_tmp$x##452][lq_tmp$x##446:=lq_tmp$x##452][lq_tmp$x##422:=lq_anf$##dxy]]}++bind 35 lq_anf$##dxv : {lq_tmp$x##398 : (Tuple  int  int) | [(lq_tmp$x##398 = ds_dxh)]}+bind 36 lq_anf$##dxv : {lq_tmp$x##404 : (Tuple  int  int) | [(lq_tmp$x##404 = ds_dxh)]}+bind 37 wink##ax3 : {lq_tmp$x##400 : int | [$k_##259[VV##268:=lq_anf$##dxv][lq_tmp$x##394:=lq_tmp$x##400][VV##258:=lq_tmp$x##400][lq_tmp$x##398:=lq_anf$##dxv][lq_tmp$x##404:=lq_anf$##dxv]]}+bind 38 cow##ax4 : {lq_tmp$x##401 : int | [$k_##262[VV##268:=lq_anf$##dxv][VV##261:=lq_tmp$x##401][lq_tmp$x##409:=wink##ax3][lq_tmp$x##398:=lq_anf$##dxv][lq_tmp$x##395:=lq_tmp$x##401][lq_tmp$x##404:=lq_anf$##dxv];+                                           $k_##266[lq_tmp$x##396:=wink##ax3][VV##265:=lq_tmp$x##401][lq_tmp$x##264:=wink##ax3][VV##268:=lq_anf$##dxv][lq_tmp$x##397:=lq_tmp$x##401][lq_tmp$x##409:=wink##ax3][lq_tmp$x##403:=lq_tmp$x##401][lq_tmp$x##398:=lq_anf$##dxv][lq_tmp$x##402:=wink##ax3][lq_tmp$x##404:=lq_anf$##dxv]]}+bind 39 lq_anf$##dxv : {lq_tmp$x##404 : (Tuple  int  int) | [(lq_tmp$x##404 = ds_dxh);+                                                             ((snd lq_tmp$x##404) = cow##ax4);+                                                             ((fst lq_tmp$x##404) = wink##ax3);+                                                             ((x_Tuple22 lq_tmp$x##404) = cow##ax4);+                                                             ((x_Tuple21 lq_tmp$x##404) = wink##ax3);+                                                             (lq_tmp$x##404 = (GHC.Tuple.$40$$44$$41$$35$$35$74 wink##ax3 cow##ax4));+                                                             ((snd lq_tmp$x##404) = cow##ax4);+                                                             ((fst lq_tmp$x##404) = wink##ax3);+                                                             ((x_Tuple22 lq_tmp$x##404) = cow##ax4);+                                                             ((x_Tuple21 lq_tmp$x##404) = wink##ax3)]}+bind 40 cow##ax4 : {VV##391 : int | [$k_##392]}+bind 41 lq_tmp$x##438 : {VV##439 : int | []}+bind 42 ds_dxi : {lq_tmp$x##422 : (Tuple  int  int) | [((snd lq_tmp$x##422) = cow##ax4);+                                                       ((fst lq_tmp$x##422) = wink##ax3);+                                                       ((x_Tuple22 lq_tmp$x##422) = cow##ax4);+                                                       ((x_Tuple21 lq_tmp$x##422) = wink##ax3)]}+bind 43 lq_anf$##dxy : {lq_tmp$x##450 : (Tuple  int  int) | [(lq_tmp$x##450 = ds_dxi)]}+bind 44 lq_anf$##dxy : {lq_tmp$x##456 : (Tuple  int  int) | [(lq_tmp$x##456 = ds_dxi)]}+bind 45 wink##ax3 : {lq_tmp$x##452 : int | [$k_##428[lq_tmp$x##425:=wink##ax3][lq_tmp$x##456:=lq_anf$##dxy][VV##427:=lq_tmp$x##452][lq_tmp$x##426:=cow##ax4][lq_tmp$x##450:=lq_anf$##dxy][lq_tmp$x##430:=lq_tmp$x##452][lq_tmp$x##446:=lq_tmp$x##452][lq_tmp$x##422:=lq_anf$##dxy]]}+bind 46 cow##ax4 : {lq_tmp$x##453 : int | [$k_##432[lq_tmp$x##425:=wink##ax3][lq_tmp$x##456:=lq_anf$##dxy][lq_tmp$x##426:=cow##ax4][VV##431:=lq_tmp$x##453][lq_tmp$x##450:=lq_anf$##dxy][lq_tmp$x##447:=lq_tmp$x##453][lq_tmp$x##461:=wink##ax3][lq_tmp$x##422:=lq_anf$##dxy][lq_tmp$x##434:=lq_tmp$x##453];+                                           $k_##436[lq_tmp$x##425:=wink##ax3][lq_tmp$x##456:=lq_anf$##dxy][lq_tmp$x##426:=cow##ax4][lq_tmp$x##455:=lq_tmp$x##453][lq_tmp$x##450:=lq_anf$##dxy][lq_tmp$x##461:=wink##ax3][lq_tmp$x##438:=wink##ax3][lq_tmp$x##421:=wink##ax3][lq_tmp$x##422:=lq_anf$##dxy][lq_tmp$x##434:=lq_tmp$x##453][lq_tmp$x##448:=wink##ax3][lq_tmp$x##449:=lq_tmp$x##453][VV##435:=lq_tmp$x##453][lq_tmp$x##454:=wink##ax3]]}+bind 47 lq_anf$##dxy : {lq_tmp$x##456 : (Tuple  int  int) | [(lq_tmp$x##456 = ds_dxi);+                                                             ((snd lq_tmp$x##456) = cow##ax4);+                                                             ((fst lq_tmp$x##456) = wink##ax3);+                                                             ((x_Tuple22 lq_tmp$x##456) = cow##ax4);+                                                             ((x_Tuple21 lq_tmp$x##456) = wink##ax3);+                                                             (lq_tmp$x##456 = (GHC.Tuple.$40$$44$$41$$35$$35$74 wink##ax3 cow##ax4));+                                                             ((snd lq_tmp$x##456) = cow##ax4);+                                                             ((fst lq_tmp$x##456) = wink##ax3);+                                                             ((x_Tuple22 lq_tmp$x##456) = cow##ax4);+                                                             ((x_Tuple21 lq_tmp$x##456) = wink##ax3)]}+bind 48 wink##awA : {VV##443 : int | [$k_##444]}++bind 49 lq_anf$##dxx : {lq_tmp$x##480 : (Tuple  int  int) | [(lq_tmp$x##480 = ds_dxi)]}+bind 50 lq_anf$##dxx : {lq_tmp$x##486 : (Tuple  int  int) | [(lq_tmp$x##486 = ds_dxi)]}+bind 51 wink##ax3 : {lq_tmp$x##482 : int | [$k_##428[lq_tmp$x##425:=wink##ax3][VV##427:=lq_tmp$x##482][lq_tmp$x##426:=cow##ax4][lq_tmp$x##476:=lq_tmp$x##482][lq_tmp$x##430:=lq_tmp$x##482][lq_tmp$x##480:=lq_anf$##dxx][lq_tmp$x##422:=lq_anf$##dxx][lq_tmp$x##486:=lq_anf$##dxx]]}+bind 52 cow##ax4 : {lq_tmp$x##483 : int | [$k_##432[lq_tmp$x##425:=wink##ax3][lq_tmp$x##426:=cow##ax4][VV##431:=lq_tmp$x##483][lq_tmp$x##491:=wink##ax3][lq_tmp$x##480:=lq_anf$##dxx][lq_tmp$x##477:=lq_tmp$x##483][lq_tmp$x##422:=lq_anf$##dxx][lq_tmp$x##434:=lq_tmp$x##483][lq_tmp$x##486:=lq_anf$##dxx];+                                           $k_##436[lq_tmp$x##425:=wink##ax3][lq_tmp$x##426:=cow##ax4][lq_tmp$x##491:=wink##ax3][lq_tmp$x##480:=lq_anf$##dxx][lq_tmp$x##479:=lq_tmp$x##483][lq_tmp$x##485:=lq_tmp$x##483][lq_tmp$x##438:=wink##ax3][lq_tmp$x##421:=wink##ax3][lq_tmp$x##422:=lq_anf$##dxx][lq_tmp$x##434:=lq_tmp$x##483][lq_tmp$x##484:=wink##ax3][lq_tmp$x##478:=wink##ax3][lq_tmp$x##486:=lq_anf$##dxx][VV##435:=lq_tmp$x##483]]}+bind 53 lq_anf$##dxx : {lq_tmp$x##486 : (Tuple  int  int) | [(lq_tmp$x##486 = ds_dxi);+                                                             ((snd lq_tmp$x##486) = cow##ax4);+                                                             ((fst lq_tmp$x##486) = wink##ax3);+                                                             ((x_Tuple22 lq_tmp$x##486) = cow##ax4);+                                                             ((x_Tuple21 lq_tmp$x##486) = wink##ax3);+                                                             (lq_tmp$x##486 = (GHC.Tuple.$40$$44$$41$$35$$35$74 wink##ax3 cow##ax4));+                                                             ((snd lq_tmp$x##486) = cow##ax4);+                                                             ((fst lq_tmp$x##486) = wink##ax3);+                                                             ((x_Tuple22 lq_tmp$x##486) = cow##ax4);+                                                             ((x_Tuple21 lq_tmp$x##486) = wink##ax3)]}+bind 54 cow##awB : {VV##473 : int | [$k_##474]}+bind 55 ds_dxo : {VV##514 : Elim.Foo | []}+bind 56 lq_anf$##dxz : {lq_tmp$x##515 : Elim.Foo | [(lq_tmp$x##515 = ds_dxo)]}+bind 57 lq_anf$##dxz : {lq_tmp$x##517 : Elim.Foo | [(lq_tmp$x##517 = ds_dxo)]}+bind 58 ds_dxp : {lq_tmp$x##525 : int | []}+bind 59 ds_dxq : {lq_tmp$x##526 : int | [(ds_dxp < lq_tmp$x##526)]}+bind 60 lq_anf$##dxz : {lq_tmp$x##517 : Elim.Foo | [(lq_tmp$x##517 = ds_dxo);+                                                    ((yy lq_tmp$x##517) = ds_dxq);+                                                    ((xx lq_tmp$x##517) = ds_dxp);+                                                    (lq_tmp$x##517 = (Elim.Foo##rlA ds_dxp ds_dxq));+                                                    ((yy lq_tmp$x##517) = ds_dxq);+                                                    ((xx lq_tmp$x##517) = ds_dxp)]}+bind 61 ds_dxl : {VV##537 : Elim.Foo | []}+bind 62 lq_anf$##dxA : {lq_tmp$x##538 : Elim.Foo | [(lq_tmp$x##538 = ds_dxl)]}+bind 63 lq_anf$##dxA : {lq_tmp$x##540 : Elim.Foo | [(lq_tmp$x##540 = ds_dxl)]}+bind 64 ds_dxm : {lq_tmp$x##548 : int | []}+bind 65 ds_dxn : {lq_tmp$x##549 : int | [(ds_dxm < lq_tmp$x##549)]}+bind 66 lq_anf$##dxA : {lq_tmp$x##540 : Elim.Foo | [(lq_tmp$x##540 = ds_dxl);+                                                    ((yy lq_tmp$x##540) = ds_dxn);+                                                    ((xx lq_tmp$x##540) = ds_dxm);+                                                    (lq_tmp$x##540 = (Elim.Foo##rlA ds_dxm ds_dxn));+                                                    ((yy lq_tmp$x##540) = ds_dxn);+                                                    ((xx lq_tmp$x##540) = ds_dxm)]}+bind 67 VV##559 : {VV##559 : int | [(VV##559 = ds_dxm)]}+bind 68 VV##561 : {VV##561 : int | [(VV##561 = ds_dxq)]}+bind 69 VV##563 : {VV##563 : Elim.Foo | [((yy VV##563) = cow##awB);+                                         ((xx VV##563) = wink##awA)]}+bind 70 VV##565 : {VV##565 : int | [(VV##565 = cow##awB)]}+bind 71 VV##567 : {VV##567 : int | [(VV##567 = wink##awA)]}+bind 72 VV##569 : {VV##569 : int | [(VV##569 = cow##ax4)]}+bind 73 VV##571 : {VV##571 : int | [(VV##571 = wink##ax3)]}+bind 74 VV##573 : {VV##573 : int | [(VV##573 = cow##ax4)]}+bind 75 VV##575 : {VV##575 : int | [(VV##575 = wink##ax3)]}+bind 76 VV##577 : {VV##577 : int | [(VV##577 = cow##ax4)]}+bind 77 VV##579 : {VV##579 : int | [(VV##579 = wink##ax3)]}+bind 78 VV##581 : {VV##581 : (Tuple  int  int) | [$k_##333[VV##332:=VV##581][ds_dxg:=GHC.Prim.void###0l]]}+bind 79 VV##583 : {VV##583 : int | [$k_##323[VV##322:=VV##583][VV##332:=VV##581][ds_dxg:=GHC.Prim.void###0l]]}+bind 80 VV##585 : {VV##585 : int | [$k_##326[VV##325:=VV##585][VV##332:=VV##581][ds_dxg:=GHC.Prim.void###0l]]}+bind 81 lq_tmp$x##264 : {VV##587 : int | []}+bind 82 VV##588 : {VV##588 : int | [$k_##330[VV##332:=VV##581][VV##329:=VV##588][ds_dxg:=GHC.Prim.void###0l][lq_tmp$x##328:=lq_tmp$x##264]]}+bind 83 VV##590 : {VV##590 : GHC.Prim.Void# | [(VV##590 = GHC.Prim.void###0l)]}+bind 84 VV##592 : {VV##592 : (Tuple  int  int) | [$k_##351[lq_tmp$x##339:=lq_anf$##dxu][lq_tmp$x##357:=VV##592][VV##350:=VV##592]]}+bind 85 VV##594 : {VV##594 : int | [$k_##341[lq_tmp$x##353:=VV##594][lq_tmp$x##339:=lq_anf$##dxu][lq_tmp$x##357:=VV##592][VV##340:=VV##594][VV##350:=VV##592]]}+bind 86 VV##596 : {VV##596 : int | [$k_##344[lq_tmp$x##339:=lq_anf$##dxu][lq_tmp$x##357:=VV##592][VV##343:=VV##596][lq_tmp$x##354:=VV##596][VV##350:=VV##592]]}+bind 87 lq_tmp$x##328 : {VV##598 : int | []}+bind 88 VV##599 : {VV##599 : int | [$k_##348[lq_tmp$x##355:=lq_tmp$x##328][lq_tmp$x##356:=VV##599][VV##347:=VV##599][lq_tmp$x##339:=lq_anf$##dxu][lq_tmp$x##346:=lq_tmp$x##328][lq_tmp$x##357:=VV##592][VV##350:=VV##592]]}+bind 89 VV##601 : {VV##601 : int | [(VV##601 = lq_anf$##dxu)]}+bind 90 VV##603 : {VV##603 : (Tuple  int  int) | [((snd VV##603) = cow##ax4);+                                                  ((fst VV##603) = wink##ax3);+                                                  ((x_Tuple22 VV##603) = cow##ax4);+                                                  ((x_Tuple21 VV##603) = wink##ax3)]}+bind 91 VV##605 : {VV##605 : int | [$k_##297[lq_tmp$x##295:=cow##ax4][lq_tmp$x##299:=VV##605][lq_tmp$x##291:=VV##603][lq_tmp$x##294:=wink##ax3][VV##296:=VV##605]]}+bind 92 VV##607 : {VV##607 : int | [$k_##301[lq_tmp$x##295:=cow##ax4][lq_tmp$x##291:=VV##603][lq_tmp$x##294:=wink##ax3][VV##300:=VV##607][lq_tmp$x##303:=VV##607]]}+bind 93 lq_tmp$x##264 : {VV##609 : int | []}+bind 94 VV##610 : {VV##610 : int | [$k_##305[lq_tmp$x##295:=cow##ax4][lq_tmp$x##290:=lq_tmp$x##264][VV##304:=VV##610][lq_tmp$x##307:=lq_tmp$x##264][lq_tmp$x##291:=VV##603][lq_tmp$x##294:=wink##ax3][lq_tmp$x##303:=VV##610]]}+bind 95 VV##612 : {VV##612 : int | [(VV##612 = cow##ax4)]}+bind 96 VV##614 : {VV##614 : int | [(VV##614 = wink##ax3)]}+bind 97 VV##616 : {VV##616 : int | [(VV##616 = yog##awz)]}+bind 98 VV##618 : {VV##618 : int | [(VV##618 = xig##awy)]}+bind 99 VV##473 : {VV##473 : int | [$k_##474]}+bind 100 VV##443 : {VV##443 : int | [$k_##444]}+bind 101 VV##435 : {VV##435 : int | [$k_##436]}+bind 102 VV##431 : {VV##431 : int | [$k_##432]}+bind 103 VV##427 : {VV##427 : int | [$k_##428]}+bind 104 VV##391 : {VV##391 : int | [$k_##392]}+bind 105 VV##361 : {VV##361 : int | [$k_##362]}+bind 106 VV##318 : {VV##318 : GHC.Prim.Void# | [$k_##319]}+bind 107 VV##350 : {VV##350 : (Tuple  int  int) | [$k_##351]}+bind 108 VV##340 : {VV##340 : int | [$k_##341]}+bind 109 VV##343 : {VV##343 : int | [$k_##344]}+bind 110 lq_tmp$x##346 : {VV##631 : int | []}+bind 111 VV##347 : {VV##347 : int | [$k_##348]}+bind 112 VV##332 : {VV##332 : (Tuple  int  int) | [$k_##333]}+bind 113 VV##322 : {VV##322 : int | [$k_##323]}+bind 114 VV##325 : {VV##325 : int | [$k_##326]}+bind 115 lq_tmp$x##328 : {VV##636 : int | []}+bind 116 VV##329 : {VV##329 : int | [$k_##330]}+bind 117 VV##304 : {VV##304 : int | [$k_##305]}+bind 118 VV##300 : {VV##300 : int | [$k_##301]}+bind 119 VV##296 : {VV##296 : int | [$k_##297]}+bind 120 VV##268 : {VV##268 : (Tuple  int  int) | [$k_##269]}+bind 121 VV##258 : {VV##258 : int | [$k_##259]}+bind 122 VV##261 : {VV##261 : int | [$k_##262]}+bind 123 lq_tmp$x##264 : {VV##644 : int | []}+bind 124 VV##265 : {VV##265 : int | [$k_##266]}+bind 125 VV##251 : {VV##251 : int | [$k_##252]}+bind 126 VV##247 : {VV##247 : int | [$k_##248]}++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       28;+       34;+       40;+       42;+       48;+       54 ]+  lhs {VV##1 : int | [(VV##1 = cow##awB)]}+  rhs {VV##1 : int | [(wink##awA < VV##1)]}+  id 1 tag [1]+  // META constraint id 1 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       28;+       34;+       40;+       42;+       48;+       49;+       50;+       51;+       52;+       53]+  lhs {VV##2 : int | [(VV##2 = cow##ax4)]}+  rhs {VV##2 : int | [$k_##474[VV##569:=VV##2][VV##F##2:=VV##2][VV##F:=VV##2][VV##473:=VV##2]]}+  id 2 tag [1]+  // META constraint id 2 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       19;+       20;+       21;+       22]+  lhs {VV##18 : (Tuple  int  int) | [((snd VV##18) = cow##ax4);+                                     ((fst VV##18) = wink##ax3);+                                     ((x_Tuple22 VV##18) = cow##ax4);+                                     ((x_Tuple21 VV##18) = wink##ax3)]}+  rhs {VV##18 : (Tuple  int  int) | [$k_##269[VV##F##18:=VV##18][VV##268:=VV##18][VV##603:=VV##18][VV##F:=VV##18]]}+  id 18 tag [1]+  // META constraint id 18 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       28;+       34;+       40;+       42;+       43;+       44;+       45;+       46;+       47]+  lhs {VV##3 : int | [(VV##3 = wink##ax3)]}+  rhs {VV##3 : int | [$k_##444[VV##571:=VV##3][VV##F:=VV##3][VV##F##3:=VV##3][VV##443:=VV##3]]}+  id 3 tag [1]+  // META constraint id 3 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       19;+       20;+       21;+       22;+       90]+  lhs {VV##19 : int | [$k_##297[lq_tmp$x##295:=cow##ax4][VV##605:=VV##19][lq_tmp$x##299:=VV##19][lq_tmp$x##291:=VV##603][VV##F##19:=VV##19][lq_tmp$x##294:=wink##ax3][VV##F:=VV##19][VV##296:=VV##19]]}+  rhs {VV##19 : int | [$k_##259[VV##605:=VV##19][VV##268:=VV##603][VV##258:=VV##19][VV##F##19:=VV##19][VV##F:=VV##19]]}+  id 19 tag [1]+  // META constraint id 19 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       28;+       34;+       40]+  lhs {VV##4 : int | [(VV##4 = cow##ax4)]}+  rhs {VV##4 : int | [$k_##432[lq_tmp$x##425:=wink##ax3][VV##431:=VV##4][VV##573:=VV##4][lq_tmp$x##434:=VV##4][VV##F:=VV##4][VV##F##4:=VV##4]]}+  id 4 tag [1]+  // META constraint id 4 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       19;+       20;+       21;+       22;+       90]+  lhs {VV##20 : int | [$k_##301[lq_tmp$x##295:=cow##ax4][VV##607:=VV##20][VV##F##20:=VV##20][lq_tmp$x##291:=VV##603][lq_tmp$x##294:=wink##ax3][VV##300:=VV##20][lq_tmp$x##303:=VV##20][VV##F:=VV##20]]}+  rhs {VV##20 : int | [$k_##262[VV##268:=VV##603][VV##607:=VV##20][VV##F##20:=VV##20][VV##261:=VV##20][VV##F:=VV##20]]}+  id 20 tag [1]+  // META constraint id 20 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       28;+       34;+       40]+  lhs {VV##5 : int | [(VV##5 = cow##ax4)]}+  rhs {VV##5 : int | [$k_##436[lq_tmp$x##425:=wink##ax3][VV##F##5:=VV##5][VV##573:=VV##5][lq_tmp$x##438:=wink##ax3][lq_tmp$x##434:=VV##5][VV##F:=VV##5][VV##435:=VV##5]]}+  id 5 tag [1]+  // META constraint id 5 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       19;+       20;+       21;+       22;+       90;+       93]+  lhs {VV##21 : int | [$k_##305[lq_tmp$x##295:=cow##ax4][lq_tmp$x##290:=lq_tmp$x##264][VV##304:=VV##21][VV##610:=VV##21][lq_tmp$x##307:=lq_tmp$x##264][lq_tmp$x##291:=VV##603][lq_tmp$x##294:=wink##ax3][lq_tmp$x##303:=VV##21][VV##F##21:=VV##21][VV##F:=VV##21]]}+  rhs {VV##21 : int | [$k_##266[VV##265:=VV##21][VV##610:=VV##21][VV##268:=VV##603][VV##F##21:=VV##21][VV##F:=VV##21]]}+  id 21 tag [1]+  // META constraint id 21 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       28;+       34;+       40]+  lhs {VV##6 : int | [(VV##6 = wink##ax3)]}+  rhs {VV##6 : int | [$k_##428[VV##F##6:=VV##6][VV##427:=VV##6][lq_tmp$x##430:=VV##6][VV##F:=VV##6][VV##575:=VV##6]]}+  id 6 tag [1]+  // META constraint id 6 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       19;+       20;+       21;+       22]+  lhs {VV##22 : int | [(VV##22 = cow##ax4)]}+  rhs {VV##22 : int | [$k_##301[VV##F##22:=VV##22][VV##612:=VV##22][lq_tmp$x##294:=wink##ax3][VV##300:=VV##22][lq_tmp$x##303:=VV##22][VV##F:=VV##22]]}+  id 22 tag [1]+  // META constraint id 22 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       28;+       34;+       35;+       36;+       37;+       38;+       39]+  lhs {VV##7 : int | [(VV##7 = cow##ax4)]}+  rhs {VV##7 : int | [$k_##392[VV##391:=VV##7][VV##F##7:=VV##7][VV##F:=VV##7][VV##577:=VV##7]]}+  id 7 tag [1]+  // META constraint id 7 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       19;+       20;+       21;+       22]+  lhs {VV##23 : int | [(VV##23 = cow##ax4)]}+  rhs {VV##23 : int | [$k_##305[VV##304:=VV##23][lq_tmp$x##307:=wink##ax3][VV##612:=VV##23][lq_tmp$x##294:=wink##ax3][lq_tmp$x##303:=VV##23][VV##F:=VV##23][VV##F##23:=VV##23]]}+  id 23 tag [1]+  // META constraint id 23 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       28;+       29;+       30;+       31;+       32;+       33]+  lhs {VV##8 : int | [(VV##8 = wink##ax3)]}+  rhs {VV##8 : int | [$k_##362[VV##579:=VV##8][VV##F##8:=VV##8][VV##361:=VV##8][VV##F:=VV##8]]}+  id 8 tag [1]+  // META constraint id 8 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       19;+       20;+       21;+       22]+  lhs {VV##24 : int | [(VV##24 = wink##ax3)]}+  rhs {VV##24 : int | [$k_##297[lq_tmp$x##299:=VV##24][VV##614:=VV##24][VV##F:=VV##24][VV##296:=VV##24][VV##F##24:=VV##24]]}+  id 24 tag [1]+  // META constraint id 24 : ()+++constraint:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16]+  lhs {VV##25 : int | [(VV##25 = yog##awz)]}+  rhs {VV##25 : int | [$k_##252[VV##251:=VV##25][lq_tmp$x##254:=VV##25][lq_tmp$x##245:=xig##awy][VV##F:=VV##25][VV##616:=VV##25][VV##F##25:=VV##25]]}+  id 25 tag [1]+  // META constraint id 25 : ()+++constraint:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16]+  lhs {VV##26 : int | [(VV##26 = xig##awy)]}+  rhs {VV##26 : int | [$k_##248[VV##618:=VV##26][VV##247:=VV##26][VV##F##26:=VV##26][VV##F:=VV##26][lq_tmp$x##250:=VV##26]]}+  id 26 tag [1]+  // META constraint id 26 : ()+++++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       24;+       25;+       26;+       115]+  reft {VV##329 : int | [$k_##330]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       24;+       25]+  reft {VV##318 : GHC.Prim.Void# | [$k_##319]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       24;+       25;+       26;+       27;+       107]+  reft {VV##343 : int | [$k_##344]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       28;+       34;+       40]+  reft {VV##427 : int | [$k_##428]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16]+  reft {VV##247 : int | [$k_##248]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       28;+       34;+       40;+       41]+  reft {VV##435 : int | [$k_##436]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       28;+       34;+       40;+       42]+  reft {VV##443 : int | [$k_##444]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       19;+       20;+       21;+       22]+  reft {VV##296 : int | [$k_##297]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       24;+       25;+       26;+       27;+       110]+  reft {VV##347 : int | [$k_##348]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       28;+       34;+       40;+       42;+       48]+  reft {VV##473 : int | [$k_##474]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       24;+       25;+       26;+       27]+  reft {VV##350 : (Tuple  int  int) | [$k_##351]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       28;+       34]+  reft {VV##391 : int | [$k_##392]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       24;+       25;+       26]+  reft {VV##332 : (Tuple  int  int) | [$k_##333]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       120]+  reft {VV##258 : int | [$k_##259]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       120]+  reft {VV##261 : int | [$k_##262]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       24;+       25;+       26;+       27;+       107]+  reft {VV##340 : int | [$k_##341]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       19;+       20;+       21;+       22;+       23]+  reft {VV##304 : int | [$k_##305]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       24;+       25;+       26;+       112]+  reft {VV##325 : int | [$k_##326]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       28]+  reft {VV##361 : int | [$k_##362]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       123]+  reft {VV##265 : int | [$k_##266]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       24;+       25;+       26;+       112]+  reft {VV##322 : int | [$k_##323]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       18;+       19;+       20;+       21;+       22]+  reft {VV##300 : int | [$k_##301]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16; 17]+  reft {VV##268 : (Tuple  int  int) | [$k_##269]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15;+       16;+       17;+       28;+       34;+       40]+  reft {VV##431 : int | [$k_##432]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16]+  reft {VV##251 : int | [$k_##252]}+  // META wf : ()
+ tests/elim/kvparam00.fq view
@@ -0,0 +1,20 @@+bind 0 x : {v : int | []}++bind 1 y : {v : int | []}++constraint:+  env [0; 1]+  lhs {VV#F1 : int | []}+  rhs {VV#F1 : int | [$k_0[v:=x]]}+  id 1 tag [3]++constraint:+  env [0; 1]+  lhs {VV#F2 : int | [$k_0[v:=y]]}+  rhs {VV#F2 : int | [y = x]}+  id 2 tag [4]++wf:+  env []+  reft {v : int | [$k_0]}+
+ tests/elim/len00.fq view
@@ -0,0 +1,23 @@++// This qualifier saves the day; solve constraints WITHOUT IT+//qualif ListZ(v : [@(0)]): (len v >= 0)++constant len : (func(2, [(@(0)  @(1)); int]))++bind 0 y : {v : [(Tuple int a)] | [len v >= 0]}++constraint:+  env [0]+  lhs {v : [(Tuple int a)] | [v = y] }+  rhs {v : [(Tuple int a)] | [$k0]   }+  id 1 tag []++constraint:+  env []+  lhs {v : [(Tuple int a)] | [$k0]             }+  rhs {v : [(Tuple int a)] | [len v >= 0] }+  id 2 tag []++wf:+  env [ ]+  reft {v : [(Tuple int a)] | [$k0] }
+ tests/elim/test00-tx.fq view
@@ -0,0 +1,12 @@+++// This qualifier saves the day; solve constraints WITHOUT IT+// qualif Zog(v:a) : (10 <= v)++bind 0 a : {v:int | (v = 10 || v = 20) }++constraint:+  env [ 0 ]+  lhs {v : int | v = a}+  rhs {v : int | 10 <= v}+  id 3 tag []
+ tests/elim/test00.fq view
@@ -0,0 +1,26 @@+// This qualifier saves the day; solve constraints WITHOUT IT+// qualif Zog(v:a) : (10 <= v)++bind 0 a : {v: int | $k0}++constraint:+  env [ ]+  lhs {v : int | v = 10}+  rhs {v : int | $k0}+  id 1 tag []++constraint:+  env [ ]+  lhs {v : int | v = 20}+  rhs {v : int | $k0}+  id 2 tag []++constraint:+  env [ 0 ]+  lhs {v : int | v = a}+  rhs {v : int | 10 <= v}+  id 3 tag []++wf:+  env [ ]+  reft {v: int | $k0}
+ tests/elim/test00a.fq view
@@ -0,0 +1,28 @@+// This qualifier saves the day; solve constraints WITHOUT IT+// qualif Zog(v:a) : (10 <= v)++bind 0 x : {v : int | true}+bind 1 y : {v : int | true}+bind 2 z : {v : int | true}++constraint:+  env [0]+  lhs {v : int | (x = 10)}+  rhs {v : int | $k0[v:=x]}+  id 1 tag []++constraint:+  env [1]+  lhs {v : int | y = 20}+  rhs {v : int | $k0[v:=y]}+  id 2 tag []++constraint:+  env [2]+  lhs {v : int | $k0[v:=z]}+  rhs {v : int | 10 <= z}+  id 3 tag []++wf:+  env [ ]+  reft {v: int | $k0}
+ tests/elim/test1.fq view
@@ -0,0 +1,29 @@++// This qualifier saves the day; solve constraints WITHOUT IT+// qualif Zog(v:a) : (10 <= v)++bind 0 x : {v : int | v = 10}+bind 1 y : {v : int | v = 20}+bind 2 a : {v : int | $k0    }+      +constraint:+  env [0]+  lhs {v : int | v = x}+  rhs {v : int | $k0   }+  id 1 tag []++constraint:+  env [1]+  lhs {v : int | v = y}+  rhs {v : int | $k0   }+  id 2 tag []++constraint:+  env [2]+  lhs {v : int | v = a  }+  rhs {v : int | 10 <= v}+  id 3 tag []++wf:+  env [ ]+  reft {v : int | $k0}
+ tests/elim/test2.fq view
@@ -0,0 +1,53 @@++// This qualifier saves the day; solve constraints WITHOUT IT+// qualif Zog(v:a): (10 <= v)++// But you may use this one+qualif Pog(v:a): (0 <= v)++bind 0 x: {v: int | v = 10}+bind 1 a: {v: int | $k1    }+bind 2 y: {v: int | v = 20}+bind 3 b: {v: int | $k1    }+bind 4 c: {v: int | $k0    }++cut $k1++constraint:+  env [ ]+  lhs {v : int | v = 0}+  rhs {v : int | $k1 }+  id 0 tag []+++constraint:+  env [0; 1]+  lhs {v : int | v = x + a}+  rhs {v : int | $k0}+  id 1 tag []++constraint:+  env [2; 3]+  lhs {v : int | v = y + b}+  rhs {v : int | $k0}+  id 2 tag []++constraint:+  env [ ]+  lhs {v : int | $k0}+  rhs {v : int | $k1}+  id 3 tag []++constraint:+  env [4]+  lhs {v : int | v = c  }+  rhs {v : int | 10 <= v}+  id 4 tag []++wf:+  env [ ]+  reft {v: int | $k0}++wf:+  env [ ]+  reft {v: int | $k1}
+ tests/elim/tuple00.fq view
@@ -0,0 +1,114 @@++bind 0 cat   : {v: int | v = 100 }+bind 1 dog   : {v: int | v = 200 }+bind 2 frog  : {v: int | v = 400 }+bind 3 mouse : {v: int | v = 500 }+bind 4 hippo : {v: int | v = 600 }+bind 5 goose : {v: int | v = 700 }+bind 6 crow  : {v: int | v = 800 }+bind 7 pig   : {v: int | v = 900 }++bind 20 x_1_1 : {v: int | $k_1_1 }+bind 21 x_1_2 : {v: int | $k_1_2 }+bind 22 x_2_1 : {v: int | $k_2_1 }+bind 23 x_2_2 : {v: int | $k_2_2 }+bind 24 x_3_1 : {v: int | $k_3_1 }+bind 25 x_3_2 : {v: int | $k_3_2 }++pack $k_1_1 : 1+pack $k_1_2 : 1+pack $k_2_1 : 2+pack $k_2_2 : 2+pack $k_3_1 : 3+pack $k_3_2 : 3+pack $k_4_1 : 4+pack $k_4_2 : 4++++constraint:+  env [ 0; 1; 2; 3; 4; 5; 6; 7 ]+  lhs {v : int | v = 1}+  rhs {v : int | $k_1_1}+  id 1 tag []++constraint:+  env [ 0; 1; 2; 3; 4; 5; 6; 7 ]+  lhs {v : int | v = 2}+  rhs {v : int | $k_1_2}+  id 2 tag []++constraint:+  env [ 20; 21 ]+  lhs {v : int | v = x_1_1 }+  rhs {v : int | $k_2_1    }+  id 3 tag []++constraint:+  env [ 20; 21 ]+  lhs {v : int | v = x_1_2 }+  rhs {v : int | $k_2_2    }+  id 4 tag []++constraint:+  env [ 22; 23 ]+  lhs {v : int | v = x_2_1 }+  rhs {v : int | $k_3_1    }+  id 5 tag []++constraint:+  env [ 22; 23 ]+  lhs {v : int | v = x_2_2 }+  rhs {v : int | $k_3_2    }+  id 6 tag []++constraint:+  env [ 24; 25 ]+  lhs {v : int | v = x_3_1 }+  rhs {v : int | $k_4_1    }+  id 7 tag []++constraint:+  env [ 24; 25 ]+  lhs {v : int | v = x_3_2 }+  rhs {v : int | $k_4_2    }+  id 8 tag []++constraint:+  env [ ]+  lhs {v : int | $k_4_1 }+  rhs {v : int | v = 1  }+  id 9 tag []++wf:+  env [ ]+  reft {v: int | $k_1_1}++wf:+  env [ ]+  reft {v: int | $k_1_2}++wf:+  env [ ]+  reft {v: int | $k_2_1}++wf:+  env [ ]+  reft {v: int | $k_2_2}++wf:+  env [ ]+  reft {v: int | $k_3_1}++wf:+  env [ ]+  reft {v: int | $k_3_2}+++wf:+  env [ ]+  reft {v: int | $k_4_1}++wf:+  env [ ]+  reft {v: int | $k_4_2}
+ tests/elim/tuple01.fq view
@@ -0,0 +1,137 @@+// This test illustrates how you can get an exponential VC from nested tuples++bind 0 cat   : {v: int | v = 100 }+bind 1 dog   : {v: int | v = 200 }+bind 2 frog  : {v: int | v = 400 }+bind 3 mouse : {v: int | v = 500 }+bind 4 hippo : {v: int | v = 600 }+bind 5 goose : {v: int | v = 700 }+bind 6 crow  : {v: int | v = 800 }+bind 7 pig   : {v: int | v = 900 }++bind 20 x_1_1 : {v: int | $k_1_1 }+bind 21 x_1_2 : {v: int | $k_1_2 }+bind 22 x_2_1 : {v: int | $k_2_1 }+bind 23 x_2_2 : {v: int | $k_2_2 }+bind 24 x_3_1 : {v: int | $k_3_1 }+bind 25 x_3_2 : {v: int | $k_3_2 }+bind 26 x_4_1 : {v: int | $k_4_1 }+bind 27 x_4_2 : {v: int | $k_4_2 }++// pack $k_1_1 : 1+// pack $k_1_2 : 1+// pack $k_2_1 : 2+// pack $k_2_2 : 2+// pack $k_3_1 : 3+// pack $k_3_2 : 3+// pack $k_4_1 : 4+// pack $k_4_2 : 4+// pack $k_5_1 : 5+// pack $k_5_2 : 5++constraint:+  env [ 0; 1; 2; 3; 4; 5; 6; 7 ]+  lhs {v : int | v = 1}+  rhs {v : int | $k_1_1}+  id 1 tag []++constraint:+  env [ 0; 1; 2; 3; 4; 5; 6; 7 ]+  lhs {v : int | v = 2}+  rhs {v : int | $k_1_2}+  id 2 tag []++constraint:+  env [ 20; 21 ]+  lhs {v : int | v = x_1_1 }+  rhs {v : int | $k_2_1    }+  id 3 tag []++constraint:+  env [ 20; 21 ]+  lhs {v : int | v = x_1_2 }+  rhs {v : int | $k_2_2    }+  id 4 tag []++constraint:+  env [ 22; 23 ]+  lhs {v : int | v = x_2_1 }+  rhs {v : int | $k_3_1    }+  id 5 tag []++constraint:+  env [ 22; 23 ]+  lhs {v : int | v = x_2_2 }+  rhs {v : int | $k_3_2    }+  id 6 tag []++constraint:+  env [ 24; 25 ]+  lhs {v : int | v = x_3_1 }+  rhs {v : int | $k_4_1    }+  id 7 tag []++constraint:+  env [ 24; 25 ]+  lhs {v : int | v = x_3_2 }+  rhs {v : int | $k_4_2    }+  id 8 tag []++constraint:+  env [ 26; 27 ]+  lhs {v : int | v = x_4_1 }+  rhs {v : int | $k_5_1    }+  id 9 tag []++constraint:+  env [ 26; 27 ]+  lhs {v : int | v = x_4_2 }+  rhs {v : int | $k_5_2    }+  id 10 tag []++constraint:+  env [ ]+  lhs {v : int | $k_5_1 }+  rhs {v : int | v = 1  }+  id 11 tag []++wf:+  env [ ]+  reft {v: int | $k_1_1}++wf:+  env [ ]+  reft {v: int | $k_1_2}++wf:+  env [ ]+  reft {v: int | $k_2_1}++wf:+  env [ ]+  reft {v: int | $k_2_2}++wf:+  env [ ]+  reft {v: int | $k_3_1}++wf:+  env [ ]+  reft {v: int | $k_3_2}+++wf:+  env [ ]+  reft {v: int | $k_4_1}++wf:+  env [ ]+  reft {v: int | $k_4_2}++wf:+  env [ ]+  reft {v: int | $k_5_1}++wf:+  env [ ]+  reft {v: int | $k_5_2}
+ tests/minimize/two-cores.fq view
@@ -0,0 +1,30 @@+qualif Cmp(v:a): (v = 10)+qualif Cmp(v:a): (v = 12)++constraint:+  env []+  lhs {v : int | [v = 10]}+  rhs {v : int | [$k_0]}+  id 1 tag [3]++constraint:+  env []+  lhs {v : int | [$k_0]}+  rhs {v : int | [v != 10]}+  id 4 tag [4]++constraint:+  env []+  lhs {v : int | [v = 12]}+  rhs {v : int | [$k_0]}+  id 2 tag [5]++constraint:+  env []+  lhs {v : int | [$k_0]}+  rhs {v : int | [v != 12]}+  id 3 tag [6]++wf:+  env []+  reft {v : int | [$k_0]}
+ tests/neg/NonLinear.fq view
@@ -0,0 +1,28 @@++bind 1 pig      : {v: int | []}+bind 2 pigOut   : {v: int | [v = pig + 1]}++bind 3 argAlice : {v: int | v = 10}+bind 4 alice    : {v: int | [$k0[vk01 := argAlice][vk02 := v]] }++bind 5 argBob   : {v: int | v = 20}+bind 6 bob      : {v: int | [$k0[vk01 := argBob][vk02 := v]] }++bind 10 vk01   : {v: int | []}++constraint:+  env [1; 2] +  lhs {v1 : int | [v1 = pigOut]} +  rhs {v1 : int | [$k0[vk01 := pig][vk02 := v1]]}+  id 1 tag [2]++constraint:+  env [3; 4; 5; 6] +  lhs {v2 : int | []} +  rhs {v2 : int | [false]}+  id 2 tag [2]++wf:+  env [10]+  reft {vk02: int | [$k0]}+
+ tests/neg/NonLinear.hs.fq view
@@ -0,0 +1,91 @@++bind 0 GHC.Num.$fNumInt##rlL : {VV##27 : (GHC.Num.Num  int) | []}+bind 1 GHC.Types.EQ##6U : {VV##28 : GHC.Types.Ordering | [(VV##28 = GHC.Types.EQ##6U)]}+bind 2 GHC.Types.LT##6S : {VV##29 : GHC.Types.Ordering | [(VV##29 = GHC.Types.LT##6S)]}+bind 3 GHC.Types.GT##6W : {VV##30 : GHC.Types.Ordering | [(VV##30 = GHC.Types.GT##6W)]}+bind 4 pig##amI : {VV##33 : int | []}+bind 5 lq_anf$##dvQ : {lq_tmp$x##41 : int | [(lq_tmp$x##41 = (1  :  int))]}+bind 6 zink##alG : {zink##0 : int | [(zink##0 = 5)]}+bind 7 zonk##alH : {zonk##1 : int | [(zonk##1 = 67)]}+bind 8 bob##alJ : {lq_tmp$x##65 : int | [$k_##38[VV##37:=lq_tmp$x##65][lq_tmp$x##67:=zonk##alH][pig##amI:=zonk##alH]]}+bind 9 alice##alI : {lq_tmp$x##71 : int | [$k_##38[VV##37:=lq_tmp$x##71][pig##amI:=zink##alG][lq_tmp$x##73:=zink##alG]]}+bind 10 VV##96 : {VV##96 : int | []}+bind 11 zink##alG : {zink##0 : int | []}+bind 12 VV##99 : {VV##99 : int | []}+bind 13 lq_tmp$x##92 : {zonk##1 : int | []}+bind 14 VV##102 : {VV##102 : int | []}+bind 15 VV##104 : {VV##104 : int | []}+bind 16 zonk##alH : {zonk##1 : int | []}+bind 17 VV##107 : {VV##107 : int | []}+bind 18 VV##109 : {VV##109 : int | [(VV##109 = (alice##alI + bob##alJ))]}+bind 19 VV##111 : {VV##111 : int | [$k_##38[VV##37:=VV##111][lq_tmp$x##88:=VV##111][lq_tmp$x##67:=zonk##alH][lq_tmp$x##65:=VV##111][pig##amI:=zonk##alH];+                                    (VV##111 = bob##alJ)]}+bind 20 VV##113 : {VV##113 : int | [$k_##38[VV##37:=VV##113][lq_tmp$x##87:=VV##113][lq_tmp$x##71:=VV##113][pig##amI:=zink##alG][lq_tmp$x##73:=zink##alG];+                                    (VV##113 = alice##alI)]}+bind 21 VV##115 : {VV##115 : int | [(VV##115 = 5);+                                    (VV##115 = zink##alG)]}+bind 22 VV##117 : {VV##117 : int | [(VV##117 = 67);+                                    (VV##117 = zonk##alH)]}+bind 23 VV##119 : {VV##119 : int | [(VV##119 = (pig##amI + lq_anf$##dvQ))]}+bind 24 VV##121 : {VV##121 : int | [(VV##121 = (1  :  int));+                                    (VV##121 = lq_anf$##dvQ)]}+bind 25 VV##123 : {VV##123 : int | [$k_##34[lq_tmp$x##57:=VV##123][VV##33:=VV##123];+                                    (VV##123 = pig##amI)]}+bind 26 VV##125 : {VV##125 : int | [(VV##125 = 1)]}+bind 27 VV##33 : {VV##33 : int | [$k_##34]}+bind 28 VV##37 : {VV##37 : int | [$k_##38]}+++++constraint:+  env [0; 1; 2; 3; 6; 7; 8; 9]+  lhs {VV##F##1 : int | [(VV##F##1 = (alice##alI + bob##alJ))]}+  rhs {VV##F##1 : int | [(VV##F##1 = 0)]}+  id 1 tag [2]+  // META constraint id 1 : ()+++constraint:+  env [0; 1; 2; 3; 6; 7]+  lhs {VV##F##2 : int | [(VV##F##2 = 5); (VV##F##2 = zink##alG)]}+  rhs {VV##F##2 : int | [$k_##34[VV##115:=VV##F##2][lq_tmp$x##70:=VV##F##2][VV##F:=VV##F##2][VV##33:=VV##F##2]]}+  id 2 tag [2]+  // META constraint id 2 : ()+++constraint:+  env [0; 1; 2; 3; 6; 7]+  lhs {VV##F##3 : int | [(VV##F##3 = 67); (VV##F##3 = zonk##alH)]}+  rhs {VV##F##3 : int | [$k_##34[lq_tmp$x##64:=VV##F##3][VV##117:=VV##F##3][VV##F:=VV##F##3][VV##33:=VV##F##3]]}+  id 3 tag [2]+  // META constraint id 3 : ()+++constraint:+  env [0; 1; 2; 3; 4; 5]+  lhs {VV##F##4 : int | [(VV##F##4 = (pig##amI + lq_anf$##dvQ))]}+  rhs {VV##F##4 : int | [$k_##38[VV##37:=VV##F##4][VV##119:=VV##F##4][VV##F:=VV##F##4]]}+  id 4 tag [1]+  // META constraint id 4 : ()+++++wf:+  env [0; 1; 2; 3; 4]+  reft {VV##37 : int | [$k_##38]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3]+  reft {VV##33 : int | [$k_##34]}+  // META wf : ()+++++++
+ tests/neg/elim-dep-00.fq view
@@ -0,0 +1,43 @@++qualif False(v:int) : (0 = 1)+qualif Zero(v:int) : (0 = v)+qualif One(v:int) : (1 = v)++bind 1 x : {v:int | $k2 }++// cut $k1 -- eliminating $k1 causes UNSOUNDNESS++cut $k2+++constraint:+  env [ ]+  lhs {v : int | v = 0 }+  rhs {v : int | $k1   }+  id 1 tag []++constraint:+  env [ 1 ]+  lhs {v : int | v = x + 1 }+  rhs {v : int | $k1       }+  id 2 tag []++constraint:+  env [ ]+  lhs {v : int | $k1}+  rhs {v : int | $k2}+  id 3 tag []++constraint:+  env [ ]+  lhs {v : int | $k2  }+  rhs {v : int | 0 = v}+  id 4 tag []++wf:+  env [ ]+  reft {v: int | $k1}++wf:+  env [ ]+  reft {v: int | $k2}
− tests/neg/num00.fq
@@ -1,28 +0,0 @@-// This qualifier saves the day; solve constraints WITHOUT IT--qualif Zog(v:a) : (0 <= v)--bind 0 zog : {v : int | true}--constraint:-  env [0]-  lhs {v : alpha | (v = 10)}-  rhs {v : alpha | $k0}-  id 1 tag []--constraint:-  env [0]-  lhs {v : alpha | $k0}-  rhs {v : alpha | $k0}-  id 2 tag []--constraint:-  env [0]-  lhs {v : alpha | $k0}-  rhs {v : alpha | 0 <= v}-  id 3 tag []--wf:-  env [0]-  reft {v: alpha | $k0}-
+ tests/neg/pack00.fq view
@@ -0,0 +1,37 @@++bind 1 pig      : {v: int | []}++bind 3 argAlice : {v: int | v = 10}+bind 4 alice    : {v: int | [$k0[vk01 := argAlice][vk02 := v]] }++bind 5 argBob   : {v: int | v = 20}+bind 6 bob      : {v: int | [$k1[vk11 := argBob][vk12 := v]] }++bind 10 vk01   : {v: int | []}+bind 11 vk11   : {v: int | []}++constraint:+  env [1]+  lhs {v1 : int | [v1 = pig + 1]}+  rhs {v1 : int | [$k0[vk01 := pig][vk02 := v1]]}+  id 1 tag [2]++constraint:+  env [1]+  lhs {v2 : int | [v2 = pig + 1]}+  rhs {v2 : int | [$k1[vk11 := pig][vk12 := v2]]}+  id 2 tag [2]++constraint:+  env [3; 4; 5; 6]+  lhs {v3 : int | [v3 = alice + bob]}+  rhs {v3 : int | [v3 = 0]}+  id 3 tag [2]++wf:+  env [10]+  reft {vk02: int | [$k0]}++wf:+  env [11]+  reft {vk12: int | [$k1]}
+ tests/neg/pack01.fq view
@@ -0,0 +1,45 @@+++bind 1 pig      : {v: int | []}++bind 3 argAlice : {v: int | v = 10}+bind 4 alice    : {v: int | [$k0[vk01 := argAlice][vk02 := v]] }++bind 5 argBob   : {v: int | v = 20}+bind 6 bob      : {v: int | [$k1[vk11 := argBob][vk12 := v]] }++bind 10 vk01   : {v: int | []}+bind 11 vk11   : {v: int | []}++// This is a version of the UNSAFE pack00.fq + the pack annotations,+// which shouldn't magically make it safe.++pack $k0 : 1+pack $k1 : 1+++constraint:+  env [1]+  lhs {v1 : int | [v1 = pig + 1]}+  rhs {v1 : int | [$k0[vk01 := pig][vk02 := v1]]}+  id 1 tag [2]++constraint:+  env [1]+  lhs {v2 : int | [v2 = pig + 1]}+  rhs {v2 : int | [$k1[vk11 := pig][vk12 := v2]]}+  id 2 tag [2]++constraint:+  env [3; 4; 5; 6]+  lhs {v3 : int | [v3 = alice + bob]}+  rhs {v3 : int | [v3 = 0]}+  id 3 tag [2]++wf:+  env [10]+  reft {vk02: int | [$k0]}++wf:+  env [11]+  reft {vk12: int | [$k1]}
tests/neg/poly0.fq view
@@ -1,3 +1,4 @@+fixpoint "--defunct"  // This definition works fine ... // constant offset : (func(0, [int ; int ; (BitVec Size32) ]))
tests/neg/poly1.fq view
@@ -1,3 +1,4 @@+fixpoint "--defunct"  // This definition works fine ... // constant offset : (func(2, [int ; (BitVec Size32) ]))
tests/neg/poly2.fq view
@@ -1,3 +1,4 @@+fixpoint "--defunct"  // This definition works fine ... // constant offset : (func(0, [int ; int ; (BitVec Size32) ]))
+ tests/neg/test00.hs.fq view
@@ -0,0 +1,286 @@+qualif Fst(v : @(1), y : @(0)): (v = fst([y])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.spec" (line 29, column 8)+qualif Snd(v : @(1), y : @(0)): (v = snd([y])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.spec" (line 30, column 8)+qualif IsEmp(v : GHC.Types.Bool, xs : [@(0)]): ((? Prop([v])) <=> (len([xs]) > 0)) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 13, column 8)+qualif IsEmp(v : GHC.Types.Bool, xs : [@(0)]): ((? Prop([v])) <=> (len([xs]) = 0)) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 14, column 8)+qualif ListZ(v : [@(0)]): (len([v]) = 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 16, column 8)+qualif ListZ(v : [@(0)]): (len([v]) >= 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 17, column 8)+qualif ListZ(v : [@(0)]): (len([v]) > 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 18, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (len([v]) = len([xs])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 20, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (len([v]) >= len([xs])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 21, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (len([v]) > len([xs])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 22, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (len([v]) <= len([xs])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 23, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (len([v]) < len([xs])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 24, column 8)+qualif EqLen(v : int, xs : [@(0)]): (v = len([xs])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 26, column 8)+qualif LenEq(v : [@(0)], x : int): (x = len([v])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 27, column 8)+qualif LenDiff(v : [@(0)], x : int): (len([v]) = (x + 1)) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 28, column 8)+qualif LenDiff(v : [@(0)], x : int): (len([v]) = (x - 1)) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 29, column 8)+qualif LenAcc(v : int, xs : [@(0)], n : int): (v = (len([xs]) + n)) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 30, column 8)+qualif Bot(v : @(0)): (0 = 1) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 3, column 8)+qualif Bot(v : @(0)): (0 = 1) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 4, column 8)+qualif Bot(v : @(0)): (0 = 1) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 5, column 8)+qualif Bot(v : bool): (0 = 1) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 6, column 8)+qualif Bot(v : int): (0 = 1) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 7, column 8)+qualif CmpZ(v : @(0)): (v < 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 9, column 8)+qualif CmpZ(v : @(0)): (v <= 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 10, column 8)+qualif CmpZ(v : @(0)): (v > 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 11, column 8)+qualif CmpZ(v : @(0)): (v >= 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 12, column 8)+qualif CmpZ(v : @(0)): (v = 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 13, column 8)+qualif CmpZ(v : @(0)): (v != 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 14, column 8)+qualif Cmp(v : @(0), x : @(0)): (v < x) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 16, column 8)+qualif Cmp(v : @(0), x : @(0)): (v <= x) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 17, column 8)+qualif Cmp(v : @(0), x : @(0)): (v > x) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 18, column 8)+qualif Cmp(v : @(0), x : @(0)): (v >= x) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 19, column 8)+qualif Cmp(v : @(0), x : @(0)): (v = x) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 20, column 8)+qualif Cmp(v : @(0), x : @(0)): (v != x) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 21, column 8)+qualif One(v : int): (v = 1) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 28, column 8)+qualif True(v : bool): (? v) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 29, column 8)+qualif False(v : bool): (~ ((? v))) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 30, column 8)+qualif True1(v : GHC.Types.Bool): (? Prop([v])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 31, column 8)+qualif False1(v : GHC.Types.Bool): (~ ((? Prop([v])))) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 32, column 8)+qualif Papp(v : @(0), p : (Pred  @(0))): (? papp1([p;+                                                   v])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 35, column 8)+qualif Papp2(v : @(1), x : @(0), p : (Pred  @(1)  @(0))): (? papp2([p;+                                                                    v;+                                                                    x])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 38, column 8)+qualif Papp3(v : @(2), x : @(0), y : @(1), p : (Pred  @(2)  @(0)  @(1))): (? papp3([p;+                                                                                    v;+                                                                                    x;+                                                                                    y])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 41, column 8)+++++constant runFun : (func(2, [(Arrow  @(0)  @(1)); @(0); @(1)]))+constant addrLen : (func(0, [int; int]))+constant xsListSelector : (func(1, [[@(0)]; [@(0)]]))+constant x_Tuple21 : (func(2, [(Tuple  @(0)  @(1)); @(0)]))+constant x_Tuple65 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(4)]))+constant GHC.Types.False$35$68 : (GHC.Types.Bool)+constant x_Tuple55 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(4)]))+constant x_Tuple33 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(2)]))+constant x_Tuple77 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(6)]))+constant papp3 : (func(6, [(Pred  @(0)  @(1)  @(2));+                           @(3);+                           @(4);+                           @(5);+                           bool]))+constant x_Tuple63 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(2)]))+constant x_Tuple41 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(0)]))+constant papp4 : (func(8, [(Pred  @(0)  @(1)  @(2)  @(6));+                           @(3);+                           @(4);+                           @(5);+                           @(7);+                           bool]))+constant x_Tuple64 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(3)]))+constant autolen : (func(1, [@(0); int]))+constant x_Tuple52 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(1)]))+constant null : (func(1, [[@(0)]; bool]))+constant papp2 : (func(4, [(Pred  @(0)  @(1)); @(2); @(3); bool]))+constant x_Tuple62 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(1)]))+constant fromJust : (func(1, [(GHC.Base.Maybe  @(0)); @(0)]))+constant x_Tuple53 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(2)]))+constant x_Tuple71 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(0)]))+constant x_Tuple74 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(3)]))+constant len : (func(2, [(@(0)  @(1)); int]))+constant x_Tuple22 : (func(2, [(Tuple  @(0)  @(1)); @(1)]))+constant x_Tuple66 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(5)]))+constant x_Tuple44 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(3)]))+constant xListSelector : (func(1, [[@(0)]; @(0)]))+constant strLen : (func(0, [int; int]))+constant x_Tuple72 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(1)]))+constant isJust : (func(1, [(GHC.Base.Maybe  @(0)); bool]))+constant Prop : (func(0, [GHC.Types.Bool; bool]))+constant x_Tuple31 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(0)]))+constant x_Tuple75 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(4)]))+constant papp1 : (func(1, [(Pred  @(0)); @(0); bool]))+constant x_Tuple61 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(0)]))+constant x_Tuple43 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(2)]))+constant x_Tuple51 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(0)]))+constant GHC.Types.I$35$$35$6c : (func(0, [int; int]))+constant x_Tuple73 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(2)]))+constant x_Tuple54 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(3)]))+constant x_Tuple32 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(1)]))+constant cmp : (func(0, [GHC.Types.Ordering; GHC.Types.Ordering]))+constant x_Tuple76 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(5)]))+constant fst : (func(2, [(Tuple  @(0)  @(1)); @(0)]))+constant snd : (func(2, [(Tuple  @(0)  @(1)); @(1)]))+constant x_Tuple42 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(1)]))+constant GHC.Types.True$35$6u : (GHC.Types.Bool)+++bind 0 GHC.Types.False$35$68 : {VV$35$159 : GHC.Types.Bool | []}+bind 1 GHC.Types.True$35$6u : {VV$35$161 : GHC.Types.Bool | []}+bind 2 GHC.Classes.$36$fOrdInt$35$rni : {VV$35$166 : (GHC.Classes.Ord  int) | []}+bind 3 GHC.Types.EQ$35$6U : {VV$35$167 : GHC.Types.Ordering | [(VV$35$167 = GHC.Types.EQ$35$6U)]}+bind 4 GHC.Types.LT$35$6S : {VV$35$168 : GHC.Types.Ordering | [(VV$35$168 = GHC.Types.LT$35$6S)]}+bind 5 GHC.Types.GT$35$6W : {VV$35$169 : GHC.Types.Ordering | [(VV$35$169 = GHC.Types.GT$35$6W)]}+bind 6 GHC.Types.True$35$6u : {v$35$4 : GHC.Types.Bool | [(? Prop([v$35$4]))]}+bind 7 GHC.Types.False$35$68 : {v$35$5 : GHC.Types.Bool | [(~ ((? Prop([v$35$5]))))]}+bind 8 GHC.Types.False$35$68 : {v$35$5 : GHC.Types.Bool | [(~ ((? Prop([v$35$5]))))]}+bind 9 GHC.Types.$91$$93$$35$6m : {VV : func(1, [[@(0)]]) | []}+bind 10 GHC.Types.True$35$6u : {v$35$4 : GHC.Types.Bool | [(? Prop([v$35$4]))]}+bind 11 GHC.Types.GT$35$6W : {VV$35$214 : GHC.Types.Ordering | [(cmp([VV$35$214]) = GHC.Types.GT$35$6W)]}+bind 12 GHC.Types.LT$35$6S : {VV$35$215 : GHC.Types.Ordering | [(cmp([VV$35$215]) = GHC.Types.LT$35$6S)]}+bind 13 GHC.Types.EQ$35$6U : {VV$35$216 : GHC.Types.Ordering | [(cmp([VV$35$216]) = GHC.Types.EQ$35$6U)]}+bind 14 GHC.Base.Nothing$35$r1d : {VV : func(1, [(GHC.Base.Maybe  @(0))]) | []}+bind 15 z$35$a10N : {VV$35$221 : int | [$k_$35$222]}+bind 16 lq_anf$36$_d116 : {lq_tmp$36$x$35$229 : int | [(lq_tmp$36$x$35$229 = (100  :  int))]}+bind 17 lq_anf$36$_d117 : {lq_tmp$36$x$35$236 : GHC.Types.Bool | [((? Prop([lq_tmp$36$x$35$236])) <=> (z$35$a10N >= lq_anf$36$_d116))]}+bind 18 lq_anf$36$_d118 : {lq_tmp$36$x$35$254 : int | [(lq_tmp$36$x$35$254 = (0  :  int))]}+bind 19 Test0.x$35$rYP : {VV$35$250 : int | [$k_$35$251]}+bind 20 lq_anf$36$_d119 : {lq_tmp$36$x$35$269 : int | [(lq_tmp$36$x$35$269 = (0  :  int))]}+bind 21 lq_anf$36$_d11a : {lq_tmp$36$x$35$275 : GHC.Types.Bool | [((? Prop([lq_tmp$36$x$35$275])) <=> (Test0.x$35$rYP > lq_anf$36$_d119))]}+bind 22 lq_anf$36$_d11b : {lq_tmp$36$x$35$291 : GHC.Types.Bool | [(lq_tmp$36$x$35$291 = lq_anf$36$_d11a)]}+bind 23 lq_anf$36$_d11b : {lq_tmp$36$x$35$293 : GHC.Types.Bool | [(lq_tmp$36$x$35$293 = lq_anf$36$_d11a)]}+bind 24 lq_anf$36$_d11b : {lq_tmp$36$x$35$293 : GHC.Types.Bool | [(lq_tmp$36$x$35$293 = lq_anf$36$_d11a);+                                                                  (~ ((? Prop([lq_tmp$36$x$35$293]))));+                                                                  (~ ((? Prop([lq_tmp$36$x$35$293]))));+                                                                  (~ ((? Prop([lq_tmp$36$x$35$293]))))]}+bind 25 lq_anf$36$_d11b : {lq_tmp$36$x$35$299 : GHC.Types.Bool | [(lq_tmp$36$x$35$299 = lq_anf$36$_d11a)]}+bind 26 lq_anf$36$_d11b : {lq_tmp$36$x$35$299 : GHC.Types.Bool | [(lq_tmp$36$x$35$299 = lq_anf$36$_d11a);+                                                                  (? Prop([lq_tmp$36$x$35$299]));+                                                                  (? Prop([lq_tmp$36$x$35$299]));+                                                                  (? Prop([lq_tmp$36$x$35$299]))]}+bind 27 Test0.prop_abs$35$r10h : {VV$35$265 : GHC.Types.Bool | [$k_$35$266]}+bind 28 VV$35$310 : {VV$35$310 : GHC.Types.Bool | [$k_$35$226[lq_tmp$36$x$35$307:=Test0.x$35$rYP][lq_tmp$36$x$35$305:=VV$35$310][VV$35$225:=VV$35$310][z$35$a10N:=Test0.x$35$rYP]]}+bind 29 VV$35$310 : {VV$35$310 : GHC.Types.Bool | [$k_$35$226[lq_tmp$36$x$35$307:=Test0.x$35$rYP][lq_tmp$36$x$35$305:=VV$35$310][VV$35$225:=VV$35$310][z$35$a10N:=Test0.x$35$rYP]]}+bind 30 VV$35$313 : {VV$35$313 : int | [(VV$35$313 = Test0.x$35$rYP)]}+bind 31 VV$35$313 : {VV$35$313 : int | [(VV$35$313 = Test0.x$35$rYP)]}+bind 32 VV$35$316 : {VV$35$316 : GHC.Types.Bool | [(VV$35$316 = GHC.Types.False$35$68)]}+bind 33 VV$35$316 : {VV$35$316 : GHC.Types.Bool | [(VV$35$316 = GHC.Types.False$35$68)]}+bind 34 VV$35$319 : {VV$35$319 : int | [(VV$35$319 = lq_anf$36$_d119)]}+bind 35 VV$35$319 : {VV$35$319 : int | [(VV$35$319 = lq_anf$36$_d119)]}+bind 36 VV$35$322 : {VV$35$322 : int | [(VV$35$322 = Test0.x$35$rYP)]}+bind 37 VV$35$322 : {VV$35$322 : int | [(VV$35$322 = Test0.x$35$rYP)]}+bind 38 VV$35$325 : {VV$35$325 : int | [(VV$35$325 = 0)]}+bind 39 VV$35$325 : {VV$35$325 : int | [(VV$35$325 = 0)]}+bind 40 VV$35$328 : {VV$35$328 : int | []}+bind 41 VV$35$328 : {VV$35$328 : int | []}+bind 42 VV$35$331 : {VV$35$331 : int | [(VV$35$331 = lq_anf$36$_d118)]}+bind 43 VV$35$331 : {VV$35$331 : int | [(VV$35$331 = lq_anf$36$_d118)]}+bind 44 VV$35$334 : {VV$35$334 : int | [(VV$35$334 = 0)]}+bind 45 VV$35$334 : {VV$35$334 : int | [(VV$35$334 = 0)]}+bind 46 VV$35$337 : {VV$35$337 : GHC.Types.Bool | [(? Prop([VV$35$337]))]}+bind 47 VV$35$337 : {VV$35$337 : GHC.Types.Bool | [(? Prop([VV$35$337]))]}+bind 48 VV$35$340 : {VV$35$340 : GHC.Types.Bool | [(VV$35$340 = lq_anf$36$_d117)]}+bind 49 VV$35$340 : {VV$35$340 : GHC.Types.Bool | [(VV$35$340 = lq_anf$36$_d117)]}+bind 50 VV$35$343 : {VV$35$343 : int | [(VV$35$343 = lq_anf$36$_d116)]}+bind 51 VV$35$343 : {VV$35$343 : int | [(VV$35$343 = lq_anf$36$_d116)]}+bind 52 VV$35$346 : {VV$35$346 : int | [(VV$35$346 = z$35$a10N)]}+bind 53 VV$35$346 : {VV$35$346 : int | [(VV$35$346 = z$35$a10N)]}+bind 54 VV$35$349 : {VV$35$349 : int | [(VV$35$349 = 100)]}+bind 55 VV$35$349 : {VV$35$349 : int | [(VV$35$349 = 100)]}+bind 56 VV$35$282 : {VV$35$282 : int | [$k_$35$283]}+bind 57 VV$35$265 : {VV$35$265 : GHC.Types.Bool | [$k_$35$266]}+bind 58 VV$35$250 : {VV$35$250 : int | [$k_$35$251]}+bind 59 VV$35$221 : {VV$35$221 : int | [$k_$35$222]}+bind 60 VV$35$225 : {VV$35$225 : GHC.Types.Bool | [$k_$35$226]}+++++constraint:+  env [0;+       1;+       2;+       3;+       19;+       4;+       20;+       5;+       21;+       6;+       22;+       7;+       8;+       9;+       25;+       10;+       26;+       11;+       12;+       13;+       14;+       30]+  lhs {VV$35$F2 : int | [(VV$35$F2 = Test0.x$35$rYP)]}+  rhs {VV$35$F2 : int | [$k_$35$222[VV$35$221:=VV$35$F2][lq_tmp$36$x$35$304:=VV$35$F2][VV$35$313:=VV$35$F2][VV$35$F:=VV$35$F2]]}+  id 2 tag [3]+  // META constraint id 2 : tests/neg/test00.hs:8:30+++constraint:+  env [0; 1; 2; 18; 3; 4; 5; 6; 7; 8; 40; 9; 10; 11; 12; 13; 14]+  lhs {VV$35$F6 : int | []}+  rhs {VV$35$F6 : int | [$k_$35$251[VV$35$328:=VV$35$F6][VV$35$250:=VV$35$F6][VV$35$F:=VV$35$F6]]}+  id 6 tag [2]+  // META constraint id 6 : tests/neg/test00.hs:6:1-12+++constraint:+  env [0;+       16;+       48;+       1;+       17;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15]+  lhs {VV$35$F8 : GHC.Types.Bool | [(VV$35$F8 = lq_anf$36$_d117)]}+  rhs {VV$35$F8 : GHC.Types.Bool | [(? Prop([VV$35$F8]))]}+  id 8 tag [1]+  // META constraint id 8 : tests/neg/test00.hs:11:23-35+++++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14]+  reft {VV$35$221 : int | [$k_$35$222]}+  // META wf : <no location info>+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14]+  reft {VV$35$250 : int | [$k_$35$251]}+  // META wf : <no location info>+++++++
+ tests/pos/LogicCurry1.hs.fq view
@@ -0,0 +1,245 @@+fixpoint "--allowho"++qualif Fst(v : @(1), y : @(0)): ((v = (fst y))) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.spec" (line 28, column 8)+qualif Snd(v : @(1), y : @(0)): ((v = (snd y))) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.spec" (line 29, column 8)+qualif Auto(v##1 : int, n : int, x : int): ((v##1 = (ack n x))) // "/Users/rjhala/research/stack/liquidhaskell/tests/pos/LogicCurry1.hs" (line 10, column 1)+qualif IsEmp(v : GHC.Types.Bool, xs : [@(0)]): ((v <=> ((len xs) > 0))) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.hquals" (line 13, column 8)+qualif IsEmp(v : GHC.Types.Bool, xs : [@(0)]): ((v <=> ((len xs) = 0))) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.hquals" (line 14, column 8)+qualif ListZ(v : [@(0)]): (((len v) = 0)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.hquals" (line 16, column 8)+qualif ListZ(v : [@(0)]): (((len v) >= 0)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.hquals" (line 17, column 8)+qualif ListZ(v : [@(0)]): (((len v) > 0)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.hquals" (line 18, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (((len v) = (len xs))) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.hquals" (line 20, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (((len v) >= (len xs))) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.hquals" (line 21, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (((len v) > (len xs))) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.hquals" (line 22, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (((len v) <= (len xs))) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.hquals" (line 23, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (((len v) < (len xs))) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.hquals" (line 24, column 8)+qualif EqLen(v : int, xs : [@(0)]): ((v = (len xs))) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.hquals" (line 26, column 8)+qualif LenEq(v : [@(0)], x : int): ((x = (len v))) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.hquals" (line 27, column 8)+qualif LenDiff(v : [@(0)], x : int): (((len v) = (x + 1))) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.hquals" (line 28, column 8)+qualif LenDiff(v : [@(0)], x : int): (((len v) = (x - 1))) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.hquals" (line 29, column 8)+qualif LenAcc(v : int, xs : [@(0)], n : int): ((v = ((len xs) + n))) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/GHC/Base.hquals" (line 30, column 8)+qualif Bot(v : @(0)): ((0 = 1)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 3, column 8)+qualif Bot(v : @(0)): ((0 = 1)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 4, column 8)+qualif Bot(v : @(0)): ((0 = 1)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 5, column 8)+qualif Bot(v : bool): ((0 = 1)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 6, column 8)+qualif Bot(v : int): ((0 = 1)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 7, column 8)+qualif CmpZ(v : @(0)): ((v < 0)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 9, column 8)+qualif CmpZ(v : @(0)): ((v <= 0)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 10, column 8)+qualif CmpZ(v : @(0)): ((v > 0)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 11, column 8)+qualif CmpZ(v : @(0)): ((v >= 0)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 12, column 8)+qualif CmpZ(v : @(0)): ((v = 0)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 13, column 8)+qualif CmpZ(v : @(0)): ((v != 0)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 14, column 8)+qualif Cmp(v : @(0), x : @(0)): ((v < x)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 16, column 8)+qualif Cmp(v : @(0), x : @(0)): ((v <= x)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 17, column 8)+qualif Cmp(v : @(0), x : @(0)): ((v > x)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 18, column 8)+qualif Cmp(v : @(0), x : @(0)): ((v >= x)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 19, column 8)+qualif Cmp(v : @(0), x : @(0)): ((v = x)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 20, column 8)+qualif Cmp(v : @(0), x : @(0)): ((v != x)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 21, column 8)+qualif One(v : int): ((v = 1)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 28, column 8)+qualif True1(v : GHC.Types.Bool): (v) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 29, column 8)+qualif False1(v : GHC.Types.Bool): ((~ (v))) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 30, column 8)+qualif Papp(v : @(0), p : (Pred  @(0))): ((papp1 p v)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 34, column 8)+qualif Papp2(v : @(1), x : @(0), p : (Pred  @(1)  @(0))): ((papp2 p v x)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 37, column 8)+qualif Papp3(v : @(2), x : @(0), y : @(1), p : (Pred  @(2)  @(0)  @(1))): ((papp3 p v x y)) // "/Users/rjhala/research/stack/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2016-05-21/7.10.3/share/x86_64-osx-ghc-7.10.3/liquidhaskell-0.6.0.0/include/Prelude.hquals" (line 39, column 8)+++++constant runFun : (func(2, [(Arrow  @(0)  @(1)); @(0); @(1)]))+constant addrLen : (func(0, [Str; int]))+constant papp5 : (func(10, [(Pred  @(0)  @(1)  @(2)  @(3)  @(4));+                            @(5);+                            @(6);+                            @(7);+                            @(8);+                            @(9);+                            bool]))+constant x_Tuple21 : (func(2, [(Tuple  @(0)  @(1)); @(0)]))+constant GHC.Types.False##68 : (bool)+constant x_Tuple65 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(4)]))+constant x_Tuple55 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(4)]))+constant x_Tuple33 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(2)]))+constant x_Tuple77 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(6)]))+constant papp3 : (func(6, [(Pred  @(0)  @(1)  @(2));+                           @(3);+                           @(4);+                           @(5);+                           bool]))+constant GHC.Types.True##6u : (bool)+constant x_Tuple63 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(2)]))+constant x_Tuple41 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(0)]))+constant GHC.Types.LT##6S : (GHC.Types.Ordering)+constant papp4 : (func(8, [(Pred  @(0)  @(1)  @(2)  @(3));+                           @(4);+                           @(5);+                           @(6);+                           @(7);+                           bool]))+constant x_Tuple64 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(3)]))+constant GHC.Types.GT##6W : (GHC.Types.Ordering)+constant autolen : (func(1, [@(0); int]))+constant x_Tuple52 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(1)]))+constant head : (func(1, [[@(0)]; @(0)]))+constant null : (func(1, [[@(0)]; bool]))+constant papp2 : (func(4, [(Pred  @(0)  @(1)); @(2); @(3); bool]))+constant x_Tuple62 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(1)]))+constant fromJust : (func(1, [(GHC.Base.Maybe  @(0)); @(0)]))+constant papp7 : (func(14, [(Pred  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                            @(7);+                            @(8);+                            @(9);+                            @(10);+                            @(11);+                            @(12);+                            @(13);+                            bool]))+constant x_Tuple53 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(2)]))+constant x_Tuple71 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(0)]))+constant ack : (func(0, [int; int; int]))+constant x_Tuple74 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(3)]))+constant len : (func(2, [(@(0)  @(1)); int]))+constant papp6 : (func(12, [(Pred  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                            @(6);+                            @(7);+                            @(8);+                            @(9);+                            @(10);+                            @(11);+                            bool]))+constant x_Tuple22 : (func(2, [(Tuple  @(0)  @(1)); @(1)]))+constant x_Tuple66 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(5)]))+constant x_Tuple44 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(3)]))+constant GHC.Err.undefined##02v : (func(1, [@(0)]))+constant strLen : (func(0, [[Char]; int]))+constant x_Tuple72 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(1)]))+constant isJust : (func(1, [(GHC.Base.Maybe  @(0)); bool]))+constant x_Tuple31 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(0)]))+constant x_Tuple75 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(4)]))+constant papp1 : (func(2, [(Pred  @(0)); @(1); bool]))+constant x_Tuple61 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(0)]))+constant x_Tuple43 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(2)]))+constant tail : (func(1, [[@(0)]; [@(0)]]))+constant GHC.Types.EQ##6U : (GHC.Types.Ordering)+constant x_Tuple51 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(0)]))+constant x_Tuple73 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(2)]))+constant Main.ack##rjG : (func(0, [int; int; int]))+constant x_Tuple54 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(3)]))+constant cmp : (func(0, [GHC.Types.Ordering; GHC.Types.Ordering]))+constant x_Tuple32 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(1)]))+constant x_Tuple76 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(5)]))+constant snd : (func(2, [(Tuple  @(0)  @(1)); @(1)]))+constant fst : (func(2, [(Tuple  @(0)  @(1)); @(0)]))+constant x_Tuple42 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(1)]))+++distinct GHC.Types.False##68 : (bool)+distinct GHC.Types.True##6u : (bool)+distinct GHC.Types.LT##6S : (GHC.Types.Ordering)+distinct GHC.Types.GT##6W : (GHC.Types.Ordering)+distinct GHC.Types.EQ##6U : (GHC.Types.Ordering)+++bind 0 GHC.Err.undefined##02v : {VV : func(1, [@(0)]) | []}+bind 1 GHC.Types.True##6u : {VV##9 : bool | [(VV##9 = GHC.Types.True##6u)]}+bind 2 GHC.Types.False##68 : {VV##10 : bool | [(VV##10 = GHC.Types.False##68)]}+bind 3 GHC.Types.EQ##6U : {VV##11 : GHC.Types.Ordering | [(VV##11 = GHC.Types.EQ##6U)]}+bind 4 GHC.Types.LT##6S : {VV##12 : GHC.Types.Ordering | [(VV##12 = GHC.Types.LT##6S)]}+bind 5 GHC.Types.GT##6W : {VV##13 : GHC.Types.Ordering | [(VV##13 = GHC.Types.GT##6W)]}+bind 6 Main.ack##rjG : {VV : func(0, [int; int; int]) | []}+bind 7 Main.ack##rjG : {VV : func(0, [int; int; int]) | []}+bind 8 m##alH : {VV##41 : int | []}+bind 9 Main.bar##rlx : {VV : func(0, [int; int; int]) | []}+bind 10 VV##55 : {VV##55 : int | []}+bind 11 m##alH : {VV##57 : int | []}+bind 12 VV##58 : {VV##58 : int | []}+bind 13 lq_tmp$x##51 : {v : int | []}+bind 14 VV##61 : {VV##61 : int | []}+bind 15 VV##63 : {VV##63 : int | []}+bind 16 lq_tmp$x##40 : {v : int | []}+bind 17 VV##66 : {VV##66 : int | [(VV##66 = (ack m##alH lq_tmp$x##40))]}+bind 18 VV##68 : {VV##68 : int | [(VV##68 = m##alH)]}+bind 19 VV##70 : {VV##70 : int | []}+bind 20 lq_tmp$x##17 : {VV##72 : int | []}+bind 21 VV##73 : {VV##73 : int | []}+bind 22 lq_tmp$x##19 : {VV##75 : int | []}+bind 23 VV##76 : {VV##76 : int | [$k_##31[lq_tmp$x##22:=lq_tmp$x##17][VV##30:=VV##76][lq_tmp$x##26:=lq_tmp$x##19][lq_tmp$x##35:=VV##76]]}+bind 24 VV##23 : {VV##23 : int | [$k_##24]}+bind 25 lq_tmp$x##22 : {VV##23 : int | [$k_##24]}+bind 26 VV##27 : {VV##27 : int | [$k_##28]}+bind 27 lq_tmp$x##26 : {VV##27 : int | [$k_##28]}+bind 28 VV##30 : {VV##30 : int | [$k_##31]}+++++constraint:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8]+  lhs {VV##F##1 : func(0, [int; int]) | [(VV##F##1 = (ack m##alH))]}+  rhs {VV##F##1 : func(0, [int; int]) | [(VV##F##1 = (ack m##alH))]}+  id 1 tag [2]+  // META constraint id 1 : ()+++constraint:+  env [0; 1; 2; 3; 4; 5; 6]+  lhs {VV##F##2 : int | []}+  rhs {VV##F##2 : int | [$k_##24[VV##70:=VV##F##2][VV##23:=VV##F##2][VV##F:=VV##F##2][lq_tmp$x##33:=VV##F##2]]}+  id 2 tag [1]+  // META constraint id 2 : ()+++constraint:+  env [0; 1; 2; 3; 4; 5; 6; 20]+  lhs {VV##F##3 : int | []}+  rhs {VV##F##3 : int | [$k_##28[lq_tmp$x##22:=lq_tmp$x##17][lq_tmp$x##34:=VV##F##3][VV##27:=VV##F##3][VV##73:=VV##F##3][VV##F:=VV##F##3]]}+  id 3 tag [1]+  // META constraint id 3 : ()+++++wf:+  env [0; 1; 2; 3; 4; 5; 6; 25]+  reft {VV##27 : int | [$k_##28]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 25; 27]+  reft {VV##30 : int | [$k_##31]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6]+  reft {VV##23 : int | [$k_##24]}+  // META wf : ()+++++++
+ tests/pos/NonLinear-pack.fq view
@@ -0,0 +1,40 @@++bind 1 pig      : {v: int | []}++bind 3 argAlice : {v: int | v = 10}+bind 4 alice    : {v: int | [$k0[vk01 := argAlice][vk02 := v]] }++bind 5 argBob   : {v: int | v = 20}+bind 6 bob      : {v: int | [$k1[vk11 := argBob][vk12 := v]] }++bind 10 vk01   : {v: int | []}+bind 11 vk11   : {v: int | []}++pack $k0 : 1+pack $k1 : 1++constraint:+  env [1]+  lhs {v1 : int | [v1 = pig + 1]}+  rhs {v1 : int | [$k0[vk01 := pig][vk02 := v1]]}+  id 1 tag [2]++constraint:+  env [1]+  lhs {v2 : int | [v2 = pig + 1]}+  rhs {v2 : int | [$k1[vk11 := pig][vk12 := v2]]}+  id 2 tag [2]++constraint:+  env [3; 4; 5; 6]+  lhs {v3 : int | [v3 = alice + bob]}+  rhs {v3 : int | [v3 = 32]}+  id 3 tag [2]++wf:+  env [10]+  reft {vk02: int | [$k0]}++wf:+  env [11]+  reft {vk12: int | [$k1]}
tests/pos/bad-subst01.fq view
@@ -1,3 +1,6 @@+// fixpoint "--eliminate=some"++ qualif Zog(v:a) : (10 <= v) qualif Bog(v:a, x:a) : (x <= v) 
+ tests/pos/bad-subst02.fq view
@@ -0,0 +1,22 @@+fixpoint "--eliminate=none"++qualif Eq(v:a, x:a): (v = x)++bind 0 x0 : {v: a0 | true }+bind 1 x1 : {v: a1 | true }++constraint:+  env [ 1 ]+  lhs {v : a1 | v = x1 }+  rhs {v : a1 | $k0[v0 := v][x0 := x1] }+  id 1 tag []++constraint:+  env [ ]+  lhs {v : a2 | $k0[v0 := v][x0 := x2] }+  rhs {v : a2 | 2 < 3 + 4 }+  id 2 tag []++wf:+  env [ 0 ]+  reft {v0 : a0 | $k0 }
+ tests/pos/bool00.fq view
@@ -0,0 +1,28 @@+qualif Zog(v:a) : (10 <= v)+qualif Bog(v:a, x:a) : (x <= v)++bind 0 a  : {v: int  | $k0}+bind 1 tt : {v: bool | v}+++constraint:+  env [ ]+  lhs {v : int | v = 10}+  rhs {v : int | $k0}+  id 1 tag []++constraint:+  env [ ]+  lhs {v : int | v = 20}+  rhs {v : int | $k0}+  id 2 tag []++constraint:+  env [ 0 ]+  lhs {v : int | v = a}+  rhs {v : int | 10 <= v}+  id 3 tag []++wf:+  env [ ]+  reft {v: int | $k0}
+ tests/pos/bool03.fq view
@@ -0,0 +1,28 @@++//qualif LE(v:a, x:a): (bool_to_int x <= bool_to_int v)++qualif LE(v:a, x:a): (x <= v)++constant lit$36$not$45$the$45$hippopotamus : (Str)+constant lit#cat : (Str)+constant lit#dog : (Str)++bind 1 bx : {v: bool | true }++bind 2 zx : {v: bool | lit#cat /= lit#dog }++constraint:+  env [ 1 ]+  lhs {v : bool | bx <= v }+  rhs {v : bool | $k1     }+  id 1 tag []++constraint:+  env [ 1; 2 ]+  lhs {v : bool | $k1 }+  rhs {v : bool | bx <= v }+  id 2 tag []++wf:+  env [1]+  reft {v : bool | $k1 }
+ tests/pos/bool04.fq view
@@ -0,0 +1,20 @@+fixpoint "--eliminate=some"++bind 1 bx : {v: int  | true }+bind 2 by : {v: bool | true }++constraint:+  env [ 2 ]+  lhs {v : int | true }+  rhs {v : int | $k1[bx := by] }+  id 1 tag []++constraint:+  env [ 1 ]+  lhs {v : int | $k1    }+  rhs {v : int | v <= v + 1 }+  id 2 tag []++wf:+  env [1]+  reft {v : int | $k1 }
tests/pos/elim00.fq view
@@ -1,3 +1,5 @@+fixpoint "--defunct"+ // trick is to do it without these qualif Cmp(v : @(0), x : @(0)): ((v > x)) // "tests/todo/elim00.hs.fq" (line 1, column 8) qualif Cmp(v : @(0), x : @(0)): ((v = x)) // "tests/todo/elim00.hs.fq" (line 2, column 8)
+ tests/pos/hex.ts.fq view
@@ -0,0 +1,342 @@+qualif Bot(v : a): (0 = 1) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif Bot(v : obj): (0 = 1) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif Bot(v : Boolean): (0 = 1) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif Bot(v : int): (0 = 1) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif CmpZ(v : int): (v < 0) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif CmpZ(v : int): (v <= 0) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif CmpZ(v : int): (v > 0) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif CmpZ(v : int): (v >= 0) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif CmpZ(v : int): (v = 0) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif CmpZ(v : int): (v != 0) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif Cmp(v : int, x : int): (v < x) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif Cmp(v : int, x : int): (v <= x) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif Cmp(v : int, x : int): (v > x) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif Cmp(v : int, x : int): (v >= x) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif Cmp(v : a, x : a): (v ~~ x) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif Cmp(v : a, x : a): (v != x) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif True1(v : Boolean): (? Prop([v])) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif False1(v : Boolean): (~ ((? Prop([v])))) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif Tag(v : a, x : Str): (ttag([v]) = x) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+qualif Len(v : b, w : a): (v < len([w])) // "/Users/rjhala/research/stack/liquid/refscript/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/refscript-0.1.0.0/include/prelude.ts" (line 1, column 1)+++++constant lit$36$Array : (Str)+constant lit$36$PI : (Str)+constant lit$36$documentElement : (Str)+constant extends_class : (func(1, [@(0); Str; bool]))+constant numeric_min_value : (int)+constant numeric_positive_infinity : (int)+constant lit$36$Document : (Str)+constant lit$36$Console : (Str)+constant lit$36$LOG10E : (Str)+constant lit$36$MAX_VALUE : (Str)+constant lit$36$Error : (Str)+constant numeric_nan : (int)+constant lit$36$Math : (Str)+constant lit$36$LN2 : (Str)+constant offset : (func(2, [@(0); Str; @(1)]))+constant hasDirectProperty : (func(1, [Str; @(0); bool]))+constant lit$36$Object : (Str)+constant lit$36$StringConstructor : (Str)+constant lit$36$object : (Str)+constant lit$36$NEGATIVE_INFINITY : (Str)+constant lit$36$BUBBLING_PHASE : (Str)+constant ttag : (func(1, [@(0); Str]))+constant lit$36$AT_TARGET : (Str)+constant lit$36$LN10 : (Str)+constant lit$36$Event : (Str)+constant numeric_max_value : (int)+constant lit$36$CAPTURING_PHASE : (Str)+constant lit$36$NaN : (Str)+constant lit$36$undefined : (Str)+constant lit$36$Function : (Str)+constant len : (func(2, [(Array  @(0)  @(1)); int]))+constant extends_interface : (func(1, [@(0); Str; bool]))+constant numeric_negative_infinity : (int)+constant lit$36$SQRT1_2 : (Str)+constant Prop : (func(1, [@(0); bool]))+constant hasProperty : (func(1, [Str; @(0); bool]))+constant lit$36$String : (Str)+constant lit$36$E : (Str)+constant lit$36$POSITIVE_INFINITY : (Str)+constant lit$36$MIN_VALUE : (Str)+constant lit$36$prototype : (Str)+constant lit$36$SQRT2 : (Str)+constant lit$36$LOG2E : (Str)+constant lit$36$Number : (Str)+constant lit$36$HTMLElement : (Str)+constant lit$36$number : (Str)+constant enumProp : (func(1, [Str; @(0); bool]))+constant lit$36$boolean : (Str)+constant lit$36$Window : (Str)+++bind 0 undefined : {v : Undefined | [(ttag([v]) = lit$36$undefined);+                                     (~ ((? Prop([v]))))]}+bind 1 Object : {VV$35$285 : Object | [(? Prop([VV$35$285]));+                                       (ttag([VV$35$285]) = lit$36$object)]}+bind 2 Object.prototype : {VV : (Object  Immutable) | [(? extends_interface([VV;+                                                                             lit$36$Object]));+                                                       (? Prop([VV]));+                                                       (ttag([VV]) = lit$36$object);+                                                       (VV ~~ offset([Object; lit$36$prototype]))]}+bind 3 NaN : {v : int | [(ttag([v]) = lit$36$number);+                         ((? Prop([v])) <=> (v != 0));+                         (v = numeric_nan)]}+bind 4 Number : {VV$35$325 : Object | [(? Prop([VV$35$325]));+                                       (ttag([VV$35$325]) = lit$36$object)]}+bind 5 Number.POSITIVE_INFINITY : {v : int | [(ttag([v]) = lit$36$number);+                                              ((? Prop([v])) <=> (v != 0));+                                              (v ~~ offset([Number; lit$36$POSITIVE_INFINITY]))]}+bind 6 Number.MIN_VALUE : {v : int | [(ttag([v]) = lit$36$number);+                                      ((? Prop([v])) <=> (v != 0));+                                      (v ~~ offset([Number; lit$36$MIN_VALUE]))]}+bind 7 Number.prototype : {VV : (Number  Immutable) | [(? extends_interface([VV;+                                                                             lit$36$Number]));+                                                       (? Prop([VV]));+                                                       (ttag([VV]) = lit$36$object);+                                                       (VV ~~ offset([Number; lit$36$prototype]))]}+bind 8 Number.NaN : {v : int | [(ttag([v]) = lit$36$number);+                                ((? Prop([v])) <=> (v != 0));+                                (v ~~ offset([Number; lit$36$NaN]))]}+bind 9 Number.NEGATIVE_INFINITY : {v : int | [(ttag([v]) = lit$36$number);+                                              ((? Prop([v])) <=> (v != 0));+                                              (v ~~ offset([Number; lit$36$NEGATIVE_INFINITY]))]}+bind 10 Number.MAX_VALUE : {v : int | [(ttag([v]) = lit$36$number);+                                       ((? Prop([v])) <=> (v != 0));+                                       (v ~~ offset([Number; lit$36$MAX_VALUE]))]}+bind 11 Math : {VV$35$387 : (Math  Immutable) | [(? extends_interface([VV$35$387;+                                                                       lit$36$Math]));+                                                 (? Prop([VV$35$387]));+                                                 (ttag([VV$35$387]) = lit$36$object)]}+bind 12 Math.SQRT2 : {v : int | [(ttag([v]) = lit$36$number);+                                 ((? Prop([v])) <=> (v != 0));+                                 (v ~~ offset([Math; lit$36$SQRT2]))]}+bind 13 Math.LN2 : {v : int | [(ttag([v]) = lit$36$number);+                               ((? Prop([v])) <=> (v != 0));+                               (v ~~ offset([Math; lit$36$LN2]))]}+bind 14 Math.PI : {v : int | [(ttag([v]) = lit$36$number);+                              ((? Prop([v])) <=> (v != 0));+                              (v ~~ offset([Math; lit$36$PI]))]}+bind 15 Math.LOG10E : {v : int | [(ttag([v]) = lit$36$number);+                                  ((? Prop([v])) <=> (v != 0));+                                  (v ~~ offset([Math; lit$36$LOG10E]))]}+bind 16 Math.LOG2E : {v : int | [(ttag([v]) = lit$36$number);+                                 ((? Prop([v])) <=> (v != 0));+                                 (v ~~ offset([Math; lit$36$LOG2E]))]}+bind 17 Math.E : {v : int | [(ttag([v]) = lit$36$number);+                             ((? Prop([v])) <=> (v != 0));+                             (v ~~ offset([Math; lit$36$E]))]}+bind 18 Math.SQRT1_2 : {v : int | [(ttag([v]) = lit$36$number);+                                   ((? Prop([v])) <=> (v != 0));+                                   (v ~~ offset([Math; lit$36$SQRT1_2]))]}+bind 19 Math.LN10 : {v : int | [(ttag([v]) = lit$36$number);+                                ((? Prop([v])) <=> (v != 0));+                                (v ~~ offset([Math; lit$36$LN10]))]}+bind 20 String : {VV$35$469 : (StringConstructor  Immutable) | [(? extends_interface([VV$35$469;+                                                                                      lit$36$StringConstructor]));+                                                                (? Prop([VV$35$469]));+                                                                (ttag([VV$35$469]) = lit$36$object)]}+bind 21 String.prototype : {VV : (String  Immutable) | [(? extends_interface([VV;+                                                                              lit$36$String]));+                                                        (? Prop([VV]));+                                                        (ttag([VV]) = lit$36$object);+                                                        (VV ~~ offset([String; lit$36$prototype]))]}+bind 22 Array : {VV$35$727 : Object | [(? Prop([VV$35$727]));+                                       (ttag([VV$35$727]) = lit$36$object)]}+bind 23 Array.prototype : {VV : (Array  Mutable  Top) | [(? extends_interface([VV;+                                                                               lit$36$Array]));+                                                         (? Prop([VV]));+                                                         (ttag([VV]) = lit$36$object);+                                                         (VV ~~ offset([Array; lit$36$prototype]))]}+bind 24 Function : {VV$35$762 : Object | [(? Prop([VV$35$762]));+                                          (ttag([VV$35$762]) = lit$36$object)]}+bind 25 Function.prototype : {VV : (Function  Immutable) | [(? extends_interface([VV;+                                                                                  lit$36$Function]));+                                                            (? Prop([VV]));+                                                            (ttag([VV]) = lit$36$object);+                                                            (VV ~~ offset([Function;+                                                                           lit$36$prototype]))]}+bind 26 Console : {VV$35$891 : Object | [(? Prop([VV$35$891]));+                                         (ttag([VV$35$891]) = lit$36$object)]}+bind 27 Console.prototype : {VV : (Console  Immutable) | [(? extends_interface([VV;+                                                                                lit$36$Console]));+                                                          (? Prop([VV]));+                                                          (ttag([VV]) = lit$36$object);+                                                          (VV ~~ offset([Console;+                                                                         lit$36$prototype]))]}+bind 28 console : {VV$35$893 : (Console  Immutable) | [(? extends_interface([VV$35$893;+                                                                             lit$36$Console]));+                                                       (? Prop([VV$35$893]));+                                                       (ttag([VV$35$893]) = lit$36$object)]}+bind 29 Error : {VV$35$983 : Object | [(? Prop([VV$35$983]));+                                       (ttag([VV$35$983]) = lit$36$object)]}+bind 30 Error.prototype : {VV : (Error  Immutable) | [(? extends_interface([VV;+                                                                            lit$36$Error]));+                                                      (? Prop([VV]));+                                                      (ttag([VV]) = lit$36$object);+                                                      (VV ~~ offset([Error; lit$36$prototype]))]}+bind 31 Event : {VV$35$1025 : Object | [(? Prop([VV$35$1025]));+                                        (ttag([VV$35$1025]) = lit$36$object)]}+bind 32 Event.CAPTURING_PHASE : {v : int | [(ttag([v]) = lit$36$number);+                                            ((? Prop([v])) <=> (v != 0));+                                            (v ~~ offset([Event; lit$36$CAPTURING_PHASE]))]}+bind 33 Event.AT_TARGET : {v : int | [(ttag([v]) = lit$36$number);+                                      ((? Prop([v])) <=> (v != 0));+                                      (v ~~ offset([Event; lit$36$AT_TARGET]))]}+bind 34 Event.prototype : {VV : (Event  Immutable) | [(? extends_interface([VV;+                                                                            lit$36$Event]));+                                                      (? Prop([VV]));+                                                      (ttag([VV]) = lit$36$object);+                                                      (VV ~~ offset([Event; lit$36$prototype]))]}+bind 35 Event.BUBBLING_PHASE : {v : int | [(ttag([v]) = lit$36$number);+                                           ((? Prop([v])) <=> (v != 0));+                                           (v ~~ offset([Event; lit$36$BUBBLING_PHASE]))]}+bind 36 document : {VV$35$1027 : (Document  Immutable) | [(? extends_interface([VV$35$1027;+                                                                                lit$36$Document]));+                                                          (? Prop([VV$35$1027]));+                                                          (ttag([VV$35$1027]) = lit$36$object)]}+bind 37 document.documentElement : {VV : (HTMLElement  Immutable) | [(? extends_interface([VV;+                                                                                           lit$36$HTMLElement]));+                                                                     (? Prop([VV]));+                                                                     (ttag([VV]) = lit$36$object);+                                                                     (VV ~~ offset([document;+                                                                                    lit$36$documentElement]))]}+bind 38 window : {VV$35$1031 : (Window  Immutable) | [(? extends_interface([VV$35$1031;+                                                                            lit$36$Window]));+                                                      (? Prop([VV$35$1031]));+                                                      (ttag([VV$35$1031]) = lit$36$object)]}+bind 39 lq_tmp_nano_1 : {VV : (BitVec  Size32) | [(VV = (lit "#x00000008" (BitVec  Size32)))]}+bind 40 a_SSA_0 : {VV : (BitVec  Size32) | [(VV ~~ lq_tmp_nano_1);+                                            (VV = (lit "#x00000008" (BitVec  Size32)))]}+bind 41 lq_tmp_nano_2 : {VV : (BitVec  Size32) | [(VV = (lit "#x00000008" (BitVec  Size32)))]}+bind 42 b_SSA_1 : {VV : (BitVec  Size32) | [(VV ~~ lq_tmp_nano_2);+                                            (VV = (lit "#x00000008" (BitVec  Size32)))]}+bind 43 lq_tmp_nano_3 : {v : (BitVec  Size32) | [(v = bvor([a_SSA_0;+                                                            a_SSA_0]))]}+bind 44 lq_tmp_nano_6 : {v : Boolean | [(ttag([v]) = lit$36$boolean);+                                        ((? Prop([v])) <=> (b_SSA_1 ~~ lq_tmp_nano_3))]}+bind 45 lq_tmp_nano_9 : {VV$35$4 : Void | []}+++++constraint:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       36;+       5;+       21;+       37;+       6;+       22;+       38;+       7;+       23;+       39;+       8;+       24;+       40;+       9;+       25;+       41;+       10;+       26;+       42;+       11;+       27;+       43;+       12;+       28;+       44;+       13;+       29;+       14;+       30;+       15;+       31]+  lhs {VV$35$F1 : Boolean | [(ttag([VV$35$F1]) = lit$36$boolean);+                             (VV$35$F1 ~~ lq_tmp_nano_6);+                             (ttag([VV$35$F1]) = lit$36$boolean);+                             ((? Prop([VV$35$F1])) <=> (b_SSA_1 ~~ lq_tmp_nano_3))]}+  rhs {VV$35$F1 : Boolean | [(? Prop([VV$35$F1]))]}+  id 1 tag [1]+  // META constraint id 1 : /Users/rjhala/research/stack/liquid/refscript/tests/pos/simple/hex.ts:7:1-7:22+++constraint:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       36;+       5;+       21;+       37;+       6;+       22;+       38;+       7;+       23;+       39;+       8;+       24;+       40;+       9;+       25;+       41;+       10;+       26;+       42;+       11;+       27;+       43;+       12;+       28;+       44;+       13;+       29;+       14;+       30;+       15;+       31]+  lhs {VV$35$F2 : Boolean | [(ttag([VV$35$F2]) = lit$36$boolean);+                             (VV$35$F2 ~~ lq_tmp_nano_6);+                             (ttag([VV$35$F2]) = lit$36$boolean);+                             ((? Prop([VV$35$F2])) <=> (b_SSA_1 ~~ lq_tmp_nano_3))]}+  rhs {VV$35$F2 : Boolean | [(? Prop([VV$35$F2]))]}+  id 2 tag [1]+  // META constraint id 2 : /Users/rjhala/research/stack/liquid/refscript/tests/pos/simple/hex.ts:7:1-7:22+++++++++
+ tests/pos/ho00.fq view
@@ -0,0 +1,21 @@+fixpoint "--allowho"+fixpoint "--eliminate=all"++bind 1 foo : {v : func(0, [Tuple; (MapReduce.List a)]) | []}++constraint:+  env [ 1 ]+  lhs {v : int | v = 12 }+  rhs {v : int | $k0    }+  id 1 tag [6]++constraint:+  env [ ]+  lhs {v : int | $k0    }+  rhs {v : int | 10 < v }+  id 2 tag [6]++wf:+  env [ ]+  reft {v: int | $k0}+
+ tests/pos/kvar-param-poly-00.fq view
@@ -0,0 +1,26 @@++// a kvar's params can be instantiated / substituted with values of a different+// type. Here, K0(v:alpha, x:alpha) but is instantiated with int.++qualif Bog(v:a, x:a) : (x = v)++bind 1 x : {v: alpha | true}++bind 2 a : {v: int | v = 10 }+bind 3 b : {v: int | $k0[x:= a]}++constraint:+  env [ 1 ]+  lhs {v : alpha  | v = x }+  rhs {v : alpha  | $k0   } +  id 1 tag []++constraint:+  env [ 2; 3 ]+  lhs {v : int | v = b  }+  rhs {v : int | v = 10 }+  id 2 tag []++wf:+  env [ 1 ]+  reft {v: alpha | $k0}
tests/pos/len00.fq view
@@ -5,11 +5,11 @@  constant len : (func(2, [(@(0)  @(1)); int])) -bind 0 y : {v : [(Tuple int a)] | [len v >= 0]}+bind 0 yoink : {v : [(Tuple int a)] | [len v >= 0]}  constraint:   env [0]-  lhs {v : [(Tuple int a)] | [v = y] }+  lhs {v : [(Tuple int a)] | [v = yoink] }   rhs {v : [(Tuple int a)] | [$k0]   }   id 1 tag [] 
+ tests/pos/listqual.hs.fq view
@@ -0,0 +1,577 @@+qualif Append(v : [@(0)], xs : [@(0)], ys : [@(0)]): (len([v]) = (len([xs]) + len([ys]))) // "tests/pos/listqual.hs" (line 3, column 12)+qualif Fst(v : @(1), y : @(0)): (v = fst([y])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.spec" (line 29, column 8)+qualif Snd(v : @(1), y : @(0)): (v = snd([y])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.spec" (line 30, column 8)+qualif Auto(v : [int]): (len([v]) = 2) // "tests/pos/listqual.hs" (line 10, column 1)+qualif IsEmp(v : GHC.Types.Bool, xs : [@(0)]): ((? Prop([v])) <=> (len([xs]) > 0)) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 13, column 8)+qualif IsEmp(v : GHC.Types.Bool, xs : [@(0)]): ((? Prop([v])) <=> (len([xs]) = 0)) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 14, column 8)+qualif ListZ(v : [@(0)]): (len([v]) = 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 16, column 8)+qualif ListZ(v : [@(0)]): (len([v]) >= 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 17, column 8)+qualif ListZ(v : [@(0)]): (len([v]) > 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 18, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (len([v]) = len([xs])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 20, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (len([v]) >= len([xs])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 21, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (len([v]) > len([xs])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 22, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (len([v]) <= len([xs])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 23, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (len([v]) < len([xs])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 24, column 8)+qualif EqLen(v : int, xs : [@(0)]): (v = len([xs])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 26, column 8)+qualif LenEq(v : [@(0)], x : int): (x = len([v])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 27, column 8)+qualif LenDiff(v : [@(0)], x : int): (len([v]) = (x + 1)) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 28, column 8)+qualif LenDiff(v : [@(0)], x : int): (len([v]) = (x - 1)) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 29, column 8)+qualif LenAcc(v : int, xs : [@(0)], n : int): (v = (len([xs]) + n)) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/GHC/Base.hquals" (line 30, column 8)+qualif Bot(v : @(0)): (0 = 1) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 3, column 8)+qualif Bot(v : @(0)): (0 = 1) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 4, column 8)+qualif Bot(v : @(0)): (0 = 1) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 5, column 8)+qualif Bot(v : bool): (0 = 1) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 6, column 8)+qualif Bot(v : int): (0 = 1) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 7, column 8)+qualif CmpZ(v : @(0)): (v < 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 9, column 8)+qualif CmpZ(v : @(0)): (v <= 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 10, column 8)+qualif CmpZ(v : @(0)): (v > 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 11, column 8)+qualif CmpZ(v : @(0)): (v >= 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 12, column 8)+qualif CmpZ(v : @(0)): (v = 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 13, column 8)+qualif CmpZ(v : @(0)): (v != 0) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 14, column 8)+qualif Cmp(v : @(0), x : @(0)): (v < x) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 16, column 8)+qualif Cmp(v : @(0), x : @(0)): (v <= x) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 17, column 8)+qualif Cmp(v : @(0), x : @(0)): (v > x) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 18, column 8)+qualif Cmp(v : @(0), x : @(0)): (v >= x) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 19, column 8)+qualif Cmp(v : @(0), x : @(0)): (v = x) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 20, column 8)+qualif Cmp(v : @(0), x : @(0)): (v != x) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 21, column 8)+qualif One(v : int): (v = 1) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 28, column 8)+qualif True(v : bool): (? v) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 29, column 8)+qualif False(v : bool): (~ ((? v))) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 30, column 8)+qualif True1(v : GHC.Types.Bool): (? Prop([v])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 31, column 8)+qualif False1(v : GHC.Types.Bool): (~ ((? Prop([v])))) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 32, column 8)+qualif Papp(v : @(0), p : (Pred  @(0))): (? papp1([p;+                                                   v])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 35, column 8)+qualif Papp2(v : @(1), x : @(0), p : (Pred  @(1)  @(0))): (? papp2([p;+                                                                    v;+                                                                    x])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 38, column 8)+qualif Papp3(v : @(2), x : @(0), y : @(1), p : (Pred  @(2)  @(0)  @(1))): (? papp3([p;+                                                                                    v;+                                                                                    x;+                                                                                    y])) // "/Users/rjhala/research/stack/liquid/liquidhaskell/.stack-work/install/x86_64-osx/nightly-2015-09-24/7.10.2/share/x86_64-osx-ghc-7.10.2/liquidhaskell-0.5.0.2/include/Prelude.hquals" (line 41, column 8)+++cut $k__185+cut $k__172+cut $k__178+cut $k__175+cut $k__182+cut $k__162+cut $k__168+cut $k__158+cut $k__165+++constant runFun : (func(2, [(Arrow  @(0)  @(1)); @(0); @(1)]))+constant addrLen : (func(0, [int; int]))+constant xsListSelector : (func(1, [[@(0)]; [@(0)]]))+constant x_Tuple21 : (func(2, [(Tuple  @(0)  @(1)); @(0)]))+constant x_Tuple65 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(4)]))+constant x_Tuple55 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(4)]))+constant x_Tuple33 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(2)]))+constant x_Tuple77 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(6)]))+constant papp3 : (func(6, [(Pred  @(0)  @(1)  @(2));+                           @(3);+                           @(4);+                           @(5);+                           bool]))+constant x_Tuple63 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(2)]))+constant x_Tuple41 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(0)]))+constant papp4 : (func(8, [(Pred  @(0)  @(1)  @(2)  @(6));+                           @(3);+                           @(4);+                           @(5);+                           @(7);+                           bool]))+constant x_Tuple64 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(3)]))+constant autolen : (func(1, [@(0); int]))+constant x_Tuple52 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(1)]))+constant null : (func(1, [[@(0)]; bool]))+constant papp2 : (func(4, [(Pred  @(0)  @(1)); @(2); @(3); bool]))+constant x_Tuple62 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(1)]))+constant fromJust : (func(1, [(GHC.Base.Maybe  @(0)); @(0)]))+constant GHC.Types.$91$$93$$35$6m : (func(1, [[@(0)]]))+constant x_Tuple53 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(2)]))+constant x_Tuple71 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(0)]))+constant GHC.Types.$58$$35$64 : (func(1, [@(0); [@(0)]; [@(0)]]))+constant x_Tuple74 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(3)]))+constant len : (func(2, [(@(0)  @(1)); int]))+constant x_Tuple22 : (func(2, [(Tuple  @(0)  @(1)); @(1)]))+constant x_Tuple66 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(5)]))+constant x_Tuple44 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(3)]))+constant xListSelector : (func(1, [[@(0)]; @(0)]))+constant strLen : (func(0, [int; int]))+constant x_Tuple72 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(1)]))+constant isJust : (func(1, [(GHC.Base.Maybe  @(0)); bool]))+constant Prop : (func(0, [GHC.Types.Bool; bool]))+constant x_Tuple31 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(0)]))+constant x_Tuple75 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(4)]))+constant papp1 : (func(1, [(Pred  @(0)); @(0); bool]))+constant x_Tuple61 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(0)]))+constant x_Tuple43 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(2)]))+constant x_Tuple51 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(0)]))+constant GHC.Types.I$35$$35$6c : (func(0, [int; int]))+constant x_Tuple73 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(2)]))+constant x_Tuple54 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(3)]))+constant x_Tuple32 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(1)]))+constant cmp : (func(0, [GHC.Types.Ordering; GHC.Types.Ordering]))+constant x_Tuple76 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(5)]))+constant fst : (func(2, [(Tuple  @(0)  @(1)); @(0)]))+constant snd : (func(2, [(Tuple  @(0)  @(1)); @(1)]))+constant x_Tuple42 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(1)]))+++bind 0 GHC.Types.$91$$93$$35$6m : {VV : func(1, [[@(0)]]) | []}+bind 1 GHC.Types.EQ$35$6U : {VV$35$125 : GHC.Types.Ordering | [(VV$35$125 = GHC.Types.EQ$35$6U)]}+bind 2 GHC.Types.LT$35$6S : {VV$35$126 : GHC.Types.Ordering | [(VV$35$126 = GHC.Types.LT$35$6S)]}+bind 3 GHC.Types.GT$35$6W : {VV$35$127 : GHC.Types.Ordering | [(VV$35$127 = GHC.Types.GT$35$6W)]}+bind 4 GHC.Types.$91$$93$$35$6m : {VV : func(1, [[@(0)]]) | []}+bind 5 GHC.Types.GT$35$6W : {VV$35$150 : GHC.Types.Ordering | [(cmp([VV$35$150]) = GHC.Types.GT$35$6W)]}+bind 6 GHC.Types.LT$35$6S : {VV$35$151 : GHC.Types.Ordering | [(cmp([VV$35$151]) = GHC.Types.LT$35$6S)]}+bind 7 GHC.Types.EQ$35$6U : {VV$35$152 : GHC.Types.Ordering | [(cmp([VV$35$152]) = GHC.Types.EQ$35$6U)]}+bind 8 GHC.Base.Nothing$35$r1d : {VV : func(1, [(GHC.Base.Maybe  @(0))]) | []}+bind 9 ds_dwT : {VV$35$164 : [a_awA] | [$k__165;+                                        (len([VV$35$164]) >= 0)]}+bind 10 ys$35$awn : {VV$35$174 : [a_awA] | [$k__175[lq_tmp_x_187:=ds_dwT][lq_tmp_x_189:=ds_dwT][ds_dwT:=ds_dwT];+                                            (len([VV$35$174]) >= 0)]}+bind 11 lq_anf__dwU : {lq_tmp_x_195 : [a_awA] | [(lq_tmp_x_195 = ds_dwT);+                                                 (len([lq_tmp_x_195]) >= 0)]}+bind 12 lq_anf__dwU : {lq_tmp_x_198 : [a_awA] | [(lq_tmp_x_198 = ds_dwT);+                                                 (len([lq_tmp_x_198]) >= 0);+                                                 (len([lq_tmp_x_198]) >= 0)]}+bind 13 lq_anf__dwU : {lq_tmp_x_198 : [a_awA] | [(lq_tmp_x_198 = ds_dwT);+                                                 (len([lq_tmp_x_198]) >= 0);+                                                 (len([lq_tmp_x_198]) = 0);+                                                 ((? null([lq_tmp_x_198])) <=> true);+                                                 (lq_tmp_x_198 = GHC.Types.$91$$93$$35$6m([]));+                                                 (len([lq_tmp_x_198]) = 0);+                                                 ((? null([lq_tmp_x_198])) <=> true);+                                                 (len([lq_tmp_x_198]) >= 0)]}+bind 14 lq_anf__dwU : {lq_tmp_x_208 : [a_awA] | [(lq_tmp_x_208 = ds_dwT);+                                                 (len([lq_tmp_x_208]) >= 0);+                                                 (len([lq_tmp_x_208]) >= 0)]}+bind 15 x$35$awo : {VV : a_awA | [$k__158[VV$35$164:=lq_anf__dwU][lq_tmp_x_208:=lq_anf__dwU][lq_tmp_x_195:=lq_anf__dwU][VV$35$157:=VV]]}+bind 16 xs$35$awp : {lq_tmp_x_218 : [a_awA] | [(len([lq_tmp_x_218]) >= 0)]}+bind 17 lq_anf__dwU : {lq_tmp_x_208 : [a_awA] | [(lq_tmp_x_208 = ds_dwT);+                                                 (len([lq_tmp_x_208]) >= 0);+                                                 (len([lq_tmp_x_208]) = (1 + len([xs$35$awp])));+                                                 ((? null([lq_tmp_x_208])) <=> false);+                                                 (xsListSelector([lq_tmp_x_208]) = xs$35$awp);+                                                 (xListSelector([lq_tmp_x_208]) = x$35$awo);+                                                 (lq_tmp_x_208 = GHC.Types.$58$$35$64([x$35$awo;+                                                                                       xs$35$awp]));+                                                 (len([lq_tmp_x_208]) = (1 + len([xs$35$awp])));+                                                 ((? null([lq_tmp_x_208])) <=> false);+                                                 (xsListSelector([lq_tmp_x_208]) = xs$35$awp);+                                                 (xListSelector([lq_tmp_x_208]) = x$35$awo);+                                                 (len([lq_tmp_x_208]) >= 0)]}+bind 18 lq_anf__dwV : {VV$35$184 : [a_awA] | [$k__185[lq_tmp_x_187:=xs$35$awp][lq_tmp_x_189:=xs$35$awp][ds_dwT:=xs$35$awp][lq_tmp_x_188:=ys$35$awn][ys$35$awn:=ys$35$awn][lq_tmp_x_190:=ys$35$awn];+                                              (len([VV$35$184]) >= 0)]}+bind 19 lq_tmp_x_259 : {VV : a_awA | []}+bind 20 lq_anf__dwW : {lq_tmp_x_264 : int | [(lq_tmp_x_264 = (1  :  int))]}+bind 21 lq_tmp_x_278 : {VV$35$279 : int | []}+bind 22 lq_anf__dwX : {lq_tmp_x_270 : [int] | [(len([lq_tmp_x_270]) = 0);+                                               ((? null([lq_tmp_x_270])) <=> true);+                                               (len([lq_tmp_x_270]) >= 0)]}+bind 23 lq_tmp_x_296 : {VV$35$297 : int | []}+bind 24 lq_anf__dwY : {lq_tmp_x_284 : [int] | [(len([lq_tmp_x_284]) = (1 + len([lq_anf__dwX])));+                                               ((? null([lq_tmp_x_284])) <=> false);+                                               (xsListSelector([lq_tmp_x_284]) = lq_anf__dwX);+                                               (xListSelector([lq_tmp_x_284]) = lq_anf__dwW);+                                               (len([lq_tmp_x_284]) >= 0)]}+bind 25 lq_anf__dwZ : {lq_tmp_x_305 : int | [(lq_tmp_x_305 = (2  :  int))]}+bind 26 lq_tmp_x_319 : {VV$35$320 : int | []}+bind 27 lq_anf__dx0 : {lq_tmp_x_311 : [int] | [(len([lq_tmp_x_311]) = 0);+                                               ((? null([lq_tmp_x_311])) <=> true);+                                               (len([lq_tmp_x_311]) >= 0)]}+bind 28 lq_tmp_x_337 : {VV$35$338 : int | []}+bind 29 lq_anf__dx1 : {lq_tmp_x_325 : [int] | [(len([lq_tmp_x_325]) = (1 + len([lq_anf__dx0])));+                                               ((? null([lq_tmp_x_325])) <=> false);+                                               (xsListSelector([lq_tmp_x_325]) = lq_anf__dx0);+                                               (xListSelector([lq_tmp_x_325]) = lq_anf__dwZ);+                                               (len([lq_tmp_x_325]) >= 0)]}+bind 30 ListQual.boo$35$rlx : {v : [int] | [(len([v]) = 2);+                                            (len([v]) >= 0)]}+bind 31 VV$35$368 : {VV$35$368 : [int] | [$k__185[lq_tmp_x_354:=lq_anf__dx1][lq_tmp_x_187:=lq_anf__dwY][lq_tmp_x_189:=lq_anf__dwY][lq_tmp_x_353:=lq_anf__dwY][ds_dwT:=lq_anf__dwY][lq_tmp_x_350:=VV$35$368][lq_tmp_x_188:=lq_anf__dx1][ys$35$awn:=lq_anf__dx1][VV$35$184:=VV$35$368][lq_tmp_x_190:=lq_anf__dx1];+                                          (len([VV$35$368]) >= 0)]}+bind 32 VV$35$368 : {VV$35$368 : [int] | [$k__185[lq_tmp_x_354:=lq_anf__dx1][lq_tmp_x_187:=lq_anf__dwY][lq_tmp_x_189:=lq_anf__dwY][lq_tmp_x_353:=lq_anf__dwY][ds_dwT:=lq_anf__dwY][lq_tmp_x_350:=VV$35$368][lq_tmp_x_188:=lq_anf__dx1][ys$35$awn:=lq_anf__dx1][VV$35$184:=VV$35$368][lq_tmp_x_190:=lq_anf__dx1];+                                          (len([VV$35$368]) >= 0)]}+bind 33 VV$35$371 : {VV$35$371 : int | [$k__356[lq_tmp_x_354:=lq_anf__dx1][lq_tmp_x_353:=lq_anf__dwY][VV$35$355:=VV$35$371][lq_tmp_x_350:=VV$35$368][lq_tmp_x_358:=VV$35$371];+                                        $k__178[lq_tmp_x_354:=lq_anf__dx1][lq_tmp_x_187:=lq_anf__dwY][lq_tmp_x_189:=lq_anf__dwY][lq_tmp_x_353:=lq_anf__dwY][ds_dwT:=lq_anf__dwY][VV$35$177:=VV$35$371][lq_tmp_x_350:=VV$35$368][lq_tmp_x_188:=lq_anf__dx1][ys$35$awn:=lq_anf__dx1][lq_tmp_x_358:=VV$35$371][VV$35$184:=VV$35$368][lq_tmp_x_190:=lq_anf__dx1]]}+bind 34 VV$35$371 : {VV$35$371 : int | [$k__356[lq_tmp_x_354:=lq_anf__dx1][lq_tmp_x_353:=lq_anf__dwY][VV$35$355:=VV$35$371][lq_tmp_x_350:=VV$35$368][lq_tmp_x_358:=VV$35$371];+                                        $k__178[lq_tmp_x_354:=lq_anf__dx1][lq_tmp_x_187:=lq_anf__dwY][lq_tmp_x_189:=lq_anf__dwY][lq_tmp_x_353:=lq_anf__dwY][ds_dwT:=lq_anf__dwY][VV$35$177:=VV$35$371][lq_tmp_x_350:=VV$35$368][lq_tmp_x_188:=lq_anf__dx1][ys$35$awn:=lq_anf__dx1][lq_tmp_x_358:=VV$35$371][VV$35$184:=VV$35$368][lq_tmp_x_190:=lq_anf__dx1]]}+bind 35 fldList : {VV$35$374 : int | []}+bind 36 VV$35$375 : {VV$35$375 : int | [$k__182[lq_tmp_x_354:=lq_anf__dx1][lq_tmp_x_187:=lq_anf__dwY][lq_tmp_x_189:=lq_anf__dwY][lq_tmp_x_353:=lq_anf__dwY][ds_dwT:=lq_anf__dwY][VV$35$181:=VV$35$375][lq_tmp_x_350:=VV$35$368][lq_tmp_x_188:=lq_anf__dx1][ys$35$awn:=lq_anf__dx1][lq_tmp_x_180:=fldList][lq_tmp_x_349:=fldList][lq_tmp_x_358:=VV$35$375][VV$35$184:=VV$35$368][lq_tmp_x_190:=lq_anf__dx1]]}+bind 37 VV$35$375 : {VV$35$375 : int | [$k__182[lq_tmp_x_354:=lq_anf__dx1][lq_tmp_x_187:=lq_anf__dwY][lq_tmp_x_189:=lq_anf__dwY][lq_tmp_x_353:=lq_anf__dwY][ds_dwT:=lq_anf__dwY][VV$35$181:=VV$35$375][lq_tmp_x_350:=VV$35$368][lq_tmp_x_188:=lq_anf__dx1][ys$35$awn:=lq_anf__dx1][lq_tmp_x_180:=fldList][lq_tmp_x_349:=fldList][lq_tmp_x_358:=VV$35$375][VV$35$184:=VV$35$368][lq_tmp_x_190:=lq_anf__dx1]]}+bind 38 VV$35$378 : {VV$35$378 : [int] | [(VV$35$378 = lq_anf__dx1);+                                          (len([VV$35$378]) >= 0)]}+bind 39 VV$35$378 : {VV$35$378 : [int] | [(VV$35$378 = lq_anf__dx1);+                                          (len([VV$35$378]) >= 0)]}+bind 40 VV$35$381 : {VV$35$381 : int | [$k__331[lq_tmp_x_329:=lq_anf__dx0][lq_tmp_x_363:=VV$35$381][VV$35$330:=VV$35$381][lq_tmp_x_366:=VV$35$378][lq_tmp_x_328:=lq_anf__dwZ][lq_tmp_x_333:=VV$35$381][lq_tmp_x_325:=VV$35$378]]}+bind 41 VV$35$381 : {VV$35$381 : int | [$k__331[lq_tmp_x_329:=lq_anf__dx0][lq_tmp_x_363:=VV$35$381][VV$35$330:=VV$35$381][lq_tmp_x_366:=VV$35$378][lq_tmp_x_328:=lq_anf__dwZ][lq_tmp_x_333:=VV$35$381][lq_tmp_x_325:=VV$35$378]]}+bind 42 lq_tmp_x_347 : {VV$35$384 : int | []}+bind 43 VV$35$385 : {VV$35$385 : int | [$k__335[lq_tmp_x_365:=VV$35$385][lq_tmp_x_329:=lq_anf__dx0][lq_tmp_x_324:=lq_tmp_x_347][lq_tmp_x_364:=lq_tmp_x_347][lq_tmp_x_366:=VV$35$378][lq_tmp_x_328:=lq_anf__dwZ][lq_tmp_x_333:=VV$35$385][lq_tmp_x_337:=lq_tmp_x_347][lq_tmp_x_325:=VV$35$378][VV$35$334:=VV$35$385]]}+bind 44 VV$35$385 : {VV$35$385 : int | [$k__335[lq_tmp_x_365:=VV$35$385][lq_tmp_x_329:=lq_anf__dx0][lq_tmp_x_324:=lq_tmp_x_347][lq_tmp_x_364:=lq_tmp_x_347][lq_tmp_x_366:=VV$35$378][lq_tmp_x_328:=lq_anf__dwZ][lq_tmp_x_333:=VV$35$385][lq_tmp_x_337:=lq_tmp_x_347][lq_tmp_x_325:=VV$35$378][VV$35$334:=VV$35$385]]}+bind 45 VV$35$388 : {VV$35$388 : [int] | [(VV$35$388 = lq_anf__dwY);+                                          (len([VV$35$388]) >= 0)]}+bind 46 VV$35$388 : {VV$35$388 : [int] | [(VV$35$388 = lq_anf__dwY);+                                          (len([VV$35$388]) >= 0)]}+bind 47 VV$35$391 : {VV$35$391 : int | [$k__290[VV$35$289:=VV$35$391][lq_tmp_x_288:=lq_anf__dwX][lq_tmp_x_292:=VV$35$391][lq_tmp_x_362:=VV$35$388][lq_tmp_x_359:=VV$35$391][lq_tmp_x_284:=VV$35$388][lq_tmp_x_287:=lq_anf__dwW]]}+bind 48 VV$35$391 : {VV$35$391 : int | [$k__290[VV$35$289:=VV$35$391][lq_tmp_x_288:=lq_anf__dwX][lq_tmp_x_292:=VV$35$391][lq_tmp_x_362:=VV$35$388][lq_tmp_x_359:=VV$35$391][lq_tmp_x_284:=VV$35$388][lq_tmp_x_287:=lq_anf__dwW]]}+bind 49 lq_tmp_x_345 : {VV$35$394 : int | []}+bind 50 VV$35$395 : {VV$35$395 : int | [$k__294[lq_tmp_x_361:=VV$35$395][lq_tmp_x_288:=lq_anf__dwX][lq_tmp_x_360:=lq_tmp_x_345][VV$35$293:=VV$35$395][lq_tmp_x_292:=VV$35$395][lq_tmp_x_362:=VV$35$388][lq_tmp_x_296:=lq_tmp_x_345][lq_tmp_x_283:=lq_tmp_x_345][lq_tmp_x_284:=VV$35$388][lq_tmp_x_287:=lq_anf__dwW]]}+bind 51 VV$35$395 : {VV$35$395 : int | [$k__294[lq_tmp_x_361:=VV$35$395][lq_tmp_x_288:=lq_anf__dwX][lq_tmp_x_360:=lq_tmp_x_345][VV$35$293:=VV$35$395][lq_tmp_x_292:=VV$35$395][lq_tmp_x_362:=VV$35$388][lq_tmp_x_296:=lq_tmp_x_345][lq_tmp_x_283:=lq_tmp_x_345][lq_tmp_x_284:=VV$35$388][lq_tmp_x_287:=lq_anf__dwW]]}+bind 52 VV$35$398 : {VV$35$398 : [int] | [(VV$35$398 = lq_anf__dx0);+                                          (len([VV$35$398]) >= 0)]}+bind 53 VV$35$398 : {VV$35$398 : [int] | [(VV$35$398 = lq_anf__dx0);+                                          (len([VV$35$398]) >= 0)]}+bind 54 VV$35$401 : {VV$35$401 : int | [$k__313[lq_tmp_x_340:=VV$35$401][lq_tmp_x_343:=VV$35$398][VV$35$312:=VV$35$401][lq_tmp_x_311:=VV$35$398][lq_tmp_x_315:=VV$35$401]]}+bind 55 VV$35$401 : {VV$35$401 : int | [$k__313[lq_tmp_x_340:=VV$35$401][lq_tmp_x_343:=VV$35$398][VV$35$312:=VV$35$401][lq_tmp_x_311:=VV$35$398][lq_tmp_x_315:=VV$35$401]]}+bind 56 lq_tmp_x_322 : {VV$35$404 : int | []}+bind 57 VV$35$405 : {VV$35$405 : int | [$k__317[lq_tmp_x_342:=VV$35$405][lq_tmp_x_343:=VV$35$398][lq_tmp_x_341:=lq_tmp_x_322][VV$35$316:=VV$35$405][lq_tmp_x_319:=lq_tmp_x_322][lq_tmp_x_311:=VV$35$398][lq_tmp_x_310:=lq_tmp_x_322][lq_tmp_x_315:=VV$35$405]]}+bind 58 VV$35$405 : {VV$35$405 : int | [$k__317[lq_tmp_x_342:=VV$35$405][lq_tmp_x_343:=VV$35$398][lq_tmp_x_341:=lq_tmp_x_322][VV$35$316:=VV$35$405][lq_tmp_x_319:=lq_tmp_x_322][lq_tmp_x_311:=VV$35$398][lq_tmp_x_310:=lq_tmp_x_322][lq_tmp_x_315:=VV$35$405]]}+bind 59 VV$35$408 : {VV$35$408 : int | [(VV$35$408 = lq_anf__dwZ)]}+bind 60 VV$35$408 : {VV$35$408 : int | [(VV$35$408 = lq_anf__dwZ)]}+bind 61 VV$35$411 : {VV$35$411 : int | [(VV$35$411 = 2)]}+bind 62 VV$35$411 : {VV$35$411 : int | [(VV$35$411 = 2)]}+bind 63 VV$35$414 : {VV$35$414 : [int] | [(VV$35$414 = lq_anf__dwX);+                                          (len([VV$35$414]) >= 0)]}+bind 64 VV$35$414 : {VV$35$414 : [int] | [(VV$35$414 = lq_anf__dwX);+                                          (len([VV$35$414]) >= 0)]}+bind 65 VV$35$417 : {VV$35$417 : int | [$k__272[lq_tmp_x_274:=VV$35$417][VV$35$271:=VV$35$417][lq_tmp_x_302:=VV$35$414][lq_tmp_x_299:=VV$35$417][lq_tmp_x_270:=VV$35$414]]}+bind 66 VV$35$417 : {VV$35$417 : int | [$k__272[lq_tmp_x_274:=VV$35$417][VV$35$271:=VV$35$417][lq_tmp_x_302:=VV$35$414][lq_tmp_x_299:=VV$35$417][lq_tmp_x_270:=VV$35$414]]}+bind 67 lq_tmp_x_281 : {VV$35$420 : int | []}+bind 68 VV$35$421 : {VV$35$421 : int | [$k__276[lq_tmp_x_269:=lq_tmp_x_281][VV$35$275:=VV$35$421][lq_tmp_x_274:=VV$35$421][lq_tmp_x_301:=VV$35$421][lq_tmp_x_302:=VV$35$414][lq_tmp_x_300:=lq_tmp_x_281][lq_tmp_x_278:=lq_tmp_x_281][lq_tmp_x_270:=VV$35$414]]}+bind 69 VV$35$421 : {VV$35$421 : int | [$k__276[lq_tmp_x_269:=lq_tmp_x_281][VV$35$275:=VV$35$421][lq_tmp_x_274:=VV$35$421][lq_tmp_x_301:=VV$35$421][lq_tmp_x_302:=VV$35$414][lq_tmp_x_300:=lq_tmp_x_281][lq_tmp_x_278:=lq_tmp_x_281][lq_tmp_x_270:=VV$35$414]]}+bind 70 VV$35$424 : {VV$35$424 : int | [(VV$35$424 = lq_anf__dwW)]}+bind 71 VV$35$424 : {VV$35$424 : int | [(VV$35$424 = lq_anf__dwW)]}+bind 72 VV$35$427 : {VV$35$427 : int | [(VV$35$427 = 1)]}+bind 73 VV$35$427 : {VV$35$427 : int | [(VV$35$427 = 1)]}+bind 74 VV$35$430 : {VV$35$430 : [a_awA] | [(len([VV$35$430]) = (1 + len([lq_anf__dwV])));+                                            ((? null([VV$35$430])) <=> false);+                                            (xsListSelector([VV$35$430]) = lq_anf__dwV);+                                            (xListSelector([VV$35$430]) = x$35$awo);+                                            (len([VV$35$430]) >= 0)]}+bind 75 VV$35$430 : {VV$35$430 : [a_awA] | [(len([VV$35$430]) = (1 + len([lq_anf__dwV])));+                                            ((? null([VV$35$430])) <=> false);+                                            (xsListSelector([VV$35$430]) = lq_anf__dwV);+                                            (xListSelector([VV$35$430]) = x$35$awo);+                                            (len([VV$35$430]) >= 0)]}+bind 76 VV$35$253 : {VV$35$253 : a_awA | [$k__254[lq_tmp_x_252:=lq_anf__dwV][lq_tmp_x_248:=VV$35$430][lq_tmp_x_251:=x$35$awo]]}+bind 77 lq_tmp_x_180 : {VV : a_awA | []}+bind 78 VV$35$253 : {VV$35$253 : a_awA | [$k__257[lq_tmp_x_252:=lq_anf__dwV][VV$35$256:=VV$35$253][lq_tmp_x_248:=VV$35$430][lq_tmp_x_259:=lq_tmp_x_180][lq_tmp_x_247:=lq_tmp_x_180][lq_tmp_x_251:=x$35$awo]]}+bind 79 VV$35$436 : {VV$35$436 : [a_awA] | [(VV$35$436 = lq_anf__dwV);+                                            (len([VV$35$436]) >= 0)]}+bind 80 VV$35$436 : {VV$35$436 : [a_awA] | [(VV$35$436 = lq_anf__dwV);+                                            (len([VV$35$436]) >= 0)]}+bind 81 VV$35$237 : {VV$35$237 : a_awA | [$k__238[lq_tmp_x_262:=VV$35$436][lq_tmp_x_189:=xs$35$awp][VV$35$184:=VV$35$436][lq_tmp_x_190:=ys$35$awn];+                                          $k__178[lq_tmp_x_262:=VV$35$436][lq_tmp_x_187:=xs$35$awp][lq_tmp_x_189:=xs$35$awp][ds_dwT:=xs$35$awp][VV$35$177:=VV$35$237][lq_tmp_x_188:=ys$35$awn][ys$35$awn:=ys$35$awn][VV$35$184:=VV$35$436][lq_tmp_x_190:=ys$35$awn]]}+bind 82 lq_tmp_x_245 : {VV : a_awA | []}+bind 83 VV$35$237 : {VV$35$237 : a_awA | [$k__182[lq_tmp_x_262:=VV$35$436][lq_tmp_x_187:=xs$35$awp][lq_tmp_x_189:=xs$35$awp][ds_dwT:=xs$35$awp][VV$35$181:=VV$35$237][lq_tmp_x_261:=lq_tmp_x_245][lq_tmp_x_188:=ys$35$awn][ys$35$awn:=ys$35$awn][lq_tmp_x_180:=lq_tmp_x_245][VV$35$184:=VV$35$436][lq_tmp_x_190:=ys$35$awn]]}+bind 84 VV : {VV : a_awA | [(VV = x$35$awo)]}+bind 85 VV$35$443 : {VV$35$443 : [a_awA] | [(VV$35$443 = ys$35$awn);+                                            (len([VV$35$443]) >= 0)]}+bind 86 VV$35$443 : {VV$35$443 : [a_awA] | [(VV$35$443 = ys$35$awn);+                                            (len([VV$35$443]) >= 0)]}+bind 87 VV : {VV : a_awA | [$k__168[lq_tmp_x_187:=ds_dwT][VV$35$167:=VV][lq_tmp_x_189:=ds_dwT][ds_dwT:=ds_dwT][lq_tmp_x_243:=VV$35$443][VV$35$174:=VV$35$443]]}+bind 88 lq_tmp_x_170 : {VV : a_awA | []}+bind 89 VV : {VV : a_awA | [$k__172[lq_tmp_x_187:=ds_dwT][lq_tmp_x_189:=ds_dwT][lq_tmp_x_242:=lq_tmp_x_170][ds_dwT:=ds_dwT][lq_tmp_x_243:=VV$35$443][lq_tmp_x_170:=lq_tmp_x_170][VV$35$174:=VV$35$443][VV$35$171:=VV]]}+bind 90 VV$35$449 : {VV$35$449 : [a_awA] | [(VV$35$449 = xs$35$awp);+                                            (len([VV$35$449]) >= 0)]}+bind 91 VV$35$449 : {VV$35$449 : [a_awA] | [(VV$35$449 = xs$35$awp);+                                            (len([VV$35$449]) >= 0)]}+bind 92 VV : {VV : a_awA | [$k__158[lq_tmp_x_215:=x$35$awo][lq_tmp_x_218:=VV$35$449][VV$35$164:=lq_anf__dwU][lq_tmp_x_208:=lq_anf__dwU][lq_tmp_x_241:=VV$35$449][lq_tmp_x_195:=lq_anf__dwU][VV$35$157:=VV];+                            $k__162[lq_tmp_x_215:=x$35$awo][lq_tmp_x_218:=VV$35$449][VV$35$164:=lq_anf__dwU][lq_tmp_x_207:=x$35$awo][lq_tmp_x_208:=lq_anf__dwU][VV$35$161:=VV][lq_tmp_x_160:=x$35$awo][lq_tmp_x_241:=VV$35$449][lq_tmp_x_195:=lq_anf__dwU][lq_tmp_x_194:=x$35$awo]]}+bind 93 lq_tmp_x_160 : {VV : a_awA | []}+bind 94 VV : {VV : a_awA | [$k__162[lq_tmp_x_215:=x$35$awo][lq_tmp_x_218:=VV$35$449][VV$35$164:=lq_anf__dwU][lq_tmp_x_207:=lq_tmp_x_160][lq_tmp_x_208:=lq_anf__dwU][VV$35$161:=VV][lq_tmp_x_160:=lq_tmp_x_160][lq_tmp_x_241:=VV$35$449][lq_tmp_x_217:=lq_tmp_x_160][lq_tmp_x_195:=lq_anf__dwU][lq_tmp_x_240:=lq_tmp_x_160][lq_tmp_x_194:=lq_tmp_x_160]]}+bind 95 VV$35$455 : {VV$35$455 : [a_awA] | [(VV$35$455 = ys$35$awn);+                                            (len([VV$35$455]) >= 0)]}+bind 96 VV$35$455 : {VV$35$455 : [a_awA] | [(VV$35$455 = ys$35$awn);+                                            (len([VV$35$455]) >= 0)]}+bind 97 VV : {VV : a_awA | [$k__168[lq_tmp_x_187:=ds_dwT][VV$35$167:=VV][lq_tmp_x_189:=ds_dwT][lq_tmp_x_206:=VV$35$455][ds_dwT:=ds_dwT][VV$35$174:=VV$35$455]]}+bind 98 lq_tmp_x_180 : {VV : a_awA | []}+bind 99 VV : {VV : a_awA | [$k__172[lq_tmp_x_187:=ds_dwT][lq_tmp_x_189:=ds_dwT][lq_tmp_x_206:=VV$35$455][ds_dwT:=ds_dwT][lq_tmp_x_205:=lq_tmp_x_180][lq_tmp_x_170:=lq_tmp_x_180][VV$35$174:=VV$35$455][VV$35$171:=VV]]}+bind 100 VV$35$355 : {VV$35$355 : int | [$k__356]}+bind 101 VV$35$334 : {VV$35$334 : int | [$k__335]}+bind 102 VV$35$330 : {VV$35$330 : int | [$k__331]}+bind 103 VV$35$316 : {VV$35$316 : int | [$k__317]}+bind 104 VV$35$312 : {VV$35$312 : int | [$k__313]}+bind 105 VV$35$293 : {VV$35$293 : int | [$k__294]}+bind 106 VV$35$289 : {VV$35$289 : int | [$k__290]}+bind 107 VV$35$275 : {VV$35$275 : int | [$k__276]}+bind 108 VV$35$271 : {VV$35$271 : int | [$k__272]}+bind 109 VV$35$164 : {VV$35$164 : [a_awA] | [$k__165;+                                             (len([VV$35$164]) >= 0)]}+bind 110 lq_tmp_x_160 : {VV : a_awA | []}+bind 111 ds_dwT : {VV$35$164 : [a_awA] | [$k__165;+                                          (len([VV$35$164]) >= 0)]}+bind 112 VV$35$174 : {VV$35$174 : [a_awA] | [$k__175;+                                             (len([VV$35$174]) >= 0)]}+bind 113 lq_tmp_x_170 : {VV : a_awA | []}+bind 114 ys$35$awn : {VV$35$174 : [a_awA] | [$k__175;+                                             (len([VV$35$174]) >= 0)]}+bind 115 VV$35$184 : {VV$35$184 : [a_awA] | [$k__185;+                                             (len([VV$35$184]) >= 0)]}+bind 116 lq_tmp_x_180 : {VV : a_awA | []}+++++constraint:+  env [0; 64; 1; 2; 3; 67; 4; 20; 68; 5; 6; 22; 7; 8]+  lhs {VV$35$F16 : int | [$k__276[VV$35$421:=VV$35$F16][lq_tmp_x_269:=lq_tmp_x_281][VV$35$275:=VV$35$F16][lq_tmp_x_274:=VV$35$F16][lq_tmp_x_301:=VV$35$F16][VV$35$F:=VV$35$F16][lq_tmp_x_302:=VV$35$414][lq_tmp_x_300:=lq_tmp_x_281][lq_tmp_x_278:=lq_tmp_x_281][lq_tmp_x_270:=VV$35$414]]}+  rhs {VV$35$F16 : int | [$k__294[VV$35$421:=VV$35$F16][lq_tmp_x_282:=VV$35$414][VV$35$F:=VV$35$F16][VV$35$293:=VV$35$F16][lq_tmp_x_292:=VV$35$F16][lq_tmp_x_296:=lq_tmp_x_281][lq_tmp_x_287:=lq_anf__dwW]]}+  id 16 tag [2]+  // META constraint id 16 : tests/pos/listqual.hs:10:1-3+++constraint:+  env [0; 1; 2; 3; 4; 20; 5; 6; 22; 7; 8; 24; 25; 27; 29; 31]+  lhs {VV$35$F1 : [int] | [$k__185[lq_tmp_x_354:=lq_anf__dx1][lq_tmp_x_187:=lq_anf__dwY][lq_tmp_x_189:=lq_anf__dwY][lq_tmp_x_353:=lq_anf__dwY][ds_dwT:=lq_anf__dwY][VV$35$F:=VV$35$F1][lq_tmp_x_350:=VV$35$F1][VV$35$368:=VV$35$F1][lq_tmp_x_188:=lq_anf__dx1][ys$35$awn:=lq_anf__dx1][VV$35$184:=VV$35$F1][lq_tmp_x_190:=lq_anf__dx1];+                           (len([VV$35$F1]) >= 0)]}+  rhs {VV$35$F1 : [int] | [(len([VV$35$F1]) = 2)]}+  id 1 tag [2]+  // META constraint id 1 : tests/pos/listqual.hs:10:1-20+++constraint:+  env [0; 1; 2; 3; 4; 20; 5; 6; 22; 70; 7; 8]+  lhs {VV$35$F17 : int | [(VV$35$F17 = lq_anf__dwW)]}+  rhs {VV$35$F17 : int | [$k__290[VV$35$424:=VV$35$F17][VV$35$289:=VV$35$F17][VV$35$F:=VV$35$F17][lq_tmp_x_292:=VV$35$F17]]}+  id 17 tag [2]+  // META constraint id 17 : tests/pos/listqual.hs:10:15+++constraint:+  env [0; 16; 1; 17; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 91; 92; 14; 15]+  lhs {VV$35$F33 : a_awA | [$k__158[lq_tmp_x_215:=x$35$awo][VV:=VV$35$F33][lq_tmp_x_218:=VV$35$449][VV$35$164:=lq_anf__dwU][lq_tmp_x_208:=lq_anf__dwU][lq_tmp_x_241:=VV$35$449][VV$35$F:=VV$35$F33][lq_tmp_x_195:=lq_anf__dwU][VV$35$157:=VV$35$F33];+                            $k__162[lq_tmp_x_215:=x$35$awo][VV:=VV$35$F33][lq_tmp_x_218:=VV$35$449][VV$35$164:=lq_anf__dwU][lq_tmp_x_207:=x$35$awo][lq_tmp_x_208:=lq_anf__dwU][VV$35$161:=VV$35$F33][lq_tmp_x_160:=x$35$awo][lq_tmp_x_241:=VV$35$449][VV$35$F:=VV$35$F33][lq_tmp_x_195:=lq_anf__dwU][lq_tmp_x_194:=x$35$awo]]}+  rhs {VV$35$F33 : a_awA | [$k__158[VV$35$164:=VV$35$449][VV$35$F:=VV$35$F33][VV$35$237:=VV$35$F33][VV$35$157:=VV$35$F33]]}+  id 33 tag [1]+  // META constraint id 33 : tests/pos/listqual.hs:6:31-32+++constraint:+  env [0; 1; 2; 3; 4; 20; 5; 6; 22; 38; 7; 8; 24; 25; 27; 29]+  lhs {VV$35$F2 : [int] | [(VV$35$F2 = lq_anf__dx1);+                           (len([VV$35$F2]) >= 0)]}+  rhs {VV$35$F2 : [int] | [$k__175[lq_tmp_x_187:=lq_anf__dwY][lq_tmp_x_189:=lq_anf__dwY][lq_tmp_x_353:=lq_anf__dwY][ds_dwT:=lq_anf__dwY][VV$35$F:=VV$35$F2][lq_tmp_x_348:=VV$35$F2][VV$35$174:=VV$35$F2][VV$35$378:=VV$35$F2]]}+  id 2 tag [2]+  // META constraint id 2 : tests/pos/listqual.hs:10:18-20+++constraint:+  env [0; 16; 1; 17; 2; 18; 3; 4; 5; 6; 7; 8; 9; 10; 74; 11; 14; 15]+  lhs {VV$35$F18 : [a_awA] | [(len([VV$35$F18]) = (1 + len([lq_anf__dwV])));+                              ((? null([VV$35$F18])) <=> false);+                              (xsListSelector([VV$35$F18]) = lq_anf__dwV);+                              (xListSelector([VV$35$F18]) = x$35$awo);+                              (len([VV$35$F18]) >= 0)]}+  rhs {VV$35$F18 : [a_awA] | [$k__185[lq_tmp_x_187:=ds_dwT][lq_tmp_x_189:=ds_dwT][VV$35$430:=VV$35$F18][ds_dwT:=ds_dwT][VV$35$F:=VV$35$F18][lq_tmp_x_188:=ys$35$awn][ys$35$awn:=ys$35$awn][VV$35$184:=VV$35$F18][lq_tmp_x_190:=ys$35$awn]]}+  id 18 tag [1]+  // META constraint id 18 : tests/pos/listqual.hs:6:20-35+++constraint:+  env [0;+       16;+       1;+       17;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       93;+       14;+       94;+       15]+  lhs {VV$35$F34 : a_awA | [$k__162[lq_tmp_x_215:=x$35$awo][VV:=VV$35$F34][lq_tmp_x_218:=VV$35$449][VV$35$164:=lq_anf__dwU][lq_tmp_x_207:=lq_tmp_x_160][lq_tmp_x_208:=lq_anf__dwU][VV$35$161:=VV$35$F34][lq_tmp_x_160:=lq_tmp_x_160][lq_tmp_x_241:=VV$35$449][VV$35$F:=VV$35$F34][lq_tmp_x_217:=lq_tmp_x_160][lq_tmp_x_195:=lq_anf__dwU][lq_tmp_x_240:=lq_tmp_x_160][lq_tmp_x_194:=lq_tmp_x_160]]}+  rhs {VV$35$F34 : a_awA | [$k__162[VV$35$164:=VV$35$449][VV$35$161:=VV$35$F34][VV$35$F:=VV$35$F34][VV$35$237:=VV$35$F34]]}+  id 34 tag [1]+  // META constraint id 34 : tests/pos/listqual.hs:6:31-32+++constraint:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 95]+  lhs {VV$35$F35 : [a_awA] | [(VV$35$F35 = ys$35$awn);+                              (len([VV$35$F35]) >= 0)]}+  rhs {VV$35$F35 : [a_awA] | [$k__185[lq_tmp_x_187:=ds_dwT][lq_tmp_x_189:=ds_dwT][ds_dwT:=ds_dwT][VV$35$F:=VV$35$F35][VV$35$455:=VV$35$F35][lq_tmp_x_188:=ys$35$awn][ys$35$awn:=ys$35$awn][VV$35$184:=VV$35$F35][lq_tmp_x_190:=ys$35$awn]]}+  id 35 tag [1]+  // META constraint id 35 : tests/pos/listqual.hs:5:20-21+++constraint:+  env [0; 1; 2; 3; 4; 20; 5; 6; 22; 7; 8; 24; 25; 27; 29; 45]+  lhs {VV$35$F6 : [int] | [(VV$35$F6 = lq_anf__dwY);+                           (len([VV$35$F6]) >= 0)]}+  rhs {VV$35$F6 : [int] | [$k__165[VV$35$164:=VV$35$F6][VV$35$F:=VV$35$F6][lq_tmp_x_346:=VV$35$F6][VV$35$388:=VV$35$F6]]}+  id 6 tag [2]+  // META constraint id 6 : tests/pos/listqual.hs:10:14-16+++constraint:+  env [0; 1; 2; 3; 4; 20; 5; 6; 22; 7; 8; 24; 25; 27; 29; 46; 47]+  lhs {VV$35$F8 : int | [$k__290[VV$35$289:=VV$35$F8][lq_tmp_x_288:=lq_anf__dwX][VV$35$F:=VV$35$F8][lq_tmp_x_292:=VV$35$F8][lq_tmp_x_362:=VV$35$388][lq_tmp_x_359:=VV$35$F8][lq_tmp_x_284:=VV$35$388][VV$35$391:=VV$35$F8][lq_tmp_x_287:=lq_anf__dwW]]}+  rhs {VV$35$F8 : int | [$k__158[VV$35$164:=VV$35$388][VV$35$F:=VV$35$F8][lq_tmp_x_346:=VV$35$388][VV$35$157:=VV$35$F8][lq_tmp_x_358:=VV$35$F8][VV$35$391:=VV$35$F8]]}+  id 8 tag [2]+  // META constraint id 8 : tests/pos/listqual.hs:10:14-16+++constraint:+  env [0; 1; 49; 2; 50; 3; 4; 20; 5; 6; 22; 7; 8; 24; 25; 27; 29; 46]+  lhs {VV$35$F9 : int | [$k__294[lq_tmp_x_361:=VV$35$F9][lq_tmp_x_288:=lq_anf__dwX][VV$35$F:=VV$35$F9][lq_tmp_x_360:=lq_tmp_x_345][VV$35$293:=VV$35$F9][lq_tmp_x_292:=VV$35$F9][VV$35$395:=VV$35$F9][lq_tmp_x_362:=VV$35$388][lq_tmp_x_296:=lq_tmp_x_345][lq_tmp_x_283:=lq_tmp_x_345][lq_tmp_x_284:=VV$35$388][lq_tmp_x_287:=lq_anf__dwW]]}+  rhs {VV$35$F9 : int | [$k__162[VV$35$164:=VV$35$388][VV$35$161:=VV$35$F9][lq_tmp_x_160:=lq_tmp_x_345][VV$35$F:=VV$35$F9][lq_tmp_x_346:=VV$35$388][VV$35$395:=VV$35$F9][lq_tmp_x_358:=VV$35$F9]]}+  id 9 tag [2]+  // META constraint id 9 : tests/pos/listqual.hs:10:14-16+++constraint:+  env [0; 16; 1; 17; 2; 3; 4; 5; 85; 6; 7; 8; 9; 10; 11; 14; 15]+  lhs {VV$35$F25 : [a_awA] | [(VV$35$F25 = ys$35$awn);+                              (len([VV$35$F25]) >= 0)]}+  rhs {VV$35$F25 : [a_awA] | [$k__175[lq_tmp_x_187:=xs$35$awp][lq_tmp_x_189:=xs$35$awp][ds_dwT:=xs$35$awp][VV$35$F:=VV$35$F25][VV$35$174:=VV$35$F25][VV$35$443:=VV$35$F25]]}+  id 25 tag [1]+  // META constraint id 25 : tests/pos/listqual.hs:6:34-35+++constraint:+  env [0; 16; 1; 17; 2; 3; 4; 5; 6; 7; 8; 9; 10; 90; 11; 14; 15]+  lhs {VV$35$F29 : [a_awA] | [(VV$35$F29 = xs$35$awp);+                              (len([VV$35$F29]) >= 0)]}+  rhs {VV$35$F29 : [a_awA] | [$k__165[VV$35$164:=VV$35$F29][VV$35$F:=VV$35$F29][VV$35$449:=VV$35$F29]]}+  id 29 tag [1]+  // META constraint id 29 : tests/pos/listqual.hs:6:31-32+++constraint:+  env [0; 64; 1; 65; 2; 3; 4; 20; 5; 6; 22; 7; 8]+  lhs {VV$35$F14 : int | [$k__272[lq_tmp_x_274:=VV$35$F14][VV$35$271:=VV$35$F14][VV$35$F:=VV$35$F14][lq_tmp_x_302:=VV$35$414][VV$35$417:=VV$35$F14][lq_tmp_x_299:=VV$35$F14][lq_tmp_x_270:=VV$35$414]]}+  rhs {VV$35$F14 : int | [$k__290[lq_tmp_x_282:=VV$35$414][VV$35$289:=VV$35$F14][VV$35$F:=VV$35$F14][VV$35$417:=VV$35$F14][lq_tmp_x_292:=VV$35$F14][lq_tmp_x_287:=lq_anf__dwW]]}+  id 14 tag [2]+  // META constraint id 14 : tests/pos/listqual.hs:10:1-3+++constraint:+  env [0; 16; 1; 17; 2; 3; 4; 5; 6; 7; 8; 9; 10; 90; 11; 14; 15]+  lhs {VV$35$F30 : [a_awA] | [(VV$35$F30 = xs$35$awp);+                              (len([VV$35$F30]) >= 0)]}+  rhs {VV$35$F30 : [a_awA] | [(len([VV$35$F30]) < len([ds_dwT]))]}+  id 30 tag [1]+  // META constraint id 30 : tests/pos/listqual.hs:6:31-32+++constraint:+  env [0; 64; 1; 65; 2; 3; 4; 20; 5; 6; 22; 7; 8]+  lhs {VV$35$F15 : int | [$k__272[lq_tmp_x_274:=VV$35$F15][VV$35$271:=VV$35$F15][VV$35$F:=VV$35$F15][lq_tmp_x_302:=VV$35$414][VV$35$417:=VV$35$F15][lq_tmp_x_299:=VV$35$F15][lq_tmp_x_270:=VV$35$414]]}+  rhs {VV$35$F15 : int | [$k__294[lq_tmp_x_282:=VV$35$414][VV$35$F:=VV$35$F15][VV$35$417:=VV$35$F15][VV$35$293:=VV$35$F15][lq_tmp_x_292:=VV$35$F15][lq_tmp_x_296:=lq_anf__dwW][lq_tmp_x_287:=lq_anf__dwW]]}+  id 15 tag [2]+  // META constraint id 15 : tests/pos/listqual.hs:10:1-3+++constraint:+  env [0; 16; 1; 17; 2; 3; 4; 5; 6; 7; 8; 9; 10; 90; 11; 14; 15]+  lhs {VV$35$F31 : [a_awA] | [(VV$35$F31 = xs$35$awp);+                              (len([VV$35$F31]) >= 0)]}+  rhs {VV$35$F31 : [a_awA] | [(len([VV$35$F31]) >= 0)]}+  id 31 tag [1]+  // META constraint id 31 : tests/pos/listqual.hs:6:31-32+++++wf:+  env [0; 1; 2; 3; 4; 20; 5; 6; 22; 7; 23; 8]+  reft {VV$35$293 : int | [$k__294]}+  +  // META wf  : tests/pos/listqual.hs:10:1-3+++wf:+  env [0; 1; 2; 3; 4; 20; 5; 6; 22; 7; 8]+  reft {VV$35$289 : int | [$k__290]}+  +  // META wf  : tests/pos/listqual.hs:10:1-3+++wf:+  env [0; 1; 2; 3; 4; 20; 5; 21; 6; 7; 8]+  reft {VV$35$275 : int | [$k__276]}+  +  // META wf  : tests/pos/listqual.hs:10:1-3+++wf:+  env [0; 1; 2; 3; 4; 20; 5; 6; 7; 8]+  reft {VV$35$271 : int | [$k__272]}+  +  // META wf  : tests/pos/listqual.hs:10:1-3+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8]+  reft {VV$35$164 : [a_awA] | [$k__165]}+  +  // META wf  : <no location info>+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 109]+  reft {VV$35$157 : a_awA | [$k__158]}+  +  // META wf  : <no location info>+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 110]+  reft {VV$35$161 : a_awA | [$k__162]}+  +  // META wf  : <no location info>+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 111]+  reft {VV$35$174 : [a_awA] | [$k__175]}+  +  // META wf  : <no location info>+++wf:+  env [0; 1; 2; 114; 3; 4; 5; 6; 7; 8; 111]+  reft {VV$35$184 : [a_awA] | [$k__185]}+  +  // META wf  : <no location info>+++++++
tests/pos/literals.fq view
@@ -3,6 +3,9 @@ constant lit#bar : (Str) constant lit#foo : (Str) +distinct lit#bar : (Str)+distinct lit#foo : (Str)+ constraint:   env []   lhs {VV#F1 : int | []}
+ tests/pos/literals01.fq view
@@ -0,0 +1,9 @@++constant lit$cat : (Str)+distinct lit$cat : (Str)++constraint:+  env []+  lhs {v : Str | v = lit$cat }+  rhs {v : Str | strLen v = 3 }+  id 1 tag [6]
+ tests/pos/literals02.fq view
@@ -0,0 +1,28 @@+constant strLen : (func(0, [[Char]; int]))+constant len : (func(2, [(@(0)  @(1)); int]))++constant lit$cat : (Str)++distinct lit$cat : (Str)+++bind 0 Data.Foldable.$36$fFoldable$91$$93$$35$$35$rlx : {VV##27 : (Data.Foldable.Foldable  fix$36$$91$$93$) | []}+bind 1 GHC.Types.True##6u : {VV##28 : bool | [(VV##28 = GHC.Types.True##6u)]}+bind 2 GHC.Types.False##68 : {VV##29 : bool | [(VV##29 = GHC.Types.False##68)]}+bind 3 GHC.Types.EQ##6U : {VV##30 : GHC.Types.Ordering | [(VV##30 = GHC.Types.EQ##6U)]}+bind 4 GHC.Types.LT##6S : {VV##31 : GHC.Types.Ordering | [(VV##31 = GHC.Types.LT##6S)]}+bind 5 GHC.Types.GT##6W : {VV##32 : GHC.Types.Ordering | [(VV##32 = GHC.Types.GT##6W)]}+bind 6 lq_anf$##1677724177##dFz : {lq_tmp$x##35 : Str | [(lq_tmp$x##35 = lit$cat)]}+bind 7 lq_anf$##1677724178##dFA : {lq_tmp$x##41 : [Char] | [(lq_tmp$x##41 ~~ lq_anf$##1677724177##dFz);+                                                            ((len lq_tmp$x##41) = (strLen lq_anf$##1677724177##dFz));+                                                            ((len lq_tmp$x##41) >= 0)]}++constraint:+  env [0; 1; 2; 3; 4; 5; 6; 7]+  lhs {VV##F##1 : int | [(VV##F##1 >= 0);+                         (VV##F##1 = (len lq_anf$##1677724178##dFA))]}+  rhs {VV##F##1 : int | [(VV##F##1 = 3)]}+  id 1 tag [1]+  // META constraint id 1 : ()++
+ tests/pos/literals03.fq view
@@ -0,0 +1,16 @@+constant lit$year     : (Str)+constant lit$title    : (Str)+constant lit$star     : (Str)+constant lit$director : (Str)++constant listElts : (func(0, [LLChar; (Set_Set Str)]))+constant Set_sng : (func(1, [@(0); (Set_Set  @(0))]))++bind 1 a  : {a : Str | a == "director" }+bind 2 things : {v : LLChar | (listElts v == (Set_cup (Set_sng lit$year) (Set_cup (Set_sng lit$star) (Set_cup (Set_sng lit$director) (Set_sng lit$title)))))}++constraint:+  env [ 1; 2 ]+  lhs {v : int | true }+  rhs {v : int | Set_mem a (listElts things)} +  id 1 tag []
+ tests/pos/literals04.fq view
@@ -0,0 +1,16 @@+constant lit$year     : (Str)+constant lit$title    : (Str)+constant lit$star     : (Str)+constant lit$director : (Str)++constant listElts : (func(0, [LLChar; (Set_Set Str)]))+constant Set_sng : (func(1, [@(0); (Set_Set  @(0))]))++bind 1 a  : {a : Str | a == "director" }+bind 2 things : {v : LLChar | (listElts v ~~ (Set_cup (Set_sng lit$year) (Set_cup (Set_sng lit$star) (Set_cup (Set_sng lit$director) (Set_sng lit$title)))))}++constraint:+  env [ 1; 2 ]+  lhs {v : int | true }+  rhs {v : int | Set_mem a (listElts things)} +  id 1 tag []
+ tests/pos/literals05.fq view
@@ -0,0 +1,14 @@+constant listElts : (func(0, [LLChar; (Set_Set Str)]))+constant Set_sng : (func(1, [@(0); (Set_Set  @(0))]))++bind 1 a  : {a : Str | a == "director" }+bind 2 things : {v : LLChar | (listElts v == (Set_cup (Set_sng "year") +                                               (Set_cup (Set_sng "star") +                                                 (Set_cup (Set_sng "director") +                                                   (Set_sng "title"))))) }++constraint:+  env [ 1; 2 ]+  lhs {v : int | true }+  rhs {v : int | Set_mem a (listElts things)} +  id 1 tag []
+ tests/pos/meas00.fq view
@@ -0,0 +1,21 @@+qualif Sz(v: Tree): (0 < thinginess v)+qualif Sz(v: Tree): (1 < 0)++constant thinginess : func(0, [Tree; int])++constraint:+  env [ ]+  lhs {v : Tree | 666 < thinginess v }+  rhs {v : Tree | $k1  }+  id 1 tag []+++constraint:+  env [ ]+  lhs {v : Tree | $k1  }+  rhs {v : Tree | 0 < thinginess v }+  id 2 tag []++wf: +  env [ ]+  reft { v: Tree | $k1 }
+ tests/pos/meas02.fq view
@@ -0,0 +1,25 @@++qualif SumZ(v:[real]): (sumD v = 0.0)++qualif SumZ(v:[real]): (((sumD v) / (sumD v)) = 1.0)++constant sumD : (func(0, [[real]; real]))++bind 0 zero    : {VV : real     | VV = 0.0 }+bind 1 pumpkin : {VV : [real] | sumD VV = 0.0 }++constraint:+  env [ 0; 1 ]+  lhs {v : [real] | v = pumpkin }+  rhs {v : [real] | $k1 }+  id 1 tag []++constraint:+  env [ ]+  lhs {v : [real] | $k1 }+  rhs {v : [real] | sumD v = 0.0 }+  id 2 tag []++wf:+  env []+  reft {v : [real] | $k1 }
+ tests/pos/min00.fq view
@@ -0,0 +1,22 @@++qualif Zog(v:a) : (10 <= v)+qualif Zog(v:a) : (9 <= v)+qualif Zog(v:a) : (8 <= v)+qualif Zog(v:a) : (99 <= v)++constraint:+  env []+  lhs {v : int | (v = 100)}+  rhs {v : int | $k0}+  id 1 tag []++constraint:+  env []+  lhs {v : int | $k0}+  rhs {v : int | (15 <= v) }+  id 1 tag []+++wf:+  env [ ]+  reft {v: int | $k0}
+ tests/pos/multi-sorts.fq view
@@ -0,0 +1,10 @@++bind 0 x  : {VV : Tree | [] }+bind 1 x  : {VV : List | [] }+bind 2 x  : {VV : real | [] }++constraint:+  env [0]+  lhs {VV : Tree | [ VV = x ] }+  rhs {VV : Tree | [ VV = x ] }+  id 1 tag [1]
tests/pos/multiple-func-sorts.fq view
@@ -1,5 +1,4 @@ // adapted from LH test vector2.hs -constant foo : (func(1, [@(0); @(0)]))-+constant foo :     func(1, [@(0); @(0)]) bind 6 foo : {VV : func(1, [@(0); @(0)]) | []}
+ tests/pos/numoverload00.fq view
@@ -0,0 +1,23 @@++qualif Foo(v:real, xiggety:real): (v = xiggety * xiggety)+qualif Bar(v:real): (v = 0.0)++bind 0 zero  : {VV : real | VV = 0.0 }+bind 1 one   : {VV : real | VV = (1.0 / 1.0) }+bind 2 thing : {VV : real | VV = zero }++constraint:+  env [ 0; 1; 2 ]+  lhs {v : real | v = thing }+  rhs {v : real | $k1 }+  id 1 tag []++constraint:+  env [ ]+  lhs {v : real | $k1 }+  rhs {v : real | v = 0.0 }+  id 2 tag []++wf:+  env []+  reft {v : real | $k1 }
tests/pos/poly0.fq view
@@ -1,3 +1,4 @@+fixpoint "--defunct"  // This definition works fine ... // constant offset : (func(0, [int ; int ; (BitVec Size32) ]))
tests/pos/poly1.fq view
@@ -1,3 +1,4 @@+fixpoint "--defunct"  // This definition works fine ... // constant offset : (func(2, [int ; (BitVec Size32) ]))
tests/pos/poly2.fq view
@@ -1,3 +1,4 @@+fixpoint "--defunct"  // This definition works fine ... // constant offset : (func(0, [int ; int ; (BitVec Size32) ]))
tests/pos/qualif-inst.fq view
@@ -4,7 +4,7 @@  constant elems : (func(1, [(Goo.T  @(0)); (Set_Set  @(0))])) -bind 48 lq_anf__d14V : {lq_tmp_x_197 : (Set_Set  a_a14x) | [(lq_tmp_x_197 = elems([s#a149]))]}+bind 48 lq_anf__d14V : {lq_tmp_x_197 : (Set_Set  a_a14x) | []}  constraint:   env []
tests/pos/test00.fq view
@@ -1,7 +1,9 @@ qualif Zog(v:a) : (10 <= v) qualif Bog(v:a, x:a) : (x <= v) -bind 0 a : {v: int | $k0}+bind 0 a : {va: int | $k0[v := va][thing := thang] }+bind 1 thing : {v: int | true }+bind 2 thang : {v: int | true }  constraint:   env [ ]@@ -22,5 +24,5 @@   id 3 tag []  wf:-  env [ ]+  env [ 2 ]   reft {v: int | $k0}
+ tests/pos/test00.hs.fq view
@@ -0,0 +1,1021 @@++qualif IsEmp(v:GHC.Types.Bool, xs: [a]) : (Prop(v) <=> len([xs]) > 0)+qualif IsEmp(v:GHC.Types.Bool, xs: [a]) : (Prop(v) <=> len([xs]) = 0)+qualif ListZ(v: [a])          : len([v]) =  0 +qualif ListZ(v: [a])          : len([v]) >= 0 +qualif ListZ(v: [a])          : len([v]) >  0 +qualif CmpLen(v:[a], xs:[b])  : len([v]) =  len([xs]) +qualif CmpLen(v:[a], xs:[b])  : len([v]) >= len([xs]) +qualif CmpLen(v:[a], xs:[b])  : len([v]) >  len([xs]) +qualif CmpLen(v:[a], xs:[b])  : len([v]) <= len([xs]) +qualif CmpLen(v:[a], xs:[b])  : len([v]) <  len([xs]) +qualif EqLen(v:int, xs: [a]): v = len([xs]) +qualif LenEq(v:[a], x: int) :  x = len([v]) +qualif LenDiff(v:[a], x:int): len([v]) = x + 1+qualif LenDiff(v:[a], x:int): len([v]) = x - 1+qualif LenAcc(v:int, xs:[a], n: int): (v = len([xs]) + n)++qualif Bot(v:obj): 0 = 1 +qualif Bot(v:a): 0 = 1 +qualif Bot(v:bool): 0 = 1 +qualif Bot(v:int): 0 = 1 +qualif CmpZ(v:a): (v <  0)+qualif CmpZ(v:a): (v <= 0)+qualif CmpZ(v:a): (v >  0)+qualif CmpZ(v:a): (v >= 0)+qualif CmpZ(v:a): (v  = 0)+qualif CmpZ(v:a): (v != 0)++qualif Cmp(v:a, x:a): (v <  x)+qualif Cmp(v:a, x:a): (v <= x)+qualif Cmp(v:a, x:a): (v >  x)+qualif Cmp(v:a, x:a): (v >= x)+qualif Cmp(v:a, x:a): (v  = x)+qualif Cmp(v:a, x:a): (v != x)++qualif One(v:int)     : v = 1+qualif True(v:bool)   : (? v) +qualif False(v:bool)  : ~ (? v) +qualif True1(v:GHC.Types.Bool): (Prop(v))+qualif False1(v:GHC.Types.Bool): (~ Prop(v))+qualif Papp(v:a, p:Pred a) : (papp1(p, v))++constant papp1 : func(1, [Pred @(0); @(0); bool])++qualif Papp2(v:a,x:b,p:Pred a b) : papp2(p, v, x)+constant papp2 : func(4, [Pred @(0) @(1); @(2); @(3); bool])++qualif Papp3(v:a,x:b, y:c, p:Pred a b c) : papp3(p, v, x, y)+constant papp3 : func(6, [Pred @(0) @(1) @(2); @(3); @(4); @(5); bool])++qualif Papp4(v:a,x:b, y:c, z:d, p:Pred a b c d) : papp4(p, v, x, y, z)+constant papp4 : func(8, [Pred @(0) @(1) @(2) @(6); @(3); @(4); @(5); @(7); bool])++++constant Prop : func(0, [GHC.Types.Bool; bool])+qualif Fst(v : @(1), fix##126#Y : @(0)): (v = fst([fix##126#Y])) // "/Users/rjhala/research/liquid/liquidhaskell/.cabal-sandbox/share/x86_64-osx-ghc-7.8.3/liquidhaskell-0.3.1.0/include/GHC/Base.spec" (line 26, column 8)+qualif Snd(v : @(1), fix##126#Y : @(0)): (v = snd([fix##126#Y])) // "/Users/rjhala/research/liquid/liquidhaskell/.cabal-sandbox/share/x86_64-osx-ghc-7.8.3/liquidhaskell-0.3.1.0/include/GHC/Base.spec" (line 27, column 8)++constant Prop : func(0, [GHC.Types.Bool; bool])+constant x_Tuple54 : func(5, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4);+                              @(3)])+constant x_Tuple44 : func(4, [FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3);+                              @(3)])+constant xListSelector : func(1, [[@(0)]; @(0)])+constant x_Tuple41 : func(4, [FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3);+                              @(0)])+constant x_Tuple76 : func(7, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4))  @(5))  @(6);+                              @(5)])+constant addrLen : func(0, [int; int])+constant x_Tuple65 : func(6, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4))  @(5);+                              @(4)])+constant x_Tuple52 : func(5, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4);+                              @(1)])+constant GHC.Types.False#68 : (GHC.Types.Bool)+constant x_Tuple64 : func(6, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4))  @(5);+                              @(3)])+constant x_Tuple33 : func(3, [FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2);+                              @(2)])+constant fst : func(2, [FAppTy (FAppTy fix##40##41#  @(0))  @(1);+                        @(0)])+constant x_Tuple31 : func(3, [FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2);+                              @(0)])+constant x_Tuple43 : func(4, [FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3);+                              @(2)])+constant x_Tuple71 : func(7, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4))  @(5))  @(6);+                              @(0)])+constant x_Tuple32 : func(3, [FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2);+                              @(1)])+constant x_Tuple72 : func(7, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4))  @(5))  @(6);+                              @(1)])+constant x_Tuple63 : func(6, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4))  @(5);+                              @(2)])+constant x_Tuple75 : func(7, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4))  @(5))  @(6);+                              @(4)])+constant x_Tuple51 : func(5, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4);+                              @(0)])+constant len : func(1, [[@(0)]; int])+constant xsListSelector : func(1, [[@(0)]; [@(0)]])+constant null : func(1, [[@(0)]; bool])+constant x_Tuple53 : func(5, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4);+                              @(2)])+constant x_Tuple22 : func(2, [FAppTy (FAppTy fix##40##41#  @(0))  @(1);+                              @(1)])+constant fromJust : func(1, [FAppTy Data.Maybe.Maybe  @(0); @(0)])+constant snd : func(2, [FAppTy (FAppTy fix##40##41#  @(0))  @(1);+                        @(1)])+constant x_Tuple73 : func(7, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4))  @(5))  @(6);+                              @(2)])+constant x_Tuple62 : func(6, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4))  @(5);+                              @(1)])+constant x_Tuple55 : func(5, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4);+                              @(4)])+constant x_Tuple74 : func(7, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4))  @(5))  @(6);+                              @(3)])+constant cmp : func(0, [GHC.Types.Ordering; GHC.Types.Ordering])+constant x_Tuple42 : func(4, [FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3);+                              @(1)])+constant x_Tuple21 : func(2, [FAppTy (FAppTy fix##40##41#  @(0))  @(1);+                              @(0)])+constant x_Tuple61 : func(6, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4))  @(5);+                              @(0)])+constant isJust : func(1, [FAppTy Data.Maybe.Maybe  @(0); bool])+constant x_Tuple66 : func(6, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4))  @(5);+                              @(5)])+constant GHC.Types.True#6u : (GHC.Types.Bool)+constant x_Tuple77 : func(7, [FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy (FAppTy fix##40##41#  @(0))  @(1))  @(2))  @(3))  @(4))  @(5))  @(6);+                              @(6)])+bind 0 GHC.Types.False#68 : {VV#171 : GHC.Types.Bool | []}+bind 1 GHC.Types.I##6c : {VV : func(0, [int; int]) | []}+bind 2 GHC.Types.True#6u : {VV#173 : GHC.Types.Bool | []}+bind 3 fix#GHC.Classes.#36#fOrdInt#35#rhx : {VV#175 : FAppTy GHC.Classes.Ord  int | []}+bind 4 fix#GHC.Num.#36#fNumInt#35#rhy : {VV#176 : FAppTy GHC.Num.Num  int | []}+bind 5 Language.Haskell.Liquid.Prelude.liquidAssertB#rpD : {VV : func(0, [GHC.Types.Bool;+                                                                          GHC.Types.Bool]) | []}+bind 6 Language.Haskell.Liquid.Prelude.choose#rpK : {VV : func(0, [int;+                                                                   int]) | []}+bind 7 GHC.Types.EQ#6U : {VV#179 : GHC.Types.Ordering | []}+bind 8 GHC.Types.LT#6S : {VV#180 : GHC.Types.Ordering | []}+bind 9 GHC.Types.GT#6W : {VV#181 : GHC.Types.Ordering | []}+bind 10 GHC.Types.True#6u : {v : GHC.Types.Bool | [(? Prop([v]))]}+bind 11 GHC.Types.False#68 : {v : GHC.Types.Bool | [(~ ((? Prop([v]))))]}+bind 12 Language.Haskell.Liquid.Prelude.plus#rou : {VV : func(0, [int;+                                                                  int;+                                                                  int]) | []}+bind 13 Language.Haskell.Liquid.Prelude.minus#rpv : {VV : func(0, [int;+                                                                   int;+                                                                   int]) | []}+bind 14 Language.Haskell.Liquid.Prelude.times#rpw : {VV : func(0, [int;+                                                                   int;+                                                                   int]) | []}+bind 15 Language.Haskell.Liquid.Prelude.eq#rpx : {VV : func(0, [int;+                                                                int;+                                                                GHC.Types.Bool]) | []}+bind 16 Language.Haskell.Liquid.Prelude.neq#rpy : {VV : func(0, [int;+                                                                 int;+                                                                 GHC.Types.Bool]) | []}+bind 17 Language.Haskell.Liquid.Prelude.leq#rpz : {VV : func(0, [int;+                                                                 int;+                                                                 GHC.Types.Bool]) | []}+bind 18 Language.Haskell.Liquid.Prelude.geq#rpA : {VV : func(0, [int;+                                                                 int;+                                                                 GHC.Types.Bool]) | []}+bind 19 Language.Haskell.Liquid.Prelude.lt#rpB : {VV : func(0, [int;+                                                                int;+                                                                GHC.Types.Bool]) | []}+bind 20 Language.Haskell.Liquid.Prelude.gt#rpC : {VV : func(0, [int;+                                                                int;+                                                                GHC.Types.Bool]) | []}+bind 21 Language.Haskell.Liquid.Prelude.liquidAssertB#rpD : {VV : func(0, [GHC.Types.Bool;+                                                                           GHC.Types.Bool]) | []}+bind 22 Language.Haskell.Liquid.Prelude.isEven#rpL : {VV : func(0, [int;+                                                                    GHC.Types.Bool]) | []}+bind 23 Language.Haskell.Liquid.Prelude.isOdd#rpM : {VV : func(0, [int;+                                                                   GHC.Types.Bool]) | []}+bind 24 GHC.Integer.Type.smallInteger#0Z : {VV : func(0, [int;+                                                          int]) | []}+bind 25 GHC.Types.I##6c : {VV : func(0, [int; int]) | []}+bind 26 fix#GHC.Prim.#43##35##35#98 : {VV : func(0, [int;+                                                     int;+                                                     int]) | []}+bind 27 fix#GHC.Prim.#45##35##35#99 : {VV : func(0, [int;+                                                     int;+                                                     int]) | []}+bind 28 fix#GHC.Prim.#61##61##35##35#9o : {VV : func(0, [int;+                                                         int;+                                                         int]) | []}+bind 29 fix#GHC.Prim.#62##61##35##35#9n : {VV : func(0, [int;+                                                         int;+                                                         int]) | []}+bind 30 fix#GHC.Prim.#60##61##35##35#9r : {VV : func(0, [int;+                                                         int;+                                                         int]) | []}+bind 31 fix#GHC.Prim.#60##35##35#9q : {VV : func(0, [int;+                                                     int;+                                                     int]) | []}+bind 32 fix#GHC.Prim.#62##35##35#9m : {VV : func(0, [int;+                                                     int;+                                                     int]) | []}+bind 33 GHC.Types.EQ#6U : {VV#220 : GHC.Types.Ordering | [(cmp([VV#220]) = GHC.Types.EQ#6U)]}+bind 34 GHC.Types.LT#6S : {VV#222 : GHC.Types.Ordering | [(cmp([VV#222]) = GHC.Types.LT#6S)]}+bind 35 GHC.Types.GT#6W : {VV#223 : GHC.Types.Ordering | [(cmp([VV#223]) = GHC.Types.GT#6W)]}+bind 36 fix##36#dOrd_a165 : {VV#232 : FAppTy GHC.Classes.Ord  a_a164 | []}+bind 37 fix##36#dNum_a166 : {VV#233 : FAppTy GHC.Num.Num  a_a164 | []}+bind 38 a_a164 : {VV : num | []}+bind 39 gooberding#a15N : {VV#234 : a_a164 | [$k_235]}+bind 40 lq_anf__d16w : {lq_tmp_x241 : int | [(lq_tmp_x241 = 0)]}+bind 41 lq_anf__d16x : {VV : a_a164 | [(VV = lq_anf__d16w)]}+bind 42 lq_anf__d16y : {lq_tmp_x254 : GHC.Types.Bool | [((? Prop([lq_tmp_x254])) <=> (gooberding#a15N >= lq_anf__d16x))]}+bind 43 lq_anf__d16z : {lq_tmp_x276 : int | [(lq_tmp_x276 = (0  :  int))]}+bind 44 Test0.x#r12i : {VV#272 : int | [$k_273]}+bind 45 lq_anf__d16A : {lq_tmp_x291 : int | [(lq_tmp_x291 = (0  :  int))]}+bind 46 lq_anf__d16B : {lq_tmp_x297 : GHC.Types.Bool | [((? Prop([lq_tmp_x297])) <=> (Test0.x#r12i > lq_anf__d16A))]}+bind 47 lq_anf__d16C : {lq_tmp_x313 : GHC.Types.Bool | [((? Prop([lq_tmp_x313])) <=> (Test0.x#r12i > lq_anf__d16A));+                                                        (lq_tmp_x313 = lq_anf__d16B)]}+bind 48 lq_anf__d16C : {lq_tmp_x315 : GHC.Types.Bool | [((? Prop([lq_tmp_x315])) <=> (Test0.x#r12i > lq_anf__d16A));+                                                        (lq_tmp_x315 = lq_anf__d16B)]}+bind 49 lq_anf__d16C : {lq_tmp_x315 : GHC.Types.Bool | [((? Prop([lq_tmp_x315])) <=> (Test0.x#r12i > lq_anf__d16A));+                                                        (lq_tmp_x315 = lq_anf__d16B);+                                                        (~ ((? Prop([lq_tmp_x315]))));+                                                        (~ ((? Prop([lq_tmp_x315]))))]}+bind 50 lq_anf__d16C : {lq_tmp_x321 : GHC.Types.Bool | [((? Prop([lq_tmp_x321])) <=> (Test0.x#r12i > lq_anf__d16A));+                                                        (lq_tmp_x321 = lq_anf__d16B)]}+bind 51 lq_anf__d16C : {lq_tmp_x321 : GHC.Types.Bool | [((? Prop([lq_tmp_x321])) <=> (Test0.x#r12i > lq_anf__d16A));+                                                        (lq_tmp_x321 = lq_anf__d16B);+                                                        (? Prop([lq_tmp_x321]));+                                                        (? Prop([lq_tmp_x321]))]}+bind 52 Test0.prop_abs#r12j : {VV#287 : GHC.Types.Bool | [$k_288]}+bind 53 VV#343 : {VV#343 : GHC.Types.Bool | [$k_239[VV#238:=VV#343][fix##36#dOrd_a165:=fix#GHC.Classes.#36#fOrdInt#35#rhx][fix##36#dNum_a166:=fix#GHC.Num.#36#fNumInt#35#rhy][gooberding#a15N:=Test0.x#r12i][lq_tmp_x332:=fix#GHC.Classes.#36#fOrdInt#35#rhx][lq_tmp_x333:=fix#GHC.Num.#36#fNumInt#35#rhy][lq_tmp_x334:=Test0.x#r12i][lq_tmp_x328:=VV#343]]}+bind 54 VV#343 : {VV#343 : GHC.Types.Bool | [$k_239[VV#238:=VV#343][fix##36#dOrd_a165:=fix#GHC.Classes.#36#fOrdInt#35#rhx][fix##36#dNum_a166:=fix#GHC.Num.#36#fNumInt#35#rhy][gooberding#a15N:=Test0.x#r12i][lq_tmp_x332:=fix#GHC.Classes.#36#fOrdInt#35#rhx][lq_tmp_x333:=fix#GHC.Num.#36#fNumInt#35#rhy][lq_tmp_x334:=Test0.x#r12i][lq_tmp_x328:=VV#343]]}+bind 55 VV#346 : {VV#346 : int | [$k_273[VV#272:=VV#346][lq_tmp_x341:=VV#346];+                                  (VV#346 = Test0.x#r12i)]}+bind 56 VV#346 : {VV#346 : int | [$k_273[VV#272:=VV#346][lq_tmp_x341:=VV#346];+                                  (VV#346 = Test0.x#r12i)]}+bind 57 VV#349 : {VV#349 : GHC.Types.Bool | [(~ ((? Prop([VV#349]))));+                                             (VV#349 = GHC.Types.False#68)]}+bind 58 VV#349 : {VV#349 : GHC.Types.Bool | [(~ ((? Prop([VV#349]))));+                                             (VV#349 = GHC.Types.False#68)]}+bind 59 VV#352 : {VV#352 : int | [(VV#352 = (0  :  int));+                                  (VV#352 = lq_anf__d16A)]}+bind 60 VV#352 : {VV#352 : int | [(VV#352 = (0  :  int));+                                  (VV#352 = lq_anf__d16A)]}+bind 61 VV#355 : {VV#355 : int | [$k_273[VV#272:=VV#355][lq_tmp_x310:=VV#355];+                                  (VV#355 = Test0.x#r12i)]}+bind 62 VV#355 : {VV#355 : int | [$k_273[VV#272:=VV#355][lq_tmp_x310:=VV#355];+                                  (VV#355 = Test0.x#r12i)]}+bind 63 VV#358 : {VV#358 : int | [(VV#358 = 0)]}+bind 64 VV#358 : {VV#358 : int | [(VV#358 = 0)]}+bind 65 VV#361 : {VV#361 : int | []}+bind 66 VV#361 : {VV#361 : int | []}+bind 67 VV#364 : {VV#364 : int | [(VV#364 = (0  :  int));+                                  (VV#364 = lq_anf__d16z)]}+bind 68 VV#364 : {VV#364 : int | [(VV#364 = (0  :  int));+                                  (VV#364 = lq_anf__d16z)]}+bind 69 VV#367 : {VV#367 : int | [(VV#367 = 0)]}+bind 70 VV#367 : {VV#367 : int | [(VV#367 = 0)]}+bind 71 VV#370 : {VV#370 : GHC.Types.Bool | [(? Prop([VV#370]))]}+bind 72 VV#370 : {VV#370 : GHC.Types.Bool | [(? Prop([VV#370]))]}+bind 73 VV#373 : {VV#373 : GHC.Types.Bool | [((? Prop([VV#373])) <=> (gooberding#a15N >= lq_anf__d16x));+                                             (VV#373 = lq_anf__d16y)]}+bind 74 VV#373 : {VV#373 : GHC.Types.Bool | [((? Prop([VV#373])) <=> (gooberding#a15N >= lq_anf__d16x));+                                             (VV#373 = lq_anf__d16y)]}+bind 75 VV : {VV : a_a164 | [(VV = lq_anf__d16w);+                             (VV = lq_anf__d16x)]}+bind 76 VV#234 : {VV#234 : a_a164 | [$k_235;+                                     (VV#234 = gooberding#a15N)]}+bind 77 VV#378 : {VV#378 : int | [(VV#378 = 0);+                                  (VV#378 = lq_anf__d16w)]}+bind 78 VV#378 : {VV#378 : int | [(VV#378 = 0);+                                  (VV#378 = lq_anf__d16w)]}+bind 79 VV#304 : {VV#304 : int | [$k_305]}+bind 80 VV#287 : {VV#287 : GHC.Types.Bool | [$k_288]}+bind 81 VV#272 : {VV#272 : int | [$k_273]}+bind 82 VV#238 : {VV#238 : GHC.Types.Bool | [$k_239]}+++constraint:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       50;+       3;+       19;+       35;+       51;+       4;+       20;+       5;+       21;+       53;+       6;+       22;+       7;+       23;+       8;+       24;+       9;+       25;+       10;+       26;+       11;+       27;+       12;+       28;+       44;+       13;+       29;+       45;+       14;+       30;+       46;+       15;+       31;+       47]+  lhs {VV#F1 : GHC.Types.Bool | [$k_239[VV#238:=VV#F1][fix##36#dOrd_a165:=fix#GHC.Classes.#36#fOrdInt#35#rhx][fix##36#dNum_a166:=fix#GHC.Num.#36#fNumInt#35#rhy][gooberding#a15N:=Test0.x#r12i][lq_tmp_x332:=fix#GHC.Classes.#36#fOrdInt#35#rhx][lq_tmp_x333:=fix#GHC.Num.#36#fNumInt#35#rhy][lq_tmp_x334:=Test0.x#r12i][lq_tmp_x328:=VV#F1][VV#343:=VV#F1][VV#F:=VV#F1]]}+  rhs {VV#F1 : GHC.Types.Bool | [$k_288[VV#287:=VV#F1][VV#343:=VV#F1][VV#F:=VV#F1]]}+  id 1 tag [3]+++constraint:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       50;+       3;+       19;+       35;+       51;+       4;+       20;+       5;+       21;+       6;+       22;+       7;+       23;+       55;+       8;+       24;+       9;+       25;+       10;+       26;+       11;+       27;+       12;+       28;+       44;+       13;+       29;+       45;+       14;+       30;+       46;+       15;+       31;+       47]+  lhs {VV#F2 : int | [$k_273[VV#272:=VV#F2][lq_tmp_x341:=VV#F2][VV#346:=VV#F2][VV#F:=VV#F2];+                      (VV#F2 = Test0.x#r12i)]}+  rhs {VV#F2 : int | [$k_235[fix##36#dOrd_a165:=fix#GHC.Classes.#36#fOrdInt#35#rhx][fix##36#dNum_a166:=fix#GHC.Num.#36#fNumInt#35#rhy][VV#234:=VV#F2][lq_tmp_x332:=fix#GHC.Classes.#36#fOrdInt#35#rhx][lq_tmp_x333:=fix#GHC.Num.#36#fNumInt#35#rhy][lq_tmp_x336:=VV#F2][VV#346:=VV#F2][VV#F:=VV#F2]]}+  id 2 tag [3]+++constraint:+  env [0;+       16;+       32;+       48;+       1;+       17;+       33;+       49;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       5;+       21;+       6;+       22;+       7;+       23;+       8;+       24;+       9;+       25;+       57;+       10;+       26;+       11;+       27;+       12;+       28;+       44;+       13;+       29;+       45;+       14;+       30;+       46;+       15;+       31;+       47]+  lhs {VV#F3 : GHC.Types.Bool | [(~ ((? Prop([VV#F3]))));+                                 (VV#F3 = GHC.Types.False#68)]}+  rhs {VV#F3 : GHC.Types.Bool | [$k_288[VV#287:=VV#F3][VV#349:=VV#F3][VV#F:=VV#F3]]}+  id 3 tag [3]+++constraint:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       5;+       21;+       6;+       22;+       7;+       23;+       8;+       24;+       9;+       25;+       10;+       26;+       11;+       27;+       59;+       12;+       28;+       44;+       13;+       29;+       45;+       14;+       30;+       15;+       31]+  lhs {VV#F4 : int | [(VV#F4 = (0  :  int)); (VV#F4 = lq_anf__d16A)]}+  rhs {VV#F4 : int | [$k_305[VV#304:=VV#F4][lq_tmp_x301:=fix#GHC.Classes.#36#fOrdInt#35#rhx][lq_tmp_x302:=Test0.x#r12i][lq_tmp_x307:=VV#F4][VV#352:=VV#F4][VV#F:=VV#F4]]}+  id 4 tag [3]+++constraint:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       5;+       21;+       6;+       22;+       7;+       23;+       8;+       24;+       9;+       25;+       10;+       26;+       11;+       27;+       12;+       28;+       44;+       13;+       29;+       45;+       61;+       14;+       30;+       15;+       31]+  lhs {VV#F5 : int | [$k_273[VV#272:=VV#F5][lq_tmp_x310:=VV#F5][VV#355:=VV#F5][VV#F:=VV#F5];+                      (VV#F5 = Test0.x#r12i)]}+  rhs {VV#F5 : int | [$k_305[VV#304:=VV#F5][lq_tmp_x301:=fix#GHC.Classes.#36#fOrdInt#35#rhx][lq_tmp_x307:=VV#F5][VV#355:=VV#F5][VV#F:=VV#F5]]}+  id 5 tag [3]+++constraint:+  env [0;+       16;+       32;+       1;+       17;+       33;+       65;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       5;+       21;+       6;+       22;+       7;+       23;+       8;+       24;+       9;+       25;+       10;+       26;+       11;+       27;+       43;+       12;+       28;+       13;+       29;+       14;+       30;+       15;+       31]+  lhs {VV#F6 : int | []}+  rhs {VV#F6 : int | [$k_273[VV#272:=VV#F6][VV#361:=VV#F6][VV#F:=VV#F6]]}+  id 6 tag [2]+++constraint:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       36;+       5;+       21;+       37;+       6;+       22;+       38;+       7;+       23;+       39;+       71;+       8;+       24;+       40;+       9;+       25;+       41;+       10;+       26;+       42;+       11;+       27;+       12;+       28;+       13;+       29;+       14;+       30;+       15;+       31]+  lhs {VV#F7 : GHC.Types.Bool | [(? Prop([VV#F7]))]}+  rhs {VV#F7 : GHC.Types.Bool | [$k_239[VV#238:=VV#F7][VV#370:=VV#F7][VV#F:=VV#F7]]}+  id 7 tag [1]+++constraint:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       36;+       5;+       21;+       37;+       6;+       22;+       38;+       7;+       23;+       39;+       8;+       24;+       40;+       9;+       25;+       41;+       73;+       10;+       26;+       42;+       11;+       27;+       12;+       28;+       13;+       29;+       14;+       30;+       15;+       31]+  lhs {VV#F8 : GHC.Types.Bool | [((? Prop([VV#F8])) <=> (gooberding#a15N >= lq_anf__d16x));+                                 (VV#F8 = lq_anf__d16y)]}+  rhs {VV#F8 : GHC.Types.Bool | [(? Prop([VV#F8]))]}+  id 8 tag [1]+++constraint:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       36;+       5;+       21;+       37;+       6;+       22;+       38;+       7;+       23;+       39;+       8;+       24;+       40;+       9;+       25;+       41;+       10;+       26;+       11;+       27;+       75;+       12;+       28;+       13;+       29;+       14;+       30;+       15;+       31]+  lhs {VV#F9 : a_a164 | [(VV#F9 = lq_anf__d16w);+                         (VV#F9 = lq_anf__d16x)]}+  rhs {VV#F9 : a_a164 | [$k_262[lq_tmp_x258:=fix##36#dOrd_a165][lq_tmp_x259:=gooberding#a15N][VV#261:=VV#F9][VV#F:=VV#F9]]}+  id 9 tag [1]+++constraint:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       36;+       5;+       21;+       37;+       6;+       22;+       38;+       7;+       23;+       39;+       8;+       24;+       40;+       9;+       25;+       41;+       10;+       26;+       11;+       27;+       12;+       28;+       76;+       13;+       29;+       14;+       30;+       15;+       31]+  lhs {VV#F10 : a_a164 | [$k_235[VV#234:=VV#F10][VV#F:=VV#F10];+                          (VV#F10 = gooberding#a15N)]}+  rhs {VV#F10 : a_a164 | [$k_262[lq_tmp_x258:=fix##36#dOrd_a165][VV#261:=VV#F10][VV#F:=VV#F10]]}+  id 10 tag [1]+++wf:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       5;+       21;+       6;+       22;+       7;+       23;+       8;+       24;+       9;+       25;+       10;+       26;+       11;+       27;+       12;+       28;+       44;+       13;+       29;+       45;+       14;+       30;+       15;+       31]+  reft {VV#304 : int | [$k_305]}+  +++wf:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       5;+       21;+       6;+       22;+       7;+       23;+       8;+       24;+       9;+       25;+       10;+       26;+       11;+       27;+       12;+       28;+       44;+       13;+       29;+       14;+       30;+       15;+       31]+  reft {VV#287 : GHC.Types.Bool | [$k_288]}+  +++wf:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       5;+       21;+       6;+       22;+       7;+       23;+       8;+       24;+       9;+       25;+       10;+       26;+       11;+       27;+       12;+       28;+       13;+       29;+       14;+       30;+       15;+       31]+  reft {VV#272 : int | [$k_273]}+  +++wf:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       36;+       5;+       21;+       37;+       6;+       22;+       38;+       7;+       23;+       8;+       24;+       9;+       25;+       10;+       26;+       11;+       27;+       12;+       28;+       13;+       29;+       14;+       30;+       15;+       31]+  reft {VV#234 : a_a164 | [$k_235]}+  +++wf:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       36;+       5;+       21;+       37;+       6;+       22;+       38;+       7;+       23;+       39;+       8;+       24;+       40;+       9;+       25;+       41;+       10;+       26;+       11;+       27;+       12;+       28;+       13;+       29;+       14;+       30;+       15;+       31]+  reft {VV#261 : a_a164 | [$k_262]}+  +++wf:+  env [0;+       16;+       32;+       1;+       17;+       33;+       2;+       18;+       34;+       3;+       19;+       35;+       4;+       20;+       36;+       5;+       21;+       37;+       6;+       22;+       38;+       7;+       23;+       39;+       8;+       24;+       9;+       25;+       10;+       26;+       11;+       27;+       12;+       28;+       13;+       29;+       14;+       30;+       15;+       31]+  reft {VV#238 : GHC.Types.Bool | [$k_239]}+  
+ tests/pos/test000.hs.fq view
@@ -0,0 +1,489 @@+qualif Fst(v : @(1), y : @(0)): (v = fst([y])) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.spec" (line 29, column 8)+qualif Snd(v : @(1), y : @(0)): (v = snd([y])) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.spec" (line 30, column 8)+qualif IsEmp(v : GHC.Types.Bool, xs : [@(0)]): ((? Prop([v])) <=> (len([xs]) > 0)) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.hquals" (line 13, column 8)+qualif IsEmp(v : GHC.Types.Bool, xs : [@(0)]): ((? Prop([v])) <=> (len([xs]) = 0)) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.hquals" (line 14, column 8)+qualif ListZ(v : [@(0)]): (len([v]) = 0) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.hquals" (line 16, column 8)+qualif ListZ(v : [@(0)]): (len([v]) >= 0) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.hquals" (line 17, column 8)+qualif ListZ(v : [@(0)]): (len([v]) > 0) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.hquals" (line 18, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (len([v]) = len([xs])) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.hquals" (line 20, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (len([v]) >= len([xs])) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.hquals" (line 21, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (len([v]) > len([xs])) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.hquals" (line 22, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (len([v]) <= len([xs])) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.hquals" (line 23, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (len([v]) < len([xs])) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.hquals" (line 24, column 8)+qualif EqLen(v : int, xs : [@(0)]): (v = len([xs])) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.hquals" (line 26, column 8)+qualif LenEq(v : [@(0)], x : int): (x = len([v])) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.hquals" (line 27, column 8)+qualif LenDiff(v : [@(0)], x : int): (len([v]) = (x + 1)) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.hquals" (line 28, column 8)+qualif LenDiff(v : [@(0)], x : int): (len([v]) = (x - 1)) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.hquals" (line 29, column 8)+qualif LenAcc(v : int, xs : [@(0)], n : int): (v = (len([xs]) + n)) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/GHC/Base.hquals" (line 30, column 8)+qualif Bot(v : @(0)): (0 = 1) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 3, column 8)+qualif Bot(v : @(0)): (0 = 1) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 4, column 8)+qualif Bot(v : @(0)): (0 = 1) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 5, column 8)+qualif Bot(v : bool): (0 = 1) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 6, column 8)+qualif Bot(v : int): (0 = 1) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 7, column 8)+qualif CmpZ(v : @(0)): (v < 0) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 9, column 8)+qualif CmpZ(v : @(0)): (v <= 0) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 10, column 8)+qualif CmpZ(v : @(0)): (v > 0) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 11, column 8)+qualif CmpZ(v : @(0)): (v >= 0) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 12, column 8)+qualif CmpZ(v : @(0)): (v = 0) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 13, column 8)+qualif CmpZ(v : @(0)): (v != 0) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 14, column 8)+qualif Cmp(v : @(0), x : @(0)): (v < x) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 16, column 8)+qualif Cmp(v : @(0), x : @(0)): (v <= x) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 17, column 8)+qualif Cmp(v : @(0), x : @(0)): (v > x) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 18, column 8)+qualif Cmp(v : @(0), x : @(0)): (v >= x) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 19, column 8)+qualif Cmp(v : @(0), x : @(0)): (v = x) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 20, column 8)+qualif Cmp(v : @(0), x : @(0)): (v != x) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 21, column 8)+qualif One(v : int): (v = 1) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 28, column 8)+qualif True(v : bool): (? v) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 29, column 8)+qualif False(v : bool): (~ ((? v))) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 30, column 8)+qualif True1(v : GHC.Types.Bool): (? Prop([v])) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 31, column 8)+qualif False1(v : GHC.Types.Bool): (~ ((? Prop([v])))) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 32, column 8)+qualif Papp(v : @(0), p : (Pred  @(0))): (? papp1([p;+                                                   v])) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 35, column 8)+qualif Papp2(v : @(1), x : @(0), p : (Pred  @(1)  @(0))): (? papp2([p;+                                                                    v;+                                                                    x])) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 38, column 8)+qualif Papp3(v : @(2), x : @(0), y : @(1), p : (Pred  @(2)  @(0)  @(1))): (? papp3([p;+                                                                                    v;+                                                                                    x;+                                                                                    y])) // "/Users/benjamin/UCSDrepos/liquidhaskell/include/Prelude.hquals" (line 41, column 8)+++++constant runFun : (func(2, [(Arrow  @(0)  @(1)); @(0); @(1)]))+constant addrLen : (func(0, [int; int]))+constant xsListSelector : (func(1, [[@(0)]; [@(0)]]))+constant x_Tuple21 : (func(2, [(Tuple  @(0)  @(1)); @(0)]))+constant x_Tuple65 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(4)]))+constant GHC.Types.False$35$68 : (GHC.Types.Bool)+constant x_Tuple55 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(4)]))+constant x_Tuple33 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(2)]))+constant x_Tuple77 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(6)]))+constant papp3 : (func(6, [(Pred  @(0)  @(1)  @(2));+                           @(3);+                           @(4);+                           @(5);+                           bool]))+constant x_Tuple63 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(2)]))+constant x_Tuple41 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(0)]))+constant papp4 : (func(8, [(Pred  @(0)  @(1)  @(2)  @(6));+                           @(3);+                           @(4);+                           @(5);+                           @(7);+                           bool]))+constant x_Tuple64 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(3)]))+constant autolen : (func(1, [@(0); int]))+constant x_Tuple52 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(1)]))+constant null : (func(1, [[@(0)]; bool]))+constant papp2 : (func(4, [(Pred  @(0)  @(1)); @(2); @(3); bool]))+constant x_Tuple62 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(1)]))+constant fromJust : (func(1, [(GHC.Base.Maybe  @(0)); @(0)]))+constant x_Tuple53 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(2)]))+constant x_Tuple71 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(0)]))+constant x_Tuple74 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(3)]))+constant len : (func(2, [(@(0)  @(1)); int]))+constant x_Tuple22 : (func(2, [(Tuple  @(0)  @(1)); @(1)]))+constant x_Tuple66 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(5)]))+constant x_Tuple44 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(3)]))+constant xListSelector : (func(1, [[@(0)]; @(0)]))+constant strLen : (func(0, [int; int]))+constant x_Tuple72 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(1)]))+constant isJust : (func(1, [(GHC.Base.Maybe  @(0)); bool]))+constant Prop : (func(0, [GHC.Types.Bool; bool]))+constant x_Tuple31 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(0)]))+constant x_Tuple75 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(4)]))+constant papp1 : (func(1, [(Pred  @(0)); @(0); bool]))+constant x_Tuple61 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(0)]))+constant x_Tuple43 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(2)]))+constant x_Tuple51 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(0)]))+constant GHC.Types.I$35$$35$6c : (func(0, [int; int]))+constant x_Tuple73 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(2)]))+constant x_Tuple54 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(3)]))+constant cmp : (func(0, [GHC.Types.Ordering; GHC.Types.Ordering]))+constant x_Tuple32 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(1)]))+constant x_Tuple76 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(5)]))+constant fst : (func(2, [(Tuple  @(0)  @(1)); @(0)]))+constant snd : (func(2, [(Tuple  @(0)  @(1)); @(1)]))+constant x_Tuple42 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(1)]))+constant GHC.Types.True$35$6u : (GHC.Types.Bool)+++bind 0 GHC.Types.False$35$68 : {VV$35$170 : GHC.Types.Bool | []}+bind 1 GHC.Types.True$35$6u : {VV$35$172 : GHC.Types.Bool | []}+bind 2 GHC.Num.$36$fNumInt$35$rma : {VV$35$178 : (GHC.Num.Num  int) | []}+bind 3 GHC.Classes.$36$fOrdInt$35$rni : {VV$35$179 : (GHC.Classes.Ord  int) | []}+bind 4 GHC.Types.EQ$35$6U : {VV$35$180 : GHC.Types.Ordering | [(VV$35$180 = GHC.Types.EQ$35$6U)]}+bind 5 GHC.Types.LT$35$6S : {VV$35$181 : GHC.Types.Ordering | [(VV$35$181 = GHC.Types.LT$35$6S)]}+bind 6 GHC.Types.GT$35$6W : {VV$35$182 : GHC.Types.Ordering | [(VV$35$182 = GHC.Types.GT$35$6W)]}+bind 7 GHC.Types.True$35$6u : {v_4 : GHC.Types.Bool | [(? Prop([v_4]))]}+bind 8 GHC.Types.False$35$68 : {v_5 : GHC.Types.Bool | [(~ ((? Prop([v_5]))))]}+bind 9 GHC.Types.False$35$68 : {v_5 : GHC.Types.Bool | [(~ ((? Prop([v_5]))))]}+bind 10 GHC.Types.$91$$93$$35$6m : {VV : func(1, [[@(0)]]) | []}+bind 11 GHC.Types.True$35$6u : {v_4 : GHC.Types.Bool | [(? Prop([v_4]))]}+bind 12 GHC.Types.GT$35$6W : {VV$35$227 : GHC.Types.Ordering | [(cmp([VV$35$227]) = GHC.Types.GT$35$6W)]}+bind 13 GHC.Types.LT$35$6S : {VV$35$228 : GHC.Types.Ordering | [(cmp([VV$35$228]) = GHC.Types.LT$35$6S)]}+bind 14 GHC.Types.EQ$35$6U : {VV$35$229 : GHC.Types.Ordering | [(cmp([VV$35$229]) = GHC.Types.EQ$35$6U)]}+bind 15 GHC.Base.Nothing$35$r1d : {VV : func(1, [(GHC.Base.Maybe  @(0))]) | []}+bind 16 lq_anf__d12p : {lq_tmp_x_238 : int | [(lq_tmp_x_238 = (0  :  int))]}+bind 17 lq_anf__d12q : {lq_tmp_x_244 : int | []}+bind 18 lq_anf__d12r : {lq_tmp_x_250 : int | [(lq_tmp_x_250 = (10  :  int))]}+bind 19 Test0.toss$35$rYP : {VV$35$234 : GHC.Types.Bool | [$k__235]}+bind 20 lq_anf__d12s : {lq_tmp_x_275 : GHC.Types.Bool | [(lq_tmp_x_275 = Test0.toss$35$rYP)]}+bind 21 lq_anf__d12s : {lq_tmp_x_277 : GHC.Types.Bool | [(lq_tmp_x_277 = Test0.toss$35$rYP)]}+bind 22 lq_anf__d12s : {lq_tmp_x_277 : GHC.Types.Bool | [(lq_tmp_x_277 = Test0.toss$35$rYP);+                                                         (~ ((? Prop([lq_tmp_x_277]))));+                                                         (~ ((? Prop([lq_tmp_x_277]))));+                                                         (~ ((? Prop([lq_tmp_x_277]))))]}+bind 23 lq_anf__d12s : {lq_tmp_x_283 : GHC.Types.Bool | [(lq_tmp_x_283 = Test0.toss$35$rYP)]}+bind 24 lq_anf__d12s : {lq_tmp_x_283 : GHC.Types.Bool | [(lq_tmp_x_283 = Test0.toss$35$rYP);+                                                         (? Prop([lq_tmp_x_283]));+                                                         (? Prop([lq_tmp_x_283]));+                                                         (? Prop([lq_tmp_x_283]))]}+bind 25 lq_anf__d12t : {lq_tmp_x_288 : GHC.Types.Bool | [(lq_tmp_x_288 = lq_anf__d12s)]}+bind 26 lq_anf__d12t : {lq_tmp_x_290 : GHC.Types.Bool | [(lq_tmp_x_290 = lq_anf__d12s)]}+bind 27 lq_anf__d12t : {lq_tmp_x_290 : GHC.Types.Bool | [(lq_tmp_x_290 = lq_anf__d12s);+                                                         (~ ((? Prop([lq_tmp_x_290]))));+                                                         (~ ((? Prop([lq_tmp_x_290]))));+                                                         (~ ((? Prop([lq_tmp_x_290]))))]}+bind 28 lq_anf__d12t : {lq_tmp_x_296 : GHC.Types.Bool | [(lq_tmp_x_296 = lq_anf__d12s)]}+bind 29 lq_anf__d12t : {lq_tmp_x_296 : GHC.Types.Bool | [(lq_tmp_x_296 = lq_anf__d12s);+                                                         (? Prop([lq_tmp_x_296]));+                                                         (? Prop([lq_tmp_x_296]));+                                                         (? Prop([lq_tmp_x_296]))]}+bind 30 Test0.prop_abs$35$r10h : {VV$35$272 : GHC.Types.Bool | [$k__273]}+bind 31 x$35$a11A : {VV$35$307 : int | [$k__308]}+bind 32 lq_anf__d12u : {lq_tmp_x_315 : int | [(lq_tmp_x_315 = (0  :  int))]}+bind 33 lq_anf__d12v : {lq_tmp_x_321 : GHC.Types.Bool | [((? Prop([lq_tmp_x_321])) <=> (x$35$a11A > lq_anf__d12u))]}+bind 34 lq_anf__d12w : {lq_tmp_x_345 : int | [$k__343[lq_tmp_x_340:=lq_anf__d12v][VV$35$342:=lq_tmp_x_345][lq_tmp_x_341:=x$35$a11A]]}+bind 35 lq_anf__d12x : {lq_tmp_x_350 : int | [(lq_tmp_x_350 = (1  :  int))]}+bind 36 lq_anf__d12y : {lq_tmp_x_373 : int | [(lq_tmp_x_373 = (12  :  int))]}+bind 37 Test0.goo$35$r10j : {VV$35$369 : int | [$k__370]}+bind 38 zzz$35$a11B : {VV$35$384 : int | [$k__385]}+bind 39 lq_anf__d12z : {lq_tmp_x_392 : int | [(lq_tmp_x_392 = (1  :  int))]}+bind 40 lq_anf__d12A : {lq_tmp_x_415 : int | [(lq_tmp_x_415 = (29  :  int))]}+bind 41 Test0.zoo$35$r10l : {VV$35$411 : int | [$k__412]}+bind 42 VV$35$426 : {VV$35$426 : int | [$k__389[lq_tmp_x_423:=lq_anf__d12A][lq_tmp_x_421:=VV$35$426][zzz$35$a11B:=lq_anf__d12A][VV$35$388:=VV$35$426]]}+bind 43 VV$35$426 : {VV$35$426 : int | [$k__389[lq_tmp_x_423:=lq_anf__d12A][lq_tmp_x_421:=VV$35$426][zzz$35$a11B:=lq_anf__d12A][VV$35$388:=VV$35$426]]}+bind 44 VV$35$429 : {VV$35$429 : int | [(VV$35$429 = lq_anf__d12A)]}+bind 45 VV$35$429 : {VV$35$429 : int | [(VV$35$429 = lq_anf__d12A)]}+bind 46 VV$35$432 : {VV$35$432 : int | [(VV$35$432 = 29)]}+bind 47 VV$35$432 : {VV$35$432 : int | [(VV$35$432 = 29)]}+bind 48 VV$35$435 : {VV$35$435 : int | [(VV$35$435 = (zzz$35$a11B + lq_anf__d12z))]}+bind 49 VV$35$435 : {VV$35$435 : int | [(VV$35$435 = (zzz$35$a11B + lq_anf__d12z))]}+bind 50 VV$35$438 : {VV$35$438 : int | [(VV$35$438 = lq_anf__d12z)]}+bind 51 VV$35$438 : {VV$35$438 : int | [(VV$35$438 = lq_anf__d12z)]}+bind 52 VV$35$441 : {VV$35$441 : int | [(VV$35$441 = zzz$35$a11B)]}+bind 53 VV$35$441 : {VV$35$441 : int | [(VV$35$441 = zzz$35$a11B)]}+bind 54 VV$35$444 : {VV$35$444 : int | [(VV$35$444 = 1)]}+bind 55 VV$35$444 : {VV$35$444 : int | [(VV$35$444 = 1)]}+bind 56 VV$35$447 : {VV$35$447 : int | [$k__312[VV$35$311:=VV$35$447][lq_tmp_x_381:=lq_anf__d12y][x$35$a11A:=lq_anf__d12y][lq_tmp_x_379:=VV$35$447]]}+bind 57 VV$35$447 : {VV$35$447 : int | [$k__312[VV$35$311:=VV$35$447][lq_tmp_x_381:=lq_anf__d12y][x$35$a11A:=lq_anf__d12y][lq_tmp_x_379:=VV$35$447]]}+bind 58 VV$35$450 : {VV$35$450 : int | [(VV$35$450 = lq_anf__d12y)]}+bind 59 VV$35$450 : {VV$35$450 : int | [(VV$35$450 = lq_anf__d12y)]}+bind 60 VV$35$453 : {VV$35$453 : int | [(VV$35$453 = 12)]}+bind 61 VV$35$453 : {VV$35$453 : int | [(VV$35$453 = 12)]}+bind 62 VV$35$456 : {VV$35$456 : int | [(VV$35$456 = (lq_anf__d12w + lq_anf__d12x))]}+bind 63 VV$35$456 : {VV$35$456 : int | [(VV$35$456 = (lq_anf__d12w + lq_anf__d12x))]}+bind 64 VV$35$459 : {VV$35$459 : int | [(VV$35$459 = lq_anf__d12x)]}+bind 65 VV$35$459 : {VV$35$459 : int | [(VV$35$459 = lq_anf__d12x)]}+bind 66 VV$35$462 : {VV$35$462 : int | [(VV$35$462 = lq_anf__d12w)]}+bind 67 VV$35$462 : {VV$35$462 : int | [(VV$35$462 = lq_anf__d12w)]}+bind 68 VV$35$465 : {VV$35$465 : int | [(VV$35$465 = 1)]}+bind 69 VV$35$465 : {VV$35$465 : int | [(VV$35$465 = 1)]}+bind 70 VV$35$468 : {VV$35$468 : int | [(VV$35$468 = x$35$a11A)]}+bind 71 VV$35$468 : {VV$35$468 : int | [(VV$35$468 = x$35$a11A)]}+bind 72 VV$35$471 : {VV$35$471 : GHC.Types.Bool | [(VV$35$471 = lq_anf__d12v)]}+bind 73 VV$35$471 : {VV$35$471 : GHC.Types.Bool | [(VV$35$471 = lq_anf__d12v)]}+bind 74 VV$35$474 : {VV$35$474 : int | [(VV$35$474 = lq_anf__d12u)]}+bind 75 VV$35$474 : {VV$35$474 : int | [(VV$35$474 = lq_anf__d12u)]}+bind 76 VV$35$477 : {VV$35$477 : int | [(VV$35$477 = x$35$a11A)]}+bind 77 VV$35$477 : {VV$35$477 : int | [(VV$35$477 = x$35$a11A)]}+bind 78 VV$35$480 : {VV$35$480 : int | [(VV$35$480 = 0)]}+bind 79 VV$35$480 : {VV$35$480 : int | [(VV$35$480 = 0)]}+bind 80 VV$35$483 : {VV$35$483 : GHC.Types.Bool | [(? Prop([VV$35$483]))]}+bind 81 VV$35$483 : {VV$35$483 : GHC.Types.Bool | [(? Prop([VV$35$483]))]}+bind 82 VV$35$486 : {VV$35$486 : GHC.Types.Bool | [(VV$35$486 = lq_anf__d12t)]}+bind 83 VV$35$486 : {VV$35$486 : GHC.Types.Bool | [(VV$35$486 = lq_anf__d12t)]}+bind 84 VV$35$489 : {VV$35$489 : GHC.Types.Bool | [(VV$35$489 = GHC.Types.False$35$68)]}+bind 85 VV$35$489 : {VV$35$489 : GHC.Types.Bool | [(VV$35$489 = GHC.Types.False$35$68)]}+bind 86 VV$35$492 : {VV$35$492 : GHC.Types.Bool | [(VV$35$492 = GHC.Types.False$35$68)]}+bind 87 VV$35$492 : {VV$35$492 : GHC.Types.Bool | [(VV$35$492 = GHC.Types.False$35$68)]}+bind 88 VV$35$495 : {VV$35$495 : GHC.Types.Bool | [((? Prop([VV$35$495])) <=> (lq_anf__d12q > lq_anf__d12r))]}+bind 89 VV$35$495 : {VV$35$495 : GHC.Types.Bool | [((? Prop([VV$35$495])) <=> (lq_anf__d12q > lq_anf__d12r))]}+bind 90 VV$35$498 : {VV$35$498 : int | [(VV$35$498 = lq_anf__d12r)]}+bind 91 VV$35$498 : {VV$35$498 : int | [(VV$35$498 = lq_anf__d12r)]}+bind 92 VV$35$501 : {VV$35$501 : int | [(VV$35$501 = lq_anf__d12q)]}+bind 93 VV$35$501 : {VV$35$501 : int | [(VV$35$501 = lq_anf__d12q)]}+bind 94 VV$35$504 : {VV$35$504 : int | [(VV$35$504 = 10)]}+bind 95 VV$35$504 : {VV$35$504 : int | [(VV$35$504 = 10)]}+bind 96 VV$35$507 : {VV$35$507 : int | [(VV$35$507 = lq_anf__d12p)]}+bind 97 VV$35$507 : {VV$35$507 : int | [(VV$35$507 = lq_anf__d12p)]}+bind 98 VV$35$510 : {VV$35$510 : int | [(VV$35$510 = 0)]}+bind 99 VV$35$510 : {VV$35$510 : int | [(VV$35$510 = 0)]}+bind 100 VV$35$411 : {VV$35$411 : int | [$k__412]}+bind 101 VV$35$384 : {VV$35$384 : int | [$k__385]}+bind 102 VV$35$388 : {VV$35$388 : int | [$k__389]}+bind 103 VV$35$369 : {VV$35$369 : int | [$k__370]}+bind 104 VV$35$307 : {VV$35$307 : int | [$k__308]}+bind 105 VV$35$342 : {VV$35$342 : int | [$k__343]}+bind 106 VV$35$328 : {VV$35$328 : int | [$k__329]}+bind 107 VV$35$311 : {VV$35$311 : int | [$k__312]}+bind 108 VV$35$272 : {VV$35$272 : GHC.Types.Bool | [$k__273]}+bind 109 VV$35$263 : {VV$35$263 : int | [$k__264]}+bind 110 VV$35$234 : {VV$35$234 : GHC.Types.Bool | [$k__235]}+++++constraint:+  env [0;+       1;+       2;+       3;+       19;+       4;+       36;+       5;+       6;+       7;+       8;+       9;+       10;+       58;+       11;+       12;+       13;+       14;+       30;+       15]+  lhs {VV$35$F5 : int | [(VV$35$F5 = lq_anf__d12y)]}+  rhs {VV$35$F5 : int | [$k__308[VV$35$307:=VV$35$F5][VV$35$F:=VV$35$F5][VV$35$450:=VV$35$F5][lq_tmp_x_378:=VV$35$F5]]}+  id 5 tag [4]+  // META constraint id 5 : tests/pos/test000.hs:16:11-12+++constraint:+  env [0;+       32;+       1;+       33;+       2;+       3;+       19;+       4;+       5;+       6;+       7;+       8;+       72;+       9;+       10;+       11;+       12;+       13;+       14;+       30;+       15;+       31]+  lhs {VV$35$F8 : GHC.Types.Bool | [(VV$35$F8 = lq_anf__d12v)]}+  rhs {VV$35$F8 : GHC.Types.Bool | [(? Prop([VV$35$F8]))]}+  id 8 tag [3]+  // META constraint id 8 : tests/pos/test000.hs:14:23-29+++constraint:+  env [0;+       80;+       1;+       2;+       3;+       19;+       4;+       20;+       5;+       6;+       7;+       23;+       8;+       24;+       9;+       25;+       10;+       11;+       12;+       28;+       13;+       29;+       14;+       15]+  lhs {VV$35$F11 : GHC.Types.Bool | [(? Prop([VV$35$F11]))]}+  rhs {VV$35$F11 : GHC.Types.Bool | [$k__273[VV$35$272:=VV$35$F11][VV$35$F:=VV$35$F11][VV$35$483:=VV$35$F11]]}+  id 11 tag [6]+  // META constraint id 11 : tests/pos/test000.hs:10:33-50+++constraint:+  env [0;+       1;+       2;+       82;+       3;+       19;+       4;+       20;+       5;+       6;+       7;+       23;+       8;+       24;+       9;+       25;+       10;+       11;+       12;+       28;+       13;+       29;+       14;+       15]+  lhs {VV$35$F12 : GHC.Types.Bool | [(VV$35$F12 = lq_anf__d12t)]}+  rhs {VV$35$F12 : GHC.Types.Bool | [(? Prop([VV$35$F12]))]}+  id 12 tag [6]+  // META constraint id 12 : tests/pos/test000.hs:10:47-50+++constraint:+  env [0;+       1;+       2;+       3;+       19;+       4;+       20;+       84;+       5;+       6;+       7;+       23;+       8;+       24;+       9;+       25;+       10;+       26;+       11;+       27;+       12;+       13;+       14;+       15]+  lhs {VV$35$F13 : GHC.Types.Bool | [(VV$35$F13 = GHC.Types.False$35$68)]}+  rhs {VV$35$F13 : GHC.Types.Bool | [$k__273[VV$35$272:=VV$35$F13][VV$35$489:=VV$35$F13][VV$35$F:=VV$35$F13]]}+  id 13 tag [6]+  // META constraint id 13 : tests/pos/test000.hs:10:57-61+++constraint:+  env [0;+       1;+       2;+       3;+       19;+       4;+       20;+       5;+       21;+       6;+       22;+       86;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       15]+  lhs {VV$35$F14 : GHC.Types.Bool | [(VV$35$F14 = GHC.Types.False$35$68)]}+  rhs {VV$35$F14 : GHC.Types.Bool | [$k__273[VV$35$272:=VV$35$F14][VV$35$F:=VV$35$F14][VV$35$492:=VV$35$F14]]}+  id 14 tag [6]+  // META constraint id 14 : tests/pos/test000.hs:11:19-23+++constraint:+  env [0;+       16;+       1;+       17;+       2;+       18;+       3;+       4;+       5;+       6;+       7;+       8;+       88;+       9;+       10;+       11;+       12;+       13;+       14;+       15]+  lhs {VV$35$F15 : GHC.Types.Bool | [((? Prop([VV$35$F15])) <=> (lq_anf__d12q > lq_anf__d12r))]}+  rhs {VV$35$F15 : GHC.Types.Bool | [$k__235[VV$35$F:=VV$35$F15][VV$35$495:=VV$35$F15][VV$35$234:=VV$35$F15]]}+  id 15 tag [5]+  // META constraint id 15 : tests/pos/test000.hs:6:1-22+++++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15]+  reft {VV$35$234 : GHC.Types.Bool | [$k__235]}+  // META wf : <no location info>+++wf:+  env [0; 1; 2; 3; 19; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 30; 15]+  reft {VV$35$307 : int | [$k__308]}+  // META wf : <no location info>+++wf:+  env [0; 1; 2; 3; 19; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15]+  reft {VV$35$272 : GHC.Types.Bool | [$k__273]}+  // META wf : tests/pos/test000.hs:(9,1)-(11,23)+++++++
+ tests/pos/unused.fq view
@@ -0,0 +1,11 @@+constant len : func(0, [Tree; int])++bind 0 x : {v : int  | true} +bind 1 x : {v : Tree | true} +bind 2 y : {v : int  | v = len x } ++constraint:+  env [ ]+  lhs {v : Tree | 666 < len v }+  rhs {v : Tree | 66  < len v }+  id 1 tag []
+ tests/pos/wl02.fq view
@@ -0,0 +1,242 @@+qualif Nat(v:int) : (0 <= v)++bind 0  x0  : {v: int | [$k0]}+bind 1  x1  : {v: int | [$k1]}+bind 2  x2  : {v: int | [$k2]}+bind 3  x3  : {v: int | [$k3]}+bind 4  x4  : {v: int | [$k4]}+bind 5  x5  : {v: int | [$k5]}+bind 6  x6  : {v: int | [$k6]}+bind 7  x7  : {v: int | [$k7]}+bind 8  x8  : {v: int | [$k8]}+bind 9  x9  : {v: int | [$k9]}+bind 10 x10 : {v: int | [$k10]}+bind 11 x11 : {v: int | [$k11]}+bind 12 x12 : {v: int | [$k12]}+bind 13 x13 : {v: int | [$k13]}+bind 14 x14 : {v: int | [$k14]}+bind 15 x15 : {v: int | [$k15]}+bind 16 x16 : {v: int | [$k16]}+bind 17 x17 : {v: int | [$k17]}+bind 18 x18 : {v: int | [$k18]}+bind 19 x19 : {v: int | [$k19]}+bind 20 x20 : {v: int | [$k20]}++constraint:+  env [ ]+  lhs {v : int | [v = 10]}+  rhs {v : int | [$k0]}+  id 0 tag [0]++constraint:+  env [ 0 ]+  lhs {v : int | [v = x0]}+  rhs {v : int | [$k1]}+  id 1 tag [0]++constraint:+  env [ 1 ]+  lhs {v : int | [v = x1]}+  rhs {v : int | [$k2]}+  id 2 tag [0]+++constraint:+  env [ 2 ]+  lhs {v : int | [v = x2]}+  rhs {v : int | [$k3]}+  id 3 tag [0]++constraint:+  env [ 3 ]+  lhs {v : int | [v = x3]}+  rhs {v : int | [$k4]}+  id 4 tag [0]++constraint:+  env [ 4 ]+  lhs {v : int | [v = x4]}+  rhs {v : int | [$k5]}+  id 5 tag [0]++constraint:+  env [ 5 ]+  lhs {v : int | [v = x5]}+  rhs {v : int | [$k6]}+  id 6 tag [0]++constraint:+  env [ 6 ]+  lhs {v : int | [v = x6]}+  rhs {v : int | [$k7]}+  id 7 tag [0]++constraint:+  env [ 7 ]+  lhs {v : int | [v = x7]}+  rhs {v : int | [$k8]}+  id 8 tag [0]++constraint:+  env [ 8 ]+  lhs {v : int | [v = x8]}+  rhs {v : int | [$k9]}+  id 9 tag [0]++constraint:+  env [ 9 ]+  lhs {v : int | [v = x9]}+  rhs {v : int | [$k10]}+  id 10 tag [0]++constraint:+  env [ 10 ]+  lhs {v : int | [v = x10]}+  rhs {v : int | [$k11]}+  id 11 tag [0]++constraint:+  env [ 11 ]+  lhs {v : int | [v = x11]}+  rhs {v : int | [$k12]}+  id 12 tag [0]+++constraint:+  env [ 12 ]+  lhs {v : int | [v = x12]}+  rhs {v : int | [$k13]}+  id 13 tag [0]++constraint:+  env [ 13 ]+  lhs {v : int | [v = x13]}+  rhs {v : int | [$k14]}+  id 14 tag [0]++constraint:+  env [ 14 ]+  lhs {v : int | [v = x14]}+  rhs {v : int | [$k15]}+  id 15 tag [0]++constraint:+  env [ 15 ]+  lhs {v : int | [v = x15]}+  rhs {v : int | [$k16]}+  id 16 tag [0]++constraint:+  env [ 16 ]+  lhs {v : int | [v = x16]}+  rhs {v : int | [$k17]}+  id 17 tag [0]++constraint:+  env [ 17 ]+  lhs {v : int | [v = x17]}+  rhs {v : int | [$k18]}+  id 18 tag [0]++constraint:+  env [ 18 ]+  lhs {v : int | [v = x18]}+  rhs {v : int | [$k19]}+  id 19 tag [0]++constraint:+  env [ 19 ]+  lhs {v : int | [v = x19]}+  rhs {v : int | [$k20]}+  id 20 tag [0]++constraint:+  env [ 20 ]+  lhs {v : int | [v = x20]}+  rhs {v : int | [0 <= v]}+  id 100 tag [0]++wf:+  env [ ]+  reft {v: int | [$k0]}++wf:+  env [ ]+  reft {v: int | [$k1]}++wf:+  env [ ]+  reft {v: int | [$k2]}++wf:+  env [ ]+  reft {v: int | [$k3]}++wf:+  env [ ]+  reft {v: int | [$k4]}++wf:+  env [ ]+  reft {v: int | [$k5]}++wf:+  env [ ]+  reft {v: int | [$k6]}++wf:+  env [ ]+  reft {v: int | [$k7]}++wf:+  env [ ]+  reft {v: int | [$k8]}+++wf:+  env [ ]+  reft {v: int | [$k9]}++wf:+  env [ ]+  reft {v: int | [$k10]}++wf:+  env [ ]+  reft {v: int | [$k11]}++wf:+  env [ ]+  reft {v: int | [$k12]}++wf:+  env [ ]+  reft {v: int | [$k13]}++wf:+  env [ ]+  reft {v: int | [$k14]}++wf:+  env [ ]+  reft {v: int | [$k15]}++wf:+  env [ ]+  reft {v: int | [$k16]}++wf:+  env [ ]+  reft {v: int | [$k17]}++wf:+  env [ ]+  reft {v: int | [$k18]}++wf:+  env [ ]+  reft {v: int | [$k19]}++wf:+  env [ ]+  reft {v: int | [$k20]}
+ tests/smt2/Smt.hs view
@@ -0,0 +1,28 @@+-- just fire up ghci, :load Smt.hs and run `go file.smt2`++module Smt where++import qualified Data.Text.Lazy.IO as T++import Language.Fixpoint.Types.Config (SMTSolver (..))+import Language.Fixpoint.Parse+import Language.Fixpoint.SmtLib2+import System.Environment++main    = do f:_ <- getArgs+             _   <- go f+             return ()++runFile f+  = readFile f >>= runString++runString str+  = runCommands $ rr str++runCommands cmds +  = do me   <- makeContext Z3+       mapM_ (T.putStrLn . smt2) cmds+       zs   <- mapM (command me) cmds+       return zs++
tests/test.hs view
@@ -20,13 +20,18 @@  unitTests   = group "Unit" [-      testGroup "native-pos" <$> dirTests nativeCmd "tests/pos"  []  ExitSuccess-    , testGroup "native-neg" <$> dirTests nativeCmd "tests/neg"  []  (ExitFailure 1)-    , testGroup "elim-pos1"  <$> dirTests elimCmd   "tests/pos"  []  ExitSuccess-    , testGroup "elim-pos2"  <$> dirTests elimCmd   "tests/elim" []  ExitSuccess-    , testGroup "elim-neg"   <$> dirTests elimCmd   "tests/neg"  []  (ExitFailure 1)+      testGroup "native-pos" <$> dirTests nativeCmd "tests/pos"    skipNativePos  ExitSuccess+    , testGroup "native-neg" <$> dirTests nativeCmd "tests/neg"    []             (ExitFailure 1)+    , testGroup "elim-crash" <$> dirTests nativeCmd "tests/crash"  []             (ExitFailure 2)+    , testGroup "elim-pos1"  <$> dirTests elimCmd   "tests/pos"    []             ExitSuccess+    , testGroup "elim-pos2"  <$> dirTests elimCmd   "tests/elim"   []             ExitSuccess+    , testGroup "elim-neg"   <$> dirTests elimCmd   "tests/neg"    []             (ExitFailure 1)+    , testGroup "elim-crash" <$> dirTests elimCmd   "tests/crash"  []             (ExitFailure 2)    ] +skipNativePos :: [FilePath]+skipNativePos = ["NonLinear-pack.fq"]+ --------------------------------------------------------------------------- dirTests :: TestCmd -> FilePath -> [FilePath] -> ExitCode -> IO [TestTree] ---------------------------------------------------------------------------@@ -71,7 +76,7 @@ nativeCmd bin dir file = printf "cd %s && %s %s" dir bin file  elimCmd :: TestCmd-elimCmd bin dir file = printf "cd %s && %s --eliminate %s" dir bin file+elimCmd bin dir file = printf "cd %s && %s --eliminate=some %s" dir bin file   
+ tests/testParser.hs view
@@ -0,0 +1,308 @@+{-# LANGUAGE OverloadedStrings #-}++module Main where++import Language.Fixpoint.Parse+import Test.Tasty+import Test.Tasty.HUnit++main :: IO ()+main = defaultMain $ parserTests++parserTests :: TestTree+parserTests =+  testGroup "Tests"+    [+      testSortP+    , testFunAppP+    , testExpr0P+    , testPredP+    ]++-- ---------------------------------------------------------------------+{-++sort = '(' sort ')'+     | 'func' funcSort+     | '[' sort ']'+     | bvsort+     | fTyCon+     | tVar++sorts = '[' sortslist ']'++sortslist = sort+          | sort `;` sortslist++funcSort = '(' int `,` sorts ')'++     e.g.(func(1, [int; @(0)]))++bvsort = '(' 'BitVec' 'Size32' ')'+       | '(' 'BitVec' 'Size64' ')'++fTyCon = 'int' | 'Integer' | 'Int' | 'real' | 'num' | 'Str'+       | SYMBOL++SYMBOL = upper case char or _, followed by many of '%' '#' '$' '\'++tVar = '@' varSort+     | LOWERID++varSort = '(' INT ')'+-}++testSortP :: TestTree+testSortP =+  testGroup "SortP"+    [ testCase "FAbs" $+        show (doParse' sortP "test" "(func(1, [int; @(0)]))") @?= "FAbs 0 (FFunc FInt (FVar 0))"++    , testCase "(FAbs)" $+        show (doParse' sortP "test" "((func(1, [int; @(0)])))") @?= "FAbs 0 (FFunc FInt (FVar 0))"++    , testCase "FApp FInt" $+        show (doParse' sortP "test" "[int]") @?=+              "FApp (FTC (TC \"[]\" (dummyLoc) (TCInfo {tc_isNum = False, tc_isReal = False, tc_isString = False}))) FInt"++    , testCase "bv32" $+        show (doParse' sortP "test" "BitVec Size32") @?=+              "FApp (FTC (TC \"BitVec\" defined from: \"test\" (line 1, column 1) to: \"test\" (line 1, column 8) (TCInfo {tc_isNum = False, tc_isReal = False, tc_isString = False}))) (FTC (TC \"Size32\" defined from: \"test\" (line 1, column 8) to: \"test\" (line 1, column 14) (TCInfo {tc_isNum = False, tc_isReal = False, tc_isString = False})))"++    , testCase "bv64" $+        show (doParse' sortP "test" "BitVec Size64") @?=+              "FApp (FTC (TC \"BitVec\" defined from: \"test\" (line 1, column 1) to: \"test\" (line 1, column 8) (TCInfo {tc_isNum = False, tc_isReal = False, tc_isString = False}))) (FTC (TC \"Size64\" defined from: \"test\" (line 1, column 8) to: \"test\" (line 1, column 14) (TCInfo {tc_isNum = False, tc_isReal = False, tc_isString = False})))"++    , testCase "FInt int" $+        show (doParse' sortP "test" "int") @?= "FInt"++    , testCase "FInt Integer" $+        show (doParse' sortP "test" "Integer") @?= "FInt"++    , testCase "FInt Int" $+        show (doParse' sortP "test" "Int") @?= "FInt"++    , testCase "FReal real" $+        show (doParse' sortP "test" "real") @?= "FReal"++    , testCase "FNum num" $+        show (doParse' sortP "test" "num") @?= "FNum"++    , testCase "FStr" $+        show (doParse' sortP "test" "Str") @?=+             "FTC (TC \"Str\" (dummyLoc) (TCInfo {tc_isNum = False, tc_isReal = False, tc_isString = True}))"++    , testCase "SYMBOL" $+        show (doParse' sortP "test" "F#y") @?=+             "FTC (TC \"F#y\" defined from: \"test\" (line 1, column 1) to: \"test\" (line 1, column 4) (TCInfo {tc_isNum = False, tc_isReal = False, tc_isString = False}))"++    , testCase "FVar 3" $+        show (doParse' sortP "test" "@(3)") @?= "FVar 3"++    , testCase "FObj " $+        show (doParse' sortP "test" "foo") @?= "FObj \"foo\""++    , testCase "FObj " $+        show (doParse' sortP "test" "_foo") @?= "FObj \"_foo\""+    ]++-- ---------------------------------------------------------------------+{-++funApp = lit+       | exprFunSpaces+       | expFunSemis+       | expFunCommas+       | simpleApp++lit = 'lit' stringLiteral sort++exprFunSpaces =++exprFunSemis =++exprFunCommas =++simpleApp = +-}+testFunAppP :: TestTree+testFunAppP =+  testGroup "FunAppP"+    [ testCase "ECon (litP)" $+        show (doParse' funAppP "test" "lit \"#x00000008\" (BitVec  Size32)") @?=+          "ECon (L \"#x00000008\" (FApp (FTC (TC \"BitVec\" defined from: \"test\" (line 1, column 19) to: \"test\" (line 1, column 27) (TCInfo {tc_isNum = False, tc_isReal = False, tc_isString = False}))) (FTC (TC \"Size32\" defined from: \"test\" (line 1, column 27) to: \"test\" (line 1, column 33) (TCInfo {tc_isNum = False, tc_isReal = False, tc_isString = False})))))"++    , testCase "ECon (exprFunSpacesP)" $+        show (doParse' funAppP "test" "fooBar baz qux") @?= "EApp (EApp (EVar \"fooBar\") (EVar \"baz\")) (EVar \"qux\")"++    , testCase "ECon (exprFunCommasP)" $+        show (doParse' funAppP "test" "fooBar (baz, qux)") @?= "EApp (EApp (EVar \"fooBar\") (EVar \"baz\")) (EVar \"qux\")"++    , testCase "ECon (exprFunSemisP)" $+        show (doParse' funAppP "test" "fooBar ([baz; qux])") @?= "EApp (EApp (EVar \"fooBar\") (EVar \"baz\")) (EVar \"qux\")"++    , testCase "ECon (simpleAppP)" $+        show (doParse' funAppP "test" "fooBar (baz + 1)") @?= "EApp (EVar \"fooBar\") (EBin Plus (EVar \"baz\") (ECon (I 1)))"+    ]++-- ---------------------------------------------------------------------+{-+expr0 = fastIf+      | symconst+      | constant+      | '_|_'+      | lam+      | '(' expr ')'+      | '(' exprCast ')'+      | symChars++-}+testExpr0P :: TestTree+testExpr0P =+  testGroup "expr0P"+    [ testCase "EIte" $+        show (doParse' expr0P "test" "if true then x else y") @?= "EIte (PAnd []) (EVar \"x\") (EVar \"y\")"++    , testCase "ESym SL" $+        show (doParse' expr0P "test" "\"foo\" ") @?= "ESym (SL \"foo\")"++    , testCase "ECon R" $+        show (doParse' expr0P "test" "0.0") @?= "ECon (R 0.0)"++    , testCase "ECon I" $+        show (doParse' expr0P "test" "0") @?= "ECon (I 0)"++    , testCase "ECon I" $+        show (doParse' expr0P "test" "0") @?= "ECon (I 0)"++    , testCase "EBot / POr []" $+        show (doParse' expr0P "test" "_|_") @?= "POr []" -- pattern for "EBot"++    , testCase "ELam" $+        show (doParse' expr0P "test" "\\ foo : Int -> true") @?= "ELam (\"foo\",FInt) (EVar \"true\")"++    , testCase "Expr" $+        show (doParse' expr0P "test" "(1)") @?= "ECon (I 1)"++    , testCase "ECst dcolon" $+        show (doParse' expr0P "test" "(1 :: Int)") @?= "ECst (ECon (I 1)) FInt"++    , testCase "ECst colon" $+        show (doParse' expr0P "test" "(1 : Int)") @?= "ECst (ECon (I 1)) FInt"++    , testCase "charsExpr EVar" $+        show (doParse' expr0P "test" "foo") @?= "EVar \"foo\""++    , testCase "charsExpr ECon" $+        show (doParse' expr0P "test" "1") @?= "ECon (I 1)"+    ]++-- ---------------------------------------------------------------------+{-++pred = expressionParse (prefixOp++infixOp) pred0++prefixOp = '~' | 'not'++infixOp  = '&&' | '||' | '=>' | '==>' | '<=>'++-- terms are pred0+pred0 = 'true' | 'false'+      | '??'+      | kvarPred+      | fastIfP+      | predr+      | '(' pred ')'+      | '?' expr+      | funApp+      | symbol+      | '&&' preds+      | '||' preds++kvarPred = kvar substs++kvar = '$' symbol++substs = {- empty -}+       | subst substs++subst = '[' symbol ':=' expr ']'++preds = '[' predslist ']'++predslist = pred+          | pred `;` predslist++fastIf = 'if' pred 'then' pred 'else' pred++predr = expr brel expr++brelP = '==' | '=' | '~~' | '!=' | '/=' | '!~' | '<' | '<=' | '>' | '>='++-}++testPredP :: TestTree+testPredP =+  testGroup "predP"+    [ testCase "PTrue" $+        show (doParse' predP "test" "true") @?= "PAnd []" -- pattern for PTrue++    , testCase "PFalse" $+        show (doParse' predP "test" "false") @?= "POr []" -- pattern for PFalse++    , testCase "PGrad / ??" $+        show (doParse' predP "test" "??") @?= "PGrad $\"\\\"test\\\" (line 1, column 3)\"  (PAnd [])"++    , testCase "kvarPred empty" $+        show (doParse' predP "test" "$foo") @?= "PKVar $\"foo\" "++    , testCase "kvarPred one" $+        show (doParse' predP "test" "$foo  [x := 1]") @?= "PKVar $\"foo\" [x:=1]"++    , testCase "kvarPred two" $+        show (doParse' predP "test" "$foo  [x := 1] [ y := true ]") @?= "PKVar $\"foo\" [x:=1][y:=true]"++    , testCase "fastIf" $+        show (doParse' predP "test" "if true then true else false" ) @?=+          -- note conversion+          "PAnd [PImp (PAnd []) (PAnd []),PImp (PNot (PAnd [])) (POr [])]"++    , testCase "brel" $+        show (doParse' predP "test" "1 == 2") @?= "PAtom Eq (ECon (I 1)) (ECon (I 2))"++    , testCase "parens pred" $+        show (doParse' predP "test" "((1 == 2))") @?= "PAtom Eq (ECon (I 1)) (ECon (I 2))"++    , testCase "? expr" $+        show (doParse' predP "test" "? (1+2)") @?= "EBin Plus (ECon (I 1)) (ECon (I 2))"++    , testCase "funApp 1" $+        show (doParse' predP "test" "f a b") @?= "EApp (EApp (EVar \"f\") (EVar \"a\")) (EVar \"b\")"++    , testCase "funApp 2" $+        show (doParse' predP "test" "f (a, b)") @?= "EApp (EApp (EVar \"f\") (EVar \"a\")) (EVar \"b\")"++    , testCase "funApp 3" $+        show (doParse' predP "test" "f ([a; b])") @?= "EApp (EApp (EVar \"f\") (EVar \"a\")) (EVar \"b\")"++    , testCase "symbol" $+        show (doParse' predP "test" "f") @?= "EVar \"f\""++    , testCase "&& 0" $+        show (doParse' predP "test" "&& []") @?= "PAnd []"++    , testCase "&& 1" $+        show (doParse' predP "test" "&& [x]") @?= "PAnd [EVar \"x\"]"++    , testCase "&& 2" $+        show (doParse' predP "test" "&& [x;y]") @?= "PAnd [EVar \"x\",EVar \"y\"]"++    , testCase "|| 0" $+        show (doParse' predP "test" "|| []") @?= "POr []"++    , testCase "|| 1" $+        show (doParse' predP "test" "|| [x]") @?= "POr [EVar \"x\"]"++    , testCase "|| 2" $+        show (doParse' predP "test" "|| [x;y]") @?= "POr [EVar \"x\",EVar \"y\"]"+    ]
+ tests/todo/MergeSort.fq view
@@ -0,0 +1,3234 @@+qualif Fst(v : @(1), y : @(0)): ((v = (fst y))) // "tests/todo/MergeSort.new.min.fq" (line 1, column 8)+qualif Snd(v : @(1), y : @(0)): ((v = (snd y))) // "tests/todo/MergeSort.new.min.fq" (line 2, column 8)+qualif Auto(VV : @(0), fld##0 : @(0)): ((VV >= fld##0)) // "tests/todo/MergeSort.new.min.fq" (line 3, column 8)+qualif Auto(VV : @(0), fld##0 : @(0)): ((VV >= fld##0)) // "tests/todo/MergeSort.new.min.fq" (line 4, column 8)+qualif Auto(VV : [@(0)], xs : [@(0)], ys : [@(0)]): (((len VV) = ((len xs) + (len ys)))) // "tests/todo/MergeSort.new.min.fq" (line 5, column 8)+qualif Auto(VV : @(0), fld##0 : @(0)): ((VV >= fld##0)) // "tests/todo/MergeSort.new.min.fq" (line 6, column 8)+qualif Auto(VV : [@(0)], xs : [@(0)]): (((len VV) = (len xs))) // "tests/todo/MergeSort.new.min.fq" (line 7, column 8)+qualif Auto(VV : @(0), fld##0 : @(0)): ((VV >= fld##0)) // "tests/todo/MergeSort.new.min.fq" (line 8, column 8)+qualif Auto(v##0 : (Tuple  [@(0)]  [@(0)]), xs : [@(0)]): ((((len (fst v##0)) + (len (snd v##0))) = (len xs))) // "tests/todo/MergeSort.new.min.fq" (line 9, column 8)+qualif Auto(v##0 : [@(0)], xs : [@(0)]): ((((len v##0) > 1) => ((len v##0) < (len xs)))) // "tests/todo/MergeSort.new.min.fq" (line 10, column 8)+qualif Auto(v##0 : [@(0)], xs : [@(0)]): ((((len v##0) > 1) => ((len v##0) < (len xs)))) // "tests/todo/MergeSort.new.min.fq" (line 11, column 8)+qualif IsEmp(v : GHC.Types.Bool, xs : [@(0)]): (((Prop v) <=> ((len xs) > 0))) // "tests/todo/MergeSort.new.min.fq" (line 12, column 8)+qualif IsEmp(v : GHC.Types.Bool, xs : [@(0)]): (((Prop v) <=> ((len xs) = 0))) // "tests/todo/MergeSort.new.min.fq" (line 13, column 8)+qualif ListZ(v : [@(0)]): (((len v) = 0)) // "tests/todo/MergeSort.new.min.fq" (line 14, column 8)+qualif ListZ(v : [@(0)]): (((len v) >= 0)) // "tests/todo/MergeSort.new.min.fq" (line 15, column 8)+qualif ListZ(v : [@(0)]): (((len v) > 0)) // "tests/todo/MergeSort.new.min.fq" (line 16, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (((len v) = (len xs))) // "tests/todo/MergeSort.new.min.fq" (line 17, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (((len v) >= (len xs))) // "tests/todo/MergeSort.new.min.fq" (line 18, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (((len v) > (len xs))) // "tests/todo/MergeSort.new.min.fq" (line 19, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (((len v) <= (len xs))) // "tests/todo/MergeSort.new.min.fq" (line 20, column 8)+qualif CmpLen(v : [@(1)], xs : [@(0)]): (((len v) < (len xs))) // "tests/todo/MergeSort.new.min.fq" (line 21, column 8)+qualif EqLen(v : int, xs : [@(0)]): ((v = (len xs))) // "tests/todo/MergeSort.new.min.fq" (line 22, column 8)+qualif LenEq(v : [@(0)], x : int): ((x = (len v))) // "tests/todo/MergeSort.new.min.fq" (line 23, column 8)+qualif LenDiff(v : [@(0)], x : int): (((len v) = (x + 1))) // "tests/todo/MergeSort.new.min.fq" (line 24, column 8)+qualif LenDiff(v : [@(0)], x : int): (((len v) = (x - 1))) // "tests/todo/MergeSort.new.min.fq" (line 25, column 8)+qualif LenAcc(v : int, xs : [@(0)], n : int): ((v = ((len xs) + n))) // "tests/todo/MergeSort.new.min.fq" (line 26, column 8)+qualif Bot(v : @(0)): ((0 = 1)) // "tests/todo/MergeSort.new.min.fq" (line 27, column 8)+qualif Bot(v : @(0)): ((0 = 1)) // "tests/todo/MergeSort.new.min.fq" (line 28, column 8)+qualif Bot(v : @(0)): ((0 = 1)) // "tests/todo/MergeSort.new.min.fq" (line 29, column 8)+qualif Bot(v : bool): ((0 = 1)) // "tests/todo/MergeSort.new.min.fq" (line 30, column 8)+qualif Bot(v : int): ((0 = 1)) // "tests/todo/MergeSort.new.min.fq" (line 31, column 8)+qualif CmpZ(v : @(0)): ((v < 0)) // "tests/todo/MergeSort.new.min.fq" (line 32, column 8)+qualif CmpZ(v : @(0)): ((v <= 0)) // "tests/todo/MergeSort.new.min.fq" (line 33, column 8)+qualif CmpZ(v : @(0)): ((v > 0)) // "tests/todo/MergeSort.new.min.fq" (line 34, column 8)+qualif CmpZ(v : @(0)): ((v >= 0)) // "tests/todo/MergeSort.new.min.fq" (line 35, column 8)+qualif CmpZ(v : @(0)): ((v = 0)) // "tests/todo/MergeSort.new.min.fq" (line 36, column 8)+qualif CmpZ(v : @(0)): ((v != 0)) // "tests/todo/MergeSort.new.min.fq" (line 37, column 8)+qualif Cmp(v : @(0), x : @(0)): ((v < x)) // "tests/todo/MergeSort.new.min.fq" (line 38, column 8)+qualif Cmp(v : @(0), x : @(0)): ((v <= x)) // "tests/todo/MergeSort.new.min.fq" (line 39, column 8)+qualif Cmp(v : @(0), x : @(0)): ((v > x)) // "tests/todo/MergeSort.new.min.fq" (line 40, column 8)+qualif Cmp(v : @(0), x : @(0)): ((v >= x)) // "tests/todo/MergeSort.new.min.fq" (line 41, column 8)+qualif Cmp(v : @(0), x : @(0)): ((v = x)) // "tests/todo/MergeSort.new.min.fq" (line 42, column 8)+qualif Cmp(v : @(0), x : @(0)): ((v != x)) // "tests/todo/MergeSort.new.min.fq" (line 43, column 8)+qualif One(v : int): ((v = 1)) // "tests/todo/MergeSort.new.min.fq" (line 44, column 8)+qualif True1(v : GHC.Types.Bool): ((Prop v)) // "tests/todo/MergeSort.new.min.fq" (line 45, column 8)+qualif False1(v : GHC.Types.Bool): ((~ ((Prop v)))) // "tests/todo/MergeSort.new.min.fq" (line 46, column 8)+qualif Papp(v : @(0), p : (Pred  @(0))): ((papp1 p v)) // "tests/todo/MergeSort.new.min.fq" (line 47, column 8)+qualif Papp2(v : @(1), x : @(0), p : (Pred  @(1)  @(0))): ((papp2 p v x)) // "tests/todo/MergeSort.new.min.fq" (line 48, column 8)+qualif Papp3(v : @(2), x : @(0), y : @(1), p : (Pred  @(2)  @(0)  @(1))): ((papp3 p v x y)) // "tests/todo/MergeSort.new.min.fq" (line 49, column 8)+++cut $k_##795+cut $k_##1160+cut $k_##1118+cut $k_##753+cut $k_##1115+cut $k_##792+cut $k_##750+cut $k_##746+cut $k_##1111+cut $k_##1153+cut $k_##788+cut $k_##1157+++pack $k_##686 : 0+pack $k_##671 : 0+pack $k_##655 : 0+pack $k_##679 : 0+pack $k_##667 : 0+pack $k_##659 : 0+pack $k_##662 : 0+pack $k_##674 : 0+pack $k_##683 : 0+pack $k_##572 : 1+pack $k_##560 : 1+pack $k_##556 : 1+pack $k_##584 : 1+pack $k_##575 : 1+pack $k_##587 : 1+pack $k_##563 : 1+pack $k_##568 : 1+pack $k_##580 : 1+pack $k_##883 : 2+pack $k_##907 : 2+pack $k_##890 : 2+pack $k_##914 : 2+pack $k_##899 : 2+pack $k_##902 : 2+pack $k_##911 : 2+pack $k_##895 : 2+pack $k_##887 : 2+pack $k_##314 : 3+pack $k_##321 : 3+pack $k_##318 : 3+pack $k_##753 : 4+pack $k_##750 : 4+pack $k_##746 : 4+pack $k_##1020 : 5+pack $k_##1017 : 5+pack $k_##540 : 6+pack $k_##543 : 6+pack $k_##639 : 7+pack $k_##642 : 7+pack $k_##971 : 8+pack $k_##968 : 8+pack $k_##168 : 9+pack $k_##175 : 9+pack $k_##172 : 9+pack $k_##1118 : 10+pack $k_##1115 : 10+pack $k_##1111 : 10+pack $k_##256 : 11+pack $k_##259 : 11+pack $k_##252 : 11+pack $k_##1037 : 12+pack $k_##1040 : 12+pack $k_##237 : 13+pack $k_##241 : 13+pack $k_##244 : 13+pack $k_##467 : 14+pack $k_##470 : 14+pack $k_##415 : 15+pack $k_##418 : 15+pack $k_##1160 : 16+pack $k_##1153 : 16+pack $k_##1157 : 16+pack $k_##387 : 17+pack $k_##390 : 17+pack $k_##867 : 18+pack $k_##864 : 18+pack $k_##844 : 19+pack $k_##841 : 19+pack $k_##1076 : 20+pack $k_##1080 : 20+pack $k_##1083 : 20+pack $k_##338 : 21+pack $k_##335 : 21+pack $k_##795 : 22+pack $k_##792 : 22+pack $k_##788 : 22+++constant runFun : (func(2, [(Arrow  @(0)  @(1)); @(0); @(1)]))+constant addrLen : (func(0, [int; int]))+constant lit$36$$47$Users$47$rjhala$47$research$47$stack$47$liquidhaskell$47$tests$47$pos$47$MergeSort.hs$58$$40$48$44$1$41$$45$$40$52$44$41$41$$124$function$32$merge : (Str)+constant papp5 : (func(10, [(Pred  @(0)  @(1)  @(2)  @(3)  @(4));+                            @(5);+                            @(6);+                            @(7);+                            @(8);+                            @(9);+                            bool]))+constant x_Tuple21 : (func(2, [(Tuple  @(0)  @(1)); @(0)]))+constant GHC.Types.False##68 : (GHC.Types.Bool)+constant x_Tuple65 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(4)]))+constant x_Tuple55 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(4)]))+constant x_Tuple33 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(2)]))+constant x_Tuple77 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(6)]))+constant papp3 : (func(6, [(Pred  @(0)  @(1)  @(2));+                           @(3);+                           @(4);+                           @(5);+                           bool]))+constant GHC.Types.True##6u : (GHC.Types.Bool)+constant x_Tuple63 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(2)]))+constant x_Tuple41 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(0)]))+constant GHC.Types.LT##6S : (GHC.Types.Ordering)+constant papp4 : (func(8, [(Pred  @(0)  @(1)  @(2)  @(3));+                           @(4);+                           @(5);+                           @(6);+                           @(7);+                           bool]))+constant x_Tuple64 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(3)]))+constant GHC.Types.GT##6W : (GHC.Types.Ordering)+constant GHC.Types.$58$$35$$35$64 : (func(1, [@(0);+                                              [@(0)];+                                              [@(0)]]))+constant autolen : (func(1, [@(0); int]))+constant x_Tuple52 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(1)]))+constant head : (func(1, [[@(0)]; @(0)]))+constant MergeSort.split##rlx : (func(1, [[@(0)];+                                          (Tuple  [@(0)]  [@(0)])]))+constant null : (func(1, [[@(0)]; bool]))+constant GHC.Classes.$60$$61$$35$$35$r4 : (func(1, [@(0);+                                                    @(0);+                                                    GHC.Types.Bool]))+constant papp2 : (func(4, [(Pred  @(0)  @(1)); @(2); @(3); bool]))+constant x_Tuple62 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(1)]))+constant GHC.Tuple.$40$$44$$41$$35$$35$74 : (func(2, [@(0);+                                                      @(1);+                                                      (Tuple  @(0)  @(1))]))+constant fromJust : (func(1, [(GHC.Base.Maybe  @(0)); @(0)]))+constant papp7 : (func(14, [(Pred  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                            @(7);+                            @(8);+                            @(9);+                            @(10);+                            @(11);+                            @(12);+                            @(13);+                            bool]))+constant MergeSort.sort##rjG : (func(1, [[@(0)]; [@(0)]]))+constant x_Tuple53 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(2)]))+constant x_Tuple71 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(0)]))+constant x_Tuple74 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(3)]))+constant len : (func(2, [(@(0)  @(1)); int]))+constant papp6 : (func(12, [(Pred  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                            @(6);+                            @(7);+                            @(8);+                            @(9);+                            @(10);+                            @(11);+                            bool]))+constant x_Tuple22 : (func(2, [(Tuple  @(0)  @(1)); @(1)]))+constant x_Tuple66 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(5)]))+constant x_Tuple44 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(3)]))+constant strLen : (func(0, [int; int]))+constant x_Tuple72 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(1)]))+constant isJust : (func(1, [(GHC.Base.Maybe  @(0)); bool]))+constant Prop : (func(0, [GHC.Types.Bool; bool]))+constant x_Tuple31 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(0)]))+constant x_Tuple75 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(4)]))+constant papp1 : (func(2, [(Pred  @(0)); @(1); bool]))+constant x_Tuple61 : (func(6, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5));+                               @(0)]))+constant x_Tuple43 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(2)]))+constant tail : (func(1, [[@(0)]; [@(0)]]))+constant GHC.Types.EQ##6U : (GHC.Types.Ordering)+constant Control.Exception.Base.patError##0e : (func(1, [int;+                                                         @(0)]))+constant MergeSort.merge##rly : (func(1, [[@(0)]; [@(0)]; [@(0)]]))+constant x_Tuple51 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(0)]))+constant x_Tuple73 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(2)]))+constant GHC.Types.$91$$93$$35$$35$6m : (func(1, [[@(0)]]))+constant x_Tuple54 : (func(5, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4));+                               @(3)]))+constant cmp : (func(0, [GHC.Types.Ordering; GHC.Types.Ordering]))+constant x_Tuple32 : (func(3, [(Tuple  @(0)  @(1)  @(2)); @(1)]))+constant x_Tuple76 : (func(7, [(Tuple  @(0)  @(1)  @(2)  @(3)  @(4)  @(5)  @(6));+                               @(5)]))+constant snd : (func(2, [(Tuple  @(0)  @(1)); @(1)]))+constant fst : (func(2, [(Tuple  @(0)  @(1)); @(0)]))+constant x_Tuple42 : (func(4, [(Tuple  @(0)  @(1)  @(2)  @(3));+                               @(1)]))+constant GHC.Prim.void###0l : (GHC.Prim.Void#)+++bind 0 GHC.Prim.void###0l : {VV##84 : GHC.Prim.Void# | []}+bind 1 GHC.Types.False##68 : {VV##86 : GHC.Types.Bool | []}+bind 2 GHC.Types.$91$$93$$35$$35$6m : {VV : func(1, [[@(0)]]) | []}+bind 3 GHC.Types.True##6u : {VV##88 : GHC.Types.Bool | []}+bind 4 GHC.Types.EQ##6U : {VV##91 : GHC.Types.Ordering | [(VV##91 = GHC.Types.EQ##6U)]}+bind 5 GHC.Types.LT##6S : {VV##92 : GHC.Types.Ordering | [(VV##92 = GHC.Types.LT##6S)]}+bind 6 GHC.Types.GT##6W : {VV##93 : GHC.Types.Ordering | [(VV##93 = GHC.Types.GT##6W)]}+bind 7 GHC.Types.True##6u : {v##4 : GHC.Types.Bool | [(Prop v##4)]}+bind 8 GHC.Types.False##68 : {v##5 : GHC.Types.Bool | [(~ ((Prop v##5)))]}+bind 9 GHC.Types.False##68 : {v##5 : GHC.Types.Bool | [(~ ((Prop v##5)))]}+bind 10 GHC.Types.$91$$93$$35$$35$6m : {VV : func(1, [[@(0)]]) | []}+bind 11 GHC.Types.True##6u : {v##4 : GHC.Types.Bool | [(Prop v##4)]}+bind 12 fix$36$$36$dOrd_azK : {VV##119 : (GHC.Classes.Ord  a_azo) | []}+bind 13 xs##ayP : {VV##120 : [a_azo] | [((len VV##120) >= 0)]}+bind 14 ds_dMl : {VV##121 : [a_azo] | [((len VV##121) >= 0)]}+bind 15 lq_anf$##dMK : {lq_tmp$x##123 : [a_azo] | [((len lq_tmp$x##123) >= 0);+                                                   (lq_tmp$x##123 = ds_dMl);+                                                   ((len lq_tmp$x##123) >= 0)]}+bind 16 lq_anf$##dMK : {lq_tmp$x##127 : [a_azo] | [((len lq_tmp$x##127) >= 0);+                                                   (lq_tmp$x##127 = ds_dMl);+                                                   ((len lq_tmp$x##127) >= 0);+                                                   ((len lq_tmp$x##127) >= 0)]}+bind 17 lq_anf$##dMK : {lq_tmp$x##127 : [a_azo] | [((len lq_tmp$x##127) >= 0);+                                                   (lq_tmp$x##127 = ds_dMl);+                                                   ((len lq_tmp$x##127) >= 0);+                                                   ((len lq_tmp$x##127) = 0);+                                                   ((null lq_tmp$x##127) <=> true);+                                                   (lq_tmp$x##127 = GHC.Types.$91$$93$$35$$35$6m);+                                                   ((len lq_tmp$x##127) = 0);+                                                   ((null lq_tmp$x##127) <=> true);+                                                   ((len lq_tmp$x##127) >= 0)]}+bind 18 lq_anf$##dMK : {lq_tmp$x##140 : [a_azo] | [((len lq_tmp$x##140) >= 0);+                                                   (lq_tmp$x##140 = ds_dMl);+                                                   ((len lq_tmp$x##140) >= 0);+                                                   ((len lq_tmp$x##140) >= 0)]}+bind 19 lq_anf$##dMU : {VV : a_azo | []}+bind 20 lq_anf$##dMV : {lq_tmp$x##154 : [a_azo] | [((len lq_tmp$x##154) >= 0)]}+bind 21 lq_anf$##dMK : {lq_tmp$x##140 : [a_azo] | [((len lq_tmp$x##140) >= 0);+                                                   (lq_tmp$x##140 = ds_dMl);+                                                   ((len lq_tmp$x##140) >= 0);+                                                   ((len lq_tmp$x##140) = (1 + (len lq_anf$##dMV)));+                                                   ((null lq_tmp$x##140) <=> false);+                                                   ((tail lq_tmp$x##140) = lq_anf$##dMV);+                                                   ((head lq_tmp$x##140) = lq_anf$##dMU);+                                                   (lq_tmp$x##140 = (GHC.Types.$58$$35$$35$64 lq_anf$##dMU lq_anf$##dMV));+                                                   ((len lq_tmp$x##140) = (1 + (len lq_anf$##dMV)));+                                                   ((null lq_tmp$x##140) <=> false);+                                                   ((tail lq_tmp$x##140) = lq_anf$##dMV);+                                                   ((head lq_tmp$x##140) = lq_anf$##dMU);+                                                   ((len lq_tmp$x##140) >= 0)]}+bind 22 ds_dMr : {VV##163 : GHC.Prim.Void# | [$k_##164]}+bind 23 lq_anf$##dML : {lq_tmp$x##178 : [a_azo] | [((len lq_tmp$x##178) >= 0);+                                                   (lq_tmp$x##178 = xs##ayP);+                                                   ((len lq_tmp$x##178) >= 0)]}+bind 24 lq_anf$##dML : {lq_tmp$x##182 : [a_azo] | [((len lq_tmp$x##182) >= 0);+                                                   (lq_tmp$x##182 = xs##ayP);+                                                   ((len lq_tmp$x##182) >= 0);+                                                   ((len lq_tmp$x##182) >= 0)]}+bind 25 lq_anf$##dML : {lq_tmp$x##182 : [a_azo] | [((len lq_tmp$x##182) >= 0);+                                                   (lq_tmp$x##182 = xs##ayP);+                                                   ((len lq_tmp$x##182) >= 0);+                                                   ((len lq_tmp$x##182) = 0);+                                                   ((null lq_tmp$x##182) <=> true);+                                                   (lq_tmp$x##182 = GHC.Types.$91$$93$$35$$35$6m);+                                                   ((len lq_tmp$x##182) = 0);+                                                   ((null lq_tmp$x##182) <=> true);+                                                   ((len lq_tmp$x##182) >= 0)]}+bind 26 lq_anf$##dML : {lq_tmp$x##195 : [a_azo] | [((len lq_tmp$x##195) >= 0);+                                                   (lq_tmp$x##195 = xs##ayP);+                                                   ((len lq_tmp$x##195) >= 0);+                                                   ((len lq_tmp$x##195) >= 0)]}+bind 27 x##ayR : {VV : a_azo | []}+bind 28 xs##ayS : {lq_tmp$x##209 : [a_azo] | [((len lq_tmp$x##209) >= 0)]}+bind 29 lq_anf$##dML : {lq_tmp$x##195 : [a_azo] | [((len lq_tmp$x##195) >= 0);+                                                   (lq_tmp$x##195 = xs##ayP);+                                                   ((len lq_tmp$x##195) >= 0);+                                                   ((len lq_tmp$x##195) = (1 + (len xs##ayS)));+                                                   ((null lq_tmp$x##195) <=> false);+                                                   ((tail lq_tmp$x##195) = xs##ayS);+                                                   ((head lq_tmp$x##195) = x##ayR);+                                                   (lq_tmp$x##195 = (GHC.Types.$58$$35$$35$64 x##ayR xs##ayS));+                                                   ((len lq_tmp$x##195) = (1 + (len xs##ayS)));+                                                   ((null lq_tmp$x##195) <=> false);+                                                   ((tail lq_tmp$x##195) = xs##ayS);+                                                   ((head lq_tmp$x##195) = x##ayR);+                                                   ((len lq_tmp$x##195) >= 0)]}+bind 30 lq_anf$##dMM : {lq_tmp$x##219 : [a_azo] | [((len lq_tmp$x##219) >= 0);+                                                   (lq_tmp$x##219 = ds_dMl);+                                                   ((len lq_tmp$x##219) >= 0)]}+bind 31 lq_anf$##dMM : {lq_tmp$x##223 : [a_azo] | [((len lq_tmp$x##223) >= 0);+                                                   (lq_tmp$x##223 = ds_dMl);+                                                   ((len lq_tmp$x##223) >= 0);+                                                   ((len lq_tmp$x##223) >= 0)]}+bind 32 lq_anf$##dMM : {lq_tmp$x##223 : [a_azo] | [((len lq_tmp$x##223) >= 0);+                                                   (lq_tmp$x##223 = ds_dMl);+                                                   ((len lq_tmp$x##223) >= 0);+                                                   ((len lq_tmp$x##223) = 0);+                                                   ((null lq_tmp$x##223) <=> true);+                                                   (lq_tmp$x##223 = GHC.Types.$91$$93$$35$$35$6m);+                                                   ((len lq_tmp$x##223) = 0);+                                                   ((null lq_tmp$x##223) <=> true);+                                                   ((len lq_tmp$x##223) >= 0)]}+bind 33 ds_dMn : {VV##232 : GHC.Prim.Void# | [$k_##233]}+bind 34 lq_anf$##dMN : {lq_tmp$x##246 : int | [(lq_tmp$x##246 ~~ lit$36$$47$Users$47$rjhala$47$research$47$stack$47$liquidhaskell$47$tests$47$pos$47$MergeSort.hs$58$$40$48$44$1$41$$45$$40$52$44$41$41$$124$function$32$merge);+                                               ((strLen lq_tmp$x##246) = 95)]}+bind 35 lq_anf$##dMM : {lq_tmp$x##266 : [a_azo] | [((len lq_tmp$x##266) >= 0);+                                                   (lq_tmp$x##266 = ds_dMl);+                                                   ((len lq_tmp$x##266) >= 0);+                                                   ((len lq_tmp$x##266) >= 0)]}+bind 36 y##ayT : {VV : a_azo | []}+bind 37 ys##ayU : {lq_tmp$x##280 : [a_azo] | [((len lq_tmp$x##280) >= 0)]}+bind 38 lq_anf$##dMM : {lq_tmp$x##266 : [a_azo] | [((len lq_tmp$x##266) >= 0);+                                                   (lq_tmp$x##266 = ds_dMl);+                                                   ((len lq_tmp$x##266) >= 0);+                                                   ((len lq_tmp$x##266) = (1 + (len ys##ayU)));+                                                   ((null lq_tmp$x##266) <=> false);+                                                   ((tail lq_tmp$x##266) = ys##ayU);+                                                   ((head lq_tmp$x##266) = y##ayT);+                                                   (lq_tmp$x##266 = (GHC.Types.$58$$35$$35$64 y##ayT ys##ayU));+                                                   ((len lq_tmp$x##266) = (1 + (len ys##ayU)));+                                                   ((null lq_tmp$x##266) <=> false);+                                                   ((tail lq_tmp$x##266) = ys##ayU);+                                                   ((head lq_tmp$x##266) = y##ayT);+                                                   ((len lq_tmp$x##266) >= 0)]}+bind 39 lq_anf$##dMO : {lq_tmp$x##290 : GHC.Types.Bool | [((Prop lq_tmp$x##290) <=> (x##ayR <= y##ayT))]}+bind 40 lq_anf$##dMP : {lq_tmp$x##302 : GHC.Types.Bool | [((Prop lq_tmp$x##302) <=> (x##ayR <= y##ayT));+                                                          (lq_tmp$x##302 = lq_anf$##dMO)]}+bind 41 lq_anf$##dMP : {lq_tmp$x##304 : GHC.Types.Bool | [((Prop lq_tmp$x##304) <=> (x##ayR <= y##ayT));+                                                          (lq_tmp$x##304 = lq_anf$##dMO)]}+bind 42 lq_anf$##dMP : {lq_tmp$x##304 : GHC.Types.Bool | [((Prop lq_tmp$x##304) <=> (x##ayR <= y##ayT));+                                                          (lq_tmp$x##304 = lq_anf$##dMO);+                                                          (~ ((Prop lq_tmp$x##304)));+                                                          (~ ((Prop lq_tmp$x##304)));+                                                          (~ ((Prop lq_tmp$x##304)))]}+bind 43 ds_dMp : {VV##309 : GHC.Prim.Void# | [$k_##310]}+bind 44 lq_tmp$x##340 : {VV : a_azo | []}+bind 45 lq_anf$##dMQ : {lq_tmp$x##326 : [a_azo] | [((len lq_tmp$x##326) = (1 + (len xs##ayS)));+                                                   ((null lq_tmp$x##326) <=> false);+                                                   ((tail lq_tmp$x##326) = xs##ayS);+                                                   ((head lq_tmp$x##326) = x##ayR);+                                                   ((len lq_tmp$x##326) >= 0)]}+bind 46 lq_anf$##dMR : {VV##374 : [a_azo] | [((len VV##374) = ((len lq_anf$##dMQ) + (len ys##ayU)));+                                             ((len VV##374) >= 0)]}+bind 47 lq_tmp$x##392 : {VV : a_azo | []}+bind 48 lq_anf$##dMP : {lq_tmp$x##398 : GHC.Types.Bool | [((Prop lq_tmp$x##398) <=> (x##ayR <= y##ayT));+                                                          (lq_tmp$x##398 = lq_anf$##dMO)]}+bind 49 lq_anf$##dMP : {lq_tmp$x##398 : GHC.Types.Bool | [((Prop lq_tmp$x##398) <=> (x##ayR <= y##ayT));+                                                          (lq_tmp$x##398 = lq_anf$##dMO);+                                                          (Prop lq_tmp$x##398);+                                                          (Prop lq_tmp$x##398);+                                                          (Prop lq_tmp$x##398)]}+bind 50 lq_tmp$x##420 : {VV : a_azo | []}+bind 51 lq_anf$##dMS : {lq_tmp$x##406 : [a_azo] | [((len lq_tmp$x##406) = (1 + (len ys##ayU)));+                                                   ((null lq_tmp$x##406) <=> false);+                                                   ((tail lq_tmp$x##406) = ys##ayU);+                                                   ((head lq_tmp$x##406) = y##ayT);+                                                   ((len lq_tmp$x##406) >= 0)]}+bind 52 lq_anf$##dMT : {VV##454 : [a_azo] | [((len VV##454) = ((len xs##ayS) + (len lq_anf$##dMS)));+                                             ((len VV##454) >= 0)]}+bind 53 lq_tmp$x##472 : {VV : a_azo | []}+bind 54 ds_dMs : {VV##521 : [a_azx] | [((len VV##521) >= 0)]}+bind 55 lq_anf$##dMW : {lq_tmp$x##523 : [a_azx] | [((len lq_tmp$x##523) >= 0);+                                                   (lq_tmp$x##523 = ds_dMs);+                                                   ((len lq_tmp$x##523) >= 0)]}+bind 56 lq_anf$##dMW : {lq_tmp$x##527 : [a_azx] | [((len lq_tmp$x##527) >= 0);+                                                   (lq_tmp$x##527 = ds_dMs);+                                                   ((len lq_tmp$x##527) >= 0);+                                                   ((len lq_tmp$x##527) >= 0)]}+bind 57 lq_anf$##dMW : {lq_tmp$x##527 : [a_azx] | [((len lq_tmp$x##527) >= 0);+                                                   (lq_tmp$x##527 = ds_dMs);+                                                   ((len lq_tmp$x##527) >= 0);+                                                   ((len lq_tmp$x##527) = 0);+                                                   ((null lq_tmp$x##527) <=> true);+                                                   (lq_tmp$x##527 = GHC.Types.$91$$93$$35$$35$6m);+                                                   ((len lq_tmp$x##527) = 0);+                                                   ((null lq_tmp$x##527) <=> true);+                                                   ((len lq_tmp$x##527) >= 0)]}+bind 58 lq_tmp$x##545 : {VV : a_azx | []}+bind 59 lq_anf$##dMX : {lq_tmp$x##537 : [a_azx] | [((len lq_tmp$x##537) = 0);+                                                   ((null lq_tmp$x##537) <=> true);+                                                   ((len lq_tmp$x##537) >= 0)]}+bind 60 lq_tmp$x##589 : {VV##590 : [a_azx] | [((len VV##590) >= 0)]}+bind 61 lq_anf$##dMW : {lq_tmp$x##598 : [a_azx] | [((len lq_tmp$x##598) >= 0);+                                                   (lq_tmp$x##598 = ds_dMs);+                                                   ((len lq_tmp$x##598) >= 0);+                                                   ((len lq_tmp$x##598) >= 0)]}+bind 62 x##ayC : {VV : a_azx | []}+bind 63 ds_dMt : {lq_tmp$x##612 : [a_azx] | [((len lq_tmp$x##612) >= 0)]}+bind 64 lq_anf$##dMW : {lq_tmp$x##598 : [a_azx] | [((len lq_tmp$x##598) >= 0);+                                                   (lq_tmp$x##598 = ds_dMs);+                                                   ((len lq_tmp$x##598) >= 0);+                                                   ((len lq_tmp$x##598) = (1 + (len ds_dMt)));+                                                   ((null lq_tmp$x##598) <=> false);+                                                   ((tail lq_tmp$x##598) = ds_dMt);+                                                   ((head lq_tmp$x##598) = x##ayC);+                                                   (lq_tmp$x##598 = (GHC.Types.$58$$35$$35$64 x##ayC ds_dMt));+                                                   ((len lq_tmp$x##598) = (1 + (len ds_dMt)));+                                                   ((null lq_tmp$x##598) <=> false);+                                                   ((tail lq_tmp$x##598) = ds_dMt);+                                                   ((head lq_tmp$x##598) = x##ayC);+                                                   ((len lq_tmp$x##598) >= 0)]}+bind 65 lq_anf$##dMY : {lq_tmp$x##622 : [a_azx] | [((len lq_tmp$x##622) >= 0);+                                                   (lq_tmp$x##622 = ds_dMt);+                                                   ((len lq_tmp$x##622) >= 0)]}+bind 66 lq_anf$##dMY : {lq_tmp$x##626 : [a_azx] | [((len lq_tmp$x##626) >= 0);+                                                   (lq_tmp$x##626 = ds_dMt);+                                                   ((len lq_tmp$x##626) >= 0);+                                                   ((len lq_tmp$x##626) >= 0)]}+bind 67 lq_anf$##dMY : {lq_tmp$x##626 : [a_azx] | [((len lq_tmp$x##626) >= 0);+                                                   (lq_tmp$x##626 = ds_dMt);+                                                   ((len lq_tmp$x##626) >= 0);+                                                   ((len lq_tmp$x##626) = 0);+                                                   ((null lq_tmp$x##626) <=> true);+                                                   (lq_tmp$x##626 = GHC.Types.$91$$93$$35$$35$6m);+                                                   ((len lq_tmp$x##626) = 0);+                                                   ((null lq_tmp$x##626) <=> true);+                                                   ((len lq_tmp$x##626) >= 0)]}+bind 68 lq_tmp$x##644 : {VV : a_azx | []}+bind 69 lq_anf$##dMZ : {lq_tmp$x##636 : [a_azx] | [((len lq_tmp$x##636) = 0);+                                                   ((null lq_tmp$x##636) <=> true);+                                                   ((len lq_tmp$x##636) >= 0)]}+bind 70 lq_tmp$x##688 : {VV##689 : [a_azx] | [((len VV##689) >= 0)]}+bind 71 lq_anf$##dMY : {lq_tmp$x##697 : [a_azx] | [((len lq_tmp$x##697) >= 0);+                                                   (lq_tmp$x##697 = ds_dMt);+                                                   ((len lq_tmp$x##697) >= 0);+                                                   ((len lq_tmp$x##697) >= 0)]}+bind 72 y##ayD : {VV : a_azx | []}+bind 73 zs##ayE : {lq_tmp$x##711 : [a_azx] | [((len lq_tmp$x##711) >= 0)]}+bind 74 lq_anf$##dMY : {lq_tmp$x##697 : [a_azx] | [((len lq_tmp$x##697) >= 0);+                                                   (lq_tmp$x##697 = ds_dMt);+                                                   ((len lq_tmp$x##697) >= 0);+                                                   ((len lq_tmp$x##697) = (1 + (len zs##ayE)));+                                                   ((null lq_tmp$x##697) <=> false);+                                                   ((tail lq_tmp$x##697) = zs##ayE);+                                                   ((head lq_tmp$x##697) = y##ayD);+                                                   (lq_tmp$x##697 = (GHC.Types.$58$$35$$35$64 y##ayD zs##ayE));+                                                   ((len lq_tmp$x##697) = (1 + (len zs##ayE)));+                                                   ((null lq_tmp$x##697) <=> false);+                                                   ((tail lq_tmp$x##697) = zs##ayE);+                                                   ((head lq_tmp$x##697) = y##ayD);+                                                   ((len lq_tmp$x##697) >= 0)]}+bind 75 ds_dMw : {v##0 : (Tuple  [a_azx]  [a_azx]) | [(((len (fst v##0)) + (len (snd v##0))) = (len zs##ayE))]}+bind 76 ds_dMw : {lq_tmp$x##762 : (Tuple  [a_azx]  [a_azx]) | [(((len (fst lq_tmp$x##762)) + (len (snd lq_tmp$x##762))) = (len zs##ayE))]}+bind 77 xs##aA4 : {lq_tmp$x##756 : [a_azx] | [(((len lq_tmp$x##756) > 1) => ((len lq_tmp$x##756) < (len zs##ayE)));+                                              ((len lq_tmp$x##756) >= 0)]}+bind 78 ys##XAl : {lq_tmp$x##758 : [a_azx] | [((len lq_tmp$x##758) >= 0)]}+bind 79 ds_dMw : {lq_tmp$x##762 : (Tuple  [a_azx]  [a_azx]) | [(((len (fst lq_tmp$x##762)) + (len (snd lq_tmp$x##762))) = (len zs##ayE));+                                                               ((snd lq_tmp$x##762) = ys##XAl);+                                                               ((fst lq_tmp$x##762) = xs##aA4);+                                                               ((x_Tuple22 lq_tmp$x##762) = ys##XAl);+                                                               ((x_Tuple21 lq_tmp$x##762) = xs##aA4);+                                                               (lq_tmp$x##762 = (GHC.Tuple.$40$$44$$41$$35$$35$74 xs##aA4 ys##XAl));+                                                               ((snd lq_tmp$x##762) = ys##XAl);+                                                               ((fst lq_tmp$x##762) = xs##aA4);+                                                               ((x_Tuple22 lq_tmp$x##762) = ys##XAl);+                                                               ((x_Tuple21 lq_tmp$x##762) = xs##aA4)]}+bind 80 xs##aA4 : {VV##752 : [a_azx] | [$k_##753;+                                        ((len VV##752) >= 0)]}+bind 81 ds_dMw : {lq_tmp$x##804 : (Tuple  [a_azx]  [a_azx]) | [(((len (fst lq_tmp$x##804)) + (len (snd lq_tmp$x##804))) = (len zs##ayE))]}+bind 82 xs##aA4 : {lq_tmp$x##798 : [a_azx] | [((len lq_tmp$x##798) >= 0)]}+bind 83 ys##aA5 : {lq_tmp$x##800 : [a_azx] | [(((len lq_tmp$x##800) > 1) => ((len lq_tmp$x##800) < (len zs##ayE)));+                                              ((len lq_tmp$x##800) >= 0)]}+bind 84 ds_dMw : {lq_tmp$x##804 : (Tuple  [a_azx]  [a_azx]) | [(((len (fst lq_tmp$x##804)) + (len (snd lq_tmp$x##804))) = (len zs##ayE));+                                                               ((snd lq_tmp$x##804) = ys##aA5);+                                                               ((fst lq_tmp$x##804) = xs##aA4);+                                                               ((x_Tuple22 lq_tmp$x##804) = ys##aA5);+                                                               ((x_Tuple21 lq_tmp$x##804) = xs##aA4);+                                                               (lq_tmp$x##804 = (GHC.Tuple.$40$$44$$41$$35$$35$74 xs##aA4 ys##aA5));+                                                               ((snd lq_tmp$x##804) = ys##aA5);+                                                               ((fst lq_tmp$x##804) = xs##aA4);+                                                               ((x_Tuple22 lq_tmp$x##804) = ys##aA5);+                                                               ((x_Tuple21 lq_tmp$x##804) = xs##aA4)]}+bind 85 ys##aA5 : {VV##794 : [a_azx] | [$k_##795;+                                        ((len VV##794) >= 0)]}+bind 86 lq_tmp$x##846 : {VV : a_azx | []}+bind 87 lq_anf$##dN0 : {lq_tmp$x##832 : [a_azx] | [((len lq_tmp$x##832) = (1 + (len xs##aA4)));+                                                   ((null lq_tmp$x##832) <=> false);+                                                   ((tail lq_tmp$x##832) = xs##aA4);+                                                   ((head lq_tmp$x##832) = x##ayC);+                                                   ((len lq_tmp$x##832) >= 0)]}+bind 88 lq_tmp$x##869 : {VV : a_azx | []}+bind 89 lq_anf$##dN1 : {lq_tmp$x##855 : [a_azx] | [((len lq_tmp$x##855) = (1 + (len ys##aA5)));+                                                   ((null lq_tmp$x##855) <=> false);+                                                   ((tail lq_tmp$x##855) = ys##aA5);+                                                   ((head lq_tmp$x##855) = y##ayD);+                                                   ((len lq_tmp$x##855) >= 0)]}+bind 90 lq_tmp$x##916 : {VV##917 : [a_azx] | [((len VV##917) >= 0)]}+bind 91 fix$36$$36$dOrd_aAe : {VV##948 : (GHC.Classes.Ord  a_azJ) | []}+bind 92 ds_dMB : {VV##949 : [a_azJ] | [((len VV##949) >= 0)]}+bind 93 lq_anf$##dN2 : {lq_tmp$x##951 : [a_azJ] | [((len lq_tmp$x##951) >= 0);+                                                   (lq_tmp$x##951 = ds_dMB);+                                                   ((len lq_tmp$x##951) >= 0)]}+bind 94 lq_anf$##dN2 : {lq_tmp$x##955 : [a_azJ] | [((len lq_tmp$x##955) >= 0);+                                                   (lq_tmp$x##955 = ds_dMB);+                                                   ((len lq_tmp$x##955) >= 0);+                                                   ((len lq_tmp$x##955) >= 0)]}+bind 95 lq_anf$##dN2 : {lq_tmp$x##955 : [a_azJ] | [((len lq_tmp$x##955) >= 0);+                                                   (lq_tmp$x##955 = ds_dMB);+                                                   ((len lq_tmp$x##955) >= 0);+                                                   ((len lq_tmp$x##955) = 0);+                                                   ((null lq_tmp$x##955) <=> true);+                                                   (lq_tmp$x##955 = GHC.Types.$91$$93$$35$$35$6m);+                                                   ((len lq_tmp$x##955) = 0);+                                                   ((null lq_tmp$x##955) <=> true);+                                                   ((len lq_tmp$x##955) >= 0)]}+bind 96 lq_tmp$x##973 : {VV : a_azJ | []}+bind 97 lq_anf$##dN2 : {lq_tmp$x##976 : [a_azJ] | [((len lq_tmp$x##976) >= 0);+                                                   (lq_tmp$x##976 = ds_dMB);+                                                   ((len lq_tmp$x##976) >= 0);+                                                   ((len lq_tmp$x##976) >= 0)]}+bind 98 x##ayy : {VV : a_azJ | []}+bind 99 ds_dMC : {lq_tmp$x##990 : [a_azJ] | [((len lq_tmp$x##990) >= 0)]}+bind 100 lq_anf$##dN2 : {lq_tmp$x##976 : [a_azJ] | [((len lq_tmp$x##976) >= 0);+                                                    (lq_tmp$x##976 = ds_dMB);+                                                    ((len lq_tmp$x##976) >= 0);+                                                    ((len lq_tmp$x##976) = (1 + (len ds_dMC)));+                                                    ((null lq_tmp$x##976) <=> false);+                                                    ((tail lq_tmp$x##976) = ds_dMC);+                                                    ((head lq_tmp$x##976) = x##ayy);+                                                    (lq_tmp$x##976 = (GHC.Types.$58$$35$$35$64 x##ayy ds_dMC));+                                                    ((len lq_tmp$x##976) = (1 + (len ds_dMC)));+                                                    ((null lq_tmp$x##976) <=> false);+                                                    ((tail lq_tmp$x##976) = ds_dMC);+                                                    ((head lq_tmp$x##976) = x##ayy);+                                                    ((len lq_tmp$x##976) >= 0)]}+bind 101 lq_anf$##dN3 : {lq_tmp$x##1000 : [a_azJ] | [((len lq_tmp$x##1000) >= 0);+                                                     (lq_tmp$x##1000 = ds_dMC);+                                                     ((len lq_tmp$x##1000) >= 0)]}+bind 102 lq_anf$##dN3 : {lq_tmp$x##1004 : [a_azJ] | [((len lq_tmp$x##1004) >= 0);+                                                     (lq_tmp$x##1004 = ds_dMC);+                                                     ((len lq_tmp$x##1004) >= 0);+                                                     ((len lq_tmp$x##1004) >= 0)]}+bind 103 lq_anf$##dN3 : {lq_tmp$x##1004 : [a_azJ] | [((len lq_tmp$x##1004) >= 0);+                                                     (lq_tmp$x##1004 = ds_dMC);+                                                     ((len lq_tmp$x##1004) >= 0);+                                                     ((len lq_tmp$x##1004) = 0);+                                                     ((null lq_tmp$x##1004) <=> true);+                                                     (lq_tmp$x##1004 = GHC.Types.$91$$93$$35$$35$6m);+                                                     ((len lq_tmp$x##1004) = 0);+                                                     ((null lq_tmp$x##1004) <=> true);+                                                     ((len lq_tmp$x##1004) >= 0)]}+bind 104 lq_tmp$x##1022 : {VV : a_azJ | []}+bind 105 lq_anf$##dN6 : {lq_tmp$x##1014 : [a_azJ] | [((len lq_tmp$x##1014) = 0);+                                                     ((null lq_tmp$x##1014) <=> true);+                                                     ((len lq_tmp$x##1014) >= 0)]}+bind 106 lq_tmp$x##1042 : {VV : a_azJ | []}+bind 107 lq_anf$##dN3 : {lq_tmp$x##1048 : [a_azJ] | [((len lq_tmp$x##1048) >= 0);+                                                     (lq_tmp$x##1048 = ds_dMC);+                                                     ((len lq_tmp$x##1048) >= 0);+                                                     ((len lq_tmp$x##1048) >= 0)]}+bind 108 lq_anf$##dN7 : {VV : a_azJ | []}+bind 109 lq_anf$##dN8 : {lq_tmp$x##1062 : [a_azJ] | [((len lq_tmp$x##1062) >= 0)]}+bind 110 lq_anf$##dN3 : {lq_tmp$x##1048 : [a_azJ] | [((len lq_tmp$x##1048) >= 0);+                                                     (lq_tmp$x##1048 = ds_dMC);+                                                     ((len lq_tmp$x##1048) >= 0);+                                                     ((len lq_tmp$x##1048) = (1 + (len lq_anf$##dN8)));+                                                     ((null lq_tmp$x##1048) <=> false);+                                                     ((tail lq_tmp$x##1048) = lq_anf$##dN8);+                                                     ((head lq_tmp$x##1048) = lq_anf$##dN7);+                                                     (lq_tmp$x##1048 = (GHC.Types.$58$$35$$35$64 lq_anf$##dN7 lq_anf$##dN8));+                                                     ((len lq_tmp$x##1048) = (1 + (len lq_anf$##dN8)));+                                                     ((null lq_tmp$x##1048) <=> false);+                                                     ((tail lq_tmp$x##1048) = lq_anf$##dN8);+                                                     ((head lq_tmp$x##1048) = lq_anf$##dN7);+                                                     ((len lq_tmp$x##1048) >= 0)]}+bind 111 ds_dMJ : {VV##1071 : GHC.Prim.Void# | [$k_##1072]}+bind 112 ds_dMD : {lq_tmp$x##1094 : (Tuple  [a_azJ]  [a_azJ]) | [(((len (fst lq_tmp$x##1094)) + (len (snd lq_tmp$x##1094))) = (len ds_dMB))]}+bind 113 ds_dMD : {lq_tmp$x##1127 : (Tuple  [a_azJ]  [a_azJ]) | [(((len (fst lq_tmp$x##1127)) + (len (snd lq_tmp$x##1127))) = (len ds_dMB))]}+bind 114 xs1##aAj : {lq_tmp$x##1121 : [a_azJ] | [(((len lq_tmp$x##1121) > 1) => ((len lq_tmp$x##1121) < (len ds_dMB)));+                                                 ((len lq_tmp$x##1121) >= 0)]}+bind 115 xs2##XAw : {lq_tmp$x##1123 : [a_azJ] | [((len lq_tmp$x##1123) >= 0)]}+bind 116 ds_dMD : {lq_tmp$x##1127 : (Tuple  [a_azJ]  [a_azJ]) | [(((len (fst lq_tmp$x##1127)) + (len (snd lq_tmp$x##1127))) = (len ds_dMB));+                                                                 ((snd lq_tmp$x##1127) = xs2##XAw);+                                                                 ((fst lq_tmp$x##1127) = xs1##aAj);+                                                                 ((x_Tuple22 lq_tmp$x##1127) = xs2##XAw);+                                                                 ((x_Tuple21 lq_tmp$x##1127) = xs1##aAj);+                                                                 (lq_tmp$x##1127 = (GHC.Tuple.$40$$44$$41$$35$$35$74 xs1##aAj xs2##XAw));+                                                                 ((snd lq_tmp$x##1127) = xs2##XAw);+                                                                 ((fst lq_tmp$x##1127) = xs1##aAj);+                                                                 ((x_Tuple22 lq_tmp$x##1127) = xs2##XAw);+                                                                 ((x_Tuple21 lq_tmp$x##1127) = xs1##aAj)]}+bind 117 xs1##aAj : {VV##1117 : [a_azJ] | [$k_##1118;+                                           ((len VV##1117) >= 0)]}+bind 118 ds_dMD : {lq_tmp$x##1169 : (Tuple  [a_azJ]  [a_azJ]) | [(((len (fst lq_tmp$x##1169)) + (len (snd lq_tmp$x##1169))) = (len ds_dMB))]}+bind 119 xs1##aAj : {lq_tmp$x##1163 : [a_azJ] | [((len lq_tmp$x##1163) >= 0)]}+bind 120 xs2##aAk : {lq_tmp$x##1165 : [a_azJ] | [(((len lq_tmp$x##1165) > 1) => ((len lq_tmp$x##1165) < (len ds_dMB)));+                                                 ((len lq_tmp$x##1165) >= 0)]}+bind 121 ds_dMD : {lq_tmp$x##1169 : (Tuple  [a_azJ]  [a_azJ]) | [(((len (fst lq_tmp$x##1169)) + (len (snd lq_tmp$x##1169))) = (len ds_dMB));+                                                                 ((snd lq_tmp$x##1169) = xs2##aAk);+                                                                 ((fst lq_tmp$x##1169) = xs1##aAj);+                                                                 ((x_Tuple22 lq_tmp$x##1169) = xs2##aAk);+                                                                 ((x_Tuple21 lq_tmp$x##1169) = xs1##aAj);+                                                                 (lq_tmp$x##1169 = (GHC.Tuple.$40$$44$$41$$35$$35$74 xs1##aAj xs2##aAk));+                                                                 ((snd lq_tmp$x##1169) = xs2##aAk);+                                                                 ((fst lq_tmp$x##1169) = xs1##aAj);+                                                                 ((x_Tuple22 lq_tmp$x##1169) = xs2##aAk);+                                                                 ((x_Tuple21 lq_tmp$x##1169) = xs1##aAj)]}+bind 122 xs2##aAk : {VV##1159 : [a_azJ] | [$k_##1160;+                                           ((len VV##1159) >= 0)]}+bind 123 lq_anf$##dN4 : {VV##1213 : [a_azJ] | [((len VV##1213) = (len xs1##aAj));+                                               ((len VV##1213) >= 0)]}+bind 124 lq_anf$##dN5 : {VV##1233 : [a_azJ] | [((len VV##1233) = (len xs2##aAk));+                                               ((len VV##1233) >= 0)]}+bind 125 fix$36$$36$dOrd_aAe : {VV##1277 : (GHC.Classes.Ord  a_azJ) | []}+bind 126 VV##1278 : {VV##1278 : [a_azJ] | [((len VV##1278) >= 0)]}+bind 127 lq_tmp$x##945 : {VV : a_azJ | []}+bind 128 lq_tmp$x##1270 : {VV##1281 : [a_azJ] | [((len VV##1281) >= 0)]}+bind 129 VV##1282 : {VV##1282 : [a_azJ] | [((len VV##1282) >= 0)]}+bind 130 lq_tmp$x##946 : {VV : a_azJ | []}+bind 131 VV##1285 : {VV##1285 : [a_azJ] | [((len VV##1285) >= 0)]}+bind 132 lq_tmp$x##945 : {VV : a_azJ | []}+bind 133 ds_dMB : {VV##1288 : [a_azJ] | [((len VV##1288) >= 0)]}+bind 134 VV##1289 : {VV##1289 : [a_azJ] | [((len VV##1289) >= 0)]}+bind 135 lq_tmp$x##946 : {VV : a_azJ | []}+bind 136 VV##1292 : {VV##1292 : [a_azJ] | [$k_##1083[VV##1082:=VV##1292][ds_dMJ:=GHC.Prim.void###0l];+                                           ((len VV##1292) >= 0)]}+bind 137 lq_tmp$x##946 : {VV : a_azJ | []}+bind 138 VV##1295 : {VV##1295 : GHC.Prim.Void# | [(VV##1295 = GHC.Prim.void###0l)]}+bind 139 VV##1297 : {VV##1297 : [a_azJ] | [((len VV##1297) = ((len lq_anf$##dN4) + (len lq_anf$##dN5)));+                                           ((len VV##1297) >= 0)]}+bind 140 lq_tmp$x##1078 : {VV : a_azJ | []}+bind 141 VV##1300 : {VV##1300 : [a_azJ] | [((len VV##1300) = (len xs2##aAk));+                                           ((len VV##1300) >= 0);+                                           (VV##1300 = lq_anf$##dN5);+                                           ((len VV##1300) >= 0)]}+bind 142 lq_tmp$x##1250 : {VV : a_azJ | []}+bind 143 VV##1303 : {VV##1303 : [a_azJ] | [((len VV##1303) = (len xs1##aAj));+                                           ((len VV##1303) >= 0);+                                           (VV##1303 = lq_anf$##dN4);+                                           ((len VV##1303) >= 0)]}+bind 144 lq_tmp$x##1249 : {VV : a_azJ | []}+bind 145 VV##1306 : {VV##1306 : [a_azJ] | [$k_##1160[VV##1159:=VV##1306][lq_tmp$x##1231:=VV##1306];+                                           ((len VV##1306) >= 0);+                                           (VV##1306 = xs2##aAk);+                                           ((len VV##1306) >= 0)]}+bind 146 lq_tmp$x##945 : {VV : a_azJ | []}+bind 147 VV##1309 : {VV##1309 : [a_azJ] | [$k_##1118[VV##1117:=VV##1309][lq_tmp$x##1211:=VV##1309];+                                           ((len VV##1309) >= 0);+                                           (VV##1309 = xs1##aAj);+                                           ((len VV##1309) >= 0)]}+bind 148 lq_tmp$x##945 : {VV : a_azJ | []}+bind 149 VV##1312 : {VV##1312 : [a_azJ] | [(((len VV##1312) > 1) => ((len VV##1312) < (len ds_dMB)));+                                           ((len VV##1312) >= 0);+                                           (VV##1312 = xs2##aAk);+                                           ((len VV##1312) >= 0)]}+bind 150 lq_tmp$x##1155 : {VV : a_azJ | []}+bind 151 VV##1315 : {VV##1315 : [a_azJ] | [(((len VV##1315) > 1) => ((len VV##1315) < (len ds_dMB)));+                                           ((len VV##1315) >= 0);+                                           (VV##1315 = xs1##aAj);+                                           ((len VV##1315) >= 0)]}+bind 152 lq_tmp$x##1113 : {VV : a_azJ | []}+bind 153 VV##1318 : {VV##1318 : [a_azJ] | [((len VV##1318) >= 0);+                                           (VV##1318 = ds_dMB);+                                           ((len VV##1318) >= 0)]}+bind 154 lq_tmp$x##1098 : {VV : a_azJ | []}+bind 155 VV##1321 : {VV##1321 : [a_azJ] | [((len VV##1321) = (1 + (len lq_anf$##dN6)));+                                           ((null VV##1321) <=> false);+                                           ((tail VV##1321) = lq_anf$##dN6);+                                           ((head VV##1321) = x##ayy);+                                           ((len VV##1321) >= 0)]}+bind 156 lq_tmp$x##946 : {VV : a_azJ | []}+bind 157 VV##1324 : {VV##1324 : [a_azJ] | [((len VV##1324) = 0);+                                           ((null VV##1324) <=> true);+                                           ((len VV##1324) >= 0);+                                           (VV##1324 = lq_anf$##dN6);+                                           ((len VV##1324) >= 0)]}+bind 158 lq_tmp$x##1034 : {VV : a_azJ | []}+bind 159 VV##1327 : {VV##1327 : [a_azJ] | [((len VV##1327) = 0);+                                           ((null VV##1327) <=> true);+                                           ((len VV##1327) >= 0)]}+bind 160 lq_tmp$x##946 : {VV : a_azJ | []}+bind 161 VV##1330 : {VV##1330 : [a_azx] | [((len VV##1330) >= 0)]}+bind 162 lq_tmp$x##515 : {VV : a_azx | []}+bind 163 ds_dMs : {VV##1333 : [a_azx] | [((len VV##1333) >= 0)]}+bind 164 VV##1334 : {VV##1334 : (Tuple  [a_azx]  [a_azx]) | []}+bind 165 VV##1336 : {VV##1336 : [a_azx] | [((len VV##1336) >= 0)]}+bind 166 lq_tmp$x##516 : {VV : a_azx | []}+bind 167 VV##1339 : {VV##1339 : [a_azx] | [((len VV##1339) >= 0)]}+bind 168 lq_tmp$x##517 : {VV : a_azx | []}+bind 169 lq_tmp$x##519 : {VV##1342 : [a_azx] | [((len VV##1342) >= 0)]}+bind 170 VV##1343 : {VV##1343 : [a_azx] | [((len VV##1343) >= 0)]}+bind 171 lq_tmp$x##518 : {VV : a_azx | []}+bind 172 VV##1346 : {VV##1346 : (Tuple  [a_azx]  [a_azx]) | [((snd VV##1346) = lq_anf$##dN1);+                                                             ((fst VV##1346) = lq_anf$##dN0);+                                                             ((x_Tuple22 VV##1346) = lq_anf$##dN1);+                                                             ((x_Tuple21 VV##1346) = lq_anf$##dN0)]}+bind 173 VV##1348 : {VV##1348 : [a_azx] | [$k_##890[VV##889:=VV##1348][lq_tmp$x##893:=VV##1348][lq_tmp$x##879:=lq_anf$##dN0][lq_tmp$x##880:=lq_anf$##dN1][lq_tmp$x##876:=VV##1346];+                                           ((len VV##1348) >= 0)]}+bind 174 lq_tmp$x##516 : {VV : a_azx | []}+bind 175 VV##1351 : {VV##1351 : [a_azx] | [$k_##902[lq_tmp$x##879:=lq_anf$##dN0][lq_tmp$x##905:=VV##1351][lq_tmp$x##880:=lq_anf$##dN1][VV##901:=VV##1351][lq_tmp$x##876:=VV##1346];+                                           ((len VV##1351) >= 0)]}+bind 176 lq_tmp$x##517 : {VV : a_azx | []}+bind 177 lq_tmp$x##519 : {VV##1354 : [a_azx] | [((len VV##1354) >= 0)]}+bind 178 VV##1355 : {VV##1355 : [a_azx] | [$k_##914[lq_tmp$x##881:=lq_tmp$x##519][VV##913:=VV##1355][lq_tmp$x##879:=lq_anf$##dN0][lq_tmp$x##916:=lq_tmp$x##519][lq_tmp$x##905:=VV##1355][lq_tmp$x##880:=lq_anf$##dN1][lq_tmp$x##876:=VV##1346];+                                           ((len VV##1355) >= 0)]}+bind 179 lq_tmp$x##518 : {VV : a_azx | []}+bind 180 VV##1358 : {VV##1358 : [a_azx] | [((len VV##1358) = (1 + (len ys##aA5)));+                                           ((null VV##1358) <=> false);+                                           ((tail VV##1358) = ys##aA5);+                                           ((head VV##1358) = y##ayD);+                                           ((len VV##1358) >= 0);+                                           (VV##1358 = lq_anf$##dN1);+                                           ((len VV##1358) >= 0)]}+bind 181 lq_tmp$x##904 : {VV : a_azx | []}+bind 182 VV##1361 : {VV##1361 : [a_azx] | [((len VV##1361) = (1 + (len xs##aA4)));+                                           ((null VV##1361) <=> false);+                                           ((tail VV##1361) = xs##aA4);+                                           ((head VV##1361) = x##ayC);+                                           ((len VV##1361) >= 0);+                                           (VV##1361 = lq_anf$##dN0);+                                           ((len VV##1361) >= 0)]}+bind 183 lq_tmp$x##892 : {VV : a_azx | []}+bind 184 VV##1364 : {VV##1364 : [a_azx] | [$k_##795[lq_tmp$x##872:=VV##1364][VV##794:=VV##1364];+                                           ((len VV##1364) >= 0);+                                           (VV##1364 = ys##aA5);+                                           ((len VV##1364) >= 0)]}+bind 185 lq_tmp$x##861 : {VV : a_azx | []}+bind 186 VV##1367 : {VV##1367 : [a_azx] | [$k_##753[VV##752:=VV##1367][lq_tmp$x##849:=VV##1367];+                                           ((len VV##1367) >= 0);+                                           (VV##1367 = xs##aA4);+                                           ((len VV##1367) >= 0)]}+bind 187 lq_tmp$x##838 : {VV : a_azx | []}+bind 188 VV##1370 : {VV##1370 : [a_azx] | [(((len VV##1370) > 1) => ((len VV##1370) < (len zs##ayE)));+                                           ((len VV##1370) >= 0);+                                           (VV##1370 = ys##aA5);+                                           ((len VV##1370) >= 0)]}+bind 189 lq_tmp$x##790 : {VV : a_azx | []}+bind 190 VV##1373 : {VV##1373 : [a_azx] | [(((len VV##1373) > 1) => ((len VV##1373) < (len zs##ayE)));+                                           ((len VV##1373) >= 0);+                                           (VV##1373 = xs##aA4);+                                           ((len VV##1373) >= 0)]}+bind 191 lq_tmp$x##748 : {VV : a_azx | []}+bind 192 VV##1376 : {VV##1376 : [a_azx] | [((len VV##1376) >= 0);+                                           (VV##1376 = zs##ayE);+                                           ((len VV##1376) >= 0)]}+bind 193 lq_tmp$x##515 : {VV : a_azx | []}+bind 194 VV##1379 : {VV##1379 : (Tuple  [a_azx]  [a_azx]) | [((snd VV##1379) = lq_anf$##dMZ);+                                                             ((fst VV##1379) = ds_dMs);+                                                             ((x_Tuple22 VV##1379) = lq_anf$##dMZ);+                                                             ((x_Tuple21 VV##1379) = ds_dMs)]}+bind 195 VV##1381 : {VV##1381 : [a_azx] | [$k_##662[lq_tmp$x##652:=lq_anf$##dMZ][lq_tmp$x##665:=VV##1381][lq_tmp$x##648:=VV##1379][lq_tmp$x##651:=ds_dMs][VV##661:=VV##1381];+                                           ((len VV##1381) >= 0)]}+bind 196 lq_tmp$x##516 : {VV : a_azx | []}+bind 197 VV##1384 : {VV##1384 : [a_azx] | [$k_##674[lq_tmp$x##652:=lq_anf$##dMZ][VV##673:=VV##1384][lq_tmp$x##648:=VV##1379][lq_tmp$x##651:=ds_dMs][lq_tmp$x##677:=VV##1384];+                                           ((len VV##1384) >= 0)]}+bind 198 lq_tmp$x##517 : {VV : a_azx | []}+bind 199 lq_tmp$x##519 : {VV##1387 : [a_azx] | [((len VV##1387) >= 0)]}+bind 200 VV##1388 : {VV##1388 : [a_azx] | [$k_##686[lq_tmp$x##652:=lq_anf$##dMZ][lq_tmp$x##688:=lq_tmp$x##519][lq_tmp$x##648:=VV##1379][VV##685:=VV##1388][lq_tmp$x##651:=ds_dMs][lq_tmp$x##653:=lq_tmp$x##519][lq_tmp$x##677:=VV##1388];+                                           ((len VV##1388) >= 0)]}+bind 201 lq_tmp$x##518 : {VV : a_azx | []}+bind 202 VV##1391 : {VV##1391 : [a_azx] | [((len VV##1391) = 0);+                                           ((null VV##1391) <=> true);+                                           ((len VV##1391) >= 0);+                                           (VV##1391 = lq_anf$##dMZ);+                                           ((len VV##1391) >= 0)]}+bind 203 lq_tmp$x##676 : {VV : a_azx | []}+bind 204 VV##1394 : {VV##1394 : [a_azx] | [((len VV##1394) >= 0);+                                           (VV##1394 = ds_dMs);+                                           ((len VV##1394) >= 0)]}+bind 205 lq_tmp$x##664 : {VV : a_azx | []}+bind 206 VV##1397 : {VV##1397 : (Tuple  [a_azx]  [a_azx]) | [((snd VV##1397) = lq_anf$##dMX);+                                                             ((fst VV##1397) = ds_dMs);+                                                             ((x_Tuple22 VV##1397) = lq_anf$##dMX);+                                                             ((x_Tuple21 VV##1397) = ds_dMs)]}+bind 207 VV##1399 : {VV##1399 : [a_azx] | [$k_##563[lq_tmp$x##553:=lq_anf$##dMX][lq_tmp$x##566:=VV##1399][lq_tmp$x##552:=ds_dMs][VV##562:=VV##1399][lq_tmp$x##549:=VV##1397];+                                           ((len VV##1399) >= 0)]}+bind 208 lq_tmp$x##516 : {VV : a_azx | []}+bind 209 VV##1402 : {VV##1402 : [a_azx] | [$k_##575[VV##574:=VV##1402][lq_tmp$x##553:=lq_anf$##dMX][lq_tmp$x##578:=VV##1402][lq_tmp$x##552:=ds_dMs][lq_tmp$x##549:=VV##1397];+                                           ((len VV##1402) >= 0)]}+bind 210 lq_tmp$x##517 : {VV : a_azx | []}+bind 211 lq_tmp$x##519 : {VV##1405 : [a_azx] | [((len VV##1405) >= 0)]}+bind 212 VV##1406 : {VV##1406 : [a_azx] | [$k_##587[lq_tmp$x##554:=lq_tmp$x##519][lq_tmp$x##553:=lq_anf$##dMX][lq_tmp$x##589:=lq_tmp$x##519][lq_tmp$x##578:=VV##1406][VV##586:=VV##1406][lq_tmp$x##552:=ds_dMs][lq_tmp$x##549:=VV##1397];+                                           ((len VV##1406) >= 0)]}+bind 213 lq_tmp$x##518 : {VV : a_azx | []}+bind 214 VV##1409 : {VV##1409 : [a_azx] | [((len VV##1409) = 0);+                                           ((null VV##1409) <=> true);+                                           ((len VV##1409) >= 0);+                                           (VV##1409 = lq_anf$##dMX);+                                           ((len VV##1409) >= 0)]}+bind 215 lq_tmp$x##577 : {VV : a_azx | []}+bind 216 VV##1412 : {VV##1412 : [a_azx] | [((len VV##1412) >= 0);+                                           (VV##1412 = ds_dMs);+                                           ((len VV##1412) >= 0)]}+bind 217 lq_tmp$x##565 : {VV : a_azx | []}+bind 218 fix$36$$36$dOrd_azK : {VV##1415 : (GHC.Classes.Ord  a_azo) | []}+bind 219 VV##1416 : {VV##1416 : [a_azo] | [((len VV##1416) >= 0)]}+bind 220 lq_tmp$x##115 : {VV : a_azo | []}+bind 221 lq_tmp$x##495 : {VV##1419 : [a_azo] | [((len VV##1419) >= 0)]}+bind 222 VV##1420 : {VV##1420 : [a_azo] | [((len VV##1420) >= 0)]}+bind 223 lq_tmp$x##116 : {VV : a_azo | []}+bind 224 lq_tmp$x##499 : {VV##1423 : [a_azo] | [((len VV##1423) >= 0)]}+bind 225 VV##1424 : {VV##1424 : [a_azo] | [((len VV##1424) >= 0)]}+bind 226 lq_tmp$x##117 : {VV : a_azo | []}+bind 227 VV##1427 : {VV##1427 : [a_azo] | [((len VV##1427) >= 0)]}+bind 228 lq_tmp$x##115 : {VV : a_azo | []}+bind 229 xs##ayP : {VV##1430 : [a_azo] | [((len VV##1430) >= 0)]}+bind 230 VV##1431 : {VV##1431 : [a_azo] | [((len VV##1431) >= 0)]}+bind 231 lq_tmp$x##116 : {VV : a_azo | []}+bind 232 lq_tmp$x##487 : {VV##1434 : [a_azo] | [((len VV##1434) >= 0)]}+bind 233 VV##1435 : {VV##1435 : [a_azo] | [((len VV##1435) >= 0)]}+bind 234 lq_tmp$x##117 : {VV : a_azo | []}+bind 235 VV##1438 : {VV##1438 : [a_azo] | [((len VV##1438) >= 0)]}+bind 236 lq_tmp$x##116 : {VV : a_azo | []}+bind 237 ds_dMl : {VV##1441 : [a_azo] | [((len VV##1441) >= 0)]}+bind 238 VV##1442 : {VV##1442 : [a_azo] | [((len VV##1442) >= 0)]}+bind 239 lq_tmp$x##117 : {VV : a_azo | []}+bind 240 VV##1445 : {VV##1445 : [a_azo] | [$k_##175[VV##174:=VV##1445][ds_dMr:=GHC.Prim.void###0l];+                                           ((len VV##1445) >= 0)]}+bind 241 lq_tmp$x##117 : {VV : a_azo | []}+bind 242 VV##1448 : {VV##1448 : GHC.Prim.Void# | [(VV##1448 = GHC.Prim.void###0l)]}+bind 243 VV##1450 : {VV##1450 : [a_azo] | [((len VV##1450) = (1 + (len lq_anf$##dMT)));+                                           ((null VV##1450) <=> false);+                                           ((tail VV##1450) = lq_anf$##dMT);+                                           ((head VV##1450) = x##ayR);+                                           ((len VV##1450) >= 0)]}+bind 244 lq_tmp$x##170 : {VV : a_azo | []}+bind 245 VV##1453 : {VV##1453 : [a_azo] | [((len VV##1453) = ((len xs##ayS) + (len lq_anf$##dMS)));+                                           ((len VV##1453) >= 0);+                                           (VV##1453 = lq_anf$##dMT);+                                           ((len VV##1453) >= 0)]}+bind 246 lq_tmp$x##464 : {VV : a_azo | []}+bind 247 VV##1456 : {VV##1456 : [a_azo] | [((len VV##1456) = (1 + (len ys##ayU)));+                                           ((null VV##1456) <=> false);+                                           ((tail VV##1456) = ys##ayU);+                                           ((head VV##1456) = y##ayT);+                                           ((len VV##1456) >= 0);+                                           (VV##1456 = lq_anf$##dMS);+                                           ((len VV##1456) >= 0)]}+bind 248 lq_tmp$x##116 : {VV : a_azo | []}+bind 249 VV##1459 : {VV##1459 : [a_azo] | [((len VV##1459) >= 0);+                                           (VV##1459 = xs##ayS);+                                           ((len VV##1459) >= 0)]}+bind 250 lq_tmp$x##115 : {VV : a_azo | []}+bind 251 VV##1462 : {VV##1462 : [a_azo] | [((len VV##1462) >= 0);+                                           (VV##1462 = ys##ayU);+                                           ((len VV##1462) >= 0)]}+bind 252 lq_tmp$x##412 : {VV : a_azo | []}+bind 253 VV##1465 : {VV##1465 : [a_azo] | [$k_##321[VV##320:=VV##1465][ds_dMp:=GHC.Prim.void###0l];+                                           ((len VV##1465) >= 0)]}+bind 254 lq_tmp$x##170 : {VV : a_azo | []}+bind 255 VV##1468 : {VV##1468 : GHC.Prim.Void# | [(VV##1468 = GHC.Prim.void###0l)]}+bind 256 VV##1470 : {VV##1470 : [a_azo] | [((len VV##1470) = (1 + (len lq_anf$##dMR)));+                                           ((null VV##1470) <=> false);+                                           ((tail VV##1470) = lq_anf$##dMR);+                                           ((head VV##1470) = y##ayT);+                                           ((len VV##1470) >= 0)]}+bind 257 lq_tmp$x##316 : {VV : a_azo | []}+bind 258 VV##1473 : {VV##1473 : [a_azo] | [((len VV##1473) = ((len lq_anf$##dMQ) + (len ys##ayU)));+                                           ((len VV##1473) >= 0);+                                           (VV##1473 = lq_anf$##dMR);+                                           ((len VV##1473) >= 0)]}+bind 259 lq_tmp$x##384 : {VV : a_azo | []}+bind 260 VV##1476 : {VV##1476 : [a_azo] | [((len VV##1476) >= 0);+                                           (VV##1476 = ys##ayU);+                                           ((len VV##1476) >= 0)]}+bind 261 lq_tmp$x##116 : {VV : a_azo | []}+bind 262 VV##1479 : {VV##1479 : [a_azo] | [((len VV##1479) = (1 + (len xs##ayS)));+                                           ((null VV##1479) <=> false);+                                           ((tail VV##1479) = xs##ayS);+                                           ((head VV##1479) = x##ayR);+                                           ((len VV##1479) >= 0);+                                           (VV##1479 = lq_anf$##dMQ);+                                           ((len VV##1479) >= 0)]}+bind 263 lq_tmp$x##115 : {VV : a_azo | []}+bind 264 VV##1482 : {VV##1482 : [a_azo] | [((len VV##1482) >= 0);+                                           (VV##1482 = xs##ayS);+                                           ((len VV##1482) >= 0)]}+bind 265 lq_tmp$x##332 : {VV : a_azo | []}+bind 266 VV##1485 : {VV##1485 : [a_azo] | [$k_##244[ds_dMn:=GHC.Prim.void###0l][VV##243:=VV##1485];+                                           ((len VV##1485) >= 0)]}+bind 267 lq_tmp$x##170 : {VV : a_azo | []}+bind 268 VV##1488 : {VV##1488 : GHC.Prim.Void# | [(VV##1488 = GHC.Prim.void###0l)]}+bind 269 VV##1490 : {VV##1490 : [a_azo] | [$k_##259[VV##258:=VV##1490][lq_tmp$x##262:=VV##1490][lq_tmp$x##250:=lq_anf$##dMN];+                                           ((len VV##1490) >= 0)]}+bind 270 lq_tmp$x##239 : {VV : a_azo | []}+bind 271 VV##1493 : {VV##1493 : int | [(VV##1493 ~~ lit$36$$47$Users$47$rjhala$47$research$47$stack$47$liquidhaskell$47$tests$47$pos$47$MergeSort.hs$58$$40$48$44$1$41$$45$$40$52$44$41$41$$124$function$32$merge);+                                       ((strLen VV##1493) = 95);+                                       (VV##1493 = lq_anf$##dMN)]}+bind 272 VV##1495 : {VV##1495 : [a_azo] | [((len VV##1495) >= 0);+                                           (VV##1495 = ds_dMl);+                                           ((len VV##1495) >= 0)]}+bind 273 lq_tmp$x##170 : {VV : a_azo | []}+bind 274 VV##1498 : {VV##1498 : [a_azo] | [((len VV##1498) >= 0);+                                           (VV##1498 = xs##ayP);+                                           ((len VV##1498) >= 0)]}+bind 275 lq_tmp$x##117 : {VV : a_azo | []}+bind 276 VV##1071 : {VV##1071 : GHC.Prim.Void# | [$k_##1072]}+bind 277 VV##1159 : {VV##1159 : [a_azJ] | [$k_##1160;+                                           ((len VV##1159) >= 0)]}+bind 278 lq_tmp$x##1155 : {VV : a_azJ | []}+bind 279 VV##1117 : {VV##1117 : [a_azJ] | [$k_##1118;+                                           ((len VV##1117) >= 0)]}+bind 280 lq_tmp$x##1113 : {VV : a_azJ | []}+bind 281 VV##1082 : {VV##1082 : [a_azJ] | [$k_##1083;+                                           ((len VV##1082) >= 0)]}+bind 282 lq_tmp$x##1078 : {VV : a_azJ | []}+bind 283 VV##913 : {VV##913 : [a_azx] | [$k_##914;+                                         ((len VV##913) >= 0)]}+bind 284 lq_tmp$x##909 : {VV : a_azx | []}+bind 285 VV##901 : {VV##901 : [a_azx] | [$k_##902;+                                         ((len VV##901) >= 0)]}+bind 286 lq_tmp$x##897 : {VV : a_azx | []}+bind 287 VV##889 : {VV##889 : [a_azx] | [$k_##890;+                                         ((len VV##889) >= 0)]}+bind 288 lq_tmp$x##885 : {VV : a_azx | []}+bind 289 VV##794 : {VV##794 : [a_azx] | [$k_##795;+                                         ((len VV##794) >= 0)]}+bind 290 lq_tmp$x##790 : {VV : a_azx | []}+bind 291 VV##752 : {VV##752 : [a_azx] | [$k_##753;+                                         ((len VV##752) >= 0)]}+bind 292 lq_tmp$x##748 : {VV : a_azx | []}+bind 293 VV##685 : {VV##685 : [a_azx] | [$k_##686;+                                         ((len VV##685) >= 0)]}+bind 294 lq_tmp$x##681 : {VV : a_azx | []}+bind 295 VV##673 : {VV##673 : [a_azx] | [$k_##674;+                                         ((len VV##673) >= 0)]}+bind 296 lq_tmp$x##669 : {VV : a_azx | []}+bind 297 VV##661 : {VV##661 : [a_azx] | [$k_##662;+                                         ((len VV##661) >= 0)]}+bind 298 lq_tmp$x##657 : {VV : a_azx | []}+bind 299 VV##586 : {VV##586 : [a_azx] | [$k_##587;+                                         ((len VV##586) >= 0)]}+bind 300 lq_tmp$x##582 : {VV : a_azx | []}+bind 301 VV##574 : {VV##574 : [a_azx] | [$k_##575;+                                         ((len VV##574) >= 0)]}+bind 302 lq_tmp$x##570 : {VV : a_azx | []}+bind 303 VV##562 : {VV##562 : [a_azx] | [$k_##563;+                                         ((len VV##562) >= 0)]}+bind 304 lq_tmp$x##558 : {VV : a_azx | []}+bind 305 VV##163 : {VV##163 : GHC.Prim.Void# | [$k_##164]}+bind 306 VV##309 : {VV##309 : GHC.Prim.Void# | [$k_##310]}+bind 307 VV##320 : {VV##320 : [a_azo] | [$k_##321;+                                         ((len VV##320) >= 0)]}+bind 308 lq_tmp$x##316 : {VV : a_azo | []}+bind 309 VV##232 : {VV##232 : GHC.Prim.Void# | [$k_##233]}+bind 310 VV##258 : {VV##258 : [a_azo] | [$k_##259;+                                         ((len VV##258) >= 0)]}+bind 311 lq_tmp$x##254 : {VV : a_azo | []}+bind 312 VV##243 : {VV##243 : [a_azo] | [$k_##244;+                                         ((len VV##243) >= 0)]}+bind 313 lq_tmp$x##239 : {VV : a_azo | []}+bind 314 VV##174 : {VV##174 : [a_azo] | [$k_##175;+                                         ((len VV##174) >= 0)]}+bind 315 lq_tmp$x##170 : {VV : a_azo | []}+++++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       80;+       82;+       83;+       84]+  lhs {VV##50 : [a_azx] | [(((len VV##50) > 1) => ((len VV##50) < (len zs##ayE)));+                           ((len VV##50) >= 0);+                           (VV##50 = ys##aA5);+                           ((len VV##50) >= 0)]}+  rhs {VV##50 : [a_azx] | [$k_##795[VV##794:=VV##50][VV##1370:=VV##50][VV##F:=VV##50][VV##F##50:=VV##50]]}+  id 50 tag [2]+  // META constraint id 50 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       77;+       78;+       79]+  lhs {VV##53 : [a_azx] | [(((len VV##53) > 1) => ((len VV##53) < (len zs##ayE)));+                           ((len VV##53) >= 0);+                           (VV##53 = xs##aA4);+                           ((len VV##53) >= 0)]}+  rhs {VV##53 : [a_azx] | [$k_##753[VV##752:=VV##53][VV##1373:=VV##53][VV##F##53:=VV##53][VV##F:=VV##53]]}+  id 53 tag [2]+  // META constraint id 53 : ()+++constraint:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       85;+       87;+       89]+  lhs {VV##30 : (Tuple  [a_azx]  [a_azx]) | [((snd VV##30) = lq_anf$##dN1);+                                             ((fst VV##30) = lq_anf$##dN0);+                                             ((x_Tuple22 VV##30) = lq_anf$##dN1);+                                             ((x_Tuple21 VV##30) = lq_anf$##dN0)]}+  rhs {VV##30 : (Tuple  [a_azx]  [a_azx]) | [(((len (fst VV##30)) + (len (snd VV##30))) = (len ds_dMs))]}+  id 30 tag [2]+  // META constraint id 30 : ()+++++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       67;+       69;+       70]+  reft {VV##685 : [a_azx] | [$k_##686]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       36;+       37;+       38;+       39;+       49]+  reft {VV##414 : a_azo | [$k_##415]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 54; 57; 59; 302]+  reft {VV##571 : a_azx | [$k_##572]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       67;+       69;+       296]+  reft {VV##670 : a_azx | [$k_##671]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       85;+       86]+  reft {VV##843 : a_azx | [$k_##844]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 19; 20; 21]+  reft {VV##163 : GHC.Prim.Void# | [$k_##164]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       85;+       87;+       89;+       287]+  reft {VV##882 : a_azx | [$k_##883]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80]+  reft {VV##794 : [a_azx] | [$k_##795]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 54; 57; 59; 304]+  reft {VV##559 : a_azx | [$k_##560]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 54; 57; 59; 303]+  reft {VV##555 : a_azx | [$k_##556]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       108;+       109;+       110;+       111;+       112;+       117;+       122;+       123]+  reft {VV##1226 : a_azJ | [$k_##1227]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       85;+       87;+       89;+       90;+       283]+  reft {VV##906 : a_azx | [$k_##907]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       36;+       37;+       38;+       39;+       42;+       43;+       307]+  reft {VV##313 : a_azo | [$k_##314]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       67;+       69;+       297]+  reft {VV##654 : a_azx | [$k_##655]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       32;+       33;+       312]+  reft {VV##236 : a_azo | [$k_##237]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       108;+       109;+       110;+       111;+       112;+       117]+  reft {VV##1159 : [a_azJ] | [$k_##1160]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       108;+       109;+       110;+       111;+       112]+  reft {VV##1117 : [a_azJ] | [$k_##1118]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       85;+       87;+       89]+  reft {VV##889 : [a_azx] | [$k_##890]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75]+  reft {VV##752 : [a_azx] | [$k_##753]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       85;+       87;+       88]+  reft {VV##866 : a_azx | [$k_##867]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       32;+       33;+       34;+       311]+  reft {VV##255 : a_azo | [$k_##256]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 54; 57; 59; 60; 300]+  reft {VV##583 : a_azx | [$k_##584]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       85;+       87;+       89;+       90]+  reft {VV##913 : [a_azx] | [$k_##914]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       108;+       109;+       110]+  reft {VV##1071 : GHC.Prim.Void# | [$k_##1072]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 54; 62; 63; 64; 67]+  reft {VV##638 : a_azx | [$k_##639]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       108;+       109;+       110;+       111;+       112;+       280]+  reft {VV##1114 : a_azJ | [$k_##1115]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       290]+  reft {VV##791 : a_azx | [$k_##792]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 54; 57; 59]+  reft {VV##574 : [a_azx] | [$k_##575]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       314]+  reft {VV##167 : a_azo | [$k_##168]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       85;+       87]+  reft {VV##863 : a_azx | [$k_##864]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 54; 57; 59; 60]+  reft {VV##586 : [a_azx] | [$k_##587]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       36;+       37;+       38;+       39;+       42]+  reft {VV##309 : GHC.Prim.Void# | [$k_##310]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       32]+  reft {VV##232 : GHC.Prim.Void# | [$k_##233]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       292]+  reft {VV##749 : a_azx | [$k_##750]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       291]+  reft {VV##745 : a_azx | [$k_##746]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       36;+       37;+       38;+       39;+       49;+       51]+  reft {VV##444 : a_azo | [$k_##445]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       103;+       105]+  reft {VV##1036 : a_azJ | [$k_##1037]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       36;+       37;+       38;+       39;+       49;+       51;+       52]+  reft {VV##466 : a_azo | [$k_##467]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74]+  reft {VV##738 : a_azx | [$k_##739]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       108;+       109;+       110;+       111;+       112;+       117;+       122;+       123;+       124]+  reft {VV##1252 : a_azJ | [$k_##1253]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       36;+       37;+       38;+       39;+       49;+       50]+  reft {VV##417 : a_azo | [$k_##418]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 54; 57; 59]+  reft {VV##562 : [a_azx] | [$k_##563]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 54; 62; 63; 64; 67; 68]+  reft {VV##641 : a_azx | [$k_##642]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       108;+       109;+       110;+       111;+       112;+       279]+  reft {VV##1110 : a_azJ | [$k_##1111]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       36;+       37;+       38;+       39;+       42;+       43]+  reft {VV##320 : [a_azo] | [$k_##321]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       85;+       87;+       89;+       286]+  reft {VV##898 : a_azx | [$k_##899]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       36;+       37;+       38;+       39;+       42;+       43;+       44]+  reft {VV##337 : a_azo | [$k_##338]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       67;+       69;+       70;+       293]+  reft {VV##678 : a_azx | [$k_##679]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       36;+       37;+       38;+       39;+       42;+       43;+       45]+  reft {VV##364 : a_azo | [$k_##365]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       108;+       109;+       110;+       111;+       281]+  reft {VV##1075 : a_azJ | [$k_##1076]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       103;+       104]+  reft {VV##1019 : a_azJ | [$k_##1020]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       36;+       37;+       38;+       39;+       49;+       51;+       52;+       53]+  reft {VV##469 : a_azo | [$k_##470]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 54; 57; 59; 301]+  reft {VV##567 : a_azx | [$k_##568]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       85;+       87;+       89]+  reft {VV##901 : [a_azx] | [$k_##902]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       36;+       37;+       38]+  reft {VV##297 : a_azo | [$k_##298]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22]+  reft {VV##174 : [a_azo] | [$k_##175]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       32;+       33;+       34]+  reft {VV##258 : [a_azo] | [$k_##259]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       108;+       109;+       110;+       111;+       112;+       117;+       277]+  reft {VV##1152 : a_azJ | [$k_##1153]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       85;+       87;+       89;+       90;+       284]+  reft {VV##910 : a_azx | [$k_##911]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       108;+       109;+       110;+       111;+       282]+  reft {VV##1079 : a_azJ | [$k_##1080]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 54; 57]+  reft {VV##539 : a_azx | [$k_##540]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       108;+       109;+       110;+       111]+  reft {VV##1103 : a_azJ | [$k_##1104]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       315]+  reft {VV##171 : a_azo | [$k_##172]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       36;+       37;+       38;+       39;+       42;+       43;+       45;+       46]+  reft {VV##386 : a_azo | [$k_##387]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       108;+       109;+       110;+       111;+       112;+       117;+       122]+  reft {VV##1206 : a_azJ | [$k_##1207]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       85;+       87;+       89;+       285]+  reft {VV##894 : a_azx | [$k_##895]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       67;+       69;+       295]+  reft {VV##666 : a_azx | [$k_##667]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       103]+  reft {VV##1016 : a_azJ | [$k_##1017]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 91; 92; 95; 96]+  reft {VV##970 : a_azJ | [$k_##971]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       85;+       87;+       89;+       288]+  reft {VV##886 : a_azx | [$k_##887]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 91; 92; 95]+  reft {VV##967 : a_azJ | [$k_##968]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       289]+  reft {VV##787 : a_azx | [$k_##788]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       32;+       33;+       313]+  reft {VV##240 : a_azo | [$k_##241]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       36;+       37;+       38;+       39;+       42;+       43;+       308]+  reft {VV##317 : a_azo | [$k_##318]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       67;+       69;+       298]+  reft {VV##658 : a_azx | [$k_##659]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       32;+       33]+  reft {VV##243 : [a_azo] | [$k_##244]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 54; 57; 58]+  reft {VV##542 : a_azx | [$k_##543]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 54; 62; 63; 64; 67; 69]+  reft {VV##661 : [a_azx] | [$k_##662]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       108;+       109;+       110;+       111;+       112;+       117;+       278]+  reft {VV##1156 : a_azJ | [$k_##1157]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       36;+       37;+       38;+       39;+       42;+       43;+       45;+       46;+       47]+  reft {VV##389 : a_azo | [$k_##390]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       108;+       109;+       110;+       111]+  reft {VV##1082 : [a_azJ] | [$k_##1083]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 54; 57; 59; 60; 299]+  reft {VV##579 : a_azx | [$k_##580]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       91;+       92;+       98;+       99;+       100;+       103;+       105;+       106]+  reft {VV##1039 : a_azJ | [$k_##1040]}+  // META wf : ()+++wf:+  env [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 54; 62; 63; 64; 67; 69]+  reft {VV##673 : [a_azx] | [$k_##674]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       36;+       37;+       38;+       39;+       42;+       43]+  reft {VV##334 : a_azo | [$k_##335]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       72;+       73;+       74;+       75;+       80;+       85]+  reft {VV##840 : a_azx | [$k_##841]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       54;+       62;+       63;+       64;+       67;+       69;+       70;+       294]+  reft {VV##682 : a_azx | [$k_##683]}+  // META wf : ()+++wf:+  env [0;+       1;+       2;+       3;+       4;+       5;+       6;+       7;+       8;+       9;+       10;+       11;+       12;+       13;+       14;+       19;+       20;+       21;+       22;+       27;+       28;+       29;+       32;+       33;+       34;+       310]+  reft {VV##251 : a_azo | [$k_##252]}+  // META wf : ()+++++++
+ tests/todo/baz.fq view
@@ -0,0 +1,22 @@+// Uncommenting the WF renders the constraints "unsafe" but right now its SAFE+// which is bad. We should fail with "missing WF" or somesuch.+++bind 0 x : {v: int | $k1 }++constraint:+  env []+  lhs {v : int | [v = 6] }+  rhs {v : int | $k1      }+  id 0 tag []++constraint:+  env [0]+  lhs {v : int | [v = x] }+  rhs {v : int | v = 0   }+  id 0 tag []++// wf:+//  env []+//  reft {v: int | $k1 }+
+ tests/todo/poly.fq view
@@ -0,0 +1,14 @@++// This definition works fine ...+// constant offset : (func(0, [int ; int ; (BitVec Size32) ]))++// But this crashes as 'offset 0' is embedded as int not bv...+constant offset : (func(1, [int; int; @(0)]))++bind 0 x  : {VV : (BitVec  Size32) | [ VV = offset 0 0 ]}++constraint:+  env [0]+  lhs {VV : (BitVec Size32) | [ VV = x ] }+  rhs {VV : (BitVec Size32) | [ VV = x ] }+  id 1 tag [1]
+ tests/todo/wl01.fq view
@@ -0,0 +1,39 @@+qualif Nat(v:int) : (0 <= v)++bind 0 x : {v: int | [$k0]}+bind 1 y : {v: int | [$k0]}+bind 2 z : {v: int | [$k1]}++constraint:+  env [ ]+  lhs {v : int | [v = 10]}+  rhs {v : int | [$k0]}+  id 1 tag [0]++constraint:+  env [ 0 ]+  lhs {v : int | [v = x + x]}+  rhs {v : int | [$k0]}+  id 2 tag [0]++constraint:+  env [ 0; 1 ]+  lhs {v : int | [v = x + y ]}+  rhs {v : int | [$k1]}+  id 3 tag [0]+++constraint:+  env [ 1 ]+  lhs {v : int | [v =  z]}+  rhs {v : int | [0 <= v]}+  id 4 tag [0]++wf:+  env [ ]+  reft {v: int | [$k0]}+++wf:+  env [ ]+  reft {v: int | [$k1]}
unix/Language/Fixpoint/Utils/Progress.hs view
@@ -6,9 +6,9 @@     , progressClose     ) where -import           Control.Monad                    (unless)+import           Control.Monad                    (when) import           System.IO.Unsafe                 (unsafePerformIO)-import           System.Console.CmdArgs.Verbosity (isLoud)+import           System.Console.CmdArgs.Verbosity (isNormal) import           Data.IORef  @@ -28,8 +28,8 @@  progressInit :: Int -> IO () progressInit n = do-  loud <- isLoud-  unless loud $ do+  normal <- isNormal +  when normal $ do     pr <- mkPB n     writeIORef pbRef (Just pr)