Skip to content

Commit

Permalink
move more defines out of CoreToLogic
Browse files Browse the repository at this point in the history
  • Loading branch information
clayrat committed Dec 19, 2024
1 parent f84a7e8 commit b008f84
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
30 changes: 0 additions & 30 deletions liquidhaskell-boot/src/Language/Haskell/Liquid/GHC/CoreToLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,12 @@ module Language.Haskell.Liquid.GHC.CoreToLogic where
coreToLogic :: String
coreToLogic = unlines
[ "define GHC.Types.True = (true)"
, "define GHC.Internal.Real.div x y = (x / y)"
, "define GHC.Internal.Real.mod x y = (x mod y)"
, "define GHC.Internal.Real.fromIntegral x = (x)"

, "define GHC.Classes.not x = (~ x)"
, "define GHC.Internal.Base.$ f x = (f x)"
, ""
, "define GHC.CString.unpackCString# x = x"
, ""
, "define Main.mempty = (mempty)"
, ""
, "define Control.Parallel.Strategies.withStrategy s x = (x)"
, ""
, "define Language.Haskell.Liquid.Equational.eq x y = (y)"

, "define Language.Haskell.Liquid.ProofCombinators.cast x y = (y)"
, "define Liquid.ProofCombinators.cast x y = (y)"
, "define ProofCombinators.cast x y = (y)"
, ""
, "define Data.Set.Base.singleton x = (Set_sng x)"
, "define Data.Set.Base.union x y = (Set_cup x y)"
, "define Data.Set.Base.intersection x y = (Set_cap x y)"
, "define Data.Set.Base.difference x y = (Set_dif x y)"
, "define Data.Set.Base.empty = (Set_empty 0)"
, "define Data.Set.Base.null x = (Set_emp x)"
, "define Data.Set.Base.member x xs = (Set_mem x xs)"
, "define Data.Set.Base.isSubsetOf x y = (Set_sub x y)"
, "define Data.Set.Base.fromList xs = (listElts xs)"
, ""
, "define Data.Set.Internal.singleton x = (Set_sng x)"
, "define Data.Set.Internal.union x y = (Set_cup x y)"
, "define Data.Set.Internal.intersection x y = (Set_cap x y)"
, "define Data.Set.Internal.difference x y = (Set_dif x y)"
, "define Data.Set.Internal.empty = (Set_empty 0)"
, "define Data.Set.Internal.null x = (Set_emp x)"
, "define Data.Set.Internal.member x xs = (Set_mem x xs)"
, "define Data.Set.Internal.isSubsetOf x y = (Set_sub x y)"
, "define Data.Set.Internal.fromList xs = (Data.Set_LHAssumptions.listElts xs)"
]
21 changes: 21 additions & 0 deletions src/Data/Set_LHAssumptions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module Data.Set_LHAssumptions where

import Data.Set
import Data.Set.Internal as I
import GHC.Types_LHAssumptions()
import Prelude hiding (null)

Expand Down Expand Up @@ -38,4 +39,24 @@ measure listElts :: [a] -> Set a
listElts [] = {v | (Set_emp v)}
listElts (x:xs) = {v | v = Set_cup (Set_sng x) (listElts xs) }

define singleton x = (Set_sng x)
define union x y = (Set_cup x y)
define intersection x y = (Set_cap x y)
define difference x y = (Set_dif x y)
define empty = (Set_empty 0)
define null x = (Set_emp x)
define member x xs = (Set_mem x xs)
define isSubsetOf x y = (Set_sub x y)
define fromList xs = (Data.Set_LHAssumptions.listElts xs)

define I.singleton x = (Set_sng x)
define I.union x y = (Set_cup x y)
define I.intersection x y = (Set_cap x y)
define I.difference x y = (Set_dif x y)
define I.empty = (Set_empty 0)
define I.null x = (Set_emp x)
define I.member x xs = (Set_mem x xs)
define I.isSubsetOf x y = (Set_sub x y)
define I.fromList xs = (Data.Set_LHAssumptions.listElts xs)

@-}
2 changes: 2 additions & 0 deletions src/GHC/CString_LHAssumptions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ _f = unpackCString#
assume GHC.CString.unpackCString#
:: x:Addr#
-> {v:[Char] | v ~~ x && len v == strLen x}

define GHC.CString.unpackCString# x = x
@-}
5 changes: 5 additions & 0 deletions src/GHC/Real_LHAssumptions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ class (Real a, Enum a) => Integral a where

// fixpoint can't handle (x mod y), only (x mod c) so we need to be more clever here
// mod :: x:a -> y:a -> {v:a | v = (x mod y) }

define div x y = (x / y)
define mod x y = (x mod y)
define fromIntegral x = (x)

@-}

0 comments on commit b008f84

Please sign in to comment.