K      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~        !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJ =Takes a type and a list of variable names and declares them. FTakes a type and a list of array names and their sizes declares them. KTakes a type and a variable and initializes it. It is YOUR responsibility  to ensure that val is of type t. LTakes a type and an array and initializes it. It is YOUR responsibility to  ensure that vals is of type t. IDeclare function prototypes, given a return type, a function name, and a  | list of argument types. Use K for a return type of void. Add an include of a library  Add an include of a header file LMN3printf, with and without a newline (nl) character.    YWFor each typed variable, this type holds all its successive values in an infinite list C Beware : each element of one of those lists corresponds to a full Atom period,  not to a single clock tick. This is a generalization of 0 N which is used for storing Maps over values parameterized by different types. HIt is extensively used in the internals of Copilot, in conjunction with  e and f  !"#$%:Holds the complete specification of a distributed monitor , type DistributedStreams = (Streams, Sends) ?A type is streamable iff a stream may emit values of that type $There are very strong links between % and  :  the types aggregated in  are exactly the % 7 types and that invariant should be kept (see methods) &BProvides access to the Map in a StreamableMaps which store values  of the good type 'CProvides a way to modify (mostly used for insertions) the Map in a 4 StreamableMaps which store values of the good type (A default value for the type a. Its value is not important. )A constructor to produce an Atom value *A constructor to get an Atom! value from an external variable +BThe argument only coerces the type, it is discarded. Returns the = format for outputting a value of this type with printf in C  For example %f for a float ,>The same, only adds the wanted precision for floating points. -5The argument only coerces the type, it is discarded.  Returns the corresponding Atom type. .HLike Show, except that the formatting is exactly the same as the one of J C for example the booleans are first converted to 0 or 1, and floats and " doubles have the good precision. /A named stream 0FContainer for mutually recursive streams, whose specifications may be " parameterized by different types 1LHolds all the different kinds of language elements that are pushed into the : Writer monad. This currently includes the actual specs, send directives, M and trigger directives. (Use the functions in Language.hs to make sends and  triggers.) 23456:An instruction to send data on a port at a given phase. 5 data Send a = Sendable a => Send (Var, Phase, Port) 789:;<=>?8Holds external variables or external functions to call. @ABCDEFGHIHArguments to be passed to a C function. Either a Copilot variable or a F constant. A little hacky that I store constants as strings so we don't have M to pass around types. However, these data are just used to make external C 4 calls, for which we have no type info anyway, so it's a bit of a moot point. JKLRSpecification of a stream, parameterized by the type of the values of the stream.  The only requirement on a is that it should be %. MNOPQRSTUV)Port over which to broadcast information WXFAtom period -- used as an option to control the duration of a Copilot tick. Y C file name Z+Names of the streams or external variables [,For calling a function with Atom variables. \;Get a variable name from a spec; throw an error otherwise. ]ECopilot variable reference, taking the name of the generated C file. ^_`aIf the L isn't a UZ or T", then throw an error; otherwise,  apply the function. b)Lookup into the map of the right type in  c)Lookup into the map of the right type in  / Launch an exception if the index is not in it deJThis function is used to iterate on all the values in all the maps stored  by a !, accumulating a value over time fghOnly keeps in sm" the values whose key+type are in l. Also returns a K bool saying whether all the elements in sm were in l. Works even if some  elements in l are not in sm. Not optimised at all. OiGet the Copilot variables. jAn empty streamableMaps. k-Verifies if its argument is equal to emptySM lGReplace all accepted special characters by sequences of underscores. PQV !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklVXZYVW?A@>;=<HIKJLUTSRQPONM0/6789:CDEFGB12345%&'()*+,-. !"#$jkbcefghlid^_`][\aV  !"#$ !"#$% &'()*+,-.&'()*+,-./01234523456789:789:;=<<=>?A@@ABCDEFGDEFGHIKJJKL UTSRQPONMMNOPQRSTUVWWXYZ[\]^_`abcdefghijklmnopqrAUsed for representing an error in the specification, detected by { s$If an output depends of a future of ( an input it will be hard to compile to  say the least tCould be compiled, but  would need bigger  prophecyArrays uThe algorithm to compile  Copilot specification can  only work if there is no  negative weighted closed  path in the specification,  as described in the original  research paper v3either an external variable is not defined, or not 5 with the good type; there is no implicit conversion  of types in Copilot w2either a variable is not defined, or not with the 9 good type ; there is no implicit conversion of types in  Copilot x%External array indexes can only take $ variables or constants as indexes. y)A drop expression of less than 0 is used M | BadSamplingPhase Var Ext -- ^ if an external variable is sampled at phase L -- 0 then there is no time for the stream to be ' -- updated J | BadSamplingArrPhase Var Ext -- ^ if an external variable is sampled at H -- phase 0 then there is no time for the 7 -- stream to be updated zthe BNF is not respected RST{Check a Copilot specification. F If it is not compilable, then returns an error describing the issue.  Else, returns Nothing UV>Checks that streams are well defined (i.e., can be compiled). |mnopqrstuvwxyz{|{rzyxwvutsmqpon|mqponnopqrzyxwvutsstuvwxyz{|}"The main function of this module.  It takes a Copilot4 specification, the values of the monitored values, ( and returns the values of the streams. W}}}&XYZ[\]^_`abcdefgh~ Compiles an Copilot specification to an Atom one. V The period is given as a Maybe : if it is Nothing, an optimal period will be chosen. iFor period of length n:  Phase 0: state update. $ Phase 1: Compute output variables. & Phase 2 - n-2: send values (if any). / Phase 2 - n-2: Sample external vars (if any).  Phase n-1: update indexes. jklmnopqrsSending data over ports. tuvwBTo make customer C triggers. Only for Spec Bool (others throw an  error). x,Building an external function call in Atom. y~~~z{|}~  For functions. For global variables.  No C arguments  XXX document  Cast a into b. We only allow  safe casts to larger types. .IBeware : crash without any possible recovery if a division by 0 happens. 2 Same risk with mod. Use div0 and mod0 if unsure. EAs mod and div, except that if the division would be by 0, the first  argument is used as a default. OBeware : both sides are executed, even if the result of one is later discarded Useful for writing libraries. Define a stream variable. Takes a function name , a port number, and a Copilot variable v and % constructs a call to the C function  name(x,y) where x is the value of the  Copilot stream v and y is the port number. Coerces a type that is % into a Copilot constant. Drop i elements from a stream.  Just a trivial wrapper over the N constructor W a<  a. JopsF, opsF2 and opsF3 are fed to Tests.Random.randomStreams. They allows N the random generated streams to include lots of operators. If you add a new N operator to Copilot, it would be nice to add it to one of those, that way it K could be used in the random streams used for testing. opsF holds all the E operators of arity 1, opsF2 of arity 2 and opsF3 of arity3 They are J StreamableMaps, because operators are sorted based on their return type. Name of the C file to generate  Options to pass to the compiler The optional period Interpret the program or not Where to put the executable Which compiler to use Code to replace the default  initialization and main This function is the core of Copilot : L it glues together analyser, interpreter and compiler, and does all the IO. X It can be called either from interface (which justs decodes the command-line argument) 2 or directly from the interactive prompt in ghci.  streams is a specification,   inputExts/ allows the user to give at runtime values for c the monitored variables. Useful for testing on randomly generated values and specifications, & or for the interpreted version.  be0 chooses between compilation or interpretation, S and if compilation is chosen (AtomToC) holds a few additionnal informations.  see description of    iterationsF just gives the number of periods the specification must be executed. h If you would rather execute it by hand, then just choose AtomToC for backEnd and 0 for iterations  verbose determines what is output.  ,If there's no Streams,  then generate random  streams. For distributed monitors. %Assign values to external variables. Set gcc options. (Set the period. If none is given, then + the smallest feasible period is computed. Interpreting? +How many iterations are we simulating for? 8Verbosity level: OnlyErrors | DefaultVerbose | Verbose. *Random seed for generating Copilot specs. Name of the C file generated. 4The C compiler to use, as a path to the executable. 8Where to place the output C files (.c, .h, and binary). +Code to append above and below the C file. +A list of Copilot variable C function name ) pairs. The C funciton is called if the * Copilot stream becomes True. The Stream - must be of Booleans and the C function must  be of type void  foo(void). There should * be no more than one function per trigger , variable. Triggers fire in the same phase $ (1) that output vars are assigned. ;Use the hardware clock to drive the timing of the program? 7Set the directives for sending stream values on ports. DSets the environment for simulation by giving a mapping of external % variables to lists of values. E.g.,  $ setE (emptySM {w32Map = fromList [("ext", [0,1..])]}) ...!sets the external variable names ext9 to take the natural numbers, up to the limit of Word32. Set the external arrays. Sets the hardware clock. See  http: github.com tomahawkinsatomblobmasterLanguageAtom/ Code.hs. )Sets the options for the compiler, e.g.,   setC "-O2" ...Sets gcc options. sManually set the period for the program. Otherwise, the minimum required period is computed automatically. E.g.,  setP 100 ...  < sets the period to be 100. The period must be at least 1. <Sets the number of iterations of the program to simulation:  setN 50  ' simulations the program for 50 steps. Set the verbosity level. JSets the compiler to use, given as a path to the executable. The default  is "gcc". HSets the directory into which the output of compiled programs should be ? placed. If the directory does not exist, it will be created. >Sets the code to precede and follow the copilot specification W If nothing, then code appropriate for communication with the interpreter is generated The main function that dispatches. 7Were streams given? If not, just make random streams. -Did s hold in the previous period? Has s6 always held (up to and including the current state)? Did s> hold at some time in the past (including the current state)? Once s2. holds, in the following state (period), does s1 continuously hold?  Returns the smallest m <= n such that drop m s is true, and -1 if no  such m exists.  Returns the smallest m <= n such that drop m s is false, and -1 if no  such m exists.  Returns the largest m <= n such that drop m s is true, and -1 if no  such m exists.  Returns the largest m <= n such that drop m s is false, and -1 if no  such m exists.               Property s holds for the next n periods. We require n >= 0. If n ==  0, then s( holds in the current period. E.g., if p = always 2 s , then we @ have the following relationship between the streams generated:    0 1 2 3 4 5 6 7  s => T T T F T T T T ...  p => T F F F T T ...    Property s) holds at the next period. For example:    0 1 2 3 4 5 6 7  s => F F F T F F T F ...  next s => F F T F F T F ...   ? Note: s must have sufficient history to drop a value from it.  Property s" holds at some period in the next n periods. If n == 0,  then s* holds in the current period. We require n >= 0 . E.g., if p =  eventually 2 s>, then we have the following relationship between the streams  generated:    s => F F F T F F F T ...  p => F T T T F T T T ...    until n s0 s1 means that eventually n s1, and up until at least the  period before s1 holds, s0 continuously holds. release n s0 s1 means that either  always n s1, or s1 holds up to and  including the period at which s0 becomes true.     Summation. Maximum value. Minimum value.  Mean value. n must not overflow  for word size a1 for streams over which computation is peformed.   !"#$0Lajmnopqrstuvwxyz{|}~ !"Sending over ports. #$%&'()*+, !"#$%&'()*+, !"#$%&'()*+, !"#$%&'()*+,-./0123456789:-./0123456789:.-/0123456789:-./0123456789:;<=>?@ABCDEFGHIJ;<=>?@ABCDEFGHIJ;<=>?@BCADEFGHIJ;<=>?@ABCDEFGHIJ !"#$%#$&#$' ()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQQRSTUUVWXYZ[\]^_`aabcdefghijklmnopqrssturvwxyz{|}~           !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJ.1KLMNOPQRSTUVWXYZ[\]8^_`abcdefghijkllmnopqrstuvwxyz{|}~                                                   copilot-1.0Language.Copilot.LanguageLanguage.Copilot.AdHocCLanguage.Copilot.HelpLanguage.Copilot.CoreLanguage.Copilot.AnalyserLanguage.Copilot.InterpreterLanguage.Copilot.CompilerLanguage.Copilot.AtomToCLanguage.Copilot.Tests.Random"Language.Copilot.Language.Sampling'Language.Copilot.Language.FunctionCalls!Language.Copilot.Language.Casting#Language.Copilot.Language.RandomOpsLanguage.Copilot.DispatchLanguage.Copilot.InterfaceLanguage.Copilot.Libs.ErrorChksLanguage.Copilot.Libs.PTLTLLanguage.Copilot.Libs.IndexesLanguage.Copilot.Libs.LTL Language.Copilot.Libs.Statistics&Language.Copilot.Examples.StatExamples"Language.Copilot.Examples.Examples%Language.Copilot.Examples.LTLExamples'Language.Copilot.Examples.PTLTLExamplesLanguage.Copilot.PrettyPrinterLanguage.CopilotbaseGHC.Num fromInteger-negateGHC.Real FractionalNumghc-primGHC.BoolBoolFalseTrue/signumabs*+varDeclarrDeclvarInit arrayInitfuncDeclincludeBracket includeQuote printfNewlineprintfhelpStrVarsStreamableMapsSMbMapi8Mapi16Mapi32Mapi64Mapw8Mapw16Mapw32Mapw64MapfMapdMap Streamable getSubMap updateSubMapunitatomConstructorexternalAtomConstructortypeId typeIdPrecatomTypeshowAsCStreamStreams LangElemsstrmssndstrigsSendsendVarsendPortsendNameExtRetExtRetAExtRetVExsExtFunExtVTriggersTriggertrigVartrigNametrigArgsArgs ArgConstVarCVSpecDropAppendF3F2FPArrPVarConstVarPortPeriodNamefuncShow getMaybeVarvPregetSpecsgetSends getTriggersnotConstVarErr getMaybeElemgetElem getAtomTypefoldStreamableMapsmapStreamableMapsmapStreamableMapsMfilterStreamableMapsgetVarsemptySM isEmptySM normalizeVarSpecSetPArrSet DropSpecSet FunSpecSet AllSpecSetErrorDependsOnFutureDependsOnClosePastNonNegativeWeightedClosedPath BadTypeExtBadType BadPArrSpecBadDrop BadSyntaxcheckgetExternalVarsinterpretStreams copilotToAtom tmpVarName tmpArrName tmpSampleStrgetPrePostCode OperatorsOperatorfromOp randomStreamsextBextI8extI16extI32extI64extW8extW16extW32extW64extFextDextArrBextArrI8 extArrI16 extArrI32 extArrI64extArrW8 extArrW16 extArrW32 extArrW64extArrFextArrD<>triggerfunvoidcastnotmoddivmod0div0<<=>=>==/=||&&^==>muxvarvarBvarI8varI16varI32varI64varW8varW16varW32varW64varFvarD.=portsendconstconstI8constI16constI32constI64constW8constW16constW32constW64constFconstDtruefalsedrop++opsFopsF2opsF3VerboseDefaultVerbose OnlyErrors Iterations InterpretedNotInterpretedBackEnd InterpreterOptsAtomToCcNamegccOpts getPeriod interpreted outputDircompiler prePostCodearrDecsclockdispatchOptionsbaseOptsnoOptstest interpretcompileverifysetEsetArrssetClocksetCsetPsetIsetNsetVsetRsetOsetGCCsetDirsetPP interfacehelpnPosChknOneChkint16Chkptltlprevious alwaysBeeneventuallyPrevsincesoonest soonestFaillatest latestFailltlalwaysnext eventuallyuntilreleasesummaxminmeant0tMeanfibt1t3t4t5yyzzxxenginedistribgcdgcd' testCoercionstestCoercions2testCoercions3i8traptestArrt99t11testingoutputtSoonesttLatesttAlwaystNexttFuturectUntil tRelease0 tRelease1 testRules tstdatprvtprvtstdatABtABtstdatEPtEPq1q2z tstdat1Sin tstdat2SintSincetSinExttSinExt2 engineRun Data.MaybeNothing printfPre printfPostnewlineoverlap showIndentedshowRawWeight&&>||> syntaxCheckdefCheck TmpSamplestmpVarstmpArrstmpIdxsPhasedValueIdxPhIdxPhasedValueArrPhA BoundedArrayBPhasedValueVarPhVIndexesOutputs ProphArrsArrIndexperiodnextSt initProphArremptyTmpSamples initOutputinitExtSamplesmakeUpdateIndexmakeOutputIndexmakeRulemakeSendmkSend sampleStr sampleExtsgetIdx makeTriggerfnCall getOutputextDeclspreCodepostCode inputExtVars sampleExtVars outputVars VariablesVNamemaxDropweightsContinueVarweightsContinuePVarweightsVarTypesweightsPVarTypesweightsAllSpecSetweightsFunSpecSetweightsDropSpecSetfoldRandomableMapsrandomWeightedaddRandomVNames addRandomSpec randomSpecaddRandomExternalrandomExternalValuesExtCl $fExtClExt $fExtCl[]ArgCltrigger' argUpdateCastablecastFromcastErrmkOpmkOp2mkOp3 mkOp2CoercemkOp2OrdmkOp2Eqnot_+$-$*$/$<$<=$>=$>$==$/=$||$&&$^$==>$mux_createMapFromElems copilotToCgccCallexecuteshowVars preludeText optStreamsoptSendsoptExts optCompile optPeriod optInterpret optIterations optVerbose optRandomSeedoptCName optCompiler optOutputDiroptPrePostCode optTriggersoptArrsoptClocksetS setTriggers createSeedgetStreamsVars getBackendchktmpName soonestHlp latestHlp foldDrops