CIS (More Propositional Calculus - 6 points)

Similar documents
COMP2111 Glossary. Kai Engelhardt. Contents. 1 Symbols. 1 Symbols 1. 2 Hoare Logic 3. 3 Refinement Calculus 5. rational numbers Q, real numbers R.

Problem 1: Suppose A, B, C and D are finite sets such that A B = C D and C = D. Prove or disprove: A = B.

Proof Calculus for Partial Correctness

Lecture 2: Axiomatic semantics

Learning Goals of CS245 Logic and Computation

Recall that the expression x > 3 is not a proposition. Why?

In this episode of The Verification Corner, Rustan Leino talks about Loop Invariants. He gives a brief summary of the theoretical foundations and

MT804 Analysis Homework II

Your quiz in recitation on Tuesday will cover 3.1: Arguments and inference. Your also have an online quiz, covering 3.1, due by 11:59 p.m., Tuesday.

Mid-Semester Quiz Second Semester, 2012

Program verification. Hoare triples. Assertional semantics (cont) Example: Semantics of assignment. Assertional semantics of a program

Department of Computer Science University at Albany, State University of New York Solutions to Sample Discrete Mathematics Examination II (Fall 2007)

Predicate Calculus lecture 1

Hoare Logic: Reasoning About Imperative Programs

Automata-Theoretic Model Checking of Reactive Systems

A Logic Primer. Stavros Tripakis University of California, Berkeley. Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 A Logic Primer 1 / 35

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

Section Summary. Section 1.5 9/9/2014

Total NP Functions I: Complexity and Reducibility

Hoare Examples & Proof Theory. COS 441 Slides 11

Hoare Logic (I): Axiomatic Semantics and Program Correctness

Chapter 3: Propositional Calculus: Deductive Systems. September 19, 2008

Mat 243 Exam 1 Review

Logic Propositional logic; First order/predicate logic

CS558 Programming Languages

Essential facts about NP-completeness:

Foundations of Mathematics MATH 220 FALL 2017 Lecture Notes

Section 2.2 Set Operations. Propositional calculus and set theory are both instances of an algebraic system called a. Boolean Algebra.

Overview. CS389L: Automated Logical Reasoning. Lecture 7: Validity Proofs and Properties of FOL. Motivation for semantic argument method

Conjunction: p q is true if both p, q are true, and false if at least one of p, q is false. The truth table for conjunction is as follows.

REVIEW FOR THIRD 3200 MIDTERM

There are problems that cannot be solved by computer programs (i.e. algorithms) even assuming unlimited time and space.

Discrete Mathematics Fall 2018 Midterm Exam Prof. Callahan. Section: NetID: Multiple Choice Question (30 questions in total, 4 points each)

Propositional and Predicate Logic

(Yet another) decision procedure for Equality Logic

Introduction. Foundations of Computing Science. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office?

Markov Networks. l Like Bayes Nets. l Graphical model that describes joint probability distribution using tables (AKA potentials)

Propositional and Predicate Logic

2/2/2018. CS 103 Discrete Structures. Chapter 1. Propositional Logic. Chapter 1.1. Propositional Logic

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

Timo Latvala. February 4, 2004

Predicate logic. Predicates and Boolean Expressions. V =100 I expresses a relationship between quantities identified

Hoare Logic: Part II

x P(x) x P(x) CSE 311: Foundations of Computing announcements last time: quantifiers, review: logical Inference Fall 2013 Lecture 7: Proofs

Formal Methods in Software Engineering

A Logic Primer. Stavros Tripakis University of California, Berkeley

Markov Networks. l Like Bayes Nets. l Graph model that describes joint probability distribution using tables (AKA potentials)

Proofs. Chapter 2 P P Q Q

Axioms for Set Theory

0 Sets and Induction. Sets

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

Temporal & Modal Logic. Acronyms. Contents. Temporal Logic Overview Classification PLTL Syntax Semantics Identities. Concurrency Model Checking

Programming Languages and Compilers (CS 421)

Computer-Aided Program Design

A Short Introduction to Hoare Logic

Logic. Propositional Logic: Syntax

Axiomatic Semantics. Hoare s Correctness Triplets Dijkstra s Predicate Transformers

3. Only sequences that were formed by using finitely many applications of rules 1 and 2, are propositional formulas.

1 Introduction (January 21)

Deductive Verification

DFA to Regular Expressions

NP-Completeness Part II

CSC 1700 Analysis of Algorithms: Warshall s and Floyd s algorithms

Math 210 Exam 2 - Practice Problems. 1. For each of the following, determine whether the statement is True or False.

CSE 1400 Applied Discrete Mathematics Proofs

Discrete Structures (2IT50)

First Order Logic vs Propositional Logic CS477 Formal Software Dev Methods

Lecture 04: Balls and Bins: Birthday Paradox. Birthday Paradox

Semester 2 Final Review

Name (print): Question 4. exercise 1.24 (compute the union, then the intersection of two sets)

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

Hoare Logic and Model Checking

Predicate Logic: Sematics Part 1

Path Testing and Test Coverage. Chapter 9

First-Order Logic (FOL)

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

Math 651 Introduction to Numerical Analysis I Fall SOLUTIONS: Homework Set 1

T Reactive Systems: Temporal Logic LTL

AAA615: Formal Methods. Lecture 2 First-Order Logic

Hoare Calculus and Predicate Transformers

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

Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions

Solutions to Sample Problems for Midterm

Show Your Work! Point values are in square brackets. There are 35 points possible. Tables of tautologies and contradictions are on the last page.

Resolution for Predicate Logic

CVO103: Programming Languages. Lecture 2 Inductive Definitions (2)

5.6 Logarithmic and Exponential Equations

1 The Well Ordering Principle, Induction, and Equivalence Relations

CSCE 551 Final Exam, April 28, 2016 Answer Key

Relations Graphical View

Def. A topological space X is disconnected if it admits a non-trivial splitting: (We ll abbreviate disjoint union of two subsets A and B meaning A B =

CHAPTER 4 CLASSICAL PROPOSITIONAL SEMANTICS

(a) For an accumulation point a of S, the number l is the limit of f(x) as x approaches a, or lim x a f(x) = l, iff

CS156: The Calculus of Computation

Unifying Theories of Programming

Logic for Computer Science Handout Week 8 DERIVED RULE MODUS TOLLENS DERIVED RULE RAA DERIVED RULE TND

Review 1. Andreas Klappenecker

On the Complexity of the Reflected Logic of Proofs

Thinking of Nested Quantification

Transcription:

1 CIS6333 Homework 1 (due Friday, February 1) 1. (Propositional Calculus - 10 points) --------------------------------------- Let P, Q, R range over state predicates of some program. Prove or disprove the following: a) P (P Q) P b) P (Q R) (P Q) (P R) c) (P Q) P Q d) P Q (P Q) (P Q) 2. (More Propositional Calculus - 6 points) ------------------------------------------ a) Prove P P b) Prove the identity of, P false P, by transforming its more structured side into its simpler side. c) Prove P Q P Q P 3. (Predicate Calculus - 10 points) --------------------------------- a) Prove ( x : R : P Q) (( x : R : P ) ( x : R : Q)) b) Prove ( x : R : P ) ( x : R : P ) c) Translate the following English statements into predicate logic: (i) Every positive integer is smaller than the absolute value of some negative integer. (Use abs.i for the absolute value of i) (ii) Real number i is the largest real solution of the equation f.i = i + 1 (iii) No integer is larger than all others. d) Translate into English the meaning of : (i) ( x, y : x R y R : (f.x < 0 0 < f.y) ( z : z Reals : f.z = 0)) (ii) ( z : z Integers even.z : ( w : w Integers odd.w : z w)) 4. (Closure) -- 30 points ------------------------- Let P and Q range over state predicates of a program prog. Recall that the statements of each action of prog are terminating. Recall that in class we defined: closed P iff {P } prog {P }

2 True or False? (Explain your answer.) a) closed false b) closed true c) (closed P or closed Q) implies (closed (P Q)) d) (closed P ) implies (closed P ) e) (closed (P Q)) implies ( s :: {P } s {Q}) f) (exists s :: {P } s {false}) implies (closed P ) g) closed (P Q) implies ( s :: {P } s {P Q}) h) closed P and closed Q and (R (P Q)) implies closed R i) closed P and closed Q and closed R implies closed (P (Q R)) 5. (Leads-to) -- 24 points -------------------------- Let P, Q, and R range over state predicates of a program prog. True or False? (Explain your answer.) a) false leads-to P Q b) (P leads-to Q) implies ((P Q) leads-to Q ) c) (P leads-to Q) implies ((P R) leads-to Q) d) ((P leads-to Q) and (P leads-to R)) implies (P leads-to (Q R)) e) (P leads-to Q) and ((Q R) leads-to T ) implies ((P R) leads-to T ) f) P leads-to Q and P leads-to R and closed R implies (P leads-to (Q R)) 6. (Variant functions) - 20 points ---------------------------------- For each program described below, prove, by exhibiting a variant function, that the desired progress property holds, or show that the progress property does not hold. Assume the semantics of minimal progress: At every step in the computation, if some action is enabled, then some enabled action is executed.

3 a) Let x.j be an integer for 0 j < N. For each j in the range 0 < j < N, consider the program action: x.j < x.(j 1) x.j, x.(j 1) := x.(j 1), x.j The progress property to be verified is: true leads-to ( j : 0 < j < N : x.j >= x.(j 1)) b) Given are line segments L.1, L.2,..., L.N in the X-Y plane (assume all 2N endpoints are unique) and a program that consists of one action for each pair (L.j, L.K) of line segments: L.j and L.k intersect --> swap any one endpoint of L.j with any one endpoint of L.k, thus making L.j and L.k nonintersecting The progress property to be verified is: the program eventually terminates 7. (Verifying closure and leads-to) ---------------------------------- Consider the program T RANS over the boolean variables b, c, and d : b c := true [] b c d := true Are the following properties true in T RANS? (Explain your answer carefully. A formal proof is not necessary.) (i) closed ( b c) (ii) closed ( c d) (iii) c leads-to d (iv) b leads-to d Does the variant function (3 number of variables of T RANS that are true) suffice to verify the leads-to predicate in part (iii)? in part (iv)?

4 8. (Distributed load balancing) ------------------------------- Prove either that the desired liveness specification holds by exhibiting a variant function, or show that it does not hold. Let x.j be an integer for each node j in an undirected graph. For each pair of neighboring nodes j and k in the graph, consider the program action: (x.j - x.k) > 1 --> x.j, x.k := x.j - 1, x.k + 1 The liveness specification to be verified for this set of actions is: true leads-to (forall j, k: j and k are neighboring nodes: x.j-x.k <= 1)

5 9. (Verifying Hoare-triples) ---------------------------- Let m, n, and l be integers, and M and N be integer constants. Carefully prove or disprove the following Hoare-triples. (Formal proofs are not necessary, but are encouraged). (a) {m = M} m < 0 m := m {m = M } (b) {m > M} m > n m, n := n, m {m n} Here are two new rules about Hoare-triples: Rule of Sequential Assignment: Let x and y be variables and E and F be expressions whose value are in the domain of x and y, respectively,a and let P be a state predicate. {(P [y := F ]) [x := E]} true x := E ; y := F {P } Rule of Guards: Let prog be a program with two actions g1 st1 and g2 st2, and let Q and R be state predicates of prog. Q g1 g2, {Q} g1 st1 {R}, {Q} g2 st2 {R} implies {Q} prog {R} Prove or disprove the following Hoare-triples: (c) {m=m n=n} true n := n+m ; m := n m ; n := n m {m=n n=m} (d) {true} l m n := m [] m l n := l {n = max(l, m)}