)P      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{ | } ~         !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO =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 P for a return type of void. Add an include of a library  Add an include of a header file QRS3printf, with and without a newline (nl) character.    QWFor 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  ] and ^  !"#$%: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 E Writer monad. This currently includes the actual specs and trigger L directives. (Use the functions in Language.hs to make sends and triggers.) 234567898Holds external variables or external functions to call. :;<=>?@ABCHArguments 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. DEFRSpecification of a stream, parameterized by the type of the values of the stream.  The only requirement on a is that it should be %. GHIJKLMNOP)Port over which to broadcast information QRFAtom period -- used as an option to control the duration of a Copilot tick. S C file name T+Names of the streams or external variables U,For calling a function with Atom variables. VECopilot variable reference, taking the name of the generated C file. WXYIf the F isn't a OT or N", then throw an error; otherwise,  apply the function. Z)Lookup into the map of the right type in  [)Lookup into the map of the right type in  / Launch an exception if the index is not in it \]JThis function is used to iterate on all the values in all the maps stored  by a !, accumulating a value over time ^_`Only 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. TaGet the Copilot variables. bAn empty streamableMaps. c-Verifies if its argument is equal to emptySM dGReplace all accepted special characters by sequences of underscores. UVN !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdNRTSPQ9;:8576BCEDFONMLKJIHG0/=>?@A<1234%&'()*+,-. !"#$bcZ[]^_`da\WXVUYN  !"#$ !"#$% &'()*+,-.&'()*+,-./012342345766789;::;<=>?@A>?@ABCEDDEF ONMLKJIHGGHIJKLMNOPQQRSTUVWXYZ[\]^_`abcdefghiAUsed for representing an error in the specification, detected by s j,If we are sampling a function and it has an 2 argument that is a Copilot stream, the weight of 5 that stream must have at least one initial element. k$If an output depends of a future of ( an input it will be hard to compile to  say the least lCould be compiled, but  would need bigger  prophecyArrays mThe 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 n3either an external variable is not defined, or not 5 with the good type; there is no implicit conversion  of types in Copilot o2either a variable is not defined, or not with the 6 good type ; there is no implicit conversion of types  in Copilot. p%External array indexes can only take $ variables or constants as indexes. q)A drop expression of less than 0 is used rthe BNF is not respected WXYsCheck a Copilot specification. F If it is not compilable, then returns an error describing the issue.  Else, returns Nothing. Z[>Checks that streams are well defined (i.e., can be compiled). t\6Is there an initial element (for sampling functions)? efghijklmnopqrstsirqponmlkjehgftehgffghi rqponmlkjjklmnopqrstu"The main function of this module.  It takes a Copilot4 specification, the values of the monitored values, ( and returns the values of the streams. ]uuuv^_`#Generate a temporary C file name. abcdvvv,efghijklmn5A tree datatype that holds Atom expressions from the o function  | until we'@ve got all variable references collected up. In particular, we $ | have told function applications. pqrstuvwxyz{|w 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. }For period n >= 5: ) Phase 0: Sample external vars (if any).  Phase 1: state update. $ Phase 2: Compute output variables. " Phase 3: Fire triggers (if any). " Phase 4 up to n: update indexes. ~JTakes the NextSts and walks over the tree building the Atom expression. oCompute the next state value. OGet the next state when one stream references another Copilot stream variable. xyzJFor each stream, make an index into its array of values telling you where + the next value in the array to update is. JFor each stream, make an index into its array of values telling you where  its current output value is. BTo make customer C triggers. Only for Spec Bool (others throw an  error). ,Building an external function call in Atom. wxyzwzyxwxyz {|}~{|}~|}{~{|}}~ 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. Coerces a type that is % into a Copilot constant. Drop i elements from a stream.  Just a trivial wrapper over the H constructor U Y:  Y, 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 Are we running a C simulator? Code to replace the default  initialization and main 'When generating C programs to test, we  don')t know how large external arrays are, so + we cannot declare them. Passing in pairs ( containing the name of the array and it's " size allows them to be declared. 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. Call Gcc to compile the code.  +If there's no Streams,  then generate random  streams. H optSends :: StreamableMaps Send, -- ^ 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.  Do we want a simulation driver? +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. 'When generating C programs to test, we  don'&t know how large external arrays are, ( so we cannot declare them. Passing in ( pairs containing the name of the array  and it's size allows them to be  declared. ;Use the hardware clock to drive the timing of the program? 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. *Set the random seed for generating random Copilot specs. 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 3Include simulation driver code (in a main() loop)? 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. 4Mean value over the current set of specs passed in.             FBoyer-Moore linear majority algorithm. Warning! Returns an arbitary * element if no majority is returned. See  below. 7Fault-tolerant average. Throw away the bottom and top n elements and G take the average of the rest. Return an error if there are less than 2 * n  + 1 elements in the list. ?Return the total sum of values, minus the high and low values. (Insert an element into an ordered list. % insert :: (Streamable a, A.OrdE a) , => (Spec a -> Spec a -> Spec Bool)  -> [Spec a] -> Spec a -> Int -> [Spec a] - insert _ xs _ idx | idx P.== length xs = [] # insert ord xs x idx | otherwise =  let n = xs !! idx  choice = mux (x ord n) x n in + choice : insert ord xs choice (idx + 1)   !"#$0FYbefghijklmnopqrstuvwxyz{|}~Sending over ports.  !"#$%&'()*+,-./01 !"#$%&'()*+,-./01 !"#$%&'()*+,-./01 !"#$%&'()*+,-./0123456789:;<=>?23456789:;<=>?32456789:;<=>?23456789:;<=>?@ABCDEFGHIJKLMNO@ABCDEFGHIJKLMNO@ABCDEGHFIJKLMNO@ABCDEFGHIJKLMNO !"#$%&$%'$%(!)*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRRSTUVWXYZ[\]]^_`abcdefghijklmnoopqnrstuvwxyz{|}~           !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQ+.RSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{||}~                                                   copilot-1.0.2Language.Copilot.LanguageLanguage.Copilot.AdHocCLanguage.Copilot.HelpLanguage.Copilot.CoreLanguage.Copilot.AnalyserLanguage.Copilot.InterpreterLanguage.Copilot.AtomToCLanguage.Copilot.CompilerLanguage.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.StatisticsLanguage.Copilot.Libs.Vote&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 LangElemsstrmstrigsExtRetExtRetAExtRetVExsExtFunExtVTriggersTriggertrigVartrigNametrigArgsArgs ArgConstVarCVSpecDropAppendF3F2FPArrPVarConstVarPortPeriodNamefuncShowvPregetSpecs getTriggersnotConstVarErr getMaybeElemgetElem getAtomTypefoldStreamableMapsmapStreamableMapsmapStreamableMapsMfilterStreamableMapsgetVarsemptySM isEmptySM normalizeVarSpecSet DropSpecSet FunSpecSet AllSpecSetErrorNoInitDependsOnFutureDependsOnClosePastNonNegativeWeightedClosedPath BadTypeExtBadType BadPArrSpecBadDrop BadSyntaxcheckgetExternalVarsinterpretStreamsgetPrePostCode copilotToAtom tmpVarName tmpArrName tmpSampleStr OperatorsOperatorfromOp randomStreamsextBextI8extI16extI32extI64extW8extW16extW32extW64extFextDextArrBextArrI8 extArrI16 extArrI32 extArrI64extArrW8 extArrW16 extArrW32 extArrW64extArrFextArrD<>triggerfunvoidcastnotmoddivmod0div0<<=>=>==/=||&&^==>muxvarvarBvarI8varI16varI32varI64varW8varW16varW32varW64varFvarD.=constconstI8constI16constI32constI64constW8constW16constW32constW64constFconstDtruefalsedrop++opsFopsF2opsF3VerboseDefaultVerbose OnlyErrors Iterations InterpretedNotInterpretedBackEnd InterpreterOptsAtomToCcNamegccOpts getPeriod interpreted outputDircompilersim prePostCodearrDecsclockdispatchOptionsbaseOptstest interpretcompileverifysetEsetArrssetClocksetCsetPsetIsetNsetVsetRsetOsetGCCsetDirsetCodesetSim interfacehelpnPosChknOneChkint16Chkptltlprevious alwaysBeeneventuallyPrevsincesoonest soonestFaillatest latestFailltlalwaysnext eventuallyuntilreleasesummaxminmeanmeanNowmajority aMajorityftAvgt0tMeanfibt1t3t4t5yymaj1zzxxdistribmonitorgcdgcd' testCoercionstestCoercions2testCoercions3i8traptestArrt99t11tdivextT interpretExtT compileExtTextT2extT3extT4extT5extT6testingoutputtSoonesttLatesttAlwaystNexttFuturectUntil tRelease0 tRelease1 testRules tstdatprvtprvtstdatABtABtstdatEPtEPq1q2z tstdat1Sin tstdat2SintSincetSinExttSinExt2engine engineRun Data.MaybeNothing printfPre printfPostnewlineoverlap showIndentedshowRawWeight&&>||> syntaxCheckdefCheckcheckInitsArgsextDeclspreCode tmpCFileName periodLooppostCode inputExtVars outputVars TmpSamplestmpVarstmpArrstmpIdxsPhasedValueIdxPhIdxPhasedValueArrPhANextStnextStF3NodeF2NodeF1Node VarRefLeafExpLeaf BoundedArrayBPhasedValueVarPhVIndexesOutputs ProphArrsArrIndexperiod makeStates nextStVar initProphArremptyTmpSamples initOutputinitExtSamplesmakeUpdateIndexmakeOutputIndexmakeRule sampleStr sampleExtsgetIdx makeTriggerfnCall getOutput VariablesVNamemaxDropweightsContinueVarweightsContinuePVarweightsVarTypesweightsPVarTypesweightsAllSpecSetweightsFunSpecSetweightsDropSpecSetfoldRandomableMapsrandomWeightedaddRandomVNames addRandomSpec randomSpecaddRandomExternalrandomExternalValuesExtCl $fExtClExt $fExtCl[]ArgCltrigger' argUpdateCastablecastFromcastErrmkOpmkOp2mkOp3 mkOp2CoercemkOp2OrdmkOp2Eqnot_+$-$*$/$<$<=$>=$>$==$/=$||$&&$^$==>$mux_createMapFromElems copilotToCgccCallexecuteshowVars preludeText optStreamsoptExts optCompile optPeriod optInterpret optIterations optVerbose optRandomSeedoptCName optCompiler optOutputDiroptPrePostCode optSimulate optTriggersoptArrsoptClock setTriggers createSeedgetStreamsVars getBackendchktmpName soonestHlp latestHlp foldDrops majority'ftAvg'insert