-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A Haskell-embedded DSL for monitoring hard real-time -- distributed systems. -- -- The concrete syntax for Copilot. -- -- Copilot is a stream (i.e., infinite lists) domain-specific language -- (DSL) in Haskell that compiles into embedded C. Copilot contains an -- interpreter, multiple back-end compilers, and other verification -- tools. -- -- A tutorial, examples, and other information are available at -- https://copilot-language.github.io. @package copilot-language @version 3.2.1 -- | Reexports Prelude from package "base" hiding identifiers -- redefined by Copilot. module Copilot.Language.Prelude seq :: a -> b -> b filter :: (a -> Bool) -> [a] -> [a] zip :: [a] -> [b] -> [(a, b)] print :: Show a => a -> IO () fst :: (a, b) -> a snd :: (a, b) -> b otherwise :: Bool map :: (a -> b) -> [a] -> [b] ($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b fromIntegral :: (Integral a, Num b) => a -> b realToFrac :: (Real a, Fractional b) => a -> b class Bounded a minBound :: Bounded a => a maxBound :: Bounded a => a class Enum a succ :: Enum a => a -> a pred :: Enum a => a -> a toEnum :: Enum a => Int -> a fromEnum :: Enum a => a -> Int enumFrom :: Enum a => a -> [a] enumFromThen :: Enum a => a -> a -> [a] enumFromTo :: Enum a => a -> a -> [a] enumFromThenTo :: Enum a => a -> a -> a -> [a] class Eq a class Fractional a => Floating a pi :: Floating a => a exp :: Floating a => a -> a log :: Floating a => a -> a sqrt :: Floating a => a -> a (**) :: Floating a => a -> a -> a logBase :: Floating a => a -> a -> a sin :: Floating a => a -> a cos :: Floating a => a -> a tan :: Floating a => a -> a asin :: Floating a => a -> a acos :: Floating a => a -> a atan :: Floating a => a -> a sinh :: Floating a => a -> a cosh :: Floating a => a -> a tanh :: Floating a => a -> a asinh :: Floating a => a -> a acosh :: Floating a => a -> a atanh :: Floating a => a -> a class Num a => Fractional a (/) :: Fractional a => a -> a -> a recip :: Fractional a => a -> a fromRational :: Fractional a => Rational -> a class (Real a, Enum a) => Integral a quot :: Integral a => a -> a -> a rem :: Integral a => a -> a -> a quotRem :: Integral a => a -> a -> (a, a) divMod :: Integral a => a -> a -> (a, a) toInteger :: Integral a => a -> Integer class Applicative m => Monad (m :: Type -> Type) (>>=) :: Monad m => m a -> (a -> m b) -> m b (>>) :: Monad m => m a -> m b -> m b return :: Monad m => a -> m a class Functor (f :: Type -> Type) fmap :: Functor f => (a -> b) -> f a -> f b (<$) :: Functor f => a -> f b -> f a class Num a (+) :: Num a => a -> a -> a (-) :: Num a => a -> a -> a (*) :: Num a => a -> a -> a negate :: Num a => a -> a abs :: Num a => a -> a signum :: Num a => a -> a fromInteger :: Num a => Integer -> a class Eq a => Ord a compare :: Ord a => a -> a -> Ordering class Read a readsPrec :: Read a => Int -> ReadS a readList :: Read a => ReadS [a] class (Num a, Ord a) => Real a toRational :: Real a => a -> Rational class (RealFrac a, Floating a) => RealFloat a floatRadix :: RealFloat a => a -> Integer floatDigits :: RealFloat a => a -> Int floatRange :: RealFloat a => a -> (Int, Int) decodeFloat :: RealFloat a => a -> (Integer, Int) encodeFloat :: RealFloat a => Integer -> Int -> a exponent :: RealFloat a => a -> Int significand :: RealFloat a => a -> a scaleFloat :: RealFloat a => Int -> a -> a isNaN :: RealFloat a => a -> Bool isInfinite :: RealFloat a => a -> Bool isDenormalized :: RealFloat a => a -> Bool isNegativeZero :: RealFloat a => a -> Bool isIEEE :: RealFloat a => a -> Bool atan2 :: RealFloat a => a -> a -> a class (Real a, Fractional a) => RealFrac a properFraction :: (RealFrac a, Integral b) => a -> (b, a) truncate :: (RealFrac a, Integral b) => a -> b round :: (RealFrac a, Integral b) => a -> b ceiling :: (RealFrac a, Integral b) => a -> b floor :: (RealFrac a, Integral b) => a -> b class Show a showsPrec :: Show a => Int -> a -> ShowS show :: Show a => a -> String showList :: Show a => [a] -> ShowS class Monad m => MonadFail (m :: Type -> Type) fail :: MonadFail m => String -> m a class Functor f => Applicative (f :: Type -> Type) pure :: Applicative f => a -> f a (<*>) :: Applicative f => f (a -> b) -> f a -> f b (*>) :: Applicative f => f a -> f b -> f b (<*) :: Applicative f => f a -> f b -> f a class Foldable (t :: Type -> Type) foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b foldr1 :: Foldable t => (a -> a -> a) -> t a -> a foldl1 :: Foldable t => (a -> a -> a) -> t a -> a null :: Foldable t => t a -> Bool length :: Foldable t => t a -> Int elem :: (Foldable t, Eq a) => a -> t a -> Bool maximum :: (Foldable t, Ord a) => t a -> a minimum :: (Foldable t, Ord a) => t a -> a product :: (Foldable t, Num a) => t a -> a class (Functor t, Foldable t) => Traversable (t :: Type -> Type) traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a) mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b) sequence :: (Traversable t, Monad m) => t (m a) -> m (t a) class Semigroup a (<>) :: Semigroup a => a -> a -> a class Semigroup a => Monoid a mempty :: Monoid a => a mappend :: Monoid a => a -> a -> a mconcat :: Monoid a => [a] -> a data Bool False :: Bool True :: Bool data Char data Double data Float data Int data Integer data Maybe a Nothing :: Maybe a Just :: a -> Maybe a data Ordering LT :: Ordering EQ :: Ordering GT :: Ordering type Rational = Ratio Integer data IO a data Word data Either a b Left :: a -> Either a b Right :: b -> Either a b id :: a -> a either :: (a -> c) -> (b -> c) -> Either a b -> c type String = [Char] type ShowS = String -> String read :: Read a => String -> a type IOError = IOException type FilePath = String writeFile :: FilePath -> String -> IO () readLn :: Read a => IO a readIO :: Read a => String -> IO a readFile :: FilePath -> IO String putStrLn :: String -> IO () putStr :: String -> IO () putChar :: Char -> IO () interact :: (String -> String) -> IO () getLine :: IO String getContents :: IO String getChar :: IO Char appendFile :: FilePath -> String -> IO () shows :: Show a => a -> ShowS showString :: String -> ShowS showParen :: Bool -> ShowS -> ShowS showChar :: Char -> ShowS odd :: Integral a => a -> Bool lcm :: Integral a => a -> a -> a gcd :: Integral a => a -> a -> a (^^) :: (Fractional a, Integral b) => a -> b -> a subtract :: Num a => a -> a -> a userError :: String -> IOError uncurry :: (a -> b -> c) -> (a, b) -> c curry :: ((a, b) -> c) -> a -> b -> c maybe :: b -> (a -> b) -> Maybe a -> b undefined :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => a errorWithoutStackTrace :: forall (r :: RuntimeRep) (a :: TYPE r). [Char] -> a error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [Char] -> a asTypeOf :: a -> a -> a ($!) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b even :: Integral a => a -> Bool zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d] zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] zip3 :: [a] -> [b] -> [c] -> [(a, b, c)] unzip3 :: [(a, b, c)] -> ([a], [b], [c]) unzip :: [(a, b)] -> ([a], [b]) tail :: [a] -> [a] splitAt :: Int -> [a] -> ([a], [a]) span :: (a -> Bool) -> [a] -> ([a], [a]) scanr1 :: (a -> a -> a) -> [a] -> [a] scanr :: (a -> b -> b) -> b -> [a] -> [b] scanl1 :: (a -> a -> a) -> [a] -> [a] scanl :: (b -> a -> b) -> b -> [a] -> [b] reverse :: [a] -> [a] replicate :: Int -> a -> [a] repeat :: a -> [a] lookup :: Eq a => a -> [(a, b)] -> Maybe b last :: [a] -> a iterate :: (a -> a) -> a -> [a] init :: [a] -> [a] head :: [a] -> a dropWhile :: (a -> Bool) -> [a] -> [a] break :: (a -> Bool) -> [a] -> ([a], [a]) takeWhile :: (a -> Bool) -> [a] -> [a] (<$>) :: Functor f => (a -> b) -> f a -> f b flip :: (a -> b -> c) -> b -> a -> c (.) :: (b -> c) -> (a -> b) -> a -> c or :: Foldable t => t Bool -> Bool notElem :: (Foldable t, Eq a) => a -> t a -> Bool concatMap :: Foldable t => (a -> [b]) -> t a -> [b] concat :: Foldable t => t [a] -> [a] any :: Foldable t => (a -> Bool) -> t a -> Bool and :: Foldable t => t Bool -> Bool all :: Foldable t => (a -> Bool) -> t a -> Bool ioError :: IOError -> IO a reads :: Read a => ReadS a readParen :: Bool -> ReadS a -> ReadS a lex :: ReadS String words :: String -> [String] unwords :: [String] -> String unlines :: [String] -> String lines :: String -> [String] sequence_ :: (Foldable t, Monad m) => t (m a) -> m () mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m () type ReadS a = String -> [(a, String)] (=<<) :: Monad m => (a -> m b) -> m a -> m b -- | Abstract syntax for streams and operators. module Copilot.Language.Stream -- | A stream in Copilot is an infinite succession of values of the same -- type. -- -- Streams can be built using simple primities (e.g., Const), by -- applying step-wise (e.g., Op1) or temporal transformations -- (e.g., Append, Drop) to streams, or by combining -- existing streams to form new streams (e.g., Op2, Op3). data Stream :: * -> * [Append] :: Typed a => [a] -> Maybe (Stream Bool) -> Stream a -> Stream a [Const] :: Typed a => a -> Stream a [Drop] :: Typed a => Int -> Stream a -> Stream a [Extern] :: Typed a => String -> Maybe [a] -> Stream a [Local] :: (Typed a, Typed b) => Stream a -> (Stream a -> Stream b) -> Stream b [Var] :: Typed a => String -> Stream a [Op1] :: (Typed a, Typed b) => Op1 a b -> Stream a -> Stream b [Op2] :: (Typed a, Typed b, Typed c) => Op2 a b c -> Stream a -> Stream b -> Stream c [Op3] :: (Typed a, Typed b, Typed c, Typed d) => Op3 a b c d -> Stream a -> Stream b -> Stream c -> Stream d [Label] :: Typed a => String -> Stream a -> Stream a -- | Wrapper to use Streams as arguments to triggers. data Arg [Arg] :: Typed a => Stream a -> Arg data StructArg StructArg :: String -> Arg -> StructArg [name_] :: StructArg -> String [arg'] :: StructArg -> Arg instance GHC.Show.Show (Copilot.Language.Stream.Stream a) instance GHC.Classes.Eq (Copilot.Language.Stream.Stream a) instance (Copilot.Core.Type.Typed a, GHC.Classes.Eq a, GHC.Num.Num a) => GHC.Num.Num (Copilot.Language.Stream.Stream a) instance (Copilot.Core.Type.Typed a, GHC.Classes.Eq a, GHC.Real.Fractional a) => GHC.Real.Fractional (Copilot.Language.Stream.Stream a) instance (Copilot.Core.Type.Typed a, GHC.Classes.Eq a, GHC.Float.Floating a) => GHC.Float.Floating (Copilot.Language.Stream.Stream a) -- | Copilot specifications consistute the main declaration of Copilot -- modules. -- -- A specification normally contains the association between streams to -- monitor and their handling functions, or streams to observe, or a -- theorem that must be proved. -- -- In order to be executed, Specs must be turned into Copilot Core -- (see Reify) and either simulated or converted into C99 code -- to be executed. module Copilot.Language.Spec -- | A specification is a list of declarations of triggers, observers, -- properties and theorems. -- -- Specifications are normally declared in monadic style, for example: -- --
--   monitor1 :: Stream Bool
--   monitor1 = [False] ++ not monitor1
--   
--   counter :: Stream Int32
--   counter = [0] ++ not counter
--   
--   spec :: Spec
--   spec = do
--     trigger "handler_1" monitor1 []
--     trigger "handler_2" (counter > 10) [arg counter]
--   
type Spec = Writer [SpecItem] () -- | An action in a specification (e.g., a declaration) that returns a -- value that can be used in subsequent actions. type Spec' a = Writer [SpecItem] a -- | Return the complete list of declarations inside a Spec or -- Spec'. -- -- The word run in this function is unrelated to running the underlying -- specifications or monitors, and is merely related to the monad defined -- by a Spec runSpec :: Spec' a -> [SpecItem] -- | An item of a Copilot specification. data SpecItem -- | An observer, representing a stream that we observe during execution at -- every sample. data Observer [Observer] :: Typed a => String -> Stream a -> Observer -- | Define a new observer as part of a specification. This allows someone -- to print the value at every iteration during interpretation. Observers -- do not have any functionality outside the interpreter. observer :: Typed a => String -> Stream a -> Spec -- | Filter a list of spec items to keep only the observers. observers :: [SpecItem] -> [Observer] -- | A trigger, representing a function we execute when a boolean stream -- becomes true at a sample. data Trigger [Trigger] :: Name -> Stream Bool -> [Arg] -> Trigger -- | Define a new trigger as part of a specification. A trigger declares -- which external function, or handler, will be called when a guard -- defined by a boolean stream becomes true. trigger :: String -> Stream Bool -> [Arg] -> Spec -- | Filter a list of spec items to keep only the triggers. triggers :: [SpecItem] -> [Trigger] -- | Construct a function argument from a stream. -- -- Args can be used to pass arguments to handlers or trigger -- functions, to provide additional information to monitor handlers in -- order to address property violations. At any given point (e.g., when -- the trigger must be called due to a violation), the arguments passed -- using arg will contain the current samples of the given -- streams. arg :: Typed a => Stream a -> Arg -- | A property, representing a boolean stream that is existentially or -- universally quantified over time. data Property [Property] :: String -> Stream Bool -> Property -- | A proposition, representing the quantification of a boolean streams -- over time. data Prop a [Forall] :: Stream Bool -> Prop Universal [Exists] :: Stream Bool -> Prop Existential -- | A proposition, representing a boolean stream that is existentially or -- universally quantified over time, as part of a specification. -- -- This function returns, in the monadic context, a reference to the -- proposition. prop :: String -> Prop a -> Writer [SpecItem] (PropRef a) -- | Filter a list of spec items to keep only the properties. properties :: [SpecItem] -> [Property] -- | A theorem, or proposition together with a proof. -- -- This function returns, in the monadic context, a reference to the -- proposition. theorem :: String -> Prop a -> Proof a -> Writer [SpecItem] (PropRef a) -- | Filter a list of spec items to keep only the theorems. theorems :: [SpecItem] -> [(Property, UProof)] -- | Universal quantification of boolean streams over time. forall :: Stream Bool -> Prop Universal -- | Existential quantification of boolean streams over time. exists :: Stream Bool -> Prop Existential -- | Extract the underlying stream from a quantified proposition. extractProp :: Prop a -> Stream Bool data Universal data Existential -- | Temporal stream transformations. module Copilot.Language.Operators.Temporal -- | Prepend a fixed number of samples to a stream. -- -- The elements to be appended at the beginning of the stream must be -- limited, that is, the list must have finite length. -- -- Prepending elements to a stream may increase the memory requirements -- of the generated programs (which now must hold the same number of -- elements in memory for future processing). (++) :: Typed a => [a] -> Stream a -> Stream a infixr 1 ++ -- | Drop a number of samples from a stream. -- -- The elements must be realizable at the present time to be able to drop -- elements. For most kinds of streams, you cannot drop elements without -- prepending an equal or greater number of elements to them first, as it -- could result in undefined samples. drop :: Typed a => Int -> Stream a -> Stream a -- | Combinators to deal with streams carrying structs. module Copilot.Language.Operators.Struct -- | Create a stream that carries a field of a struct in another stream. -- -- This function implements a projection of a field of a struct over -- time. For example, if a struct of type T has two fields, -- t1 of type Int and t2 of type -- Word8, and s is a stream of type Stream T, -- then s # t2 has type Stream Word8 and contains the -- values of the t2 field of the structs in s at any -- point in time. (#) :: (KnownSymbol s, Typed t, Typed a, Struct a) => Stream a -> (a -> Field s t) -> Stream t -- | Comparison operators applied point-wise on streams. module Copilot.Language.Operators.Ord -- | Compare two streams point-wise for order. -- -- The output stream contains the value True at a point in time if the -- element in the first stream is smaller or equal than the element in -- the second stream at that point in time, and False otherwise. (<=) :: (Ord a, Typed a) => Stream a -> Stream a -> Stream Bool -- | Compare two streams point-wise for order. -- -- The output stream contains the value True at a point in time if the -- element in the first stream is greater or equal than the element in -- the second stream at that point in time, and False otherwise. (>=) :: (Ord a, Typed a) => Stream a -> Stream a -> Stream Bool -- | Compare two streams point-wise for order. -- -- The output stream contains the value True at a point in time if the -- element in the first stream is smaller than the element in the second -- stream at that point in time, and False otherwise. (<) :: (Ord a, Typed a) => Stream a -> Stream a -> Stream Bool -- | Compare two streams point-wise for order. -- -- The output stream contains the value True at a point in time if the -- element in the first stream is greater than the element in the second -- stream at that point in time, and False otherwise. (>) :: (Ord a, Typed a) => Stream a -> Stream a -> Stream Bool -- | Pick values from one of two streams, depending whether a condition is -- true or false. module Copilot.Language.Operators.Mux -- | Convenient synonym for ifThenElse. mux :: Typed a => Stream Bool -> Stream a -> Stream a -> Stream a -- | If-then-else applied point-wise to three streams (a condition stream, -- a then-branch stream, and an else-branch stream). -- -- Produce a stream that, at any point in time, if the value of the first -- stream at that point is true, contains the value in the second stream -- at that time, otherwise it contains the value in the third stream. ifThenElse :: Typed a => Stream Bool -> Stream a -> Stream a -> Stream a -- | Let expressions. -- -- Although Copilot is a DSL embedded in Haskell and Haskell does support -- let expressions, we want Copilot to be able to implement sharing, to -- detect when the same stream is being used in multiple places in a -- specification and avoid recomputing it unnecessarily. module Copilot.Language.Operators.Local -- | Let expressions. -- -- Create a stream that results from applying a stream to a function on -- streams. Standard usage would be similar to Haskell's let. See the -- following example, where stream1, stream2 and -- s are all streams carrying values of some numeric type: -- --
--   expression = local (stream1 + stream2) $ \s ->
--                (s >= 0 && s <= 10)
--   
--   
local :: (Typed a, Typed b) => Stream a -> (Stream a -> Stream b) -> Stream b -- | Label a stream with additional information. module Copilot.Language.Operators.Label -- | This function allows you to label a stream with a tag, which can be -- used by different backends to provide additional information either in -- error messages or in the generated code (e.g., for traceability -- purposes). -- -- Semantically, a labelled stream is just the stream inside it. The use -- of label should not affect the observable behavior of the monitor, and -- how it is used in the code generated is a decision specific to each -- backend. label :: Typed a => String -> Stream a -> Stream a -- | Primitives to build streams connected to external variables. module Copilot.Language.Operators.Extern -- | Create a stream populated by an external global variable. -- -- The Copilot compiler does not check that the type is correct. If the -- list given as second argument does not constrain the type of the -- values carried by the stream, this primitive stream building function -- will match any stream of any type, which is potentially dangerous if -- the global variable mentioned has a different type. We rely on the -- compiler used with the generated code to detect type errors of this -- kind. extern :: Typed a => String -> Maybe [a] -> Stream a -- | Create a stream carrying values of type Bool, populated by an external -- global variable. externB :: String -> Maybe [Bool] -> Stream Bool -- | Create a stream carrying values of type Word8, populated by an -- external global variable. externW8 :: String -> Maybe [Word8] -> Stream Word8 -- | Create a stream carrying values of type Word16, populated by an -- external global variable. externW16 :: String -> Maybe [Word16] -> Stream Word16 -- | Create a stream carrying values of type Word32, populated by an -- external global variable. externW32 :: String -> Maybe [Word32] -> Stream Word32 -- | Create a stream carrying values of type Word64, populated by an -- external global variable. externW64 :: String -> Maybe [Word64] -> Stream Word64 -- | Create a stream carrying values of type Int8, populated by an external -- global variable. externI8 :: String -> Maybe [Int8] -> Stream Int8 -- | Create a stream carrying values of type Int16, populated by an -- external global variable. externI16 :: String -> Maybe [Int16] -> Stream Int16 -- | Create a stream carrying values of type Int32, populated by an -- external global variable. externI32 :: String -> Maybe [Int32] -> Stream Int32 -- | Create a stream carrying values of type Int64, populated by an -- external global variable. externI64 :: String -> Maybe [Int64] -> Stream Int64 -- | Create a stream carrying values of type Double, populated by an -- external global variable. externD :: String -> Maybe [Double] -> Stream Double -- | Deprecated. funArg :: Typed a => Stream a -> Arg -- | Equality applied point-wise on streams. module Copilot.Language.Operators.Eq -- | Compare two streams point-wise for equality. -- -- The output stream contains the value True at a point in time if both -- argument streams contain the same value at that point in time. (==) :: (Eq a, Typed a) => Stream a -> Stream a -> Stream Bool -- | Compare two streams point-wise for inequality. -- -- The output stream contains the value True at a point in time if both -- argument streams contain different values at that point in time. (/=) :: (Eq a, Typed a) => Stream a -> Stream a -> Stream Bool -- | Primitives to build constant streams. module Copilot.Language.Operators.Constant -- | Create a constant stream that is equal to the given argument, at any -- point in time. constant :: Typed a => a -> Stream a -- | Create a constant stream carrying values of type Bool that is -- equal to the given argument, at any point in time. constB :: Bool -> Stream Bool -- | Create a constant stream carrying values of type Word8 that is -- equal to the given argument, at any point in time. constW8 :: Word8 -> Stream Word8 -- | Create a constant stream carrying values of type Word16 that is -- equal to the given argument, at any point in time. constW16 :: Word16 -> Stream Word16 -- | Create a constant stream carrying values of type Word32 that is -- equal to the given argument, at any point in time. constW32 :: Word32 -> Stream Word32 -- | Create a constant stream carrying values of type Word64 that is -- equal to the given argument, at any point in time. constW64 :: Word64 -> Stream Word64 -- | Create a constant stream carrying values of type Int8 that is -- equal to the given argument, at any point in time. constI8 :: Int8 -> Stream Int8 -- | Create a constant stream carrying values of type Int16 that is -- equal to the given argument, at any point in time. constI16 :: Int16 -> Stream Int16 -- | Create a constant stream carrying values of type Int32 that is -- equal to the given argument, at any point in time. constI32 :: Int32 -> Stream Int32 -- | Create a constant stream carrying values of type Int64 that is -- equal to the given argument, at any point in time. constI64 :: Int64 -> Stream Int64 -- | Create a constant stream carrying values of type Float that is -- equal to the given argument, at any point in time. constF :: Float -> Stream Float -- | Create a constant stream carrying values of type Double that is -- equal to the given argument, at any point in time. constD :: Double -> Stream Double -- | Type-safe casting operators. module Copilot.Language.Operators.Cast -- | Perform a safe cast from Stream a to Stream b. cast :: (Cast a b, Typed a, Typed b) => Stream a -> Stream b -- | Perform an unsafe cast from Stream a to Stream b. unsafeCast :: (UnsafeCast a b, Typed a, Typed b) => Stream a -> Stream b -- | Class to capture casting between types for which it can be performed -- safely. class Cast a b -- | Class to capture casting between types for which casting may be unsafe -- and/or result in a loss of precision or information. class UnsafeCast a b instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word64 GHC.Word.Word32 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word64 GHC.Word.Word16 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word64 GHC.Word.Word8 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word32 GHC.Word.Word16 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word32 GHC.Word.Word8 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word16 GHC.Word.Word8 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int64 GHC.Int.Int32 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int64 GHC.Int.Int16 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int64 GHC.Int.Int8 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int32 GHC.Int.Int16 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int32 GHC.Int.Int8 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int16 GHC.Int.Int8 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int64 GHC.Types.Float instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int32 GHC.Types.Float instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int16 GHC.Types.Float instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int8 GHC.Types.Float instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int64 GHC.Types.Double instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int32 GHC.Types.Double instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int16 GHC.Types.Double instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int8 GHC.Types.Double instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word64 GHC.Types.Float instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word32 GHC.Types.Float instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word16 GHC.Types.Float instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word8 GHC.Types.Float instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word64 GHC.Types.Double instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word32 GHC.Types.Double instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word16 GHC.Types.Double instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word8 GHC.Types.Double instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word64 GHC.Int.Int64 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word32 GHC.Int.Int32 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word16 GHC.Int.Int16 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word8 GHC.Int.Int8 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int64 GHC.Word.Word64 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int32 GHC.Word.Word32 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int16 GHC.Word.Word16 instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int8 GHC.Word.Word8 instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Types.Bool instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Word.Word8 instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Word.Word16 instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Word.Word32 instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Word.Word64 instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Int.Int8 instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Int.Int16 instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Int.Int32 instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Int.Int64 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word8 GHC.Word.Word8 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word8 GHC.Word.Word16 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word8 GHC.Word.Word32 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word8 GHC.Word.Word64 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word8 GHC.Int.Int16 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word8 GHC.Int.Int32 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word8 GHC.Int.Int64 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word16 GHC.Word.Word16 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word16 GHC.Word.Word32 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word16 GHC.Word.Word64 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word16 GHC.Int.Int32 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word16 GHC.Int.Int64 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word32 GHC.Word.Word32 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word32 GHC.Word.Word64 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word32 GHC.Int.Int64 instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word64 GHC.Word.Word64 instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int8 GHC.Int.Int8 instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int8 GHC.Int.Int16 instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int8 GHC.Int.Int32 instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int8 GHC.Int.Int64 instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int16 GHC.Int.Int16 instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int16 GHC.Int.Int32 instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int16 GHC.Int.Int64 instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int32 GHC.Int.Int32 instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int32 GHC.Int.Int64 instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int64 GHC.Int.Int64 -- | Boolean operators applied point-wise to streams. module Copilot.Language.Operators.Boolean -- | Apply the and (&&) operator to two boolean streams, -- point-wise. (&&) :: Stream Bool -> Stream Bool -> Stream Bool infixr 4 && -- | Apply the or (||) operator to two boolean streams, point-wise. (||) :: Stream Bool -> Stream Bool -> Stream Bool infixr 4 || -- | Negate all the values in a boolean stream. not :: Stream Bool -> Stream Bool -- | A stream that contains the constant value True. true :: Stream Bool -- | A stream that contains the constant value False. false :: Stream Bool -- | Apply the exclusive-or (xor) operator to two boolean streams, -- point-wise. xor :: Stream Bool -> Stream Bool -> Stream Bool -- | Apply the implication (==>) operator to two boolean streams, -- point-wise. (==>) :: Stream Bool -> Stream Bool -> Stream Bool -- | Implement negation over quantified extensions of boolean streams. -- -- For details, see Prop. module Copilot.Language.Operators.Propositional -- | Negate a proposition. not :: Negatable a b => a -> b instance Copilot.Language.Operators.Propositional.Negatable (Copilot.Language.Spec.Prop Copilot.Theorem.Prove.Existential) (Copilot.Language.Spec.Prop Copilot.Theorem.Prove.Universal) instance Copilot.Language.Operators.Propositional.Negatable (Copilot.Language.Spec.Prop Copilot.Theorem.Prove.Universal) (Copilot.Language.Spec.Prop Copilot.Theorem.Prove.Existential) -- | Bitwise operators applied on streams, pointwise. module Copilot.Language.Operators.BitWise class Eq a => Bits a (.&.) :: Bits a => a -> a -> a (.|.) :: Bits a => a -> a -> a complement :: Bits a => a -> a -- | See xor. (.^.) :: Bits a => a -> a -> a -- | Shifting values of a stream to the left. (.<<.) :: (Bits a, Typed a, Typed b, Integral b) => Stream a -> Stream b -> Stream a -- | Shifting values of a stream to the right. (.>>.) :: (Bits a, Typed a, Typed b, Integral b) => Stream a -> Stream b -> Stream a instance (Copilot.Core.Type.Typed a, Data.Bits.Bits a) => Data.Bits.Bits (Copilot.Language.Stream.Stream a) -- | Integral class operators applied point-wise on streams. module Copilot.Language.Operators.Integral -- | Apply the div operation to two streams, point-wise. div :: (Typed a, Integral a) => Stream a -> Stream a -> Stream a -- | Apply the mod operation to two streams, point-wise. mod :: (Typed a, Integral a) => Stream a -> Stream a -> Stream a -- | Apply a limited form of exponentiation (^) to two streams, -- point-wise. -- -- Either the first stream must be the constant 2, or the second must be -- a constant stream. (^) :: (Typed a, Typed b, Num a, Bits a, Integral b) => Stream a -> Stream b -> Stream a -- | Combinators to deal with streams carrying arrays. module Copilot.Language.Operators.Array -- | Create a stream that carries an element of an array in another stream. -- -- This function implements a projection of the element of an array at a -- given position, over time. For example, if s is a stream of -- type Stream (Array '5 Word8), then s .!! 3 has type -- Stream Word8 and contains the 3rd element (starting from -- zero) of the arrays in s at any point in time. (.!!) :: (KnownNat n, t' ~ InnerType t, Flatten t t', Typed t, Typed t') => Stream (Array n t) -> Stream Word32 -> Stream t -- | Transform a Copilot Language specification into a Copilot Core -- specification. module Copilot.Language.Reify -- | Transform a Copilot Language specification into a Copilot Core -- specification. reify :: Spec' a -> IO Spec -- | Main Copilot language export file. -- -- This is mainly a meta-module that re-exports most definitions in this -- library. It also provides a default pretty printer that prints a -- specification to stdout. module Copilot.Language data Int8 data Int16 data Int32 data Int64 type Name = String class (Show a, Typeable a) => Typed a -- | Report an error due to a bug in Copilot. impossible :: String -> String -> a -- | Report an error due to an error detected by Copilot (e.g., user -- error). badUsage :: String -> a -- | Simulate a number of steps of a given specification, printing the -- results in a table in comma-separated value (CSV) format. csv :: Integer -> Spec -> IO () -- | Simulate a number of steps of a given specification, printing the -- results in a table in readable format. -- -- Compared to csv, this function is slower but the output may be -- more readable. interpret :: Integer -> Spec -> IO () -- | A specification is a list of declarations of triggers, observers, -- properties and theorems. -- -- Specifications are normally declared in monadic style, for example: -- --
--   monitor1 :: Stream Bool
--   monitor1 = [False] ++ not monitor1
--   
--   counter :: Stream Int32
--   counter = [0] ++ not counter
--   
--   spec :: Spec
--   spec = do
--     trigger "handler_1" monitor1 []
--     trigger "handler_2" (counter > 10) [arg counter]
--   
type Spec = Writer [SpecItem] () -- | A stream in Copilot is an infinite succession of values of the same -- type. -- -- Streams can be built using simple primities (e.g., Const), by -- applying step-wise (e.g., Op1) or temporal transformations -- (e.g., Append, Drop) to streams, or by combining -- existing streams to form new streams (e.g., Op2, Op3). data Stream :: * -> * -- | Define a new observer as part of a specification. This allows someone -- to print the value at every iteration during interpretation. Observers -- do not have any functionality outside the interpreter. observer :: Typed a => String -> Stream a -> Spec -- | Define a new trigger as part of a specification. A trigger declares -- which external function, or handler, will be called when a guard -- defined by a boolean stream becomes true. trigger :: String -> Stream Bool -> [Arg] -> Spec -- | Construct a function argument from a stream. -- -- Args can be used to pass arguments to handlers or trigger -- functions, to provide additional information to monitor handlers in -- order to address property violations. At any given point (e.g., when -- the trigger must be called due to a violation), the arguments passed -- using arg will contain the current samples of the given -- streams. arg :: Typed a => Stream a -> Arg -- | A proposition, representing a boolean stream that is existentially or -- universally quantified over time, as part of a specification. -- -- This function returns, in the monadic context, a reference to the -- proposition. prop :: String -> Prop a -> Writer [SpecItem] (PropRef a) -- | A theorem, or proposition together with a proof. -- -- This function returns, in the monadic context, a reference to the -- proposition. theorem :: String -> Prop a -> Proof a -> Writer [SpecItem] (PropRef a) -- | Universal quantification of boolean streams over time. forall :: Stream Bool -> Prop Universal -- | Existential quantification of boolean streams over time. exists :: Stream Bool -> Prop Existential -- | Transform a high-level Copilot Language specification into a low-level -- Copilot Core specification and pretty-print it to stdout. prettyPrint :: Spec -> IO () module Copilot