Mathematically Rigorous Software Design Review of mathematical prerequisites

Similar documents
AXIOMS FOR THE INTEGERS

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

Chapter 3: Propositional Languages

Discrete Mathematics Lecture 4. Harper Langston New York University

Introductory logic and sets for Computer scientists

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2

Propositional Logic. Part I

MA651 Topology. Lecture 4. Topological spaces 2

Algebra of Sets (Mathematics & Logic A)

Propositional Logic Formal Syntax and Semantics. Computability and Logic

Chapter 3. Set Theory. 3.1 What is a Set?

Handout 9: Imperative Programs and State

CSE 215: Foundations of Computer Science Recitation Exercises Set #4 Stony Brook University. Name: ID#: Section #: Score: / 4

CSE 20 DISCRETE MATH. Fall

Algebraic Expressions

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1

Summary of Course Coverage

4&5 Binary Operations and Relations. The Integers. (part I)

1.1 - Introduction to Sets

CSE 20 DISCRETE MATH. Winter

COUNTING AND PROBABILITY

These notes present some properties of chordal graphs, a set of undirected graphs that are important for undirected graphical models.

LECTURE 8: SETS. Software Engineering Mike Wooldridge

Lecture 15: The subspace topology, Closed sets

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

Lecture 4: examples of topological spaces, coarser and finer topologies, bases and closed sets

Lecture Notes on Induction and Recursion

CS40-S13: Functional Completeness

Notes for Recitation 8

Computer Science and Mathematics. Part I: Fundamental Mathematical Concepts Winfried Kurth

Guidelines for Writing Mathematical Proofs

Propositional Logic. Andreas Klappenecker

Functions. How is this definition written in symbolic logic notation?

Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

CS422 - Programming Language Design

Section 6.3: Further Rules for Counting Sets

Lecture : Topological Space

Figure 1.1: This is an illustration of a generic set and its elements.

Pebble Sets in Convex Polygons

EDAA40 At home exercises 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

Recursively Defined Functions

MC 302 GRAPH THEORY 10/1/13 Solutions to HW #2 50 points + 6 XC points

CS4215 Programming Language Implementation. Martin Henz

3 Pairs and Lists. 3.1 Formal vs. Informal Proofs

CSC Discrete Math I, Spring Sets

Programming Languages Third Edition

DISCRETE MATHEMATICS

Review of Sets. Review. Philippe B. Laval. Current Semester. Kennesaw State University. Philippe B. Laval (KSU) Sets Current Semester 1 / 16

CSE 215: Foundations of Computer Science Recitation Exercises Set #9 Stony Brook University. Name: ID#: Section #: Score: / 4

The set consisting of all natural numbers that are in A and are in B is the set f1; 3; 5g;

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

The Intersection of Two Sets

CHAPTER 8. Copyright Cengage Learning. All rights reserved.

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections p.

Binary Decision Diagrams

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

THREE LECTURES ON BASIC TOPOLOGY. 1. Basic notions.

Lecture (04) Boolean Algebra and Logic Gates

Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee

MATH 22 MORE ABOUT FUNCTIONS. Lecture M: 10/14/2003. Form follows function. Louis Henri Sullivan

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

MAT 3271: Selected Solutions to the Assignment 6

PROOF OF THE COLLATZ CONJECTURE KURMET SULTAN. Almaty, Kazakhstan. ORCID ACKNOWLEDGMENTS

CSC 501 Semantics of Programming Languages

Formal semantics of loosely typed languages. Joep Verkoelen Vincent Driessen

EXTREME POINTS AND AFFINE EQUIVALENCE

A GRAPH FROM THE VIEWPOINT OF ALGEBRAIC TOPOLOGY

RATIONAL CURVES ON SMOOTH CUBIC HYPERSURFACES. Contents 1. Introduction 1 2. The proof of Theorem References 9

correlated to the Michigan High School Mathematics Content Expectations

STABILITY AND PARADOX IN ALGORITHMIC LOGIC

Inference rule for Induction

Integrated Math I. IM1.1.3 Understand and use the distributive, associative, and commutative properties.

Appendix 1. Description Logic Terminology

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

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning

4 Generating functions in two variables

Propositional Calculus. Math Foundations of Computer Science

CS100: DISCRETE STRUCTURES

9.5 Equivalence Relations

Z Notation. June 21, 2018

Propositional Calculus. Math Foundations of Computer Science

T. Background material: Topology

Sub: EM-III (14MA301) Section: A & B Date: 13/07/17 One Mark Questions: 1. a) Write the iterative formula to compute 3 N by Newton s method.

LOGIC AND DISCRETE MATHEMATICS

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1

An Interesting Way to Combine Numbers

Topology Homework 3. Section Section 3.3. Samuel Otten

Answers to specimen paper questions. Most of the answers below go into rather more detail than is really needed. Please let me know of any mistakes.

PRG PROGRAMMING ESSENTIALS. Lecture 2 Program flow, Conditionals, Loops

BOOLEAN ALGEBRA AND CIRCUITS

Lower Bounds for Cutting Planes (Extended Abstract)

Characterization of Boolean Topological Logics

Topology - I. Michael Shulman WOMP 2004

Chapter 1: Number and Operations

CMPSCI 250: Introduction to Computation. Lecture #7: Quantifiers and Languages 6 February 2012

Equations and Functions, Variables and Expressions

SEVENTH EDITION and EXPANDED SEVENTH EDITION

3.7 Denotational Semantics

Transcription:

Mathematically Rigorous Software Design 2002 September 27 Part 1: Boolean algebra 1. Define the Boolean functions and, or, not, implication ( ), equivalence ( ) and equals (=) by truth tables. 2. In an expression the various functions are evaluated in the following order unless otherwise indicated by parentheses: (exponentiation) +, - (sign) *, / (multiplication, division) +, - (addition, subtraction) <, >, =,,, (relations) not (also written ) and (also written ) or (also written ),, (logical implications) Prove that the following equalities hold for all x, y, z IB (IB = {false, true}). Base your proofs on your answer to question 1 above. 2.1. (x and y) = (y and x) 2.2. (x or y) = (y or x) 2.3. (x and (y and z)) = ((x and y) and z) 2.4. (x or (y or z)) = ((x or y) or z) 2.5. (x and (y or z)) = ((x and y) or (x and z)) 2.6. (x or (y and z)) = ((x or y) and (x or z)) 2.7. (x and not x) = false 2.8. (x and false) = false 2.9. (x and x) = x 2.10. (x and true) = x 2.11. (x or false) = x 2.12. (x or x) = x 2.13. (x or true) = true Part 1, page 1 of 3

2.14. (x or not x) = true 2.15. (x or (x and y)) = x 2.16. (x or (not x and y)) = (x or y) 2.17. (not (not x)) = x 2.18. (not (x and y)) = ((not x) or (not y)) 2.19. (not (x or y)) = ((not x) and (not y)) 2.20. (x y) = (not (x and not y)) 2.21. (x y) = ((not x) or y) 2.22. (x y) = ((not y) (not x)) 2.23. (z and (x y)) = (z and ((z and x) y)) 2.24. (x = y) = ((x and y) or (not x and not y)) 2.25. (x (y=z)) = ((x and y)=(x and z)) 2.26. (x (y=z)) ((x and y)=(x and z)) What is the practical significance of 2.26? 3. Let B, C and D be Boolean variables or functions (i.e. functions with values in IB = {false, true}). The function F is defined as follows: F = C, if B = true, = D, if B = false Write an equivalent expression for F using only B, C, D, and the Boolean functions and, or and not. Prove that your expression for F satisifes the definition above. 4. Simplify or expand the following expressions: 4.1: x and (y z) 4.2: x or (y z) 4.3: (x and y) z 4.4: (x or y) z 4.5: -x>0 and x<0 or x>0 and not x<0 4.6: -x 0 and x<0 or x 0 and not x<0 4.7: -x<0 and x<0 or x<0 and not x<0 4.8: -x 0 and x<0 or x 0 and not x<0 4.9: (w or x) and (y or z) Part 1, page 2 of 3

4.10: [ia na or ib nb] and [ib>nb or ia na and A(ia) B(ib)] 4.11: [ia na or ib nb] and [ib>nb or ia na and ib nb and A(ia) B(ib)] 4.12: not (ib>nb or ia na and A(ia) B(ib)) 5. Show that {not (ia na and [ib>nb or A(ia) B(ib)])} = {ib nb and [ia>na or A(ia)>B(ib)]} when (ia na or ib nb). Part 1, page 3 of 3

Mathematically Rigorous Software Design Part 2: Notation 1. The notation f.x is often used in place of the more classical form f(x). The dot (.) is interpreted as an infix operator with the meaning "functional application", i.e. the application of the function f to the argument x. 2. Proofs are often written in the following format: = = expression 1 expression 2 expression 3 etc. This is defined to mean (expression 1 = expression 2) and (expression 2 = expression 3), etc. Similarly, expression 1 expression 2 expression 3 is defined to mean (expression 1 expression 2) and (expression 2 expression 3). 3. The notation (op i : r.i : exp.i) means exp.i1 op exp.i2 op exp.i3... where op is any operator (function) satisfying the commutative and associative laws and where i1, i2, i3, etc. are all the values of i for which r.i is true. The expression (function) exp need not be Boolean; its range may be any set consistent with the definition of the particular op. The above definition can be extended to cover situations in which op is not commutative or not associative (or both). If op is not commutative, then the order in which the elements i1, i2, etc. appear must be defined. Usually, this order will be the order defined on the set to which the values of i1, i2, etc. belong. This set will often be specified within the Boolean function r. If op is not associative, the grouping (implied parentheses) must be specified, e.g. left to right. Part 2, page 1 of 2

If quantification over the empty set is specified (i.e. if there is no value for i for which r.i is true), then the value of the entire expression is defined to be the identity element of the operator op. (Why is this convention appropriate and convenient?) ( i : i S : exp.i), (A i : i S : exp.i) and ( i : i S : exp.i) are often written instead of ( i S:exp.i) or other similar forms. Similarly, ( i : i S : exp.i), (E i : i S : exp.i) and ( i : i S : exp.i) are often written for ( i S:exp.i) or other similar forms. 4. Many target groups of readers are not particularly familiar with mathematical symbols such as,,,, etc. They find the resulting, often rather dense, expressions difficult to read and understand. Readability can often be facilitated by using more descriptive notation such as and, or, etc. instead of the mathematical symbols. Splitting an expression over two or more lines and indenting appropriately can often improve readability of long expressions considerably. 5. The familiar Σ notation can be generalized to commutative and associative operations (functions) other than addition in the obvious manner, e.g. etc. and i=1 n exp.i Formally, op i=1 n exp.i means (op i : i Z 1 i n : exp.i). Part 2, page 2 of 2

Mathematically Rigorous Software Design Part 3: Images and preimages of a function 1. Let F be a function with domain Xd and range Yr; F maps any element of Xd to some element of Yr. Further, let X1 and Xd be subsets of a set X. Similarly, let Y1 and Yr be subsets of a set Y. The image of X1 under F is defined as the set of all elements of Y to which F maps elements of X1. Somewhat more precisely, the image of X1 under F is the set of all F.x for which x X1 and F.x is defined. Formally, the image of X1 under F is the set ( x : x X1 Xd : {F.x}) The image of X1 under F is written F.X1 and is a subset of Yr (and hence of Y). The function referred to in the expression F.X1 (where X1 X) is, strictly speaking, a different function than the one referred to in the expression F.x (where x X). The same notation is usually used, however, since the two functions are so closely related. The preimage of Y1 under F is defined as the set of all elements of X which F maps to elements of Y1. Somewhat more precisely, the preimage of Y1 under F is the set of all x for which F.x is defined and in Y1. Formally, the preimage of Y1 under F is the set ( x : x Xd F.x Y1 : {x}) The preimage of Y1 under F is written F -1.Y1 and is a subset of Xd (and hence of X). The range Yr of F is the image of X under F. The domain Xd of F is the preimage of Y under F. 2. The formation of images and preimages are monotonic operations: X1 X2 F.X1 F.X2 Y1 Y2 F -1.Y1 F -1.Y2 The reverse implications are not, however, generally true. 3. The images and preimages of intersections and unions are equal to the intersections and unions of images and preimages: F.(X1 X2) = (F.X1) (F.X2) [= valid only if F is a one-to-one function, otherwise ] F.(X1 X2) = (F.X1) (F.X2) Part 3, page 1 of 2

F -1.(Y1 Y2) = (F -1.Y1) (F -1.Y2) F -1.(Y1 Y2) = (F -1.Y1) (F -1.Y2) where X1 and X2 are subsets of X and Y1 and Y2 are subsets of Y (cf. above). 4. Image formation and preimage formation are not inverses of each other, that is, neither nor F -1.(F.X1) = X1 F.(F -1.Y1) = Y1 holds in general. F -1.(F.X1) will not contain elements x in X1 for which F.x is undefined. F -1.(F.X1) will contain elements not in X1 which are mapped to values in F.X1. F.(F -1.Y1) does not contain elements of Y1 outside the range of F. F -1.Y1 contains only elements which F maps into Y1, so it is true that F.(F -1.Y1) Y1 It is recommended that the student prove the above statements and find counterexamples of those statements purported not to be true. Part 3, page 2 of 2

Part 4: Boolean series Mathematically Rigorous Software Design 1. The value of the empty and series, e.g. and 0 i=1 exp.i is defined to be true. The value of the empty or series is defined to be false. (Why?) 2. A term may be taken out of a Boolean series only if the series is not empty. E.g. the equality [and n i=1 exp.i] = [exp.n and n-1 i=1 exp.i] is true in general only if 1 n. To take a term out of a series which may be empty, one must in effect make a case distinction, e.g. by and-ing the series in question with a tautology (a universally true expression) which distinguishes between an empty and a non-empty series. In the above example, a suitable such expression is (n<1 or 1 n). The resulting generally valid expressions for removing a term from a series are: [and i=a b exp.i] = [b<a or a b and exp.b and i=a b-1 exp.i] [or i=a b exp.i] = [a b and (exp.b or i=a b-1 exp.i)] Part 4, page 1 of 1

Mathematically Rigorous Software Design Part 5: Extending the domain of a function 1. One sometimes wants to extend the definition of a function for arguments not in the domain of the original function. The general pattern of such an extension is as follows. Let f be a function with domain D and range R. Furthermore let D' be a superset of D. The function f' is defined in the following general way: f'.x = f.x, if x D =?, otherwise where? represents any arbitrary value. One often useful convention is to replace the? above with a value (an element) undef which is neither in D nor in R. Other conventions, in which other values are substituted for? above, are also useful in specific contexts. 2. In modelling mathematically some types of run time errors, e.g. those resulting from references to undeclared variables, one can extend the definitions of the Boolean functions and, or and not over the set {false, undef, true} in different ways. See The Spine of Software, p. 271 ff. Part 5, page 1 of 1

Part 6: Proofs by induction Mathematically Rigorous Software Design Often one wants to prove that a proposition (expression, Boolean function) E with an integer argument is true for all values of its argument. Proof by induction is one structural form for such a proof. In such a proof, one proves that (1) the proposition is true for some particular value of its argument and (2) the truth of the proposition for one value of its argument implies the truth of the proposition for the next value of the argument. Together, these two steps prove that the proposition is true for every value of its argument greater than or equal to the particular value used in part 1 of the proof. Part 1 of the proof is called the base case. Part 2 is called the inductive step. Typically the theorem to be proved is of the form: Theorem: If... (a given hypothesis) is true, then E.n is true for all integer values of n 0. Often the given hypothesis consists of an iterative definition of a function and the proposition E.n states that the value of the function for the argument n is given by a closed (non-iterative) formula. The proof by induction of a theorem stated in the above form consists of the two parts mentioned above, i.e. of proofs of the following lemmata: Lemma 1: E.0 is true. Lemma 2: E.n E.(n+1) for any (each, every, all) integer n 0. In the proofs of these two lemmata one may, of course, use (assume the truth of) the hypothesis of original theorem. In some cases, lemma 2 above cannot be proved because the truth of E.n alone does not imply the truth of E.(n+1). Sometimes the truth of all of the propositions E.0, E.1,... E.n is needed to prove that E.(n+1) is true. In such cases, the following alternative form of lemma 2 must be proved: Lemma 2 alternative: ( i : i Z 0 i n : E.i) E.(n+1) for any (each, every, all) integer n 0. If one is not careful to structure and formulate an attempted proof by induction clearly and correctly, mistakes are often made. It is worthwhile to write every proof by induction painstakingly precisely and accurately. The time taken to formulate the proof correctly on the Part 6, page 1 of 2

first attempt is saved by eliminating the necessity to find and correct errors later and to rewrite the proof. Part 6, page 2 of 2