THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600 (Formal Methods in Software Engineering)

Size: px
Start display at page:

Download "THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600 (Formal Methods in Software Engineering)"

Transcription

1 THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester 2007 COMP2600 (Formal Methods in Software Engineering) Writing Period: 3 hours duration Study Period: 15 minutes duration Permitted Materials: None Answer ALL five questions. Question 5 has internal choice. The questions are followed by labelled, framed blank spaces into which your answers are to be written. Additional answer panels are provided (at the end of the paper) should you wish to use more space for an answer than is provided in the associated labelled panels. If you use an additional panel, be sure to indicate clearly the question and part to which it is linked. Name (family name first): Student Number: The following are for use by the examiners. Q1 Mark Q2 Mark Q3 Mark Q4 Mark Q5 Mark Total Mark COMP2600 (Formal Methods in Software Engineering) Page 1 of 34

2 QUESTION 1 [19 marks] Structural Induction and Lambda Calculus (a) The append function (++) for lists is defined as: (++) :: [a] -> [a] -> [a] [ ] ++ ys = ys (x:xs) ++ ys = x:(xs ++ ys) The function revapp reverses its first argument and appends it to its second argument. It is defined as revapp :: [a] -> [a] -> [a] revapp [] ys = ys revapp (x:xs) ys = revapp xs (x:ys) Prove by induction that revapp xs (ys ++ zs) = (revapp xs ys) ++ zs You need to choose an induction variable so that clauses of the definitions above are easily applied; the proof shown of the step case goal will guide you in this. (i) State and prove the base case goal QUESTION 1(a)(i) (ii) State the inductive hypothesis QUESTION 1(a)(ii) [1 mark] COMP2600 (Formal Methods in Software Engineering) Page 2 of 34

3 (iii) The following is a proof of the step case goal. Give the justification for each of the steps in the proof. QUESTION 1(a)(iii) revapp (x:xs) (ys ++ zs) = revapp xs (x : (ys ++ zs)) = revapp xs ((x:ys) ++ zs) = (revapp xs (x:ys)) ++ zs = (revapp (x:xs) ys) ++ zs (iv) In fact the proof above reveals that the main result, the goals and the inductive hypothesis should have a universal quantifier,... Explain why this is so. Restate the result being proved and/or the inductive hypothesis, with this quantifier included. QUESTION 1(a)(iv) [1 mark] COMP2600 (Formal Methods in Software Engineering) Page 3 of 34

4 (b) The following datatype declaration describes a binary tree type, containing data items of type a. data Tree a = TNode a (Tree a) (Tree a) TNil (i) Express 1 / \ 2 / \ 3 / \ as a binary tree, of the type Tree Int. QUESTION 1(b)(i) (ii) For such a tree you can define the left spine, which is a list of the data items down the left-hand edge of the tree. For the tree shown above this would be [1,2]. (The corresponding right spine would be just [1]). The left spine can be defined as follows: lsp :: Tree a -> [a] lsp TNil = [] lsp (TNode a tl tr) = a : lsp tl As you should recall, the map function for lists is given by: map :: (a -> b) -> [a] -> [b] map f [] = [] map f (x : xs) = (f x) : (map f xs) There is a map function for binary trees, which we call mapt, which applies a given transformation to every data item in the tree. mapt :: (a -> b) -> Tree a -> Tree b mapt f TNil = TNil mapt f (TNode a tl tr) = TNode (f a) (mapt f tl) (mapt f tr) We wish to prove by structural induction the result lsp (mapt f t) = map f (lsp t) COMP2600 (Formal Methods in Software Engineering) Page 4 of 34

5 (iii) State and prove the base case goal QUESTION 1(b)(iii) [1 mark] (iv) State the step case goal and the inductive hypotheses QUESTION 1(b)(iv) (v) Prove the step case goal. QUESTION 1(b)(v) [3 marks] COMP2600 (Formal Methods in Software Engineering) Page 5 of 34

6 (c) Use α-conversion to change the following to an equivalent expresssion in which distinct bound variables are represented by different letters. (λx. (λx. x + 2) 3 + x) 4 QUESTION 1(c) [1 mark] (d) Simplify the following expressions by applying functions to arguments where possible (and appropriate). (i) (λf. (λx. f (x + 2))) (λy. y 3) QUESTION 1(d)(i) (ii) (λf. f (λx. x + 6)) (λg. 3 g(4)) QUESTION 1(d)(ii) Recall that in (λx....), the scope of the λx. extends to the closing parenthesis. COMP2600 (Formal Methods in Software Engineering) Page 6 of 34

7 QUESTION 2 [23 marks] Natural Deduction and Z (a) Construct natural deduction proofs for the following tautologies of propositional logic. Do not use truth tables or algebraic laws; just use the introduction and elimination rules cited in lectures and shown at the end of this paper. (i) A C (A B) C B that is, A ((C (A B)) (C B)) QUESTION 2(a)(i) (ii) (A B) (B A) A that is, ((A B) (B A)) A QUESTION 2(a)(ii) [3 marks] COMP2600 (Formal Methods in Software Engineering) Page 7 of 34

8 (b) The answer box below contains the formulae that form the steps of a Natural Deduction proof of ( A B) (A B). You must complete the proof by adding the justifications for each step, giving the name of the deduction rule used, the prior steps that are used by the rule (if any) and showing assumptions that are discharged at that point. QUESTION 2(b) [3 marks] 1. A B 2. A 3. A 4. B 5. A A 6. B 7. B 8. B 9. A B 10. A B A B COMP2600 (Formal Methods in Software Engineering) Page 8 of 34

9 (c) Construct natural deduction proofs for the following tautology of predicate calculus. Use just the introduction and elimination rules for predicate calculus cited in lectures, plus the rules for propositional logic. ( x. P(x) Q(x)) }{{} (A) ( y. P(y)) ( z. R(z)) }{{} (B) ( w. Q(w) R(w)) }{{} (C) that is ( x. (P(x) Q(x))) ((( y. P(y)) ( z. R(z))) ( w. (Q(w) R(w)))) (You may use the notation (A),(B),(C) to abbreviate your answer) QUESTION 2(c) [3 marks] COMP2600 (Formal Methods in Software Engineering) Page 9 of 34

10 (d) The answer box below contains the formulae that form the steps of a Natural Deduction proof of ( x. P(x) Q(x)) ( y. P(y)) ( w. Q(w)) You must complete the proof by adding the justifications for each step, giving the name of the deduction rule used, the prior steps that are used by the rule (if any) and showing assumptions that are discharged at that point. QUESTION 2(d) [3 marks] 1. ( x. P(x) Q(x)) ( y. P(y)) 2. ( x. P(x) Q(x)) 3. ( y. P(y)) 4. P(x) Q(x) 5. P(x) 6. Q(x) 7. w. Q(w) 8. (P(x) Q(x)) ( w. Q(w)) 9. ( w. Q(w)) 10. ( x. P(x) Q(x)) ( y. P(y)) ( w. Q(w)) COMP2600 (Formal Methods in Software Engineering) Page 10 of 34

11 (e) The following Z schemas partially specify a system which acts as an address book for friends names, phone numbers and addresses. The given types in this specification are Person, Number and Address. The state schema for the system is: AddressBook entries : Person (Number Address) p : Person; n 1,n 2 : Number; a 1,a 2 : Address ((p (n 1,a 1 ) entries) (p (n 2,a 2 ) entries)) (a 1 = a 2 ) n : Number; p 1,p 2 : Person; a 1,a 2 : Address ((p 1 (n,a 1 ) entries) (p 2 (n,a 2 ) entries)) (a 1 = a 2 ) AddEntry o AddressBook p? : Person n? : Number a? : Address (p? (n?,a?)) entries n : Number; a : Address ((p? (n,a)) entries (a = a?) a : Address ((n?,a) (ran entries)) (a = a?) entries = entries {(p? (n?,a?))} (i) The phrase AddressBook appears in the AddEntry o schema. What is the point of having this line in the declarations part of the schema? QUESTION 2(e)(i) (ii) Give the postcondition(s) for the successful completion of the address book operation called AddEntry. QUESTION 2(e)(ii) [1 mark] COMP2600 (Formal Methods in Software Engineering) Page 11 of 34

12 (iii) Pick one of the possible precondition violations for AddEntry and write an appropriate error schema. QUESTION 2(e)(iii) (iv) Assuming that the address book starts out empty, write the Initial schema that describes the initial state of the system. QUESTION 2(e)(iv) [1 mark] (v) Express the system invariant for AddressBook in simple English. QUESTION 2(e)(v) [3 marks] COMP2600 (Formal Methods in Software Engineering) Page 12 of 34

13 QUESTION 3 [20 marks] Hoare Logic and Weakest Precondition Calculus In this question, many of the parts refer to the rules of Hoare Logic and the Weakest Precondition Calculus. These are to be found in Appendices 2 and 3 at the end of this paper. (a) For what pre-conditions P and programs A does {P} A {False} hold? QUESTION 3(a) [1 mark] (b) For a program A, describe the condition wp (A,False). QUESTION 3(b) [1 mark] (c) If the following proposed rule is valid then give a proof of its validity, using the rules of Hoare Logic; if it is not, then provide a counter-example. {P} S {Q R} {P} S {Q} {P} S {R} QUESTION 3(c) COMP2600 (Formal Methods in Software Engineering) Page 13 of 34

14 (d) In this part of the question we analyse a piece of code using Hoare logic. The following code, called Mult, does multiplication by repeated addition and doubling: t:=0; while n 0 do t := t + (n mod 2) * m; n := n div 2; m := m * 2; } Body Loop Mult Note: unlike in some programming languages, we use definitions of mod and div where regardless of the sign of n, n mod 2 is either 0 or 1. n div 2 is integer division, rounded towards. For example, 3 div 2 = 2 and 3 mod 2 = + 1 Thus, always, n = (n div 2) 2 + (n mod 2) (you may use this result later) (i) Using the deduction rules of Hoare Logic (see Appendix 2 on page 34), show that the formula t + n m = prod (call this R) is an invariant for the body of the loop. (That is, prove that {R}Body{R}) (Note: prod is a logical variable which does not appear in the program, but may appear in pre- or post-conditions, and has a single value throughout). QUESTION 3(d)(i) COMP2600 (Formal Methods in Software Engineering) Page 14 of 34

15 (ii) Use the previous result, {R}Body{R}, and add some more proof steps (again using the rules on page 34) to choose a suitable pre-condition P and prove that the following Hoare triple holds {P} Mult {t = prod} (make P as weak a precondition as possible to achieve the given postcondition). QUESTION 3(d)(ii) [3 marks] (iii) In what way(s) does the above Hoare triple fail to show the circumstances when the Mult program computes the product of the initial values of n and m? QUESTION 3(d)(iii) [1 mark] COMP2600 (Formal Methods in Software Engineering) Page 15 of 34

16 (e) In the remaining parts of this question we analyse the same program Mult using the Weakest Precondition Calculus. We find the weakest precondition of the program Mult. As before it has the following code: note also the remarks in part (c) about the meaning of div and mod. t:=0; while n 0 do t := t + (n mod 2) * m; n := n div 2; m := m * 2; } Body Loop We will also refer to these conditions Q : t = prod R : t + n m = prod Mult Our desired postcondition in this case is Q Let P i be the predicate that the while-loop will execute exactly i times and terminate in a state satisfying the post-condition Q. (P i is a condition on the state that must be true immediately before the while loop is executed). (i) Show that wp(body, R) = R QUESTION 3(e)(i) (ii) Let U(n) be a predicate involving n, but not involving t or m. What is wp(body,u(n))? You need not show details of the calculation, but state which Weakest Precondition rules are used to obtain your result. QUESTION 3(e)(ii) [1 mark] COMP2600 (Formal Methods in Software Engineering) Page 16 of 34

17 (iii) Show that P 0 is given by (n = 0) R. QUESTION 3(e)(iii) [1 mark] (iv) There is a general formula for P k, given by P k (2 k 1 n < 2 k ) R (This formula applies only for k 1). Prove this formula by induction. Ensure it is clear which value(s) of k are involved in the base case and the step case. You may use the result wp(body,r) = R, and you may use your answer to part (e)(ii). In using these, you may also use this result: wp(s, A B) = wp(s, A) wp(s, B) QUESTION 3(e)(iv) [3 marks] COMP2600 (Formal Methods in Software Engineering) Page 17 of 34

18 (v) Derive the (weakest) condition for the loop to execute some number of times and terminate in a state satisfying the post-condition, ie, wp(loop,q). QUESTION 3(e)(v) (vi) Derive the weakest pre-condition for whole program, ie, wp(mult,q). QUESTION 3(e)(vi) [1 mark] COMP2600 (Formal Methods in Software Engineering) Page 18 of 34

19 QUESTION 4 [20 marks] Finite State Machines and Turing Machines (a) (Finite State Machines) The following grammar, expressed in EBNF, is for binary numbers. The vocabulary of this language fragment is the set of characters { 0, 1 } and the start symbol is <S>. (In this context ε denotes the empty string.) <S> ::= 0 1 <C> <C> ::= 0 <C> 1 <C> ε Let L N be the language described by this grammar. Let L R be the set of strings in L N, reversed, ie L R = {reverse of w w L N }. (e.g. the string is in L R because is in L N.) (i) Give a finite state automaton, (which may be nondeterministic), with at most 3 states, which recognises the language L N. (Hint: A standard technique is to map each of the nonterminals of the grammar into states and (if necessary) add one final (accepting) state.) QUESTION 4(a)(i) COMP2600 (Formal Methods in Software Engineering) Page 19 of 34

20 (ii) Give a deterministic finite state automaton, with as few states as possible, which recognises the language L N. QUESTION 4(a)(ii) (iii) Explain why there can be no deterministic finite state automaton, which recognises the language L N, with fewer than four states. QUESTION 4(a)(iii) [3 marks] COMP2600 (Formal Methods in Software Engineering) Page 20 of 34

21 (iv) Give a finite state automaton, (which may be nondeterministic), with at most 3 states, which recognises the language L R. QUESTION 4(a)(iv) (v) Give regular expressions for the languages L N and L R. QUESTION 4(a)(v) (vi) Give a regular grammar for L R. QUESTION 4(a)(vi) COMP2600 (Formal Methods in Software Engineering) Page 21 of 34

22 (b) (Turing Machines) The following diagram shows a Turing machine, whose purpose is either to accept or reject the input string. The input string consists of 0 s and 1 s, and the rest of the tape is blank (Λ). (A string accepted if the machine reaches the halt state and rejected if the machine gets stuck in another state.) Initially the head is somewhere in the input string. 0 0,L S 0 1 1,L 0 0,L halt Λ Λ,R Λ Λ,S 1 1,L 0 Λ,R S 1 S 4 1 Λ,L 0 0,R S 1 2 1,R Λ Λ,L S 3 (i) What purposes do the states S 0 and S 2 serve? What purposes do the states S 1 and S 3 serve? QUESTION 4(b)(i) [3 marks] COMP2600 (Formal Methods in Software Engineering) Page 22 of 34

23 (ii) What change is accomplished on the tape between each time that state S 0 is left and the time it is next entered? QUESTION 4(b)(ii) (iii) What is the language accepted by this machine? QUESTION 4(b)(iii) COMP2600 (Formal Methods in Software Engineering) Page 23 of 34

24 QUESTION 5 [18 marks] Answer three parts of this five-part question. Each part is worth 6 marks for a maximum value of 18 marks. (a) (Computability) Assume that the Halting Problem has no solution. Consider a program canhalttest which takes an (encoded) program P and returns a result indicating whether there is some input on which P halts. Show that no such program can be written. QUESTION 5(a) [6 marks] COMP2600 (Formal Methods in Software Engineering) Page 24 of 34

25 (b) (Another Turing machine question) Specify a Turing machine which will multiply a binary number on its tape by 5. When we do this operation manually we would work from right to left and compute at each bit position a new value and a carry, which can be 0, 1,2 3 or 4. The pair (new bit, carry-out) is a simple function of old bit value and carry-in. The following table captures this function ,0 1,0 0,1 1,1 0,2 1 1,2 0,3 1,3 0,4 1,4 Λ 0,0 1,0 0,1 1,1 0,2 QUESTION 5(b) [6 marks] COMP2600 (Formal Methods in Software Engineering) Page 25 of 34

26 (c) (Pushdown Automata) M is the following deterministic PDA: M = ({q 0,q 1,q 2 },{a,b,#},{e,z},δ,q 0,Z,{q 2 }) where δ, the next state function, is given in the following table: a,z b,z #,Z a,e b,e #,E q 0 q 0,EZ q 1,EZ q 2,ε q 0,EE q 0,ε q 1 q 0,EZ q 1,EZ q 2,ε q 1,ε q 1,EE q 2 (Entries in this table that have a dash indicate no further operation happens; it will be acceptance if the state is q 2 or rejection otherwise. Entries that are a pair indicate the next state and the sequence of symbols that replace the previous top one on the stack. Remember that Z is used to mark the bottom of the stack.) (i) Which of the following strings does M recognise? ab# bab# aaa# aaabbbb# QUESTION 5(c)(i) (ii) What language does M recognise? QUESTION 5(c)(ii) COMP2600 (Formal Methods in Software Engineering) Page 26 of 34

27 M is a variation on M, as follows: M = ({q 0,q 1,q 2 },{a,b,#},{e,z},δ,q 0,Z,{q 2 }) where δ, its next state relation, is characterized in the following table, which gives the possibilities for next states based on the usual factors (current state, input symbol, stack top). (In the column headed ε, E the input is ignored, and the next state is only dependent on the current state and the symbol on the top of the stack.) a,z b,z #,Z a,e b,e #,E ε,e q 0 q 0,EZ q 1,EZ q 2,ε q 0,EE q 0,ε q 1,ε q 1 q 0,EZ q 1,EZ q 2,ε q 1,ε q 1,EE q 0,ε q 2 (i) What language does M accept? QUESTION 5(c)(i) COMP2600 (Formal Methods in Software Engineering) Page 27 of 34

28 (d) (Parsing) (i) Why is the following grammar left-recursive? S a S S S QUESTION 5(d)(i) [1 mark] (ii) Find an grammar which is not left-recursive and which recognises the same language as that of the grammar above. Is your grammar LL(1)? Why? QUESTION 5(d)(ii) COMP2600 (Formal Methods in Software Engineering) Page 28 of 34

29 (iii) Consider a similar language to that of the grammar above, but where each string has an additional symbol # at the end. This language could be given by the following grammar, using S as the start symbol S S# S a S S S Find an LL(1) grammar for that language. (Hint: do not try using the non-terminal S of the grammar given). QUESTION 5(d)(iii) (iv) Consider the grammar given by the following productions, with start symbol E E ::= T T E T ::= P T P P ::= (E) a b c d We use the grammar to parse the string a b c d. Show unambiguously, using parentheses, how the string is interpreted (for example, a (b (c d)), or ((a b) c) d, etc). QUESTION 5(d)(iv) [1 mark] COMP2600 (Formal Methods in Software Engineering) Page 29 of 34

30 (e) (Prolog) This question concerns four different Prolog programs, called A,B,C,D. For all four programs, the fact database contains the following two facts. parent(a,b). parent(b,c). Each of the four programs also contains two rules, as follows. A { ancestor(x,y) : ancestor(x,z),parent(z,y). ancestor(x, Y) : parent(x, Y). B { ancestor(x,y) : parent(x,y). ancestor(x, Y) : ancestor(x, Z), parent(z, Y). C { ancestor(x,y) : parent(z,y),ancestor(x,z). ancestor(x, Y) : parent(x, Y). D { ancestor(x,y) : parent(x,y). ancestor(x, Y) : parent(z, Y), ancestor(x, Z). For each program, the query ancestor(a,b). is run (and after a result is given, the system is prompted for further results). The four programs give these four different results. 1 3 A = a,b = b A = b,b = c A = a,b = c no returns no results, just runs forever 2 4 A = a,b = c A = a,b = b A = b,b = c no A = a,b = b A = b,b = c A = a,b = c after these results, runs forever (i) State which of the four programs give each of the four results. QUESTION 5(e)(i) [3 marks] COMP2600 (Formal Methods in Software Engineering) Page 30 of 34

31 (ii) Give reasons for your answer to the last part. You need to show how the differences between the four observed behaviours are related to the differences between the four programs. QUESTION 5(e)(ii) [3 marks] COMP2600 (Formal Methods in Software Engineering) Page 31 of 34

32 Additional answers. Clearly indicate the corresponding question and part. COMP2600 (Formal Methods in Software Engineering) Page 32 of 34

33 Appendix 1 - Natural Deduction Rules -I -E p q p q p q p p q q -I p p q p q p -E p q [p] r r [q] r -I [p] q p q -E p p q q -I -E [p] q q p [ p] q q p -I -E p(x) [x not free in assumptions] x. p(x) x. p(x) p(a) -I p(a) x. p(x) -E p(x) q [x arbitrary] x. p(x) q [x is not free in q] COMP2600 (Formal Methods in Software Engineering) Page 33 of 34

34 Appendix 2 - Rules of Hoare Logic Assignment Axiom: Precondition Strengthening: Postcondition Weakening: Sequence: Conditional: While: {P[e/v]} v := e {P} P Q {Q} S {R} {P} S {R} {P} S {Q} Q R {P} S {R} {P} S 1 {Q} {Q} S 2 {R} {P} S 1 ; S 2 {R} {P b} S 1 {Q} {P b} S 2 {Q} {P} if b then S 1 else S 2 {Q} {P b} S {P} {P} while b do S {P b} Appendix 3 - Rules about Weakest Preconditions wp(v:= e, Q(v)) Q(e) wp(a 1 ; A 2, Q) wp(a 1, wp(a 2, Q)) wp(if b then A 1 else A 2, Q) (b wp(a 1,Q)) ( b wp(a 2,Q)) (b wp(a 1,Q)) ( b wp(a 2,Q)) wp(if b then A, Q) (b wp(a,q)) ( b Q) (b wp(a,q)) ( b Q) If P k is the weakest predicate that must be true before while B do A executes to guarantee that the loop terminates after exactly k iterations in a state that satisfies Q, then P 0 b Q P k+1 b wp(a,p k ) wp(while b do A, Q) k. (k 0 P k ) COMP2600 (Formal Methods in Software Engineering) Page 34 of 34

THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600 (Formal Methods for Software Engineering)

THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600 (Formal Methods for Software Engineering) THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester 2012 COMP2600 (Formal Methods for Software Engineering) Writing Period: 3 hours duration Study Period: 15 minutes duration Permitted Materials: One A4

More information

THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600 (Formal Methods for Software Engineering)

THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600 (Formal Methods for Software Engineering) THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester 2010 COMP2600 (Formal Methods for Software Engineering) Writing Period: 3 hours duration Study Period: 15 minutes duration Permitted Materials: One A4

More information

Mid-Semester Quiz Second Semester, 2012

Mid-Semester Quiz Second Semester, 2012 THE AUSTRALIAN NATIONAL UNIVERSITY Mid-Semester Quiz Second Semester, 2012 COMP2600 (Formal Methods for Software Engineering) Writing Period: 1 hour duration Study Period: 10 minutes duration Permitted

More information

THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600/COMP6260 (Formal Methods for Software Engineering)

THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600/COMP6260 (Formal Methods for Software Engineering) THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester 2016 COMP2600/COMP6260 (Formal Methods for Software Engineering) Writing Period: 3 hours duration Study Period: 15 minutes duration Permitted Materials:

More information

WITH SOME SAMPLE SOLUTIONS

WITH SOME SAMPLE SOLUTIONS THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester 2011 COMP2600 (Formal Methods for Software Engineering) Writing Period: 3 hours duration Study Period: 15 minutes duration Permitted Materials: One A4

More information

Hoare Logic: Part II

Hoare Logic: Part II Hoare Logic: Part II COMP2600 Formal Methods for Software Engineering Jinbo Huang Australian National University COMP 2600 Hoare Logic II 1 Factorial {n 0} fact := 1; i := n; while (i >0) do fact := fact

More information

Weakest Precondition Calculus

Weakest Precondition Calculus Weakest Precondition Calculus COMP2600 Formal Methods for Software Engineering Rajeev Goré Australian National University Semester 2, 2016 (Most lecture slides due to Ranald Clouston) COMP 2600 Weakest

More information

Hoare Calculus and Predicate Transformers

Hoare Calculus and Predicate Transformers Hoare Calculus and Predicate Transformers Wolfgang Schreiner Wolfgang.Schreiner@risc.uni-linz.ac.at Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria http://www.risc.uni-linz.ac.at

More information

Axiomatic Semantics. Lecture 9 CS 565 2/12/08

Axiomatic Semantics. Lecture 9 CS 565 2/12/08 Axiomatic Semantics Lecture 9 CS 565 2/12/08 Axiomatic Semantics Operational semantics describes the meaning of programs in terms of the execution steps taken by an abstract machine Denotational semantics

More information

Foundations of Computation

Foundations of Computation The Australian National University Semester 2, 2018 Research School of Computer Science Tutorial 6 Dirk Pattinson Foundations of Computation The tutorial contains a number of exercises designed for the

More information

Lecture Notes on Inductive Definitions

Lecture Notes on Inductive Definitions Lecture Notes on Inductive Definitions 15-312: Foundations of Programming Languages Frank Pfenning Lecture 2 September 2, 2004 These supplementary notes review the notion of an inductive definition and

More information

Part I: Definitions and Properties

Part I: Definitions and Properties Turing Machines Part I: Definitions and Properties Finite State Automata Deterministic Automata (DFSA) M = {Q, Σ, δ, q 0, F} -- Σ = Symbols -- Q = States -- q 0 = Initial State -- F = Accepting States

More information

What happens to the value of the expression x + y every time we execute this loop? while x>0 do ( y := y+z ; x := x:= x z )

What happens to the value of the expression x + y every time we execute this loop? while x>0 do ( y := y+z ; x := x:= x z ) Starter Questions Feel free to discuss these with your neighbour: Consider two states s 1 and s 2 such that s 1, x := x + 1 s 2 If predicate P (x = y + 1) is true for s 2 then what does that tell us about

More information

Deterministic Finite Automata

Deterministic Finite Automata Deterministic Finite Automata COMP2600 Formal Methods for Software Engineering Ranald Clouston Australian National University Semester 2, 2013 COMP 2600 Deterministic Finite Automata 1 Pop quiz What is

More information

Hoare Logic: Reasoning About Imperative Programs

Hoare Logic: Reasoning About Imperative Programs Hoare Logic: Reasoning About Imperative Programs COMP1600 / COMP6260 Dirk Pattinson Australian National University Semester 2, 2018 Programming Paradigms Functional. (Haskell, SML, OCaml,... ) main paradigm:

More information

Theory Bridge Exam Example Questions

Theory Bridge Exam Example Questions Theory Bridge Exam Example Questions Annotated version with some (sometimes rather sketchy) answers and notes. This is a collection of sample theory bridge exam questions. This is just to get some idea

More information

3130CIT Theory of Computation

3130CIT Theory of Computation GRIFFITH UNIVERSITY School of Computing and Information Technology 3130CIT Theory of Computation Final Examination, Semester 2, 2006 Details Total marks: 120 (40% of the total marks for this subject) Perusal:

More information

Automata Theory (2A) Young Won Lim 5/31/18

Automata Theory (2A) Young Won Lim 5/31/18 Automata Theory (2A) Copyright (c) 2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Lecture Notes on Inductive Definitions

Lecture Notes on Inductive Definitions Lecture Notes on Inductive Definitions 15-312: Foundations of Programming Languages Frank Pfenning Lecture 2 August 28, 2003 These supplementary notes review the notion of an inductive definition and give

More information

CS481F01 Prelim 2 Solutions

CS481F01 Prelim 2 Solutions CS481F01 Prelim 2 Solutions A. Demers 7 Nov 2001 1 (30 pts = 4 pts each part + 2 free points). For this question we use the following notation: x y means x is a prefix of y m k n means m n k For each of

More information

Dynamic Semantics. Dynamic Semantics. Operational Semantics Axiomatic Semantics Denotational Semantic. Operational Semantics

Dynamic Semantics. Dynamic Semantics. Operational Semantics Axiomatic Semantics Denotational Semantic. Operational Semantics Dynamic Semantics Operational Semantics Denotational Semantic Dynamic Semantics Operational Semantics Operational Semantics Describe meaning by executing program on machine Machine can be actual or simulated

More information

Hoare Logic: Reasoning About Imperative Programs

Hoare Logic: Reasoning About Imperative Programs Hoare Logic: Reasoning About Imperative Programs COMP1600 / COMP6260 Dirk Pattinson Australian National University Semester 2, 2017 Catch Up / Drop in Lab When Fridays, 15.00-17.00 Where N335, CSIT Building

More information

Lecture Notes: Axiomatic Semantics and Hoare-style Verification

Lecture Notes: Axiomatic Semantics and Hoare-style Verification Lecture Notes: Axiomatic Semantics and Hoare-style Verification 17-355/17-665/17-819O: Program Analysis (Spring 2018) Claire Le Goues and Jonathan Aldrich clegoues@cs.cmu.edu, aldrich@cs.cmu.edu It has

More information

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET Regular Languages and FA A language is a set of strings over a finite alphabet Σ. All languages are finite or countably infinite. The set of all languages

More information

CPS 220 Theory of Computation Pushdown Automata (PDA)

CPS 220 Theory of Computation Pushdown Automata (PDA) CPS 220 Theory of Computation Pushdown Automata (PDA) Nondeterministic Finite Automaton with some extra memory Memory is called the stack, accessed in a very restricted way: in a First-In First-Out fashion

More information

Turing Machines Part II

Turing Machines Part II Turing Machines Part II COMP2600 Formal Methods for Software Engineering Katya Lebedeva Australian National University Semester 2, 2016 Slides created by Katya Lebedeva COMP 2600 Turing Machines 1 Why

More information

Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions

Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions Chapter 1 Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions 1.1 The IMP Language IMP is a programming language with an extensible syntax that was developed in the late 1960s. We will

More information

Deterministic Finite Automata

Deterministic Finite Automata Deterministic Finite Automata COMP2600 Formal Methods for Software Engineering Katya Lebedeva Australian National University Semester 2, 2016 Slides by Ranald Clouston and Katya Lebedeva. COMP 2600 Deterministic

More information

Learning Goals of CS245 Logic and Computation

Learning Goals of CS245 Logic and Computation Learning Goals of CS245 Logic and Computation Alice Gao April 27, 2018 Contents 1 Propositional Logic 2 2 Predicate Logic 4 3 Program Verification 6 4 Undecidability 7 1 1 Propositional Logic Introduction

More information

Hoare Logic I. Introduction to Deductive Program Verification. Simple Imperative Programming Language. Hoare Logic. Meaning of Hoare Triples

Hoare Logic I. Introduction to Deductive Program Verification. Simple Imperative Programming Language. Hoare Logic. Meaning of Hoare Triples Hoare Logic I Introduction to Deductive Program Verification Işıl Dillig Program Spec Deductive verifier FOL formula Theorem prover valid contingent Example specs: safety (no crashes), absence of arithmetic

More information

Theory of Computation

Theory of Computation Theory of Computation Lecture #2 Sarmad Abbasi Virtual University Sarmad Abbasi (Virtual University) Theory of Computation 1 / 1 Lecture 2: Overview Recall some basic definitions from Automata Theory.

More information

Halting and Equivalence of Program Schemes in Models of Arbitrary Theories

Halting and Equivalence of Program Schemes in Models of Arbitrary Theories Halting and Equivalence of Program Schemes in Models of Arbitrary Theories Dexter Kozen Cornell University, Ithaca, New York 14853-7501, USA, kozen@cs.cornell.edu, http://www.cs.cornell.edu/~kozen In Honor

More information

Proof Rules for Correctness Triples

Proof Rules for Correctness Triples Proof Rules for Correctness Triples CS 536: Science of Programming, Fall 2018 A. Why? We can t generally prove that correctness triples are valid using truth tables. We need proof axioms for atomic statements

More information

Theory of Computation

Theory of Computation Theory of Computation Lecture #10 Sarmad Abbasi Virtual University Sarmad Abbasi (Virtual University) Theory of Computation 1 / 43 Lecture 10: Overview Linear Bounded Automata Acceptance Problem for LBAs

More information

What we have done so far

What we have done so far What we have done so far DFAs and regular languages NFAs and their equivalence to DFAs Regular expressions. Regular expressions capture exactly regular languages: Construct a NFA from a regular expression.

More information

Deductive Verification

Deductive Verification Deductive Verification Mooly Sagiv Slides from Zvonimir Rakamaric First-Order Logic A formal notation for mathematics, with expressions involving Propositional symbols Predicates Functions and constant

More information

Introduction to Metalogic

Introduction to Metalogic Philosophy 135 Spring 2008 Tony Martin Introduction to Metalogic 1 The semantics of sentential logic. The language L of sentential logic. Symbols of L: Remarks: (i) sentence letters p 0, p 1, p 2,... (ii)

More information

Last Time. Inference Rules

Last Time. Inference Rules Last Time When program S executes it switches to a different state We need to express assertions on the states of the program S before and after its execution We can do it using a Hoare triple written

More information

Theory of Computation Turing Machine and Pushdown Automata

Theory of Computation Turing Machine and Pushdown Automata Theory of Computation Turing Machine and Pushdown Automata 1. What is a Turing Machine? A Turing Machine is an accepting device which accepts the languages (recursively enumerable set) generated by type

More information

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY No part of this publication may be reproduced or distributed in any form or any means, electronic, mechanical, photocopying, or otherwise without the prior permission of the author. GATE SOLVED PAPER Computer

More information

Automata Theory and Formal Grammars: Lecture 1

Automata Theory and Formal Grammars: Lecture 1 Automata Theory and Formal Grammars: Lecture 1 Sets, Languages, Logic Automata Theory and Formal Grammars: Lecture 1 p.1/72 Sets, Languages, Logic Today Course Overview Administrivia Sets Theory (Review?)

More information

Languages, regular languages, finite automata

Languages, regular languages, finite automata Notes on Computer Theory Last updated: January, 2018 Languages, regular languages, finite automata Content largely taken from Richards [1] and Sipser [2] 1 Languages An alphabet is a finite set of characters,

More information

Proving Programs Correct

Proving Programs Correct Proving Programs Correct Page 1 of 9 Proving Programs Correct How can we be sure that a piece of code does what we want it to do? One way is to try testing the code on a large group of data. Another is

More information

ECS 120 Lesson 15 Turing Machines, Pt. 1

ECS 120 Lesson 15 Turing Machines, Pt. 1 ECS 120 Lesson 15 Turing Machines, Pt. 1 Oliver Kreylos Wednesday, May 2nd, 2001 Before we can start investigating the really interesting problems in theoretical computer science, we have to introduce

More information

Lecture 17: Floyd-Hoare Logic for Partial Correctness

Lecture 17: Floyd-Hoare Logic for Partial Correctness Lecture 17: Floyd-Hoare Logic for Partial Correctness Aims: To look at the following inference rules Page 1 of 9 sequence; assignment and consequence. 17.1. The Deduction System for Partial Correctness

More information

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK COMS11700 Undecidability Department of Computer Science, University of Bristol Bristol, UK 4 April 2014 COMS11700: Undecidability Slide 1/29 Decidability We are particularly interested in Turing machines

More information

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises Automata and Computability Solutions to Exercises Spring 27 Alexis Maciel Department of Computer Science Clarkson University Copyright c 27 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

More information

CSE 311: Foundations of Computing I Autumn 2014 Practice Final: Section X. Closed book, closed notes, no cell phones, no calculators.

CSE 311: Foundations of Computing I Autumn 2014 Practice Final: Section X. Closed book, closed notes, no cell phones, no calculators. CSE 311: Foundations of Computing I Autumn 014 Practice Final: Section X YY ZZ Name: UW ID: Instructions: Closed book, closed notes, no cell phones, no calculators. You have 110 minutes to complete the

More information

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u,

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u, 1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u, v, x, y, z as per the pumping theorem. 3. Prove that

More information

Further discussion of Turing machines

Further discussion of Turing machines Further discussion of Turing machines In this lecture we will discuss various aspects of decidable and Turing-recognizable languages that were not mentioned in previous lectures. In particular, we will

More information

Axiomatic Semantics. Hoare s Correctness Triplets Dijkstra s Predicate Transformers

Axiomatic Semantics. Hoare s Correctness Triplets Dijkstra s Predicate Transformers Axiomatic Semantics Hoare s Correctness Triplets Dijkstra s Predicate Transformers Goal of a program = IO Relation Problem Specification Properties satisfied by the input and expected of the output (usually

More information

Computational Models - Lecture 4

Computational Models - Lecture 4 Computational Models - Lecture 4 Regular languages: The Myhill-Nerode Theorem Context-free Grammars Chomsky Normal Form Pumping Lemma for context free languages Non context-free languages: Examples Push

More information

3 Propositional Logic

3 Propositional Logic 3 Propositional Logic 3.1 Syntax 3.2 Semantics 3.3 Equivalence and Normal Forms 3.4 Proof Procedures 3.5 Properties Propositional Logic (25th October 2007) 1 3.1 Syntax Definition 3.0 An alphabet Σ consists

More information

Automata Theory - Quiz II (Solutions)

Automata Theory - Quiz II (Solutions) Automata Theory - Quiz II (Solutions) K. Subramani LCSEE, West Virginia University, Morgantown, WV {ksmani@csee.wvu.edu} 1 Problems 1. Induction: Let L denote the language of balanced strings over Σ =

More information

Lecture 13: Turing Machine

Lecture 13: Turing Machine Lecture 13: Turing Machine Instructor: Ketan Mulmuley Scriber: Yuan Li February 19, 2015 Turing machine is an abstract machine which in principle can simulate any computation in nature. Church-Turing Thesis:

More information

Hoare Logic (I): Axiomatic Semantics and Program Correctness

Hoare Logic (I): Axiomatic Semantics and Program Correctness Hoare Logic (I): Axiomatic Semantics and Program Correctness (Based on [Apt and Olderog 1991; Gries 1981; Hoare 1969; Kleymann 1999; Sethi 199]) Yih-Kuen Tsay Dept. of Information Management National Taiwan

More information

CS 21 Decidability and Tractability Winter Solution Set 3

CS 21 Decidability and Tractability Winter Solution Set 3 CS 21 Decidability and Tractability Winter 2018 Posted: January 31 Solution Set 3 If you have not yet turned in the Problem Set, you should not consult these solutions. 1. (a) A 2-NPDA is a 7-tuple (Q,,

More information

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises Automata and Computability Solutions to Exercises Fall 28 Alexis Maciel Department of Computer Science Clarkson University Copyright c 28 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

More information

Section 14.1 Computability then else

Section 14.1 Computability then else Section 14.1 Computability Some problems cannot be solved by any machine/algorithm. To prove such statements we need to effectively describe all possible algorithms. Example (Turing machines). Associate

More information

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0 Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0 Turing Machines Now for a machine model of much greater power.

More information

CPSC 421: Tutorial #1

CPSC 421: Tutorial #1 CPSC 421: Tutorial #1 October 14, 2016 Set Theory. 1. Let A be an arbitrary set, and let B = {x A : x / x}. That is, B contains all sets in A that do not contain themselves: For all y, ( ) y B if and only

More information

Theory of Computation

Theory of Computation Fall 2002 (YEN) Theory of Computation Midterm Exam. Name:... I.D.#:... 1. (30 pts) True or false (mark O for true ; X for false ). (Score=Max{0, Right- 1 2 Wrong}.) (1) X... If L 1 is regular and L 2 L

More information

CSC 7101: Programming Language Structures 1. Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11.

CSC 7101: Programming Language Structures 1. Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11. Axiomatic Semantics Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 1 Overview We ll develop proof rules, such as: { I b } S { I } { I } while b do S end { I b } That allow us to verify

More information

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 8 January 24, 2018 Outline Turing Machines and variants multitape TMs nondeterministic TMs Church-Turing Thesis So far several models of computation finite automata

More information

First Order Logic vs Propositional Logic CS477 Formal Software Dev Methods

First Order Logic vs Propositional Logic CS477 Formal Software Dev Methods First Order Logic vs Propositional Logic CS477 Formal Software Dev Methods Elsa L Gunter 2112 SC, UIUC egunter@illinois.edu http://courses.engr.illinois.edu/cs477 Slides based in part on previous lectures

More information

Reasoning About Imperative Programs. COS 441 Slides 10b

Reasoning About Imperative Programs. COS 441 Slides 10b Reasoning About Imperative Programs COS 441 Slides 10b Last time Hoare Logic: { P } C { Q } Agenda If P is true in the initial state s. And C in state s evaluates to s. Then Q must be true in s. Program

More information

Lecture 17: Language Recognition

Lecture 17: Language Recognition Lecture 17: Language Recognition Finite State Automata Deterministic and Non-Deterministic Finite Automata Regular Expressions Push-Down Automata Turing Machines Modeling Computation When attempting to

More information

Logic. Propositional Logic: Syntax

Logic. Propositional Logic: Syntax Logic Propositional Logic: Syntax Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about

More information

Advanced Topics in LP and FP

Advanced Topics in LP and FP Lecture 1: Prolog and Summary of this lecture 1 Introduction to Prolog 2 3 Truth value evaluation 4 Prolog Logic programming language Introduction to Prolog Introduced in the 1970s Program = collection

More information

Propositional Logic: Syntax

Propositional Logic: Syntax Logic Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about time (and programs) epistemic

More information

Proof Calculus for Partial Correctness

Proof Calculus for Partial Correctness Proof Calculus for Partial Correctness Bow-Yaw Wang Institute of Information Science Academia Sinica, Taiwan September 7, 2016 Bow-Yaw Wang (Academia Sinica) Proof Calculus for Partial Correctness September

More information

(a) Definition of TMs. First Problem of URMs

(a) Definition of TMs. First Problem of URMs Sec. 4: Turing Machines First Problem of URMs (a) Definition of the Turing Machine. (b) URM computable functions are Turing computable. (c) Undecidability of the Turing Halting Problem That incrementing

More information

CP405 Theory of Computation

CP405 Theory of Computation CP405 Theory of Computation BB(3) q 0 q 1 q 2 0 q 1 1R q 2 0R q 2 1L 1 H1R q 1 1R q 0 1L Growing Fast BB(3) = 6 BB(4) = 13 BB(5) = 4098 BB(6) = 3.515 x 10 18267 (known) (known) (possible) (possible) Language:

More information

1. Consider the conditional E = p q r. Use de Morgan s laws to write simplified versions of the following : The negation of E : 5 points

1. Consider the conditional E = p q r. Use de Morgan s laws to write simplified versions of the following : The negation of E : 5 points Introduction to Discrete Mathematics 3450:208 Test 1 1. Consider the conditional E = p q r. Use de Morgan s laws to write simplified versions of the following : The negation of E : The inverse of E : The

More information

CISC4090: Theory of Computation

CISC4090: Theory of Computation CISC4090: Theory of Computation Chapter 2 Context-Free Languages Courtesy of Prof. Arthur G. Werschulz Fordham University Department of Computer and Information Sciences Spring, 2014 Overview In Chapter

More information

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs Harry Lewis October 8, 2013 Reading: Sipser, pp. 119-128. Pushdown Automata (review) Pushdown Automata = Finite automaton

More information

Chapter 1. Formal Definition and View. Lecture Formal Pushdown Automata on the 28th April 2009

Chapter 1. Formal Definition and View. Lecture Formal Pushdown Automata on the 28th April 2009 Chapter 1 Formal and View Lecture on the 28th April 2009 Formal of PA Faculty of Information Technology Brno University of Technology 1.1 Aim of the Lecture 1 Define pushdown automaton in a formal way

More information

Section 1 (closed-book) Total points 30

Section 1 (closed-book) Total points 30 CS 454 Theory of Computation Fall 2011 Section 1 (closed-book) Total points 30 1. Which of the following are true? (a) a PDA can always be converted to an equivalent PDA that at each step pops or pushes

More information

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu Part 4 out of 5 ETH Zürich (D-ITET) October, 12 2017 Last week, we showed the equivalence of DFA, NFA and REX

More information

Strong AI vs. Weak AI Automated Reasoning

Strong AI vs. Weak AI Automated Reasoning Strong AI vs. Weak AI Automated Reasoning George F Luger ARTIFICIAL INTELLIGENCE 6th edition Structures and Strategies for Complex Problem Solving Artificial intelligence can be classified into two categories:

More information

Most General computer?

Most General computer? Turing Machines Most General computer? DFAs are simple model of computation. Accept only the regular languages. Is there a kind of computer that can accept any language, or compute any function? Recall

More information

Hoare Logic and Model Checking

Hoare Logic and Model Checking Hoare Logic and Model Checking Kasper Svendsen University of Cambridge CST Part II 2016/17 Acknowledgement: slides heavily based on previous versions by Mike Gordon and Alan Mycroft Introduction In the

More information

Pushdown Automata. Chapter 12

Pushdown Automata. Chapter 12 Pushdown Automata Chapter 12 Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely what it needs is a stack, which gives it an unlimited

More information

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012 Decision Problems with TM s Look at following sets: Lecture 31: Halting Problem CSCI 81 Spring, 2012 Kim Bruce A TM = { M,w M is a TM and w L(M)} H TM = { M,w M is a TM which halts on input w} TOTAL TM

More information

Spring 2015 Program Analysis and Verification. Lecture 4: Axiomatic Semantics I. Roman Manevich Ben-Gurion University

Spring 2015 Program Analysis and Verification. Lecture 4: Axiomatic Semantics I. Roman Manevich Ben-Gurion University Spring 2015 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University Agenda Basic concepts of correctness Axiomatic semantics (pages 175-183) Hoare Logic

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Chomsky Normal Form and TURING MACHINES TUESDAY Feb 4 CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form:

More information

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions? Before We Start The Pumping Lemma Any questions? The Lemma & Decision/ Languages Future Exam Question What is a language? What is a class of languages? Context Free Languages Context Free Languages(CFL)

More information

Lecture 2: Connecting the Three Models

Lecture 2: Connecting the Three Models IAS/PCMI Summer Session 2000 Clay Mathematics Undergraduate Program Advanced Course on Computational Complexity Lecture 2: Connecting the Three Models David Mix Barrington and Alexis Maciel July 18, 2000

More information

CS20a: Turing Machines (Oct 29, 2002)

CS20a: Turing Machines (Oct 29, 2002) CS20a: Turing Machines (Oct 29, 2002) So far: DFA = regular languages PDA = context-free languages Today: Computability 1 Handicapped machines DFA limitations Tape head moves only one direction 2-way DFA

More information

CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning.

CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning. 3: Logic Why logic? Logic about inference or argument Start from assumptions or axioms Make deductions according to rules of reasoning Logic 3-1 Why logic? (continued) If I don t buy a lottery ticket on

More information

Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE

Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE Axiomatic Semantics Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE 6341 1 Outline Introduction What are axiomatic semantics? First-order logic & assertions about states Results (triples)

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY REVIEW for MIDTERM 1 THURSDAY Feb 6 Midterm 1 will cover everything we have seen so far The PROBLEMS will be from Sipser, Chapters 1, 2, 3 It will be

More information

CS156: The Calculus of Computation Zohar Manna Autumn 2008

CS156: The Calculus of Computation Zohar Manna Autumn 2008 Page 3 of 52 Page 4 of 52 CS156: The Calculus of Computation Zohar Manna Autumn 2008 Lecturer: Zohar Manna (manna@cs.stanford.edu) Office Hours: MW 12:30-1:00 at Gates 481 TAs: Boyu Wang (wangboyu@stanford.edu)

More information

MA/CSSE 474 Theory of Computation

MA/CSSE 474 Theory of Computation MA/CSSE 474 Theory of Computation CFL Hierarchy CFL Decision Problems Your Questions? Previous class days' material Reading Assignments HW 12 or 13 problems Anything else I have included some slides online

More information

Solution Scoring: SD Reg exp.: a(a

Solution Scoring: SD Reg exp.: a(a MA/CSSE 474 Exam 3 Winter 2013-14 Name Solution_with explanations Section: 02(3 rd ) 03(4 th ) 1. (28 points) For each of the following statements, circle T or F to indicate whether it is True or False.

More information

CS 70 Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1 Solutions

CS 70 Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1 Solutions CS 70 Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1 Solutions PRINT Your Name: Answer: Oski Bear SIGN Your Name: PRINT Your Student ID: CIRCLE your exam room: Dwinelle

More information

CS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus

CS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus CS 4110 Programming Languages & Logics Lecture 16 Programming in the λ-calculus 30 September 2016 Review: Church Booleans 2 We can encode TRUE, FALSE, and IF, as: TRUE λx. λy. x FALSE λx. λy. y IF λb.

More information

Undecidable Problems and Reducibility

Undecidable Problems and Reducibility University of Georgia Fall 2014 Reducibility We show a problem decidable/undecidable by reducing it to another problem. One type of reduction: mapping reduction. Definition Let A, B be languages over Σ.

More information

Logic. Propositional Logic: Syntax. Wffs

Logic. Propositional Logic: Syntax. Wffs Logic Propositional Logic: Syntax Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about

More information

Pushdown Automata (Pre Lecture)

Pushdown Automata (Pre Lecture) Pushdown Automata (Pre Lecture) Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2017 Dantam (Mines CSCI-561) Pushdown Automata (Pre Lecture) Fall 2017 1 / 41 Outline Pushdown Automata Pushdown

More information