A Lift Controller in Lustre. (a case study in developing a reactive system) Leszek Holenderski

Size: px
Start display at page:

Download "A Lift Controller in Lustre. (a case study in developing a reactive system) Leszek Holenderski"

Transcription

1 Presented at 5 th Nordic Workshop on Program Correctness, Turku, Finland, October 25{28, Published in Proc. of the 5 th Nordic Workshop on Program Correctness, ed. R.J.R. Back and K. Sere, Abo Akademi Report B/18, 1994, pp 96{111. A Lift Controller in Lustre (a case study in developing a reactive system) Leszek Holenderski GMD-SET, Schloss Birlinghoven, D Sankt Augustin, Germany lhol@gmdzi.gmd.de Abstract We show how to develop (i.e. specify, program and verify) a nontrivial reactive system, in a relatively easy way, using existing software tools and a bit of elementary mathematics. The reactive system is a lift controller, the software tools are the Lustre compiler [2] and the symbolic model checker Lesar [4], and the elementary mathematics is simply a basic propositional calculus. 1 Introduction We have chosen the well-known lift example since it suits well our purposes: its requirement specication is obvious (since we all know the application domain) and it is simple enough to be fully specied, yet complex enough to be non-trivial. We program the lift controller in Lustre, which is a data-ow language for programming synchronous reactive systems. Since Lustre is a declarative, high-level language, it can be considered to be a specication language as well. In Lustre, a behaviour of a reactive system with input channels a, b, : : : and output channels x, y, : : :, is specied by equations of the form x = expr where x is an output channel, expr (built from various built-in operators) may depend on both input and output channels. There must be exactly one such a equation for every output channel. In the computational model for synchronous system, time is assumed to be discrete, i.e. modelled by natural numbers. The equation simply means that in every instant of time the value On leave from Institute of Informatics, Warsaw University, Poland 1

2 emitted on channel x should be the value of expr. Since Lustre expressions may involve an operator which allows to refer to the previous value of a channel, the current value emitted on x may depend on the communication history of the system. In the paper we show how to formally verify several properties of our lift controller. They are listed in section 5. All of them can be veried either manually or automatically. Manual verication consists in proving that a formula encoding the property to be veried follows from the equations which constitute a Lustre program. Due to a precise, yet intuitively simple, formal semantics of Lustre, such proofs can be made formal in the usual mathematical sense, i.e. presented on the level of formality accepted by humans. Automated verication was done using a symbolic model checker called Lesar. Both the model and the formula to be checked can be specied in Lustre itself. The latter is possible since, in fact, Lustre boolean expressions can be seen as formulas in a simple temporal logic with an immediate past operator, and using Lustre recursive equations one can dene more complex temporal past operators. Lesar can be applied only to pure Lustre programs, i.e. those operating on boolean values only, and it can check only invariance properties. Although the lift controller is not a pure Lustre program, it was possible to extract from it a purely boolean part for which all the properties we have veried manually could be veried also automatically. On the other hand, due to the limitations of the Lesar tool, even a simple property that the lift does not change its position unless it is forced to by some requests, could not be veried automatically. However, it could easily be veried manually. All the properties we have veried for the lift controller are invariance (safety) properties. As is well-known, in the context of real-time reactive systems, most liveness properties are reducible to invariance properties since one is usually interested in events happening at moments of time bounded by some other events, e.g. ticks generated by a clock. However, in the case of the lift controller, there is an important property, namely that every request should eventually be served, which does not t this scenario. We analyse this property in [5]. Using Lesar to fully automate verication of a reactive system has already been reported in [4]. Although we show how to extend those results by applying a similar approach to a more complex (and not purely boolean) system, here we concentrate on the manual verication. 2

3 2 A quick introduction to Lustre Lustre is a declarative data-ow language for programming synchronous reactive systems. In what follows, we only describe the fragment of Lustre which we use in the paper. The full language is described in [3]. A reactive system is viewed in Lustre as a network of reactive components, called nodes in Lustre parlance, connected by communication channels. With every node there are associated its input and output channels through which the node interacts with its environment. Channels are typed, and as usual, the types simply restrict the set of possible values which can be transmitted via channels. A declaration of a node has the following syntax: node name (inputs) returns (outputs); local declarations let body tel; where inputs and outputs are lists of channels (together with their types), local declarations introduce some auxiliary objects used by the node, if any, and body species the node's reactive behaviour, i.e. what it sends to its outputs in response to what it receives on its inputs. A program in basic Lustre is a set of declarations of nodes, with one node being distinguished as a main node. The main node's interface becomes the interface of the whole network. The topology of the network, i.e. what channels connect what nodes, is not given explicitly (since Lustre, being a data-ow language, has no explicit parallel composition operator), but instead can be deduced from the source of a Lustre program. The topology is not that important anyway, since the declarative reading of Lustre programs, which is given later, does not rely on this notion. What is important is that the syntax of the language guarantees that every input channel of a node is either an input channel of the network, or is an output channel of exactly one other node in the network. There is no such a restriction for output channels. One output channel of a node may be an input channel of several other nodes, and simultaneously, it may be an output channel of the whole network. The underlying computational model is that for synchronous data-ow languages: Time is discrete, i.e. continuous real-time is divided into a denumerable set of disjoint segments called instants of time. The segments are numbered by successive natural numbers. 3

4 0 1 2 At the beginning of every instant an environment must provide values on all input channels of a network, and then all nodes in the network perform a reaction step, which results in sending some values to all output channels of the network. This ends the instant. For one node, the reaction step consists in sending values to all its output channels. The value sent to an output channel may depend on the values currently present on the node's input channels. It is immediately available to all nodes which use the output channel as their input channels. Thus, the communication mechanism is based on instantaneous broadcasting. In any instant of time all channels in the network transmit exactly one value of a respective type. The value is either supplied by an external environment, in the case of the network input channels, or is a result of sending a value, in the same instant, by an internal node. Thus, a communication history of a channel can be represented by an innite sequence of values (called streams) transmitted through the channel, and a node can be viewed as a function from tuples of input streams to tuples of output streams. For a stream s = hv 0 ; v 1 ; v 2 ; : : :i its ith component is denoted by hsi i. The input-output function of a node is specied by a set of (possibly recursive) equations which form the node's body. An equation has the form variable = expression where variable is either a name of an output channel of the node, or an auxiliary variable declared in the local declarations part. Both variables and expressions denote streams, and v = e simply means that 8 i 0 : hvi i = hei i. Expressions are built from constants, variables and operators. Constants denote constant sequences (e.g. h1i i = 1). Variables are either input, output or auxiliary channels. Operators are of two kinds: data operators and sequence operators. The data operators (e.g. arithmetic +, -, *, /, : : : or boolean and, or, not, : : :) are applied point-wise, i.e. hop(e 1 ; e 2 ; : : :)i i = op(he 1 i i ; he 2 i i ; : : :) Conditional expression if e then e 0 else e 00 is a special case of a data operator. 4

5 The sequence operators are pre(e) (previous value) and e -> e 0 (initialisation). pre(e) returns the value of e in the previous instant, i.e. hpre(e)i 0 = undened; hpre(e)i i+1 = hei i In the rst instant, e -> e 0 value of e 0, i.e. returns the value of e, and in all later instants, the he -> e 0 i 0 = hei 0 ; he -> e 0 i i+1 = he0 i i+1 Operator -> is called an initialization operator since it is usually used to initialize pre(e), which is not dened in the rst instant. It has the weakest binding power. Nodes may be applied in expressions as functions in other programming languages. Assuming the following declaration node name (i1:t1; i2:t2;: : :) returns (o1:t1 0 ; o 2:T2 0 ;: : :); local declarations let body tel; name(e 1 ; e 2 ; : : : ) returns a tuple of streams (o 1 ; o 2 ; : : :) dened by body with all occurrences of i 1, i 2, : : : replaced by e 1, e 2, : : :, respectively. For example, the following program node edge (x: bool) returns (y: bool); let y = false -> (x and pre(not x)); tel; node main (x: bool) returns (rising, falling: bool); let rising = edge(x); falling = edge(not x); tel; species a reactive system which recognizes rising and falling edges in a supplied input signal. The signal is encoded as a stream of boolean values with true interpreted as up and false interpreted as down. Node edge recognizes rising edges. A declarative reading for the denition of y is the following: initially y equals false, and afterwards it is true i currently x is up and in the previous instant it was down. Substituting not x for x in the body of edge gives the denition of the falling edge. The network for the program has the following structure: 5

6 x - main - edge - not - edge - falling - rising where x - edge false - - not - pre - a n d - - -> - y 3 The lift example Lift moves and stops while reacting to requests caused by pressing buttons. There are 3 kinds of buttons. They are called lift, up and down buttons, respectively. The lift buttons are in the lift itself; up and down buttons are at oors (of course, there is no up button on the last oor and down button on the ground oor). With every button there is associated a lamp which represents a pending request caused by pressing a respective button. A lamp should be switched on when the respective button is pressed, and switched o when the respective request is served. In our simplied version of the lift example, observable positions of the lift are just oors at which it stops or which are passed during its movement. Thus, in every observable state of the lift's behaviour, i.e. in every instant of time, the lift is at some oor, either stopped at it or passing it. When the lift is stopped at a oor it can either start moving up or down, if respective requests appear, or otherwise remain at the oor. When the lift is approaching a oor during its movement it should decide whether to stop at the oor or continue the movement. The decision is based on the current 6

7 requests which are the pending requests from the previous position plus the new requests accumulated during the movement of the lift. The main tasks of the lift controller is to decide at any observation point what action the lift should perform next. The possible actions are called stop, up and dn. The stop action causes the lift either to stop (if it moves) or to remain at the same oor (if it is stopped). The up action causes the lift either to start moving (if it is stopped at a oor) or to continue its movement (if it passes a oor). In any case, up increments the lift's position by one oor. The dn action is dual to up. In addition, the lift controller should decide whether doors should be opened and what lamps should be on. The lift is operating according to the following strategy: the direction of the movement is not changed before all requests in that direction have been served. 4 Lift in Lustre In Lustre, there are only 3 built-in types: bool, int and real. More complicated user-dened types can easily be incorporated into a program, as abstract data types, by dening names of types and signatures of applicable functions. Implementation of user-dened types is given in a host language, which currently is C. In our Lustre program we use an abstract data type, called Flags, which is implemented as a boolean array indexed by oors. The type is declared as type Flags; function At (pos: int; f: Flags) returns (b: bool); function Above (pos: int; f: Flags) returns (b: bool); function Below (pos: int; f: Flags) returns (b: bool); function SwitchOff (pos: int; f: Flags) returns (x: Flags); function OR (f1, f2: Flags) returns (f: Flags); where At returns the value of f at index pos (i.e. f[pos]), Above returns true i f[i] is true for some i > pos (and returns false if pos is greater or equal to the last oor), Below is a dual to Above, SwitchOff returns f with f[pos] set to false, and OR returns the result of element-wise disjunction of f 1 and f 2. The node implementing our lift controller has the following interface: node lift (LB, UB, DB: Flags) returns (pos: int; stop, up, dn, opened: bool; LL, UL, DL: Flags); 7

8 The inputs represent current requests, i.e. those accumulated since the previous instant. They encode the state of respective buttons, as either being pressed or not, at the beginning of a current instant. The outputs encode the reaction of the lift to the current requests: pos is the number of the current oor; one of stop, up and dn is true, indicating what action the lift should perform at the current oor; opened indicates whether the doors should be opened or closed; LL, UL and DL indicate the state of respective lamps. The rest of this section is devoted to listing the equations which constitute the body of the node lift. The current position of the lift is initially 0 and afterwards is incremented, decremented or left unchanged, depending on the previous action of the lift: pos = 0 -> pre(pos) + if pre(up) then 1 else if pre(dn) then -1 else 0; There are some auxiliary variables involved in dening the rest of the outputs. The rst group is dened as LR = LB -> OR(pre(LL), LB); -- lift request UR = UB -> OR(pre(UL), UB); -- up request DR = DB -> OR(pre(DL), DB); -- down request AR = OR(LR, OR(UR, DR)); -- any request and denotes the requests which have not yet been served. Initially, these are just current requests, and afterwards they are simply a disjunction of pending requests (i.e. the state of lamps in the previous instant) and current requests. The second group is dened as RequestAbove = Above(pos, AR); RequestBelow = Below(pos, AR); StopWhileUp = At(pos, LR) or At(pos, UR); -- stop while moving up StopWhileDn = At(pos, LR) or At(pos, DR); -- stop while moving dn where RequestAbove is true i there is some pending request above the current oor, and StopWhileUp is true i the lift should stop when approaching the current oor while moving up (which is the case when there is either a lift or an up request at the current oor). RequestBelow and StopWhileDn are respective duals. The lift should move up if there is a pending request above the current oor, provided that it is neither currently serving down requests, nor needs to stop while moving up: up = RequestAbove and not(onwaydn or StopUp); OnWayDn =...; StopUp = false -> pre(up) and StopWhileUp; 8

9 The condition OnWayDn should become true if the lift starts moving down, and should remain true during a lift movement, until there are no requests below. This can be done by sustaining condition up until not RequestBelow. Thus, OnWayDn = sustain(false->pre(dn), not RequestBelow); where the auxiliary function sustain is declared as node sustain (on, off: bool) returns (s: bool); let s = on -> if on then true else if off then false else pre(s); tel; which reads \sustain condition on until condition o becomes true" (the output s becomes true whenever on is true, and remains true until off is true, whereupon it becomes false and remains false until on is true again). Note that in Lustre, nodes are used in expressions as user-dened operators, i.e. as functions in other programming languages. The denition of dn is almost dual to up. The dierence is caused by the need to choose between going up or down when both cases are possible, e.g. when the lift is stopped at a oor and there are both requests above and below. We decided that in such a case going up has priority, and thus dn = not up and RequestBelow and not(onwayup or StopDn); OnWayUp = sustain(false->pre(up), not RequestAbove); StopDn = false -> pre(dn) and StopWhileDn; Now, the denition of stop and opened is obvious: stop = not up and not dn; opened = stop; The denitions of lamps are the following: LL = if stop then SwitchOff(pos,LR) else LR; UL = if up or stop and not RequestBelow then SwitchOff(pos,UR) else UR; DL = if dn or stop and not RequestAbove then SwitchOff(pos,DR) else DR; They follow from the fact that lamps should represent pending requests which are simply those requests recorded at the beginning of an instant, which have not been served during that instant. 9

10 5 Verication In this section we prove that our lift controller satises the following properties: 1. the doors are always opened when the lift stops at some oor; 2. the doors are always closed when the lift is moving; 3. the lift can never change the direction of its movement without previously stopping at some oor; 4. the lift may decide to go up only if there is a request concerning a oor above a current oor; 5. similarly for going down (observe that (4) and (5) imply that the lift may only move if there is a request); 6. the lift should not make unrequested stops. The properties can be veried either manually or automatically. 5.1 Manual verication Manual verication of a Lustre program consists in proving that a formula encoding the property to be veried follows from the equations which constitute the Lustre program. Due to a precise, yet intuitively simple, semantics of Lustre such proofs can be made formal in the usual mathematical sense, i.e. presented on the level of formality accepted by humans. All the properties we verify can be formulated as always (i.e. in every instant of time, is true) where is a propositional formula containing some variables appearing in the lift controller program. For example, property (1) can be formalized as always stop ) opened, which immediately follows from the equation opened=stop by an observation that equality of booleans is their logical equivalence. In an equally easy way we can prove property (2). The property can be formulated as always up _ dn ) :opened which, by transposition of implication, is equivalent to always opened ) :up ^ :dn, and this follows directly from the denitions of opened and stop. Property (4) can be formulated as always up ) RequestAbove, which follows directly from the equation up=requestabove and... Property (5), i.e. always dn ) RequestBelow, can be proven in the same way. Properties (3) and (6) are more dicult to prove. Their proofs need two additional lemmas, which themselves are interesting facts about our lift controller. 10

11 5.1.1 At any time, exactly one of stop, up or dn is true The property can be formalised as always (1) stop ) :up (2) stop ) :dn (3) up ) :stop (4) up ) :dn (5) dn ) :stop (6) dn ) :up (7) stop _ up _ dn (1) and (2) follow directly from the denition of stop, and (6) follows directly from the denition of dn. (3), (4) and (5) follow from (1), (6) and (2) by transposition of respective implications. (7) is equivalent, by simple propositional reasoning, to :up ^ :dn ) stop, which in turn follows directly from the denition of stop. Remark Since any propositional formula can be treated as a Lustre expression denoting a boolean stream, the proof shows that the above formulas (1){(7) denote the constant stream true. Since pre distributes over all data operators, if (stop => not up) = true then also (pre(stop) => not pre(up)) = pre(true) = true, in all the instants in which the pre's are dened. Hence, pre(stop) ) :pre(up). In other words, pre(stop), pre(up) and pre(dn) are also mutually exclusive, whenever they are dened. This observation is used later on OnWayDn and OnWayUp are mutually exclusive By transposition, it suces to prove that always OnWayDn ) :OnWayUp. The proof is done by induction on the number of a current instant of time. In the rst instant, both OnWayDn and OnWayUp are false. The inductive hypothesis can be formalised as pre(onwaydn ) :OnWayUp). By unfolding sustain in the denitions of OnWayDn and OnWayUp, one gets OnWayDn = false -> if pre(dn) then true else if not RequestAbove then false else pre(onwaydn); from which it follows that OnWayDn ) pre(dn) _ pre(onwaydn). Similarly, OnWayUp ) pre(up) _ pre(onwayup). Assume that OnWayDn is true in the current instant, hence pre(dn) _ pre(onwaydn) is also true. If pre(dn) is true then pre(up) is false (from 11

12 the mutual exclusion of up and dn) and pre(onwayup) is false (from the denition of dn), thus OnWayUp is false. If pre(onwaydn) is true then pre(up) is false (from the denition of up) and pre(onwayup) is false (from the inductive hypothesis), thus OnWayUp is false The lift cannot change the direction of its movement without stopping Property (3) can be formulated as always (up ) pre(stop _ up)) ^ (dn ) pre(stop _ dn)). Notice that the formula makes sense only in all instants of time but the rst one, and in such a case, from the remark in section 5.1.1, up ) pre(stop_up) is equivalent to up ) :pre(dn), which in turn is equivalent to pre(dn) ) :up, by transposition. The last implication follows directly from the denition of up, by observing that pre(dn) ) OnWayDn, which follows from the unfolding of sustain in the denition of OnWayDn (see section 5.1.2). In a similar way one can prove dn ) pre(stop _ dn), which nishes the proof of property (3) The lift should not make unrequested stops Property (6) can be formulated as always stop ) (:RequestAbove _ :RequestBelow _ StopWhileUp _ StopWhileDn) From the denition of stop, and by simple propositional reasoning, this is equivalent to ) up _ dn, where = RequestAbove ^ RequestBelow ^ :StopWhileUp ^ :StopWhileDn. Thus, it is sucient to prove that dn is true provided is true and up is false, and this can be further reduced, by the denition of dn, to proving that ^ :up ) :OnWayUp. Let us assume that up is false then from the denition of up, and under the assumption, it follows that OnWayDn must be true. By the mutual exclusion of OnWayDn and OnWayUp, OnWayUp must be false. 5.2 Automated verication A fully automated verication can be applied to pure Lustre programs, i.e. those operating on boolean values only, and when the property describing some relation between its inputs and outputs can be encoded as a Lustre boolean expression. In such a case, the Lesar [4] tool (included in the Lustre programming environment) can produce a yes/no answer to the question 12

13 whether the property holds invariantly during all possible computations of the program. This can be done by using a technique called a symbolic model checking. More precisely, Lesar accepts as its input a pure Lustre program whose main node has only one output. It returns yes if the output is invariantly true for all possible inputs. Thus, assuming the output is called OK, it checks whether the condition dening OK is always true during execution of the node, no matter what inputs are. Although the lift controller is not a pure Lustre program, it was possible to extract from it a purely boolean part for which properties (1){(6) could be proved by Lesar. The extracted program has the property that whatever can be proved about it also holds for the original program. The denition of OK for the properties we want to verify is the following. Properties (1) and (2) can be encoded as OK = (if stop then opened else true) and -- prop (1) (if up or dn then not opened else true); -- prop (2) where if p then q else true encodes p ) q. In a similar way, property (3) can be encoded as OK = (true -> if up then pre(stop or up) else true) and -- prop (3) (true -> if dn then pre(stop or dn) else true); -- prop (3) where true ->... takes care for a proper initialization of otherwise undened expressions. And nally, properties (4), (5) and (6) can be encoded as OK = (if up then RequestAbove else true) and -- prop (4) (if dn then RequestBelow else true) and -- prop (5) (if stop then StopWhileUp or StopWhileDn or -- prop (6) not RequestAbove or not RequestBelow else true); For the following verify program, Lesar returns yes: node verify (RequestBelow, RequestAbove, StopWhileUp, StopWhileDn: bool) returns (OK: bool); var opened, stop, up, dn, OnWayUp, StopUp, OnWayDn, StopDn: bool; let up = RequestAbove and not(onwaydn or StopUp); OnWayDn = sustain(false->pre(dn), not RequestBelow); StopUp = false -> pre(up) and StopWhileUp; 13

14 dn = not up and RequestBelow and not(onwayup or StopDn); OnWayUp = sustain(false->pre(up), not RequestAbove); StopDn = false -> pre(dn) and StopWhileDn; stop opened = not up and not dn; = stop; OK =...; tel; node sustain (on, off: bool) returns (s: bool);... Observe that all the equations in the verify program are taken from the original program for the lift controller (besides the equation for OK, of course). Thus the verify program has the following property: if OK is invariantly true for all possible streams RequestBelow, RequestAbove, StopWhileUp and StopWhileDn, then OK is also invariantly true for all possible stimuli to the original program. This follows from the fact that the stimuli can generate (using the denitions removed from the original program) only a subset of all the possible streams. Thus, all the properties which hold for the verify program also hold for the original program, in particular properties (1){(6). 6 Conclusions We have shown how, using existing software tools, one may specify and partly verify a non-trivial reactive system. Using Lustre and Lesar in such a context has many advantages. Lustre, due to its declarativness, allows for concise specications which can then be easily veried, either manually or automatically. The former is possible due to the precise, yet relatively simple, semantics which is intuitive enough to allow a presentation of proofs on a level of abstraction suited for humans. This is a very important issue, since the automation of proofs is still quite limited. Lesar can prove only those safety properties of a program which depend on purely boolean parts of the program and which can be reduced to an invariance of propositional formulas in a kind of a temporal logic with the immediate past operator. For example, it cannot deal with the property always pre(stop) ) pos = pre(pos) which states that the lift does not move unless it is forced to. On the other hand, the property can easily be proven manually, just by inspecting the equa- 14

15 tion dening pos (and using the fact that pre(stop), pre(up) and pre(dn) are mutually exclusive). Although formal verication adds yet another step to a software development process, it is obviously worth the eort since it provides a sound justication of system's correctness with respect to the veried properties. On the other hand, formal verication has its own disadvantages. It is usually complex, and thus needs special skills and time. It is also error-prone itself, unless done automatically (but even in this case a formal proof of the correctness of the tool used for such an automation would be necessary, in principle). Furthermore, the state of the art in formal verication methods is far from being satisfactory, in the sense that it is feasible to verify only relatively simple properties of relatively simple systems. For those reasons formal verication should be still complemented by systematic testing. In [5] we extend the results presented in the current paper, by combining formal verication and systematic testing to validate the lift controller. References [1] P. Caspi, N. Halbwachs, D. Pilaud, J. A. Plaice, Lustre: a declarative language for programming synchronous systems, Proc. of the 14th Symposium on Principle of Programming Languages, Muenchen, Sep. 1987, 178{188. [2] N. Halbwachs, P. Caspi, P. Raymond, D. Pilaud, The Synchronous Data Flow Programming Language Lustre, IEEE Special Issue on Real Time Programming, Proceedings of the IEEE, 79(9), Sep. 1991, 1305{1320. [3] N. Halbwachs, A Tutorial of Lustre, Lustre distribution, available by anonymous ftp from imag.imag.fr as le /ftp/pub/lustre/tutorial.ps, Jan. 1993, 1{19 [4] N. Halbwachs, F. Lagnier, C. Ratel, Programming and Verifying Real-Time Systems by Means of the Synchronous Data-Flow Language Lustre, IEEE Trans. on Software Eng., 18(9), Sep. 1992, 785{793. [5] M. Mullerburg, L. Holenderski, Combining Testing and Formal Verication for Validating Reactive Systems, submitted to the Fourth European Conference on Software Quality, Basel, Switzerland, Jan Appendix: The Full Lustre Program type Flags; function At (pos: int; f: Flags) returns (b: bool); function Above (pos: int; f: Flags) returns (b: bool); function Below (pos: int; f: Flags) returns (b: bool); function SwitchOff (pos: int; f: Flags) returns (x: Flags); function OR (f1, f2: Flags) returns (f: Flags); 15

16 node sustain (on, off: bool) returns (s: bool); -- sustain 'on' until 'off' let s = on -> if on then true else if off then false else pre(s); tel; node lift (LB, UB, DB: Flags) returns (pos: int; stop, dn, up, opened: bool; LL, UL, DL: Flags); var LR, UR, DR, AR: Flags; RequestAbove, RequestBelow, StopWhileUp, StopWhileDn: bool; OnWayUp, StopUp, OnWayDn, StopDn: bool; let LR = LB -> OR(pre(LL), LB); -- lift request UR = UB -> OR(pre(UL), UB); -- up request DR = DB -> OR(pre(DL), DB); -- down request AR = OR(LR, OR(UR, DR)); -- any request RequestAbove = Above(pos, AR); RequestBelow = Below(pos, AR); StopWhileUp = At(pos, LR) or At(pos, UR); -- stop while moving up StopWhileDn = At(pos, LR) or At(pos, DR); -- stop while moving down pos = 0 -> pre(pos) + if pre(up) then 1 else if pre(dn) then -1 else 0; up = RequestAbove and not(onwaydn or StopUp); OnWayDn = sustain(false->pre(dn), not RequestBelow); StopUp = false -> pre(up) and StopWhileUp; dn = not up and RequestBelow and not(onwayup or StopDn); OnWayUp = sustain(false->pre(up), not RequestAbove); StopDn = false -> pre(dn) and StopWhileDn; stop = not up and not dn; LL = if stop then SwitchOff(pos,LR) else LR; UL = if up or stop and not RequestBelow then SwitchOff(pos,UR) else UR; DL = if dn or stop and not RequestAbove then SwitchOff(pos,DR) else DR; tel; 16

a Means for Validating Reactive Systems. Schloss Birlinghoven Software Testing, Verication and Reliability

a Means for Validating Reactive Systems. Schloss Birlinghoven Software Testing, Verication and Reliability Title: Systematic Testing: a Means for Validating Reactive Systems. Author: Monika Mullerburg GMD - SET Schloss Birlinghoven D-53757 Sankt Augustin Tel.: + 49 (2241) 14-2428 Fax : + 49 (2241) 14-2035 e-mail:

More information

Programming with Lustre

Programming with Lustre Programming with 1 Using tools This tutorial shows how to use the tool on a tiny program (the rising edge detector). You can indeed write your own program and experiment with it. 1.1 Writing the edge program

More information

Programming Languages Third Edition

Programming Languages Third Edition Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand

More information

Reactive Types. Jean-Pierre Talpin. Campus de Beaulieu, Rennes, France.

Reactive Types. Jean-Pierre Talpin. Campus de Beaulieu, Rennes, France. Reactive Types Jean-Pierre Talpin IRISA (INRIA-Rennes & CNRS URA 227) Campus de Beaulieu, 35000 Rennes, France E-mail: talpin@irisa.fr Abstract. Synchronous languages, such as Signal, are best suited for

More information

Handout 9: Imperative Programs and State

Handout 9: Imperative Programs and State 06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 9: Imperative Programs and State Imperative

More information

On Meaning Preservation of a Calculus of Records

On Meaning Preservation of a Calculus of Records On Meaning Preservation of a Calculus of Records Emily Christiansen and Elena Machkasova Computer Science Discipline University of Minnesota, Morris Morris, MN 56267 chri1101, elenam@morris.umn.edu Abstract

More information

Verifying Safety Property of Lustre Programs: Temporal Induction

Verifying Safety Property of Lustre Programs: Temporal Induction 22c181: Formal Methods in Software Engineering The University of Iowa Spring 2008 Verifying Safety Property of Lustre Programs: Temporal Induction Copyright 2008 Cesare Tinelli. These notes are copyrighted

More information

Lecture Notes on Program Equivalence

Lecture Notes on Program Equivalence Lecture Notes on Program Equivalence 15-312: Foundations of Programming Languages Frank Pfenning Lecture 24 November 30, 2004 When are two programs equal? Without much reflection one might say that two

More information

Synchronous reactive programming

Synchronous reactive programming Synchronous reactive programming Marcus Sundman Department of Computer Science Åbo Akademi University, FIN-20520 Åbo, Finland e-mail: marcus.sundman@iki.fi URL: http://www.iki.fi/marcus.sundman/ Abstract

More information

Chapter 3: Propositional Languages

Chapter 3: Propositional Languages Chapter 3: Propositional Languages We define here a general notion of a propositional language. We show how to obtain, as specific cases, various languages for propositional classical logic and some non-classical

More information

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic 3.4 Deduction and Evaluation: Tools 3.4.1 Conditional-Equational Logic The general definition of a formal specification from above was based on the existence of a precisely defined semantics for the syntax

More information

Propositional Logic. Part I

Propositional Logic. Part I Part I Propositional Logic 1 Classical Logic and the Material Conditional 1.1 Introduction 1.1.1 The first purpose of this chapter is to review classical propositional logic, including semantic tableaux.

More information

Hoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré

Hoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré Hoare Logic COMP2600 Formal Methods for Software Engineering Rajeev Goré Australian National University Semester 2, 2016 (Slides courtesy of Ranald Clouston) COMP 2600 Hoare Logic 1 Australian Capital

More information

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e

More information

A macro- generator for ALGOL

A macro- generator for ALGOL A macro- generator for ALGOL byh.leroy Compagnie Bull-General Electric Paris, France INTRODUCfION The concept of macro-facility is ambiguous, when applied to higher level languages. For some authorsl,2,

More information

Lecture 2. The SCADE Language Data Flow Kernel. Daniel Kästner AbsInt GmbH 2012

Lecture 2. The SCADE Language Data Flow Kernel. Daniel Kästner AbsInt GmbH 2012 Lecture 2 The SCADE Language Data Flow Kernel Daniel Kästner AbsInt GmbH 2012 2 Synchronous Programming Two simple ways of implementing reactive systems: Event-driven Foreach input_event

More information

Abstract This paper describes AxSL, an Axiomatic Specication Language that extends algebraic axiom methods to support object-oriented concepts such as

Abstract This paper describes AxSL, an Axiomatic Specication Language that extends algebraic axiom methods to support object-oriented concepts such as Extending Algebraic Axiom Techniques to Handle Object-Oriented Specications Alyce Brady, Member, IEEE David R. Musser, Member, IEEE Computer Society David L. Spooner, Member, IEEE August 2, 1999 Abstract

More information

Timing Analysis Enhancement for Synchronous Program

Timing Analysis Enhancement for Synchronous Program Timing Analysis Enhancement for Synchronous Program Extended Abstract Pascal Raymond, Claire Maiza, Catherine Parent-Vigouroux, Fabienne Carrier, and Mihail Asavoae Grenoble-Alpes University Verimag, Centre

More information

3.7 Denotational Semantics

3.7 Denotational Semantics 3.7 Denotational Semantics Denotational semantics, also known as fixed-point semantics, associates to each programming language construct a well-defined and rigorously understood mathematical object. These

More information

Formal semantics of loosely typed languages. Joep Verkoelen Vincent Driessen

Formal semantics of loosely typed languages. Joep Verkoelen Vincent Driessen Formal semantics of loosely typed languages Joep Verkoelen Vincent Driessen June, 2004 ii Contents 1 Introduction 3 2 Syntax 5 2.1 Formalities.............................. 5 2.2 Example language LooselyWhile.................

More information

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions): CS 70 Discrete Mathematics for CS Fall 2003 Wagner Lecture 7 This lecture returns to the topic of propositional logic. Whereas in Lecture 1 we studied this topic as a way of understanding proper reasoning

More information

Distributed Systems Programming (F21DS1) Formal Verification

Distributed Systems Programming (F21DS1) Formal Verification Distributed Systems Programming (F21DS1) Formal Verification Andrew Ireland Department of Computer Science School of Mathematical and Computer Sciences Heriot-Watt University Edinburgh Overview Focus on

More information

A Correctness Proof for a Practical Byzantine-Fault-Tolerant Replication Algorithm

A Correctness Proof for a Practical Byzantine-Fault-Tolerant Replication Algorithm Appears as Technical Memo MIT/LCS/TM-590, MIT Laboratory for Computer Science, June 1999 A Correctness Proof for a Practical Byzantine-Fault-Tolerant Replication Algorithm Miguel Castro and Barbara Liskov

More information

Induction and Semantics in Dafny

Induction and Semantics in Dafny 15-414 Lecture 11 1 Instructor: Matt Fredrikson Induction and Semantics in Dafny TA: Ryan Wagner Encoding the syntax of Imp Recall the abstract syntax of Imp: a AExp ::= n Z x Var a 1 + a 2 b BExp ::=

More information

Semantics of programming languages

Semantics of programming languages Semantics of programming languages Informatics 2A: Lecture 27 John Longley School of Informatics University of Edinburgh jrl@inf.ed.ac.uk 21 November, 2011 1 / 19 1 2 3 4 2 / 19 Semantics for programming

More information

Denotational semantics

Denotational semantics 1 Denotational semantics 2 What we're doing today We're looking at how to reason about the effect of a program by mapping it into mathematical objects Specifically, answering the question which function

More information

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics Recall Architecture of Compilers, Interpreters CMSC 330: Organization of Programming Languages Source Scanner Parser Static Analyzer Operational Semantics Intermediate Representation Front End Back End

More information

Principles of Programming Languages

Principles of Programming Languages Principles of Programming Languages Lesson 14 Type Checking Collaboration and Management Dana Fisman www.cs.bgu.ac.il/~ppl172 1 Type Checking We return to the issue of type safety we discussed informally,

More information

An Eect Type System for Modular Distribution of Dataow Programs

An Eect Type System for Modular Distribution of Dataow Programs An Eect Type System for Modular Distribution of Dataow Programs Gwenaël Delaval 1 Alain Girault 1 Marc Pouzet 2 P P 1 INRIA Rhône-Alpes, Pop-Art project ART 2 LRI, Demons team June 13, 2008 LCTES, Tucson,

More information

An Introduction to Lustre

An Introduction to Lustre An Introduction to Lustre Monday Oct 06, 2014 Philipp Rümmer Uppsala University Philipp.Ruemmer@it.uu.se 1/35 ES Programming languages Which language to write embedded software in? Traditional: low-level

More information

SAMOS: an Active Object{Oriented Database System. Stella Gatziu, Klaus R. Dittrich. Database Technology Research Group

SAMOS: an Active Object{Oriented Database System. Stella Gatziu, Klaus R. Dittrich. Database Technology Research Group SAMOS: an Active Object{Oriented Database System Stella Gatziu, Klaus R. Dittrich Database Technology Research Group Institut fur Informatik, Universitat Zurich fgatziu, dittrichg@ifi.unizh.ch to appear

More information

Part II. Hoare Logic and Program Verification. Why specify programs? Specification and Verification. Code Verification. Why verify programs?

Part II. Hoare Logic and Program Verification. Why specify programs? Specification and Verification. Code Verification. Why verify programs? Part II. Hoare Logic and Program Verification Part II. Hoare Logic and Program Verification Dilian Gurov Props: Models: Specs: Method: Tool: safety of data manipulation source code logic assertions Hoare

More information

A Note on Fairness in I/O Automata. Judi Romijn and Frits Vaandrager CWI. Abstract

A Note on Fairness in I/O Automata. Judi Romijn and Frits Vaandrager CWI. Abstract A Note on Fairness in I/O Automata Judi Romijn and Frits Vaandrager CWI P.O. Box 94079, 1090 GB Amsterdam, The Netherlands judi@cwi.nl, fritsv@cwi.nl Abstract Notions of weak and strong fairness are studied

More information

Verifying Periodic Task-Control Systems. Vlad Rusu? Abstract. This paper deals with the automated verication of a class

Verifying Periodic Task-Control Systems. Vlad Rusu? Abstract. This paper deals with the automated verication of a class Verifying Periodic Task-Control Systems Vlad Rusu? Abstract. This paper deals with the automated verication of a class of task-control systems with periods, durations, and scheduling specications. Such

More information

Sugar 2.0 An Introduction

Sugar 2.0 An Introduction Sugar 2.0 An Introduction Cindy Eisner 1 Dana Fisman 1,2 1 IBM Haifa Research Laboratory 2 Weizmann Institute of Science, Rehovot, Israel {eisner,danaf}@il.ibm.com 1 Introduction Sugar is a language for

More information

The Esterel language

The Esterel language Pascal Raymond, Verimag-CNRS Introduction 2 The first synchronous language (early 80 s) Gérard Berry and his team (École des Mines de Paris / INRIA Sophia-Antipolis) Imperative, sequential style (i.e.

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

Argos: an automaton-based synchronous language

Argos: an automaton-based synchronous language Computer Languages 27 (2001) 61 92 www.elsevier.com/locate/complang Argos: an automaton-based synchronous language Florence Maraninchi a;, Yann Remond b a VERIMAG 1 /Institut National Polytechnique de

More information

Introduction 2 The first synchronous language (early 80 s) Gérard Berry and his team (École des Mines de Paris / INRIA Sophia-Antipolis) Imperative, s

Introduction 2 The first synchronous language (early 80 s) Gérard Berry and his team (École des Mines de Paris / INRIA Sophia-Antipolis) Imperative, s Pascal Raymond, Verimag-CNRS Introduction 2 The first synchronous language (early 80 s) Gérard Berry and his team (École des Mines de Paris / INRIA Sophia-Antipolis) Imperative, sequential style (i.e.

More information

Outline. Computer Science 331. Information Hiding. What This Lecture is About. Data Structures, Abstract Data Types, and Their Implementations

Outline. Computer Science 331. Information Hiding. What This Lecture is About. Data Structures, Abstract Data Types, and Their Implementations Outline Computer Science 331 Data Structures, Abstract Data Types, and Their Implementations Mike Jacobson 1 Overview 2 ADTs as Interfaces Department of Computer Science University of Calgary Lecture #8

More information

Lambda Calculus and Type Inference

Lambda Calculus and Type Inference Lambda Calculus and Type Inference Björn Lisper Dept. of Computer Science and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ October 13, 2004 Lambda Calculus and Type

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Fall 2016 Lecture 7a Andrew Tolmach Portland State University 1994-2016 Values and Types We divide the universe of values according to types A type is a set of values and a

More information

Type Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules.

Type Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules. Outline Type Checking General properties of type systems Types in programming languages Notation for type rules Logical rules of inference Common type rules 2 Static Checking Refers to the compile-time

More information

Improving the Static Analysis of Loops by Dynamic Partitioning Techniques

Improving the Static Analysis of Loops by Dynamic Partitioning Techniques Improving the Static Analysis of Loops by Dynamic Partitioning echniques Matthieu Martel CEA - Recherche echnologique LIS-DSI-SLA CEA F91191 Gif-Sur-Yvette Cedex, France Matthieu.Martel@cea.fr Abstract

More information

.Math 0450 Honors intro to analysis Spring, 2009 Notes #4 corrected (as of Monday evening, 1/12) some changes on page 6, as in .

.Math 0450 Honors intro to analysis Spring, 2009 Notes #4 corrected (as of Monday evening, 1/12) some changes on page 6, as in  . 0.1 More on innity.math 0450 Honors intro to analysis Spring, 2009 Notes #4 corrected (as of Monday evening, 1/12) some changes on page 6, as in email. 0.1.1 If you haven't read 1.3, do so now! In notes#1

More information

Programming Languages

Programming Languages CSE 230: Winter 2008 Principles of Programming Languages Ocaml/HW #3 Q-A Session Push deadline = Mar 10 Session Mon 3pm? Lecture 15: Type Systems Ranjit Jhala UC San Diego Why Typed Languages? Development

More information

Outline. General properties of type systems. Types in programming languages. Notation for type rules. Common type rules. Logical rules of inference

Outline. General properties of type systems. Types in programming languages. Notation for type rules. Common type rules. Logical rules of inference Type Checking Outline General properties of type systems Types in programming languages Notation for type rules Logical rules of inference Common type rules 2 Static Checking Refers to the compile-time

More information

Lecture 2: Intro to Concurrent Processing. A Model of Concurrent Programming

Lecture 2: Intro to Concurrent Processing. A Model of Concurrent Programming Lecture 2: Intro to Concurrent Processing The SR Language. Correctness and Concurrency. Mutual Exclusion & Critical Sections. Software Solutions to Mutual Exclusion. Dekker s Algorithm. The Bakery Algorithm.

More information

Bootcamp. Christoph Thiele. Summer An example of a primitive universe

Bootcamp. Christoph Thiele. Summer An example of a primitive universe Bootcamp Christoph Thiele Summer 2012 0.1 An example of a primitive universe A primitive universe consists of primitive objects and primitive sets. This allows to form primitive statements as to which

More information

,, 1{48 () c Kluwer Academic Publishers, Boston. Manufactured in The Netherlands. Optimal Representations of Polymorphic Types with Subtyping * ALEXAN

,, 1{48 () c Kluwer Academic Publishers, Boston. Manufactured in The Netherlands. Optimal Representations of Polymorphic Types with Subtyping * ALEXAN ,, 1{48 () c Kluwer Academic Publishers, Boston. Manufactured in The Netherlands. Optimal Representations of Polymorphic Types with Subtyping * ALEXANDER AIKEN aiken@cs.berkeley.edu EECS Department, University

More information

SCADE S E M I N A R I N S O F T W A R E E N G I N E E R I N G P R E S E N T E R A V N E R B A R R

SCADE S E M I N A R I N S O F T W A R E E N G I N E E R I N G P R E S E N T E R A V N E R B A R R SCADE 1 S E M I N A R I N S O F T W A R E E N G I N E E R I N G P R E S E N T E R A V N E R B A R R What is SCADE? Introduction 2 Software Critical Application Development Environment, a Lustrebased IDE

More information

MA651 Topology. Lecture 4. Topological spaces 2

MA651 Topology. Lecture 4. Topological spaces 2 MA651 Topology. Lecture 4. Topological spaces 2 This text is based on the following books: Linear Algebra and Analysis by Marc Zamansky Topology by James Dugundgji Fundamental concepts of topology by Peter

More information

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals Review CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics e ::= λx. e x ee c v ::= λx. e c (λx. e) v e[v/x] e 1 e 2 e 1 e 2 τ ::= int τ τ Γ ::= Γ,x : τ e 2 e 2 ve 2 ve 2 e[e /x]:

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Operational Semantics CMSC 330 Summer 2018 1 Formal Semantics of a Prog. Lang. Mathematical description of the meaning of programs written in that language

More information

Lecture 3: Recursion; Structural Induction

Lecture 3: Recursion; Structural Induction 15-150 Lecture 3: Recursion; Structural Induction Lecture by Dan Licata January 24, 2012 Today, we are going to talk about one of the most important ideas in functional programming, structural recursion

More information

A taxonomy of race. D. P. Helmbold, C. E. McDowell. September 28, University of California, Santa Cruz. Santa Cruz, CA

A taxonomy of race. D. P. Helmbold, C. E. McDowell. September 28, University of California, Santa Cruz. Santa Cruz, CA A taxonomy of race conditions. D. P. Helmbold, C. E. McDowell UCSC-CRL-94-34 September 28, 1994 Board of Studies in Computer and Information Sciences University of California, Santa Cruz Santa Cruz, CA

More information

Modal Logic: Implications for Design of a Language for Distributed Computation p.1/53

Modal Logic: Implications for Design of a Language for Distributed Computation p.1/53 Modal Logic: Implications for Design of a Language for Distributed Computation Jonathan Moody (with Frank Pfenning) Department of Computer Science Carnegie Mellon University Modal Logic: Implications for

More information

This chapter describes the syntax and semantics of the safemos programming language,

This chapter describes the syntax and semantics of the safemos programming language, A Real-time Programming Language R.W.S. Hale and He Jifeng Overview URL: http://www.cam.sri.com/tr/crc039/paper.ps.z Towards Verified Systems, Jonathan Bowen (ed.), Elsevier; 1992 This chapter describes

More information

Towards a Reference Framework. Gianpaolo Cugola and Carlo Ghezzi. [cugola, P.za Leonardo da Vinci 32.

Towards a Reference Framework. Gianpaolo Cugola and Carlo Ghezzi. [cugola, P.za Leonardo da Vinci 32. Inconsistencies in Software Development: Towards a Reference Framework Gianpaolo Cugola and Carlo Ghezzi [cugola, ghezzi]@elet.polimi.it Dipartimento di Elettronica e Informazione Politecnico di Milano

More information

Denotational Semantics. Domain Theory

Denotational Semantics. Domain Theory Denotational Semantics and Domain Theory 1 / 51 Outline Denotational Semantics Basic Domain Theory Introduction and history Primitive and lifted domains Sum and product domains Function domains Meaning

More information

CITS5501 Software Testing and Quality Assurance Formal methods

CITS5501 Software Testing and Quality Assurance Formal methods CITS5501 Software Testing and Quality Assurance Formal methods Unit coordinator: Arran Stewart May 1, 2018 1 / 49 Sources Pressman, R., Software Engineering: A Practitioner s Approach, McGraw-Hill, 2005

More information

COSC252: Programming Languages: Semantic Specification. Jeremy Bolton, PhD Adjunct Professor

COSC252: Programming Languages: Semantic Specification. Jeremy Bolton, PhD Adjunct Professor COSC252: Programming Languages: Semantic Specification Jeremy Bolton, PhD Adjunct Professor Outline I. What happens after syntactic analysis (parsing)? II. Attribute Grammars: bridging the gap III. Semantic

More information

1 Introduction One of the contributions of Java is in its bytecode verier, which checks type safety of bytecode for JVM (Java Virtual Machine) prior t

1 Introduction One of the contributions of Java is in its bytecode verier, which checks type safety of bytecode for JVM (Java Virtual Machine) prior t On a New Method for Dataow Analysis of Java Virtual Machine Subroutines Masami Hagiya Department of Information Science, Graduate School of Science, University of Tokyo hagiyais.s.u-tokyo.ac.jp Abstract

More information

perform. If more storage is required, more can be added without having to modify the processor (provided that the extra memory is still addressable).

perform. If more storage is required, more can be added without having to modify the processor (provided that the extra memory is still addressable). How to Make Zuse's Z3 a Universal Computer Raul Rojas January 14, 1998 Abstract The computing machine Z3, built by Konrad Zuse between 1938 and 1941, could only execute xed sequences of oating-point arithmetical

More information

(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1

(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1 CS 70 Discrete Mathematics for CS Fall 2000 Wagner MT1 Sol Solutions to Midterm 1 1. (16 pts.) Theorems and proofs (a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are

More information

2 Robert Harper However, the program contains a subtle error that we tease out by attempting to carry out a proof of its correctness. The development

2 Robert Harper However, the program contains a subtle error that we tease out by attempting to carry out a proof of its correctness. The development J. Functional Programming 1 (1): 1{000, January 1993 c 1993 Cambridge University Press 1 FUNCTIONAL PEARLS Proof-Directed Debugging Robert Harper Carnegie Mellon University Pittsburgh, PA 15213 Abstract

More information

CS2 Algorithms and Data Structures Note 10. Depth-First Search and Topological Sorting

CS2 Algorithms and Data Structures Note 10. Depth-First Search and Topological Sorting CS2 Algorithms and Data Structures Note 10 Depth-First Search and Topological Sorting In this lecture, we will analyse the running time of DFS and discuss a few applications. 10.1 A recursive implementation

More information

Lecture Notes on Arrays

Lecture Notes on Arrays Lecture Notes on Arrays 15-122: Principles of Imperative Computation July 2, 2013 1 Introduction So far we have seen how to process primitive data like integers in imperative programs. That is useful,

More information

KAT and PHL in Coq. 1 Introduction. 2 Revision of KAT and PHL concepts. David Pereira 1 and Nelma Moreira 1

KAT and PHL in Coq. 1 Introduction. 2 Revision of KAT and PHL concepts. David Pereira 1 and Nelma Moreira 1 KAT and PHL in Coq David Pereira 1 and Nelma Moreira 1 LIACC University of Porto {dpereira,nam}@ncc.up.pt Abstract. In this paper we describe an implementation of Kleene Algebras with Tests (KAT) in the

More information

Dynamic Logic David Harel, The Weizmann Institute Dexter Kozen, Cornell University Jerzy Tiuryn, University of Warsaw The MIT Press, Cambridge, Massac

Dynamic Logic David Harel, The Weizmann Institute Dexter Kozen, Cornell University Jerzy Tiuryn, University of Warsaw The MIT Press, Cambridge, Massac Dynamic Logic David Harel, The Weizmann Institute Dexter Kozen, Cornell University Jerzy Tiuryn, University of Warsaw The MIT Press, Cambridge, Massachusetts, 2000 Among the many approaches to formal reasoning

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler

More information

Boolean expressions. Elements of Programming Languages. Conditionals. What use is this?

Boolean expressions. Elements of Programming Languages. Conditionals. What use is this? Boolean expressions Elements of Programming Languages Lecture 3: Booleans, conditionals, and types James Cheney So far we ve considered only a trivial arithmetic language L Arith Let s extend L Arith with

More information

Reasoning About Programs Panagiotis Manolios

Reasoning About Programs Panagiotis Manolios Reasoning About Programs Panagiotis Manolios Northeastern University March 22, 2012 Version: 58 Copyright c 2012 by Panagiotis Manolios All rights reserved. We hereby grant permission for this publication

More information

Programming Languages Fall 2014

Programming Languages Fall 2014 Programming Languages Fall 2014 Lecture 7: Simple Types and Simply-Typed Lambda Calculus Prof. Liang Huang huang@qc.cs.cuny.edu 1 Types stuck terms? how to fix it? 2 Plan First I For today, we ll go back

More information

Formalizing Dijkstra

Formalizing Dijkstra Formalizing Dijkstra 1 Formalizing Dijkstra John Harrison Intel Corporation A Discipline of Programming Mechanizing programming logics Relational semantics Weakest preconditions Guarded commands Theorems

More information

Comp 411 Principles of Programming Languages Lecture 7 Meta-interpreters. Corky Cartwright January 26, 2018

Comp 411 Principles of Programming Languages Lecture 7 Meta-interpreters. Corky Cartwright January 26, 2018 Comp 411 Principles of Programming Languages Lecture 7 Meta-interpreters Corky Cartwright January 26, 2018 Denotational Semantics The primary alternative to syntactic semantics is denotational semantics.

More information

CS 395T Computational Learning Theory. Scribe: Wei Tang

CS 395T Computational Learning Theory. Scribe: Wei Tang CS 395T Computational Learning Theory Lecture 1: September 5th, 2007 Lecturer: Adam Klivans Scribe: Wei Tang 1.1 Introduction Many tasks from real application domain can be described as a process of learning.

More information

Uncertain Data Models

Uncertain Data Models Uncertain Data Models Christoph Koch EPFL Dan Olteanu University of Oxford SYNOMYMS data models for incomplete information, probabilistic data models, representation systems DEFINITION An uncertain data

More information

CS4215 Programming Language Implementation. Martin Henz

CS4215 Programming Language Implementation. Martin Henz CS4215 Programming Language Implementation Martin Henz Thursday 26 January, 2012 2 Chapter 4 The Language simpl In this chapter, we are exting the language epl in order to provide a more powerful programming

More information

Fundamental Concepts. Chapter 1

Fundamental Concepts. Chapter 1 Chapter 1 Fundamental Concepts This book is about the mathematical foundations of programming, with a special attention on computing with infinite objects. How can mathematics help in programming? There

More information

Alloy: A Lightweight Object Modelling Notation

Alloy: A Lightweight Object Modelling Notation Alloy: A Lightweight Object Modelling Notation Daniel Jackson, ACM Transactions on Software Engineering, 2002 Presented By: Steven Stewart, 2012-January-23 1 Alloy: 2002 to present Software is built on

More information

A Simplied NP-complete MAXSAT Problem. Abstract. It is shown that the MAX2SAT problem is NP-complete even if every variable

A Simplied NP-complete MAXSAT Problem. Abstract. It is shown that the MAX2SAT problem is NP-complete even if every variable A Simplied NP-complete MAXSAT Problem Venkatesh Raman 1, B. Ravikumar 2 and S. Srinivasa Rao 1 1 The Institute of Mathematical Sciences, C. I. T. Campus, Chennai 600 113. India 2 Department of Computer

More information

Formal Methods in Software Engineering. Lecture 07

Formal Methods in Software Engineering. Lecture 07 Formal Methods in Software Engineering Lecture 07 What is Temporal Logic? Objective: We describe temporal aspects of formal methods to model and specify concurrent systems and verify their correctness

More information

SCR*: A Toolset for Specifying and. Analyzing Software Requirements? Constance Heitmeyer, James Kirby, Bruce Labaw and Ramesh Bharadwaj

SCR*: A Toolset for Specifying and. Analyzing Software Requirements? Constance Heitmeyer, James Kirby, Bruce Labaw and Ramesh Bharadwaj SCR*: A Toolset for Specifying and Analyzing Software Requirements? Constance Heitmeyer, James Kirby, Bruce Labaw and Ramesh Bharadwaj Naval Research Laboratory, Code 5546, Washington, DC 20375, USA Abstract.

More information

Introduction to Axiomatic Semantics

Introduction to Axiomatic Semantics Introduction to Axiomatic Semantics Meeting 10, CSCI 5535, Spring 2009 Announcements Homework 3 due tonight Homework 2 is graded 13 (mean), 14 (median), out of 21 total, but Graduate class: final project

More information

with an interpretation of the function and relation symbols occurring in. A valuation is a mapping : Var! D from the given innite set of variables Var

with an interpretation of the function and relation symbols occurring in. A valuation is a mapping : Var! D from the given innite set of variables Var Liveness and Safety in Concurrent Constraint rograms Andreas odelski Max-lanck-Institut fur Informatik Im Stadtwald, D-66123 Saarbrucken podelski@mpi-sb.mpg.de 1 Temporal operators In this section we recall

More information

size, runs an existing induction algorithm on the rst subset to obtain a rst set of rules, and then processes each of the remaining data subsets at a

size, runs an existing induction algorithm on the rst subset to obtain a rst set of rules, and then processes each of the remaining data subsets at a Multi-Layer Incremental Induction Xindong Wu and William H.W. Lo School of Computer Science and Software Ebgineering Monash University 900 Dandenong Road Melbourne, VIC 3145, Australia Email: xindong@computer.org

More information

Outline. What is semantics? Denotational semantics. Semantics of naming. What is semantics? 2 / 21

Outline. What is semantics? Denotational semantics. Semantics of naming. What is semantics? 2 / 21 Semantics 1 / 21 Outline What is semantics? Denotational semantics Semantics of naming What is semantics? 2 / 21 What is the meaning of a program? Recall: aspects of a language syntax: the structure of

More information

Concepts of programming languages

Concepts of programming languages Concepts of programming languages Lecture 5 Wouter Swierstra 1 Announcements Submit your project proposal to me by email on Friday; The presentation schedule in now online Exercise session after the lecture.

More information

SORT INFERENCE \coregular" signatures, they derive an algorithm for computing a most general typing for expressions e which is only slightly more comp

SORT INFERENCE \coregular signatures, they derive an algorithm for computing a most general typing for expressions e which is only slightly more comp Haskell Overloading is DEXPTIME{complete Helmut Seidl Fachbereich Informatik Universitat des Saarlandes Postfach 151150 D{66041 Saarbrucken Germany seidl@cs.uni-sb.de Febr., 1994 Keywords: Haskell type

More information

CS52 - Assignment 8. Due Friday 4/15 at 5:00pm.

CS52 - Assignment 8. Due Friday 4/15 at 5:00pm. CS52 - Assignment 8 Due Friday 4/15 at 5:00pm https://xkcd.com/859/ This assignment is about scanning, parsing, and evaluating. It is a sneak peak into how programming languages are designed, compiled,

More information

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions): CS 70 Discrete Mathematics for CS Spring 2005 Clancy/Wagner Notes 7 This lecture returns to the topic of propositional logic. Whereas in Lecture Notes 1 we studied this topic as a way of understanding

More information

Proving the Correctness of Distributed Algorithms using TLA

Proving the Correctness of Distributed Algorithms using TLA Proving the Correctness of Distributed Algorithms using TLA Khushboo Kanjani, khush@cs.tamu.edu, Texas A & M University 11 May 2007 Abstract This work is a summary of the Temporal Logic of Actions(TLA)

More information

Semantics of programming languages

Semantics of programming languages Semantics of programming languages Informatics 2A: Lecture 28 Mary Cryan School of Informatics University of Edinburgh mcryan@inf.ed.ac.uk 21 November 2018 1 / 18 Two parallel pipelines A large proportion

More information

Programming Embedded Systems

Programming Embedded Systems Programming Embedded Systems Lecture 10 An introduction to Lustre Wednesday Feb 15, 2012 Philipp Rümmer Uppsala University Philipp.Ruemmer@it.uu.se 1/34 Course topic: programming lang. Which language to

More information

1.3. Conditional expressions To express case distinctions like

1.3. Conditional expressions To express case distinctions like Introduction Much of the theory developed in the underlying course Logic II can be implemented in a proof assistant. In the present setting this is interesting, since we can then machine extract from a

More information

Computability and Complexity

Computability and Complexity Computability and Complexity Turing Machines CAS 705 Ryszard Janicki Department of Computing and Software McMaster University Hamilton, Ontario, Canada janicki@mcmaster.ca Ryszard Janicki Computability

More information

Proving Properties on Programs From the Coq Tutorial at ITP 2015

Proving Properties on Programs From the Coq Tutorial at ITP 2015 Proving Properties on Programs From the Coq Tutorial at ITP 2015 Reynald Affeldt August 29, 2015 Hoare logic is a proof system to verify imperative programs. It consists of a language of Hoare triples

More information

INF672 Protocol Safety and Verification. Karthik Bhargavan Xavier Rival Thomas Clausen

INF672 Protocol Safety and Verification. Karthik Bhargavan Xavier Rival Thomas Clausen INF672 Protocol Safety and Verication Karthik Bhargavan Xavier Rival Thomas Clausen 1 Course Outline Lecture 1 [Today, Sep 15] Introduction, Motivating Examples Lectures 2-4 [Sep 22,29, Oct 6] Network

More information

Lecture Notes on Contracts

Lecture Notes on Contracts Lecture Notes on Contracts 15-122: Principles of Imperative Computation Frank Pfenning Lecture 2 August 30, 2012 1 Introduction For an overview the course goals and the mechanics and schedule of the course,

More information