CSC313 High Integrity Systems/CSCM13 Critical Systems. CSC313/CSCM13 Chapter 2 1/ 221

Size: px
Start display at page:

Download "CSC313 High Integrity Systems/CSCM13 Critical Systems. CSC313/CSCM13 Chapter 2 1/ 221"

Transcription

1 CSC313 High Integrity Systems/CSCM13 Critical Systems CSC313/CSCM13 Chapter 2 1/ 221

2 CSC313 High Integrity Systems/ CSCM13 Critical Systems Course Notes Chapter 2: SPARK Ada Sect. 2 (f) Anton Setzer Dept. of Computer Science, Swansea University csetzer/lectures/ critsys/current/index.html October 30, 2017 CSC313/CSCM13 Chapter 2 2/ 221

3 2 (a) Introduction into Ada 2 (b) Architecture of SPARK Ada 2 (c) Language Restrictions in SPARK Ada 2 (d) Data Flow Analysis 2 (e) Information Flow Analysis 2 (g) Verification Cond. (Range, Loops, Procedures, Functions) 2 (h) Example: A railway interlocking system CSC313/CSCM13 Chapter 2 3/ 221

4 2 (a) Introduction into Ada 2 (b) Architecture of SPARK Ada 2 (c) Language Restrictions in SPARK Ada 2 (d) Data Flow Analysis 2 (e) Information Flow Analysis 2 (g) Verification Cond. (Range, Loops, Procedures, Functions) 2 (h) Example: A railway interlocking system CSC313/CSCM13 Sect. 2 (f) 142/ 221

5 Pre- and Post-Conditions Two kinds of annotations are relevant: Pre-conditions, e.g.: with Pre => M >= 0 and N < 0; Expressing: at the beginning variable M is 0 and variable N is < 0. Post-conditions, e.g.: with Post => M = M Old + 1; Expressing: after having executed the procedure the value of M is the same as the value of M when beginning the procedure (denoted by M Old, incremented by 1. Then examiner generates formulae which express: If the pre-conditions hold, and the procedure is executed, afterwards the post-condition holds. If there are no pre-conditions, then the formula expresses that the post-condition holds always. (sect2f/example2f-1/) CSC313/CSCM13 Sect. 2 (f) 143/ 221

6 Notation in pre-2014 SPARK Ada -- #pre M >= 0 and N < 0; -- #post M = M +1; Here M is the pre-2014 SPARK Ada notation for X Old. CSC313/CSCM13 Sect. 2 (f) 144/ 221

7 Hoare Logic The basic formal system which takes pre- and post-conditions in an imperative program and derives generated verification conditions, is called Hoare Logic Named after Sir Tony Hoare (Professor emeritus from Oxford and Microsoft Research, Cambridge), Computer Scientist. Winner of the Turing Award Knighted by the Queen for his achievements in Computer Science. CSC313/CSCM13 Sect. 2 (f) 145/ 221

8 Tony Hoare with his Wife Jill (After having been knighted by the Queen.) CSC313/CSCM13 Sect. 2 (f) 146/ 221

9 Quotation Tony Hoare The most important property of a program is whether it accomplishes the intention of its user. CSC313/CSCM13 Sect. 2 (f) 147/ 221

10 Verification Conditions In post-conditions, X Old stands for the value of X before executing the procedure, X stands for the value after executing it, e.g. X=X Old+1; expresses: The value of X after executing the procedure is the value of X before executing it + 1. X Old can occur only in post-conditions (especially not in assert statements introduced later); seems to be due to a restriction of Ada. CSC313/CSCM13 Sect. 2 (f) 148/ 221

11 Verification Conditions On the white board I will sometimes write for brevity X instead of X Old. For instance we write X = X + 1 instead of X = X Old + 1 CSC313/CSCM13 Sect. 2 (f) 149/ 221

12 Connectives in Verification Conditions Formulae are built using: Boolean valued expressions E.g. N = M, N < M or F(N), if F(N) of type Boolean, Boolean connectives and, or, not, xor, if condition then conclusion which stands for condition conclusion if condition then ifcondition else elsecondition which stands for (condition ifcondition) ( (condition) elsecondition) quantifiers for all => for some => Remark: If in the pre-condition there are occurrences of quantifiers, the whole pre-condition is at the moment ignored. In the post-condition they are treated correctly. CSC313/CSCM13 Sect. 2 (f) 150/ 221

13 Example (Verification Conditions) Example (not very meaningful): with => Pre => ((M >= 0 xor N < 0) or (if not (N > 0) then M > 0) and (if N > 0 then M > 0 else M < 0)), Post => ((for all X in => g(x,m )) or (for some X in Integer => X = M Old + 1)); (sect2f/example2f-2/, example2f-3/, example2f-3b/) CSC313/CSCM13 Sect. 2 (f) 151/ 221

14 Remark on X Old X Old should only be used if X is an input-output parameter (locally or globally) If it is an input parameter only, then it cannot be changed, so X and X Old are always the same. In that case SPARK Ada issues a warning. If it is an output parameter only, then it has no initial value, so X Old is in fact undefined. In that case SPARK Ada doesn t (yet?) issue a warning. An output parameter of a procedure cannot occur in the pre-condition, because its initial value is undefined. (sect2f/example2f-5/) CSC313/CSCM13 Sect. 2 (f) 152/ 221

15 Example 1 (Verification Conditions) Assume the following wrong program: procedure Wrong Increment(X : in out Integer) with Depends => (X => X), Pre => X >= 0, Post => X = X Old + 1 and X >= 1; procedure body Wrong Increment(X : in out Integer) is begin X := X + X; end Wrong Increment; The mistake in this program is that the body should read X:= X + 1; instead of X := X + X;. The post-condition is not fulfilled in general. (sect2f/example2f-6/) CSC313/CSCM13 Sect. 2 (f) 153/ 221

16 Example (Cont.) procedure Wrong Increment(X : in out Integer) with Depends => (X => X), Pre => X >= 0, Post => X = X Old + 1 and X >= 1; procedure body Wrong Increment(X : in out Integer) is begin X := X + X; end Wrong Increment; When going through the program we see that at the end X = X Old + X Old Therefore, replacing X by X Old + X Old the post-condition reads: X Old + X Old = X Old + 1 X Old +X Old 1 CSC313/CSCM13 Sect. 2 (f) 154/ 221

17 Example 1 (Verification Conditions) procedure Wrong Increment(X : in out Integer) with Depends => (X => X), Pre => X >= 0, Post => X = X Old + 1 and X >= 1; procedure body Wrong Increment(X : in out Integer) is begin X := X + X; end Wrong Increment; That the pre-condition implies the post-condition therefore reads X Old 0 X Old + X Old = X Old + 1 X Old Here binds more than therefore the formula is the same as X Old 0 (X Old + X Old = X Old + 1 X Old + X Old 1) We call the above the from the pre- and post-conditions. generated verification condition derived CSC313/CSCM13 Sect. 2 (f) 155/ 221

18 Example (Verification Conditions) We use in this module usually verification conditions for the conditions you write in the code, and generated verification conditions for the ones derived by using Hoare Logic. Since in mathematics one usually writes lower case characters we replace X by x. Since there are only occurrences of x Old, we replace them by x. We obtain x 0 x + x = x + 1 x + x 1 This above formulae has to be treated as being implicitly universally quantified, and stands for x.(x 0 x + x = x + 1 x + x 1) CSC313/CSCM13 Sect. 2 (f) 156/ 221

19 Example (Verification Conditions) x.(x 0 x + x = x + 1 x + x 1) This corresponds to what the correctness of the function means: For all inputs x, we have that, if x fulfils the pre-condition, then after executing the program it fulfils the post-condition. That the above formula does not hold can be shown by giving a counter example: Take x := 0. Then x 0 holds, but not x + x = x + 1. The program is incorrect, since the generated verification conditions don t hold (universally). In order for the program to be correct it needs to be correct for all arguments. Note that for x = 1 the formula is true, but the program is still incorrect. CSC313/CSCM13 Sect. 2 (f) 157/ 221

20 Why3 Platform SPARK Ada uses the Why3 system (without the user interface), which is free software developed by the French research organisation INRIA. Why3 is a tool which converts imperative code from the intermediate languages mlw and code from the language why3 into generated verification conditions which are then fed into various automated theorem provers Alt-ergo, CVC3, CVC4, and Z3. interactive theorem provers Coq and Isabelle. CSC313/CSCM13 Sect. 2 (f) 158/ 221

21 Architecture of Why3 Platform (Source: CSC313/CSCM13 Sect. 2 (f) 159/ 221

22 Why3 Platform SPARK Ada uses the why3 system to generate verification conditions and feed them into the automated theorem prover alt-ergo. It then reports whether they have been proven or not proven. One can feed the conditions as well into other automated theorem provers and interactive theorem provers such as Coq. In order to display the generated verification conditions, it is useful to install why3 separately and run why3 on the.mlw files generated by SPARK Ada. CSC313/CSCM13 Sect. 2 (f) 160/ 221

23 Result of Applying Why3 to.mlw Files CSC313/CSCM13 Sect. 2 (f) 161/ 221

24 Current Problems with Why3 The version used in the Linux Lab currently displays error messages as on the following screen These error messages are due to the fact that the spark ada version refers to a different version of why3 then the why3 ide we are using. You can ignore error messages of the form. File..., line..., characters...: axiom... does not contain any local abstract symbol The SPARK Ada documentation doesn t mention the why3 system they use why3 without the GUI, but don t intend the verification conditions to be viewed uwing the why3 with GUI. CSC313/CSCM13 Sect. 2 (f) 162/ 221

25 Error Messages of Why3 CSC313/CSCM13 Sect. 2 (f) 163/ 221

26 Main Generated Verification Conditions in Why3 (with Range Check) CSC313/CSCM13 Sect. 2 (f) 164/ 221

27 Interpreting the Output of Why3 Machine integers have a limited amount of bytes. Therefore the integers cannot be arbitrarily big and and small. There exists a maximum and minimum machine integer. SPARK Ada adds conditions guaranteeing that the integers are between the minimum and maximum integer. It has a relation in_range1 o expressing that o is between the minimum and maximum integer. There occurs as well a relation dynamic_property1 first1 last1 x which is automatically generated, but is equal to in_range1 x CSC313/CSCM13 Sect. 2 (f) 165/ 221

28 Interpreting the Output of Why3 The above is sufficient for understanding the output of why3 if one uses progressively split for generating verification conditions (recommended). Otherwise one will see when using wh3 as well a data type integer which are machine integers and therefore bounded, a data type int which are unbounded mathematical integers, and an operation to_int : integer int CSC313/CSCM13 Sect. 2 (f) 166/ 221

29 Significance of Range Checks For a program SPARK Ada generates verification conditions which check that in each step of the program all integers stay in the range of machine integers. Note that it is necessary to have these range checks, because otherwise we could indeed get overflow errors. If x is a very large integer, x + x might actually be out of range and result in an overflow error at run time. CSC313/CSCM13 Sect. 2 (f) 167/ 221

30 Turning Off Check for Range Conditions When learning SPARK Ada, it is good to initially ignore the range conditions. We have provided a file mainwithoutrangecheck.gpr which is an alternative to the main.gpr file. When using this file range checks will be switched off The main change is that the switch in main.gpr for Default_Switches ( ada ) use ( -gnatwa ); have been replaced by for Default_Switches ( ada ) use ( -gnato33 ); CSC313/CSCM13 Sect. 2 (f) 168/ 221

31 Simplified Generated Verification Conditions In this section we will discuss the verification condition excluding the range conditions. We will show however as as well the verification conditions including the range conditions. In the next subsection I will discuss how one can enhance the pre-, post- and other conditions so that SPARK Ada proves that the integers stay within the range of machine integers. CSC313/CSCM13 Sect. 2 (f) 169/ 221

32 Main Verification Conditions in Why3 Without Range Check CSC313/CSCM13 Sect. 2 (f) 170/ 221

33 Simplified Generated Verification Conditions Using a format used in pre-2014 Spark Ada we can write the generated verification condition (excluding range check) as follows: H1 : x 0. H2 : x1 = x + x. C1 : x1 = x + 1. C2 : x1 1. In the above (a format used in pre-2014 SPARK Ada) H1, H2,... are hypotheses, C1, C2,... are conclusions and the above formula stands for x 0 x1 = x + x x1 = x + 1 x1 1 CSC313/CSCM13 Sect. 2 (f) 171/ 221

34 Simplified Generated Verification Conditions We choose the above since usually generated verification conditions will have the form H1 H2 Hn C1 C2 Cm CSC313/CSCM13 Sect. 2 (f) 172/ 221

35 Simplified Generated Verification Conditions H1 : x 0. H2 : x1 = x + x. C1 : x1 = x + 1. C2 : x1 1. We simplify this to H1 : x 0. C1 : x + x =x + 1. C2 : x + x 1 which is the formula we obtained before: x 0 x + x = x + 1 x + x 1 CSC313/CSCM13 Sect. 2 (f) 173/ 221

36 Main Generated Verification Conditions in Why3 with Range Check CSC313/CSCM13 Sect. 2 (f) 174/ 221

37 Additional Generated Verification Conditions for Range Checks CSC313/CSCM13 Sect. 2 (f) 175/ 221

38 Additional Generated Verification Conditions for Range Checks CSC313/CSCM13 Sect. 2 (f) 176/ 221

39 Example 2 (Verification Conditions) Assume the correct program: procedure Correct Increment(X : in out Integer) with Depends => (X => X), Pre => X >= 0, Post => X = X Old + 1 and X >= 1; procedure body Correct Increment(X : in out Integer) is begin X := X + 1; end Correct Increment; (sect2f/example2f-7/) CSC313/CSCM13 Sect. 2 (f) 177/ 221

40 Example 2 (Cont.) procedure Correct Increment(X : in out Integer) with Depends => (X => X), Pre => X >= 0, Post => X = X Old + 1 and X >= 1; procedure body Correct Increment(X : in out Integer) is begin X := X + 1; end Correct Increment; When going through the program, we see that at the end X = X Old + 1. Therefore the post-condition reads X Old + 1 = X Old + 1 X Old CSC313/CSCM13 Sect. 2 (f) 178/ 221

41 Example 2 (Cont.) procedure Correct Increment(X : in out Integer) with Depends => (X => X), Pre => X >= 0, Post => X = X Old + 1 and X >= 1; procedure body Correct Increment(X : in out Integer) is begin X := X + 1; end Correct Increment; The complete generated verification condition is therefore X Old 0 X Old + 1 = X Old + 1 X Old which is then written as x 0 x + 1 = x + 1 x CSC313/CSCM13 Sect. 2 (f) 179/ 221

42 Output of Why3 Applied to Output from Spark Ada (Without Range Check) CSC313/CSCM13 Sect. 2 (f) 180/ 221

43 Example 2 (Cont.) This reads in the pre-spark 2014 syntax as follows: H1 : x 0 H2 : x1 = x + 1 C1 : x1 = x + 1 C2 : x1 1 The last condition can be simplified to H1 : x 0 C1 : x+1 = x + 1 C2 : x+1 1 CSC313/CSCM13 Sect. 2 (f) 181/ 221

44 Example 2 (Cont.) H1 : x 0 C1 : x+1 = x + 1 C2 : x+1 1 This condition is the same as what we obtained by hand: x 0 x + 1 = x + 1 x This condition would be provable. The range conditions regarding machine integers are not provable, as reported by SPARK Ada. CSC313/CSCM13 Sect. 2 (f) 182/ 221

45 Main Output of Why3 With Range Conditions CSC313/CSCM13 Sect. 2 (f) 183/ 221

46 Additional Range conditions CSC313/CSCM13 Sect. 2 (f) 184/ 221

47 Additional Range conditions CSC313/CSCM13 Sect. 2 (f) 185/ 221

48 Assert And Cut Condition One can insert in between the procedures an assert_and_cut condition. Now the formulae express: From the pre-condition follows at that position the assert_and_cut-condition. From the assert_and_cut-condition at that position follows the post-condition. Assert_and_cut conditions serve therefore as intermediate proof-goals. CSC313/CSCM13 Sect. 2 (f) 186/ 221

49 SPARK Ada Syntax for Assert And Cut The pre-2014 syntax was -- # assert X = 1; The new syntax is pragma Assert_And_Cut (X = 1); CSC313/CSCM13 Sect. 2 (f) 187/ 221

50 Several Assert And Cut Conditions One can have as well several assert_and_cut-conditions. If one has 2 assert_and_cut-conditions for instance the conditions express From the pre-condition follows the first assert_and_cut-condition (at its place). From the the first assert_and_cut-condition follows the second assert_and_cut-condition (at its place) From the the second assert_and_cut-condition follows the post-condition. CSC313/CSCM13 Sect. 2 (f) 188/ 221

51 Example Assert And Cut Condition Consider the program: procedure Ex Assert And Cut(X : in out Integer) with Depends => (X => X), Pre => X = 0, Post => X = 3; procedure Ex Assert And Cut(X : in out Integer) is begin X := X + 1; pragma Assert_And_Cut (X = 1); X := X + 1; pragma Assert_And_Cut (X = 2); X := X + 1; end Ex Assert Cut; (sect2f/example2f-9/) CSC313/CSCM13 Sect. 2 (f) 189/ 221

52 Example Assert And Cut Condition The implication from the pre-condition to the first assert_and_cut condition is: X Old = 0 X Old+1 = 1. That the first assert_and_cut condition implies the second assert_and_cut condition is the following: X = 1 X+1 = 2; That the second assert_and_cut condition implies the post-condition is the following: X = 2 X+1 = 3; CSC313/CSCM13 Sect. 2 (f) 190/ 221

53 Why3 Precondition implies Assert And Cut 1 (Without Range Check) CSC313/CSCM13 Sect. 2 (f) 191/ 221

54 Example 2 (Cont.) Pre condition implies first assert_and_cut-condition H1 : x = 0 H2 : x1 = x + 1 C1 : x1 = 1 This can be simplified to H1 : x = 0 C1 : x+1 = 1 CSC313/CSCM13 Sect. 2 (f) 192/ 221

55 Why3 Assert And Cut1 to Assert And Cut2 (Without Range Check) CSC313/CSCM13 Sect. 2 (f) 193/ 221

56 Example 2 (Cont.) First assert_and_cut-condition implies second assert_and_cut-condition H1 : x = 0 H2 : x1 = 1 H3 : x2 = x1 + 1 C1 : x2 = 2 This can be simplified to (omitting superfluous x) H1 : x1 = 1 C1 : x1 +1 = 2 CSC313/CSCM13 Sect. 2 (f) 194/ 221

57 Additional Use of Pre-Condition Note that the pre-condition was added here (and later) as an axiom. Therefore it can be used for proving all statements including from first Assert_And_Cut statement follows second Assert_And_Cut statement, from last Assert_And_Cut statement follows post-condition. It looks as if this is there to keep compatibilty with previous versions of SPARK Ada. CSC313/CSCM13 Sect. 2 (f) 195/ 221

58 Why3 Assert And Cut3 to Post Condition CSC313/CSCM13 Sect. 2 (f) 196/ 221

59 Example 2 (Cont.) Second assert_and_cut-condition implies post-condition H1 : x = 0 H2 : x1 = 2 H3 : x2 = x1 + 1 C1 : x2 = 3 This can be simplified to (omitting superfluous x) H1 : x1 = 2 C1 : x1 +1 = 3 CSC313/CSCM13 Sect. 2 (f) 197/ 221

60 Why3 Precondition implies Assert And Cut 1 (With Range Check) CSC313/CSCM13 Sect. 2 (f) 198/ 221

61 Why3 Assert And Cut1 to Assert And Cut2 (With Range Check) CSC313/CSCM13 Sect. 2 (f) 199/ 221

62 Why3 Assert And Cut3 to Post Condition (With Range Check) CSC313/CSCM13 Sect. 2 (f) 200/ 221

63 Why3 Range Condition 1 CSC313/CSCM13 Sect. 2 (f) 201/ 221

64 Why3 Range Condition 2 CSC313/CSCM13 Sect. 2 (f) 202/ 221

65 Why3 Range Condition 3 CSC313/CSCM13 Sect. 2 (f) 203/ 221

66 Assert Condition vs Assert And Cut There is as well an assert directive. The difference is: If one has an assert_and_cut directive, then previous verification conditions are not included in the next step. If one has an assert directive, then previous verification conditions are included. So if one has two assert conditions then the generated verification condition are From the pre-condition follows the first assert-condition (at its place). From the pre-condition and the first assert-condition (at its place) follows the second assert-condition (at its place) From the pre-condition and the first assert-condition (at its place) and the second assert-condition (at its place) follows the post-condition. CSC313/CSCM13 Sect. 2 (f) 204/ 221

67 Assert vs Assert And Cut If one has assert conditions instead, then the first condition is as before, but the second and third are From the pre-condition follows the first assert-condition (at its place). From the first assert-condition (at its place) follows the second assert-condition (at its place) From the second assert-condition (at its place) follows the post-condition. CSC313/CSCM13 Sect. 2 (f) 205/ 221

68 SPARK Ada Syntax for Assert The pre-2014 syntax was --# check X = 1; The new syntax is pragma Assert (X = 1); CSC313/CSCM13 Sect. 2 (f) 206/ 221

69 Example Assert Condition Consider the program: procedure One Assert(X : in out Integer) with Depends => (X => X), Pre => X = 0, Post => X = 2; procedure body One Assert(X : in out Integer) is begin X := X + 1; pragma Assert (X = 1); X := X + 1; end One Assert; That the pre-condition implies the assert condition is the following generated verification condition: X Old = 0 X Old+1 = 1; (sect2f/example2f-8/) CSC313/CSCM13 Sect. 2 (f) 207/ 221

70 Example Assert Condition Consider the program: procedure One Assert(X : in out Integer) with Depends => (X => X), Pre => X = 0, Post => X = 2; procedure body One Assert(X : in out Integer) is begin X := X + 1; pragma Assert (X = 1); X := X + 1; end One Assert; That the pre- and the assert-condition implies the post-condition is the following generated verification condition: X Old = 0 X Old+1 = 1 (X Old+1) + 1 = 2; CSC313/CSCM13 Sect. 2 (f) 208/ 221

71 Why3 - Pre Condition implies Assert Condition (Without Range Check) CSC313/CSCM13 Sect. 2 (f) 209/ 221

72 Generated Verification Conditions Pre condition implies assert-condition (range conditions omitted, as well int the following): H1 : x = 0 H2 : x1 = x + 1 C1 : x1 = 1 which is just or simplified: H1 : x = 0 C1 : x+1 = 1 x = 0 x + 1 = 1 CSC313/CSCM13 Sect. 2 (f) 210/ 221

73 Why3 - Pre Condition + Assert implies Post Condition CSC313/CSCM13 Sect. 2 (f) 211/ 221

74 Generated Verification Conditions Condition that pre- condition and assert condition imply post-condition reads H1 : x = 0 H2 : x1 = x + 1 H3 : x1 = 1 H4 : x2 = x1 + 1 C1 : x2 = 2 or simplified: H1 : x = 0 H2 : x+1= 1 C1 : (x+1)+1 = 2 which is just x = 0 x + 1 = 1 (x + 1) + 1 = 2 CSC313/CSCM13 Sect. 2 (f) 212/ 221

75 Why3 - Pre Condition implies Assert Condition (With Range Check) CSC313/CSCM13 Sect. 2 (f) 213/ 221

76 Why3 - Pre Condition + Assert implies Post Condition (With Range Check) CSC313/CSCM13 Sect. 2 (f) 214/ 221

77 Why3 - Range Condition 1 CSC313/CSCM13 Sect. 2 (f) 215/ 221

78 Why3 - Range Condition 2 CSC313/CSCM13 Sect. 2 (f) 216/ 221

79 Assert in Other Languages Many many languages (e.g. C++, Java) have an assert directive. The condition is then usually checked at run time, e.g. in C++ #include <assert.h> assert (myint!=null); Checking of this condition can be disabled using #define NDEBUG In the Boost library for C++ there is as well a static assert. It allows to check at compile time whether certain values which are determined by the template mechanism have certain values: BOOST STATIC ASSERT(std::numeric limits<int>::digits >= 32); This doesn t allow to check values of the program which are obtained after the execution of some code. CSC313/CSCM13 Sect. 2 (f) 217/ 221

80 Assert, Pre- and Post Conditions in Standard Ada In Ada 2005 assert was introduced to be used similarly to other languages: depending on pragmas (Assert, Assertion_Policy), the assert statement is checked with messages being printed out, or it is ignored. Therefore they were meant to be decidable conditions. That explains why X Old is not allowed in assert statements, since it would require the compiler to keep track of the original value of X. In Ada 2012 pre- and post-conditions were added, which can be treated similarly. In Ada 2012 the intention for pre- and post-conditions and assert pragmas was that they can be be used as well for verification tools, such as in SPARK Ada. CSC313/CSCM13 Sect. 2 (f) 218/ 221

81 Work Around for X Old not allowed in Assert statements X Old is not allowed in the pragmas Assert and Assert_And_Cut. The way around this is to use an auxiliary constant which contains a copy of X Old: Example: procedure Test(X : in out Integer) with Depends => (X => X), Post => (X = X Old + 2); procedure body Test(X : in out Integer) is Xold : constant Integer := X; begin X := X + 1; pragma Assert_And_Cut (X = Xold + 1); X := X + 1; end Test CSC313/CSCM13 Sect. 2 (f) 219/ 221

82 Work Around for X Old not allowed in Assert statements The above example was (example2f-11/) This is legal in SPARK Ada, although Xold is not used in the Ada code, since it occurs in the assert statement. It works because one of the axioms added by SPARK Ada is that Xold = X Old, which can be used in proving the two verification conditions. This is formulated as an axiom, which can be used in all verification conditions. CSC313/CSCM13 Sect. 2 (f) 220/ 221

83 2 (h) Example: A railway interlocking system Sections 2 (g) - (h) will be distributed later CSC313/CSCM13 Sect. 2 (h) 221/ 221

Remark CSC313 High Integrity Systems/ CSCM13 Critical Systems

Remark CSC313 High Integrity Systems/ CSCM13 Critical Systems Remark CSC313 High Integrity Systems/ CSCM13 Critical Systems Course Notes Chapter 2: SPARK Ada Anton Setzer Dept. of Computer Science, Swansea University Sections 2 (a) - (g) will be highly based on John

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

CS 313 High Integrity Systems/ CS M13 Critical Systems

CS 313 High Integrity Systems/ CS M13 Critical Systems CS 313 High Integrity Systems/ CS M13 Critical Systems Course Notes Chapter 2: SPARK Ada Anton Setzer Dept. of Computer Science, Swansea University http://www.cs.swan.ac.uk/ csetzer/lectures/ critsys/10/index.html

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

CSC313 High Integrity Systems/CSCM13 Critical Systems. CSC313/CSCM13 Chapter 1 1/ 38

CSC313 High Integrity Systems/CSCM13 Critical Systems. CSC313/CSCM13 Chapter 1 1/ 38 CSC313 High Integrity Systems/CSCM13 Critical Systems CSC313/CSCM13 Chapter 1 1/ 38 CSC313 High Integrity Systems/ CSCM13 Critical Systems Course Notes Chapter 1: Programming Languages for Writing Safety-Critical

More information

Verification Condition Generation

Verification Condition Generation Verification Condition Generation Jorge Sousa Pinto Departamento de Informática / Universidade do Minho jsp@di.uminho.pt www.di.uminho.pt/~jsp Outline (1) - From Hoare Logic to VCGen algorithms: an architecture

More information

Lecture 5 - Axiomatic semantics

Lecture 5 - Axiomatic semantics Program Verification March 2014 Lecture 5 - Axiomatic semantics Lecturer: Noam Rinetzky Scribes by: Nir Hemed 1.1 Axiomatic semantics The development of the theory is contributed to Robert Floyd, C.A.R

More information

Introduction to Axiomatic Semantics (1/2)

Introduction to Axiomatic Semantics (1/2) #1 Introduction to Axiomatic Semantics (1/2) How s The Homework Going? Remember that you can t just define a meaning function in terms of itself you must use some fixed point machinery. #2 #3 Observations

More information

Introduction to Axiomatic Semantics (1/2)

Introduction to Axiomatic Semantics (1/2) #1 Introduction to Axiomatic Semantics (1/2) How s The Homework Going? Remember: just do the counterexample guided abstraction refinement part of DPLL(T). If you notice any other errors, those are good

More information

Why. an intermediate language for deductive program verification

Why. an intermediate language for deductive program verification Why an intermediate language for deductive program verification Jean-Christophe Filliâtre CNRS Orsay, France AFM workshop Grenoble, June 27, 2009 Jean-Christophe Filliâtre Why tutorial AFM 09 1 / 56 Motivations

More information

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 19 Tuesday, April 3, 2018 1 Introduction to axiomatic semantics The idea in axiomatic semantics is to give specifications

More information

An Annotated Language

An Annotated Language Hoare Logic An Annotated Language State and Semantics Expressions are interpreted as functions from states to the corresponding domain of interpretation Operators have the obvious interpretation Free of

More information

Spark verification features

Spark verification features Spark verification features Paul Jackson School of Informatics University of Edinburgh Formal Verification Spring 2018 Adding specification information to programs Verification concerns checking whether

More information

CMSC 330: Organization of Programming Languages. Operational Semantics

CMSC 330: Organization of Programming Languages. Operational Semantics CMSC 330: Organization of Programming Languages Operational Semantics Notes about Project 4, Parts 1 & 2 Still due today (7/2) Will not be graded until 7/11 (along with Part 3) You are strongly encouraged

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

When Brunel s ship the SS Great Britain was launched into the River Thames, it made such a splash that several spectators on the opposite bank were

When Brunel s ship the SS Great Britain was launched into the River Thames, it made such a splash that several spectators on the opposite bank were C. A. R. Hoare Emeritus Professor of Computing at the University of Oxford and is now a senior researcher at Microsoft Research in Cambridge, England. He received the 1980 ACM Turing Award for his fundamental

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

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

Lecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning

Lecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning Lecture 1 Contracts 15-122: Principles of Imperative Computation (Fall 2018) Frank Pfenning In these notes we review contracts, which we use to collectively denote function contracts, loop invariants,

More information

18-642: Code Style for Compilers

18-642: Code Style for Compilers 18-642: Code Style for Compilers 9/6/2018 2017-2018 Philip Koopman Programming can be fun, so can cryptography; however they should not be combined. Kreitzberg and Shneiderman 2017-2018 Philip Koopman

More information

Hardware versus software

Hardware versus software Logic 1 Hardware versus software 2 In hardware such as chip design or architecture, designs are usually proven to be correct using proof tools In software, a program is very rarely proved correct Why?

More information

In Our Last Exciting Episode

In Our Last Exciting Episode In Our Last Exciting Episode #1 Lessons From Model Checking To find bugs, we need specifications What are some good specifications? To convert a program into a model, we need predicates/invariants and

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 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning Lecture 1 Contracts 15-122: Principles of Imperative Computation (Spring 2018) Frank Pfenning In these notes we review contracts, which we use to collectively denote function contracts, loop invariants,

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

Rethinking Automated Theorem Provers?

Rethinking Automated Theorem Provers? Rethinking Automated Theorem Provers? David J. Pearce School of Engineering and Computer Science Victoria University of Wellington @WhileyDave http://whiley.org http://github.com/whiley Background Verification:

More information

Programming with Dependent Types Interactive programs and Coalgebras

Programming with Dependent Types Interactive programs and Coalgebras Programming with Dependent Types Interactive programs and Coalgebras Anton Setzer Swansea University, Swansea, UK 14 August 2012 1/ 50 A Brief Introduction into ML Type Theory Interactive Programs in Dependent

More information

Lectures 20, 21: Axiomatic Semantics

Lectures 20, 21: Axiomatic Semantics Lectures 20, 21: Axiomatic Semantics Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Static Analysis Based on slides by George Necula Pratikakis (CSD) Axiomatic Semantics

More information

CIS 890: Safety Critical Systems

CIS 890: Safety Critical Systems CIS 890: Safety Critical Systems Lecture: SPARK -- Analysis Tools Copyright 2007, John Hatcliff. The syllabus and all lectures for this course are copyrighted materials and may not be used in other course

More information

CS 161 Computer Security

CS 161 Computer Security Wagner Spring 2014 CS 161 Computer Security 1/27 Reasoning About Code Often functions make certain assumptions about their arguments, and it is the caller s responsibility to make sure those assumptions

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

Testing, Debugging, and Verification

Testing, Debugging, and Verification Testing, Debugging, and Verification Formal Specification, Part II Srinivas Pinisetty 23 November 2017 Introduction Today: Introduction to Dafny: An imperative language with integrated support for formal

More information

Lecture 10 Design by Contract

Lecture 10 Design by Contract CS 5959 Writing Solid Code Fall 2015 Nov-23 Lecture 10 Design by Contract Zvonimir Rakamarić University of Utah Design by Contract Also called assume-guarantee reasoning Developers annotate software components

More information

Numerical Computations and Formal Methods

Numerical Computations and Formal Methods Program verification Formal arithmetic Decision procedures Proval, Laboratoire de Recherche en Informatique INRIA Saclay IdF, Université Paris Sud, CNRS October 28, 2009 Program verification Formal arithmetic

More information

Chapter 3 (part 3) Describing Syntax and Semantics

Chapter 3 (part 3) Describing Syntax and Semantics Chapter 3 (part 3) Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings

More information

6. Hoare Logic and Weakest Preconditions

6. Hoare Logic and Weakest Preconditions 6. Hoare Logic and Weakest Preconditions Program Verification ETH Zurich, Spring Semester 07 Alexander J. Summers 30 Program Correctness There are many notions of correctness properties for a given program

More information

Static semantics. Lecture 3-6: Semantics. Attribute grammars (2) Attribute grammars. Attribute grammars example. Dynamic semantics

Static semantics. Lecture 3-6: Semantics. Attribute grammars (2) Attribute grammars. Attribute grammars example. Dynamic semantics Lecture 3-6: Semantics Static semantics Attribute grammars Dynamic semantics Denotational semantics: semantic equations Axiomatic semantics: inference rules and correctness proofs Static semantics Semantics

More information

CSC313 High Integrity Systems/CSCM13 Critical Systems. CSC313/CSCM13 Chapter 2 1/ 356

CSC313 High Integrity Systems/CSCM13 Critical Systems. CSC313/CSCM13 Chapter 2 1/ 356 CSC313 High Integrity Systems/CSCM13 Critical Systems CSC313/CSCM13 Chapter 2 1/ 356 CSC313 High Integrity Systems/ CSCM13 Critical Systems Course Notes Chapter 2: SPARK Ada Anton Setzer Dept. of Computer

More information

Deductive Verification in Frama-C and SPARK2014: Past, Present and Future

Deductive Verification in Frama-C and SPARK2014: Past, Present and Future Deductive Verification in Frama-C and SPARK2014: Past, Present and Future Claude Marché (Inria & Université Paris-Saclay) OSIS, Frama-C & SPARK day, May 30th, 2017 1 / 31 Outline Why this joint Frama-C

More information

Hybrid Verification in SPARK 2014: Combining Formal Methods with Testing

Hybrid Verification in SPARK 2014: Combining Formal Methods with Testing IEEE Software Technology Conference 2015 Hybrid Verification in SPARK 2014: Combining Formal Methods with Testing Steve Baird Senior Software Engineer Copyright 2014 AdaCore Slide: 1 procedure Array_Indexing_Bug

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

Enhance Verification using Ghost Code

Enhance Verification using Ghost Code Enhance Verification using Ghost Code Claire Dross SSAS Workshop 2018 Ghost Code, What Is It? 2 Ghost Code General Definition Ghost code does not affect normal execution of a program. Regular Code Ghost

More information

Deductive Program Verification with Why3, Past and Future

Deductive Program Verification with Why3, Past and Future Deductive Program Verification with Why3, Past and Future Claude Marché ProofInUse Kick-Off Day February 2nd, 2015 A bit of history 1999: Jean-Christophe Filliâtre s PhD Thesis Proof of imperative programs,

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

CS 275 Automata and Formal Language Theory. First Problem of URMs. (a) Definition of the Turing Machine. III.3 (a) Definition of the Turing Machine

CS 275 Automata and Formal Language Theory. First Problem of URMs. (a) Definition of the Turing Machine. III.3 (a) Definition of the Turing Machine CS 275 Automata and Formal Language Theory Course Notes Part III: Limits of Computation Chapt. III.3: Turing Machines Anton Setzer http://www.cs.swan.ac.uk/ csetzer/lectures/ automataformallanguage/13/index.html

More information

LECTURE 17. Expressions and Assignment

LECTURE 17. Expressions and Assignment LECTURE 17 Expressions and Assignment EXPRESSION SYNTAX An expression consists of An atomic object, e.g. number or variable. An operator (or function) applied to a collection of operands (or arguments)

More information

A Catalog of While Loop Specification Patterns

A Catalog of While Loop Specification Patterns A Catalog of While Loop Specification Patterns Aditi Barua and Yoonsik Cheon TR #14-65 September 2014 Keywords: functional program verification, intended functions, program specification, specification

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

From Event-B Models to Dafny Code Contracts

From Event-B Models to Dafny Code Contracts From Event-B Models to Dafny Code Contracts Mohammadsadegh Dalvandi, Michael Butler, Abdolbaghi Rezazadeh Electronic and Computer Science School, University of Southampton Southampton, United Kingdom {md5g11,mjb,ra3}@ecs.soton.ac.uk

More information

A3. Programming Languages for Writing Safety-Critical Software

A3. Programming Languages for Writing Safety-Critical Software A3. Programming Languages for Writing Safety-Critical Software (a) Overview. (b) SPARK Ada. Critical Systems, CS 411, Lent term 2002, Sec. A3 A3-1 (a) Overview Important Factors for Programming Languages

More information

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Spring 2018 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory

More information

Defining the Ethereum Virtual Machine for Interactive Theorem Provers

Defining the Ethereum Virtual Machine for Interactive Theorem Provers Defining the Ethereum Virtual Machine for Interactive Theorem Provers Ethereum Foundation Workshop on Trusted Smart Contracts Malta, Apr. 7, 2017 1/32 Outline 1 2 3 Remaining Problems 4 2/32 Outline 1

More information

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d)

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d) CMSC 330: Organization of Programming Languages Tail Calls A tail call is a function call that is the last thing a function does before it returns let add x y = x + y let f z = add z z (* tail call *)

More information

Simply-Typed Lambda Calculus

Simply-Typed Lambda Calculus #1 Simply-Typed Lambda Calculus #2 Back to School What is operational semantics? When would you use contextual (small-step) semantics? What is denotational semantics? What is axiomatic semantics? What

More information

Technical presentation

Technical presentation TOWARDS A COGNITIVE COMPUTING PLATFORM SUPPORTING A UNIFIED APPROACH TOWARDS PRIVACY, SECURITY AND SAFETY (PSS) OF IOT SYSTEMS The VESSEDIA Project Technical presentation Armand PUCCETTI, CEA Rome, 11th

More information

Runtime Checking for Program Verification Systems

Runtime Checking for Program Verification Systems Runtime Checking for Program Verification Systems Karen Zee, Viktor Kuncak, and Martin Rinard MIT CSAIL Tuesday, March 13, 2007 Workshop on Runtime Verification 1 Background Jahob program verification

More information

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered

More information

CS 242. Fundamentals. Reading: See last slide

CS 242. Fundamentals. Reading: See last slide CS 242 Fundamentals Reading: See last slide Syntax and Semantics of Programs Syntax The symbols used to write a program Semantics The actions that occur when a program is executed Programming language

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

Runtime Checking and Test Case Generation for Python

Runtime Checking and Test Case Generation for Python Runtime Checking and Test Case Generation for Python Anna Durrer Master Thesis Chair of Programming Methodology D-INFK ETH Supervisor: Marco Eilers, Prof. Peter Müller 24. Mai 2017 1 Introduction This

More information

Arguing for program correctness and writing correct programs

Arguing for program correctness and writing correct programs Arguing for program correctness and writing correct programs Saying things about states, programs Program state s1: x=4, y=-1.5, A={ me, you, he Assertions about program states x=3 False in s1 (y=x) x>=0

More information

Proving Security Properties in Software of Unknown Provenance

Proving Security Properties in Software of Unknown Provenance DEPENDABLE COMPUTING Proving Security Properties in Software of Unknown Provenance SOUND STATIC ANALYSIS FOR SECURITY WORKSHOP Ashlie B. Hocking 1 2018 June 2017 In collaboration with: Ben Rodes 1, John

More information

1007 Imperative Programming Part II

1007 Imperative Programming Part II Agenda 1007 Imperative Programming Part II We ve seen the basic ideas of sequence, iteration and selection. Now let s look at what else we need to start writing useful programs. Details now start to be

More information

Advances in Programming Languages

Advances in Programming Languages O T Y H Advances in Programming Languages APL8: ESC/Java2 David Aspinall (including slides by Ian Stark and material adapted from ESC/Java2 tutorial by David Cok, Joe Kiniry and Erik Poll) School of Informatics

More information

Proof Carrying Code(PCC)

Proof Carrying Code(PCC) Discussion p./6 Proof Carrying Code(PCC Languaged based security policy instead of OS-based A mechanism to determine with certainity that it is safe execute a program or not Generic architecture for providing

More information

CSCI-GA Scripting Languages

CSCI-GA Scripting Languages CSCI-GA.3033.003 Scripting Languages 12/02/2013 OCaml 1 Acknowledgement The material on these slides is based on notes provided by Dexter Kozen. 2 About OCaml A functional programming language All computation

More information

AXIOMS FOR THE INTEGERS

AXIOMS FOR THE INTEGERS AXIOMS FOR THE INTEGERS BRIAN OSSERMAN We describe the set of axioms for the integers which we will use in the class. The axioms are almost the same as what is presented in Appendix A of the textbook,

More information

Warm-Up Problem. 1. What is the definition of a Hoare triple satisfying partial correctness? 2. Recall the rule for assignment: x (assignment)

Warm-Up Problem. 1. What is the definition of a Hoare triple satisfying partial correctness? 2. Recall the rule for assignment: x (assignment) Warm-Up Problem 1 What is the definition of a Hoare triple satisfying partial correctness? 2 Recall the rule for assignment: x (assignment) Why is this the correct rule and not the following rule? x (assignment)

More information

Material from Recitation 1

Material from Recitation 1 Material from Recitation 1 Darcey Riley Frank Ferraro January 18, 2011 1 Introduction In CSC 280 we will be formalizing computation, i.e. we will be creating precise mathematical models for describing

More information

Lecture 2: SML Basics

Lecture 2: SML Basics 15-150 Lecture 2: SML Basics Lecture by Dan Licata January 19, 2012 I d like to start off by talking about someone named Alfred North Whitehead. With someone named Bertrand Russell, Whitehead wrote Principia

More information

CSC 501 Semantics of Programming Languages

CSC 501 Semantics of Programming Languages CSC 501 Semantics of Programming Languages Subtitle: An Introduction to Formal Methods. Instructor: Dr. Lutz Hamel Email: hamel@cs.uri.edu Office: Tyler, Rm 251 Books There are no required books in this

More information

Mathematics for Computer Scientists 2 (G52MC2)

Mathematics for Computer Scientists 2 (G52MC2) Mathematics for Computer Scientists 2 (G52MC2) L03 : More Coq, Classical Logic School of Computer Science University of Nottingham October 8, 2009 The cut rule Sometimes we want to prove a goal Q via an

More information

CSC313 High Integrity Systems/CSCM13 Critical Systems CSC313 High Integrity Systems/ CSCM13 Critical Systems

CSC313 High Integrity Systems/CSCM13 Critical Systems CSC313 High Integrity Systems/ CSCM13 Critical Systems CSC313 High Integrity Systems/CSCM13 Critical Systems CSC313 High Integrity Systems/ CSCM13 Critical Systems Course Notes Chapter 2: SPARK Ada Anton Setzer Dept. of Computer Science, Swansea University

More information

Formal Methods. CITS5501 Software Testing and Quality Assurance

Formal Methods. CITS5501 Software Testing and Quality Assurance Formal Methods CITS5501 Software Testing and Quality Assurance Pressman, R. Software Engineering: A Practitioner s Approach. Chapter 28. McGraw-Hill, 2005 The Science of Programming, David Gries, 1981

More information

The Compiler So Far. CSC 4181 Compiler Construction. Semantic Analysis. Beyond Syntax. Goals of a Semantic Analyzer.

The Compiler So Far. CSC 4181 Compiler Construction. Semantic Analysis. Beyond Syntax. Goals of a Semantic Analyzer. The Compiler So Far CSC 4181 Compiler Construction Scanner - Lexical analysis Detects inputs with illegal tokens e.g.: main 5 (); Parser - Syntactic analysis Detects inputs with ill-formed parse trees

More information

Softwaretechnik. Program verification. Software Engineering Albert-Ludwigs-University Freiburg. June 30, 2011

Softwaretechnik. Program verification. Software Engineering Albert-Ludwigs-University Freiburg. June 30, 2011 Softwaretechnik Program verification Software Engineering Albert-Ludwigs-University Freiburg June 30, 2011 (Software Engineering) Softwaretechnik June 30, 2011 1 / 28 Road Map Program verification Automatic

More information

Lecture 2: Big-Step Semantics

Lecture 2: Big-Step Semantics Lecture 2: Big-Step Semantics 1 Representing Abstract Syntax These are examples of arithmetic expressions: 2 * 4 1 + 2 + 3 5 * 4 * 2 1 + 2 * 3 We all know how to evaluate these expressions in our heads.

More information

Functional Languages. Hwansoo Han

Functional Languages. Hwansoo Han Functional Languages Hwansoo Han Historical Origins Imperative and functional models Alan Turing, Alonzo Church, Stephen Kleene, Emil Post, etc. ~1930s Different formalizations of the notion of an algorithm

More information

Formal Semantics of Programming Languages

Formal Semantics of Programming Languages Formal Semantics of Programming Languages Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson http://www.daimi.au.dk/~bra8130/wiley_book/wiley.html Benefits of formal

More information

Lecture Notes on Ints

Lecture Notes on Ints Lecture Notes on Ints 15-122: Principles of Imperative Computation Frank Pfenning Lecture 2 August 26, 2010 1 Introduction Two fundamental types in almost any programming language are booleans and integers.

More information

FreePascal changes: user documentation

FreePascal changes: user documentation FreePascal changes: user documentation Table of Contents Jochem Berndsen February 2007 1Introduction...1 2Accepted syntax...2 Declarations...2 Statements...3 Class invariants...3 3Semantics...3 Definitions,

More information

An Operational and Axiomatic Semantics for Non-determinism and Sequence Points in C

An Operational and Axiomatic Semantics for Non-determinism and Sequence Points in C An Operational and Axiomatic Semantics for Non-determinism and Sequence Points in C Robbert Krebbers Radboud University Nijmegen January 22, 2014 @ POPL, San Diego, USA 1 / 16 What is this program supposed

More information

Reasoning About Imperative Programs. COS 441 Slides 10

Reasoning About Imperative Programs. COS 441 Slides 10 Reasoning About Imperative Programs COS 441 Slides 10 The last few weeks Agenda reasoning about functional programming It s very simple and very uniform: substitution of equal expressions for equal expressions

More information

Basic Verification Strategy

Basic Verification Strategy ormal Verification Basic Verification Strategy compare behavior to intent System Model of system behavior intent Verifier results Intent Usually, originates with requirements, refined through design and

More information

Formal Semantics of Programming Languages

Formal Semantics of Programming Languages Formal Semantics of Programming Languages Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson http://www.daimi.au.dk/~bra8130/wiley_book/wiley.html Benefits of formal

More information

Proofwriting Checklist

Proofwriting Checklist CS103 Winter 2019 Proofwriting Checklist Cynthia Lee Keith Schwarz Over the years, we ve found many common proofwriting errors that can easily be spotted once you know how to look for them. In this handout,

More information

The semantics of a programming language is concerned with the meaning of programs, that is, how programs behave when executed on computers.

The semantics of a programming language is concerned with the meaning of programs, that is, how programs behave when executed on computers. Semantics The semantics of a programming language is concerned with the meaning of programs, that is, how programs behave when executed on computers. The semantics of a programming language assigns a precise

More information

Practical introduction to Frama-C (without Mathematical notations ;-) )

Practical introduction to Frama-C (without Mathematical notations ;-) ) Practical introduction to Frama-C (without Mathematical notations ;-) ) David MENTRÉ Using content of Jochen Burghardt (Fraunhofer First), Virgile Prevosto (CEA), Julien Signoles

More information

Advances in Programming Languages

Advances in Programming Languages T O Y H Advances in Programming Languages APL4: JML The Java Modeling Language David Aspinall (slides originally by Ian Stark) School of Informatics The University of Edinburgh Thursday 21 January 2010

More information

Warm-Up Problem. Let be a set of well-formed Predicate logic formulas. Let be well-formed Predicate logic formulas. Prove or disprove the following.

Warm-Up Problem. Let be a set of well-formed Predicate logic formulas. Let be well-formed Predicate logic formulas. Prove or disprove the following. Warm-Up Problem Let be a set of well-formed Predicate logic formulas Let be well-formed Predicate logic formulas Prove or disprove the following If then 1/35 Program Verification Carmen Bruni Lecture 18

More information

GNATprove a Spark2014 verifying compiler Florian Schanda, Altran UK

GNATprove a Spark2014 verifying compiler Florian Schanda, Altran UK 1 GNATprove a Spark2014 verifying compiler Florian Schanda, Altran UK Tool architecture User view Source gnatprove Verdict 2 Tool architecture More detailed view... Source Encoding CVC4 gnat2why gnatwhy3

More information

Dialects of ML. CMSC 330: Organization of Programming Languages. Dialects of ML (cont.) Features of ML. Functional Languages. Features of ML (cont.

Dialects of ML. CMSC 330: Organization of Programming Languages. Dialects of ML (cont.) Features of ML. Functional Languages. Features of ML (cont. CMSC 330: Organization of Programming Languages OCaml 1 Functional Programming Dialects of ML ML (Meta Language) Univ. of Edinburgh,1973 Part of a theorem proving system LCF The Logic of Computable Functions

More information

Assignment #4: Lambda Calculus & Semi-automatic Program Verification. You are allowed to work on this assignment in pairs. Hand in Requirements:

Assignment #4: Lambda Calculus & Semi-automatic Program Verification. You are allowed to work on this assignment in pairs. Hand in Requirements: Assignment #4: Lambda Calculus & Semi-automatic Program Verification You are allowed to work on this assignment in pairs. Hand in Requirements: Download a4-materials.tar.gz from the course website. Following

More information

Program verification. Generalities about software Verification Model Checking. September 20, 2016

Program verification. Generalities about software Verification Model Checking. September 20, 2016 Program verification Generalities about software Verification Model Checking Laure Gonnord David Monniaux September 20, 2016 1 / 43 The teaching staff Laure Gonnord, associate professor, LIP laboratory,

More information

The PCAT Programming Language Reference Manual

The PCAT Programming Language Reference Manual The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language

More information

Formal Verification of MIX Programs

Formal Verification of MIX Programs Formal Verification of MIX Programs Jean-Christophe Filliâtre CNRS LRI, Univ Paris-Sud, Orsay F-91405 INRIA Futurs, ProVal, Orsay F-91893 Abstract We introduce a methodology to formally verify MIX programs.

More information

Deductive Program Verification with Why3

Deductive Program Verification with Why3 Deductive Program Verification with Why3 Jean-Christophe Filliâtre CNRS Mathematical Structures of Computation Formal Proof, Symbolic Computation and Computer Arithmetic Lyon, February 2014 definition

More information

SPARK Update Ada Europe 2012

SPARK Update Ada Europe 2012 [SPARK] SPARK Update Ada Europe 2012 Stuart Matthews Copyright Altran Praxis Contents Background SPARK Pro Product Update SPARK Book New Edition SPARK Training Copyright Altran Praxis Corporate Markets

More information

The Substitution Model

The Substitution Model The Substitution Model Prof. Clarkson Fall 2017 Today s music: Substitute by The Who Review Previously in 3110: simple interpreter for expression language abstract syntax tree (AST) evaluation based on

More information

How invariants help writing loops Author: Sander Kooijmans Document version: 1.0

How invariants help writing loops Author: Sander Kooijmans Document version: 1.0 How invariants help writing loops Author: Sander Kooijmans Document version: 1.0 Why this document? Did you ever feel frustrated because of a nasty bug in your code? Did you spend hours looking at the

More information