Exercises for Discrete Maths

Similar documents
Definition: A binary relation R from a set A to a set B is a subset R A B. Example:

Section Summary. Relations and Functions Properties of Relations. Combining Relations

3 The language of proof

Sets and Motivation for Boolean algebra

With Question/Answer Animations

Relations Graphical View

We want to show P (n) is true for all integers

Induction and Recursion

Chapter Summary. Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms

Proof Techniques (Review of Math 271)

Notes. Relations. Introduction. Notes. Relations. Notes. Definition. Example. Slides by Christopher M. Bourke Instructor: Berthe Y.

Induction and recursion. Chapter 5

Mathematical Induction

MAT115A-21 COMPLETE LECTURE NOTES

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

The Real Number System

Propositional Logic, Predicates, and Equivalence

Mathematical Induction

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

Discrete Structures, Final Exam

Math 324 Summer 2012 Elementary Number Theory Notes on Mathematical Induction

Complete Induction and the Well- Ordering Principle

MATH10040: Chapter 0 Mathematics, Logic and Reasoning

MATH 61-02: PRACTICE PROBLEMS FOR FINAL EXAM

ICS141: Discrete Mathematics for Computer Science I

Relations. We have seen several types of abstract, mathematical objects, including propositions, predicates, sets, and ordered pairs and tuples.

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

CS1800: Strong Induction. Professor Kevin Gold

CSE 1400 Applied Discrete Mathematics Proofs

CS1800: Mathematical Induction. Professor Kevin Gold

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

REVIEW QUESTIONS. Chapter 1: Foundations: Sets, Logic, and Algorithms

Homework #2 Solutions Due: September 5, for all n N n 3 = n2 (n + 1) 2 4

Announcements. Read Section 2.1 (Sets), 2.2 (Set Operations) and 5.1 (Mathematical Induction) Existence Proofs. Non-constructive

Discrete Mathematics: Lectures 6 and 7 Sets, Relations, Functions and Counting Instructor: Arijit Bishnu Date: August 4 and 6, 2009

1 Sequences and Summation

Packet #2: Set Theory & Predicate Calculus. Applied Discrete Mathematics

Automata Theory and Formal Grammars: Lecture 1

MATH 114 Fall 2004 Solutions to practice problems for Final Exam

Foundations of Mathematics MATH 220 FALL 2017 Lecture Notes

CSC Discrete Math I, Spring Relations

1 Predicates and Quantifiers

Notes for Math 290 using Introduction to Mathematical Proofs by Charles E. Roberts, Jr.

means is a subset of. So we say A B for sets A and B if x A we have x B holds. BY CONTRAST, a S means that a is a member of S.

Lecture Notes on DISCRETE MATHEMATICS. Eusebius Doedel

Relations. Relations of Sets N-ary Relations Relational Databases Binary Relation Properties Equivalence Relations. Reading (Epp s textbook)

We are going to discuss what it means for a sequence to converge in three stages: First, we define what it means for a sequence to converge to zero

Lecture Notes 1 Basic Concepts of Mathematics MATH 352

CM10196 Topic 2: Sets, Predicates, Boolean algebras

Math 13, Spring 2013, Lecture B: Midterm

CHAPTER 4 SOME METHODS OF PROOF

Topics in Logic and Proofs

Chapter 5: Sequences, Mathematic Induction, and Recursion

CIS 375 Intro to Discrete Mathematics Exam 3 (Section M001: Green) 6 December Points Possible

CHAPTER 8: EXPLORING R

Discrete Mathematics. Spring 2017

What can you prove by induction?

Writing proofs for MATH 51H Section 2: Set theory, proofs of existential statements, proofs of uniqueness statements, proof by cases

Math 230 Final Exam, Spring 2008

Logic, Sets, and Proofs

5. Use a truth table to determine whether the two statements are equivalent. Let t be a tautology and c be a contradiction.

MATH 363: Discrete Mathematics

Department of Computer Science University at Albany, State University of New York Solutions to Sample Discrete Mathematics Examination I (Spring 2008)

n n P} is a bounded subset Proof. Let A be a nonempty subset of Z, bounded above. Define the set

Week 4-5: Generating Permutations and Combinations

Notation Index. gcd(a, b) (greatest common divisor) NT-16

Tree sets. Reinhard Diestel

a + b = b + a and a b = b a. (a + b) + c = a + (b + c) and (a b) c = a (b c). a (b + c) = a b + a c and (a + b) c = a c + b c.

Lecture 7 Feb 4, 14. Sections 1.7 and 1.8 Some problems from Sec 1.8

Properties of the Integers

Preliminaries. Introduction to EF-games. Inexpressivity results for first-order logic. Normal forms for first-order logic

Introduction to Basic Proof Techniques Mathew A. Johnson

Background for Discrete Mathematics

The semantics of propositional logic

Exam 2. Is g one-to-one? Is g onto? Why? Solution: g is not one-to-one, since for c A, g(b) = g(c) = c. g is not onto, since a / g(a).

ICS141: Discrete Mathematics for Computer Science I

Propositional Logic. What is discrete math? Tautology, equivalence, and inference. Applications

CIS 375 Intro to Discrete Mathematics Exam 3 (Section M004: Blue) 6 December Points Possible

CMSC 27130: Honors Discrete Mathematics

Writing proofs for MATH 61CM, 61DM Week 1: basic logic, proof by contradiction, proof by induction

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

Logic and Proofs. (A brief summary)

Review 3. Andreas Klappenecker

CHAPTER 1. Relations. 1. Relations and Their Properties. Discussion

Chapter 2. Mathematical Reasoning. 2.1 Mathematical Models

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

CSCE 222 Discrete Structures for Computing. Review for the Final. Hyunyoung Lee

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

TECHNISCHE UNIVERSITEIT EINDHOVEN Faculteit Wiskunde en Informatica. Final exam Logic & Set Theory (2IT61) (correction model)

Informatics 1 - Computation & Logic: Tutorial 3

Trinity Christian School Curriculum Guide

Tableau-based decision procedures for the logics of subinterval structures over dense orderings

Do not open this exam until you are told to begin. You will have 75 minutes for the exam.

Proofs. Chapter 2 P P Q Q

Relationships between elements of sets occur in many contexts. Every day we deal with

MATH CSE20 Homework 5 Due Monday November 4

Notes on ordinals and cardinals

Math.3336: Discrete Mathematics. Chapter 9 Relations

CS 173: Induction. Madhusudan Parthasarathy University of Illinois at Urbana-Champaign. February 7, 2016

MATH 324 Summer 2011 Elementary Number Theory. Notes on Mathematical Induction. Recall the following axiom for the set of integers.

Transcription:

Exercises for Discrete Maths Discrete Maths Rosella Gennari http://www.inf.unibz.it/~gennari gennari@inf.unibz.it Computer Science Free University of Bozen-Bolzano

Disclaimer. The course exercises are meant as complementary material for the students of the course of Discrete Maths and Logic at the Free University of Bozen- Bolzano. The grayed out parts were discussed briefly in class; hence exam exercises are not modeled on them.

1 Contents 1. Basic Direct Proofs 1 1.1. Basic Notions 1 1.2. Divisibility 2 2. Indirect Proofs: Contradiction and Well Ordering for Natural Numbers 2 2.1. Prime Numbers 2 2.2. The Quotient Remainder Theorem 3 2.3. Bases 4 3. Order Relations and Well-founded Induction 6 4. Mathematical and Structural Induction 6 4.1. Natural Numbers and Mathematical Induction 7 4.2. Invariants and Mathematical Induction 9 4.3. Structural Induction 10 4.4. Relational Algebras 11 References 12 1.1. Basic Notions. 1. Basic Direct Proofs 1.1.1. Exercise. If a and b are integers then 2a + 4b + 1 is always odd. Proof. 2a + 4b = 2(a + 2b) = 2c which is, by definition, even. Hence 2c + 1 is, by definition, odd. 1.1.2. Exercise. The sum of any two even numbers is even. Proof. Such proofs typically start with let m and n be any two objects with a property, in this case being even. What tableau rule does such a statement remind you of? Then such proofs continue with then there exist two integers, n and m with a certain property ; in this case, the property is m = 2m and n = 2n. Is it wise to use m = m or n = n? Why not? What tableaux rule does this remind you of? The proof then continues using the distributivity property of integers: m + n = 2m + 2n = 2(m + n ) and the definition of being even to conclude that m + n is even.

2 1.1.3. Exercise. Do exercises 39 and 40 of [4]. Prove both statements. Proof. Sketch. 39. The error lies in resolving the existentially quantified statements with the same constant k (what does it remind you of?). 40. The error is inverting thesis and hypothesis. A proof of the statement goes as follows, succinctly: let k be any integer greater than 0. Then k 2 + 2k + 1 = (k + 1) 2, which is composite since k 1. 1.2. Divisibility. 1.2.1. Exercise. For all integers a, b and c, if a b and a c then a (b + c) Proof. By hypothesis and definition of divisibility, there exist r and s so that ar = b and as = c. Then ar + as = b + c, hence, by distributivity, a(r + s) = b + c, that is, a (b + c). 1.2.2. Exercise. Does the vice versa of (1) hold true, that is, if a (b + c) then a b or a c? Proof. The vice-versa is false. To show this, one needs a counter-example. Take a = 2, b = 1 and c = 3. Then a (b + c) and yet a divides neither b nor c. 2. Indirect Proofs: Contradiction and Well Ordering for Natural Numbers In the following section we rely on the well ordering principle for the set N of natural numbers, generalised, in Chapter 5 of [4], to a set S of integers having minimum with respect to the natural order <: Let S be a nonempty subset of N. Then S contains its minimum, that is, there exists an element m of S such that m < b for all natural numbers b of S. 2.1. Prime Numbers. 2.1.1. Exercise. Every composite natural number n > 1 is divisible by a prime. Proof. Assume not and let n be the minimum composite number that is not divisible by any prime. Now, being composite, n = rs, with 1 < r, s < n. By assumption, r and s cannot be prime and they are both divisible by a prime. Contradiction. For an alternative proof, see Example 5.4.1.

2.1.2. Exercise. For any natural number N and prime p, if p N then p (N + 1). Proof. Assume not and let p N and p (N + 1). Then there exist r and s with pr = N and ps = N + 1. Then p(s r) = 1, and hence p = 1, which is a contradiction. 2.1.3. Exercise. There are infinitely many prime natural numbers. Proof. Assume not and let S = {p 1,..., p n } be the finite set of all prime numbers. Consider now N = Π n i=1p i, that is, the product of all the prime numbers in S. Take N + 1. This is divisible by no prime in S by the above Exercise 2.1.2, and hence, by definition of S, it is divisible by no prime. The converse of Exercise 2.1.1 implies that N +1 is prime. But N +1 is a prime that does not belong to S, which is defined as the set of all primes. Contradiction. 2.2. The Quotient Remainder Theorem. 2.2.1. Exercise. Consider the Quotient-Remainder Theorem 4.4.1 of [4], p. 180. Theorem (Quotient Remainder). For every integer a and integer b > 0, there exist and are unique q and r so that a = q.b + r and 0 r < b. Prove it using the well-ordering principle. Using the proof, define an algorithm for computing the remainder of the division between integers. Proof. Take r 1 = a b 0. If r 1 < b then r = r 1. Else take r 2 = r 1 b 0. If r 2 < b then r = r 2. Repeat until finding r n+1 = r n b 0 with r n+1 < b. The existence of such r n+1 is a consequence of the well-ordering principle applied to the set of natural numbers r n b. Now we have got a b = r 1 with r 1 > b > 0 r 1 b = r 2 with r 2 > b > 0. r n b = r n+1 with b > r n+1 0. giving a (n + 1).b = r n+1, and hence a = (n + 1).b + r n+1, with 0 r 1 < b. Notice that a rigorous proof of this equality requires induction on the property I(n + 1) a = (n + 1).b + r n+1 starting with I(1). Try it yourself as soon as you tackle induction. Uniqueness is proved as follows. If a = q 1 b+r 1 and a = q 2 b+r 2 with 0 r 1, r 2 < b then (q 1 q 2 ).b = (r 2 r 1 ). From this, observe that r 1 = r 2 iff q 1 = q 2, being b > 0. 3

4 Let us reason by contradiction and assume that (q 1 q 2 ) 0 (which, given the above observation, is equivalent to (r 1 r 2 ) 0). We now reason by cases. Case 1: (q 1 q 2 ) 1. Take q = (q 1 q 2 ) and r = (r 2 r 1 ). Then qb = r. Since 1 q and b > 0 we have that b q.b. Since r 1 < b and 0 r 2 we have that r < b r 2 < b. The absurdum now follows from b qb = r < b. Case 2: (q 2 q 1 ) 1. Take q = (q 2 q 1 ) and r = (r 1 r 2 ) and reason as in Case 1. As for the algorithm, try it yourself and then check your result against Algorithm 4.8.1, p. 216 of [4]. The Quotient Remainder Theorem allows us to introduce two functions, div b computing the unique quotient and mod b computing the unique rest of the division of any integer by an arbitrarily fixed positive natural number b: for any integer a, a div b is the quotient of the division of a by b; for any integer a, a mod b is the rest of the division of a by b. 2.3. Bases. Consider a natural number b > 1 as a basis (popular bases are 10 and 2). 2.3.1. Exercise. Use the Quotient Remainder Theorem to show that, for every natural number a, there exist 1 r 0,..., r k b 1 so that a = r k b k + r k 1 b k 1 + + r 0 b 0. Proof. The proof is just a sketch and is alternative to the one of Theorem 5.4.1 of [4], which is a special case of this exercise. Call the procedure defined in the Quotient Remainder Theorem (QRT, in brief) to compute remainders with mod and quotients with div in the following procedure in pseudo-code: Algorithm 2.1: Representation(a, b) q a div b; r 0 a mod b; i 1; while q 0 do q q div b; r i q mod b; i i + 1; 1 And they are unique.

Let q 0 = 0 and q i denote the value of q after the i-th execution of the loop body, with i 1. Observe that q i = q i+1.b + r i+1 (*), with 0 r i+1 < b, and hence q i+1 < q i for all i. The procedure terminates by virtue of the well-ordering principle applied to the set of quotients {q i q i > 0}, with the first q n+1 equal to 0. Given (*) and the fact that q n+1 = 0, we have what follows: a = q 0.b + r 0 = (q 1.b + r 1 ).b + r 0 = q 1.b 2 + r 1.b + r 0 =... = q n.b n+1 + r n.b n + + r 1.b 1 + r 0 = = (q n+1.b + r n+1 ).b n+1 + r n.b n + + r 1.b 1 + r 0 = = r n+1.b n+1 + r n.b n + + r 1.b 1 + r 0 Notice that a rigorous proof of the above rewriting requires induction on the following property, I(i): 5 a = q i.b i+1 + r i.b i + + r 1.b 1 + r 0 ftry it by yourself as soon as you tackle induction. 2.3.2. Exercise. How many bits (binary digits) are needed to represent a natural number x in binary notation? (Not Part of the Exam) 754 Chapter 11 Analysis of Algorithm Efficiency By definition of the floor function, then, Proof. From Exercise 7 above, we know that log 2 x = k. x = c k.2 k + + + c 1.2 1 + c 0 b. Recall that the floor of a positive number is its integer part. For instance, 2.82 = 2. Hence property (11.4.2) can be described in words as follows: and hence the number is k + 1. This is equal to the floor of log 2 (x) + 1. The proof of the equality follows from If x is a positive results number in [4], that lies namely: between twotheorem consecutive integer 5.2.3, powers concerning of 2, geometric sequences, seethealso floor of Section the logarithm 4 with below; base 2Example of x is the exponent 11.4.1, of thepp. smaller 753 754, power of of 2. which the graphical interpretation is depicted in Fig. 1, and p. 755. A graphical interpretation follows: then log 2 x lies in here: k + 1 k y = log 2 x 3 2 1 0 1 2 2 2 = 4 2 3 = 8 2 k 2 k+1 If x lies in here Figure 1. From [4], p. 754 One consequence of property (11.4.2) does not appear particularly interesting in its own right but is frequently needed as a step in the analysis of algorithm efficiency. Example 11.4.2 When log 2 (n 1) = log 2 n Prove the following property: For any odd integer n > 1, log 2 (n 1) = log 2 n. 11.4.3 Solution If n is an odd integer that is greater than 1, then n lies strictly between two successive powers of 2: 2 k < n < 2 k+1 for some integer k > 0. 11.4.4 It follows that 2 k n 1because2 k < n and both 2 k and n are integers. Consequently,

6 3. Order Relations and Well-founded Induction An order over a set S is a binary relation R over S (that is, R S S) so that: it is irreflexive: for all a S, (a, a) R (an element is never related to itself via the relation); it is antisymmetric: for all a, b S, if (a, b) R then (b, a) R; it is transitive: if (a, b) R and (b, c) R then (a, c) R. Usually, an order relation is denoted by < and, instead of using the set-theoretic notation (a, b) <, we tend to write a < b. Then (S, <) is referred to as ordering. Consider an ordering (S, <). The ordering is total if, for all a and b of S, it is (either) a < b or b < a; else the ordering is partial. An ordering (S, <) is well-founded if the following holds for all non-empty T S: T has a minimal element with respect to <, that is, there exists m T so that, for all n S, if n < m then n T. A well ordering (S, <) is an ordering that is well-founded and total; being the ordering total, an element that is minimal is also the unique minimal element, that is, it is the minimum of S with respect to <. The following theorem, concerning well-founded orderings, goes under the name of well-founded induction: it yields the other forms of induction we will work with, namely, mathematical induction for natural numbers and structural induction for inductively defined sets such as the languages of propositional or first-order logic, or trees. This theorem, alone, could motivate why orderings, and well-founded orderings in particular are important in the study of computer science. Theorem 1 (Well-founded Induction). Consider a well-founded ordering (S, <). Let P be a subset of S, that is, a property of S elements. Assume the following for P and for any y S: for all x S, whenever x < y then x P (i.e., P holds for all x so that x < y); this yields that y P (i.e., P holds for y). Then P = S (that is, P holds for all the elements of S). For a rather comprehensive and yet accessible overview of the topic, see Part I, Chapter 2 of [2]. 4. Mathematical and Structural Induction The following exercises are based on Chapter 5 of [4].

4.1. Natural Numbers and Mathematical Induction. Mathematical induction can be derived from well-founded induction once known that (N, <) is a wellfounded ordering. Consider a property P of natural numbers, that is, P N. You suspect that P holds for all natural numbers greater than a given one, say m (this is fixed and depends on P, e.g., it can be 0). A proof by mathematical induction of the statement P holds for all natural numbers greater than or equal to m goes as follows. Idea of a Proof by (Week) Mathematical Induction. Consider a property P N. In order to prove that P = N {i N i < m} (that is, P holds for all natural numbers greater than or equal to m) it is sufficient to prove what follows. induction basis: m P (that is, P holds true for m); induction step: take a generic n N {i N i < m}; as inductive hypothesis, assume that n P (that is, P holds true for n); using the inductive hypothesis, prove that (n + 1) P (that is, P holds true for n + 1). Next, let us see proofs my mathematical induction working with sequences and inequalities. Sequences are functions with domain the set of natural numbers. They can be defined explicitly with a formula, in terms of other known functions, or recursively in terms of themselves. See Section 5.9, p. 290 of [4]. 7 4.1.1. Exercise. Reason on how you can explicitly and recursively define a sequence with first terms as follows: (i) with first terms 1, 1, 2, 6, 24, 120; (ii) with first terms 0, 1, 0, 1, 0, 1; (iii) with first terms 0, 2, 4, 6, 8, 10. Proof. (i) Each term s n is equal to n!, and hence a recursive definition of the sequence is s 0 = 1 and, for every n 1, s n = n.s (n 1). (ii) The sequence of terms s n is alternating 0 s and 1 s, returning the remainders of the division of n by 2, and hence a recursive definition of the sequence is s 0 = 0 and, for every n 1, s n = (s (n 1) + 1) mod 2. (iii) The sequence is alternating positive and negative even integers, starting with s 0 = 0 and s 1 = 2, of the form { 2n if n is even s n = 2n otherwise,

8 and hence a recursive definition of the sequence, using the sign function sgn defined over integers m as 1 if m < 0 sgn(m) = 0 if m = 0 1 otherwise, is s 0 = 0, s 1 = 2 and, for every n 2, s n = sgn(s n 1 ).( s (n 1) +2). Alternatively, for every n 2, s n = ( 1) n.( s (n 1) +2) 4.1.2. Exercise. Reason on how you can recursively define a sequence with first terms as follows: (i) with first terms 1, 1, 2, 3, 5, 8, 13; (ii) with first terms 0, 1, 1, 2, 2, 3, 3, 4. Proof. (i) The given terms can be from the Fibonacci sequence for rabbits reproduction: s 0 = 1 and s 1 = 1; for every n 2, s n = s n 2 + s n 1 ; (ii) The first two terms are 0 and 1; the subsequent terms are obtained from 0 and 1 by recursively adding 1. A recursive definition of a sequence with those terms goes as follows: s 0 = 0 and s 1 = 1; for every n 2, s n+1 = s n 1 + 1. 4.1.3. Exercise. Find the explicit definition of the sequence that is recursively defined as follows: a 0 =0 a n+1 = 1 2 a n Use induction to prove that your definition is correct. Proof. We start computing the first 6 values and conjecture that, for each n, the explicit definition could be as follows: b n = n n + 1 In order to prove that, for every natural number n, a n = b n, we conduct a proof by mathematical induction. (Induction basis) The explicit definition gives b 0 = 0 which is equal to a 0. (Induction step) Let us assume that b n = a n and prove that b n+1 = a n+1. Let us 1 reason forward on a n+1. This is equal to 2 a n and hence, by induction hypothesis,. Therefore a n+1 = n+1 which is b n+2 n+1. to 1 2 n n+1

4.1.4. Exercise. Tackle Exercises 5.2.5, p. 256, and 5.2.H.33, p. 258, from Chapter 5 of [4]. 9 4.1.5. Exercise. Let n P be the following statement ( n(n + 1) 1 3 + 2 3 + + n 3 = 2 with n N and n 1. Tackle the following questions. (1) What statement is 1 P? Prove that 1 P, which is the basis step of the induction proof. (2) What statement is (n + 1) P? (3) Assume n P as inductive hypothesis. Using this, prove (n + 1) P. In such a manner, you tackle the induction step. ) 2 4.1.6. Exercise. Let n P be the following statement n < 2 n with n N and n 0. Tackle the following questions. (1) What statement is 0 P? Does 0 P hold true? (2) What statement is (n + 1) P? (3) Assume n P as inductive hypothesis. Using this, prove (n + 1) P. In such a manner, you tackle the induction step. Proof. (1) n P is 1 < 2 1, which is true. This is the basis step of an induction proof of the inequality. (2) (n + 1) P is n + 1 < 2 n+1 (3) Let us assume n P, that is, n < 2 n, and let us prove (n + 1) P, that is, n + 1 < 2 n+1. We reason forward from our assumption: since n < 2 n, then 2.n < 2.2 n = 2 n+1 ( ). For all n 1, n + 1 n + n = 2.n ( ). Now, ( ) and ( ) yield that n + 1 < 2 n+1, that is, (n + 1) P holds true. 4.2. Invariants and Mathematical Induction. One of the most important applications of induction is proving that a program or process preserves certain properties from state to state: this property is an invariant. See Section 5.5 of [4] for a definition of (strong) program correctness and of loop invariants.

10 4.2.1. Exercise. Consider a robot that can move only diagonally along an N N grid. More precisely: (0) the robot starts at (0, 0); (I) at step (m, n), the robot moves to (m + k, n + j) where k, j {1, 1}. Can the robot ever reach position (0, 1)? (Taken from [1]) Proof. The answer is negative. This is obtained by proving that the property the sum of the robot coordinates is even is an invariant of the robot moves. 4.2.2. Exercise. Prove that property I(i) in the proof of Exercise 2.3.7 is a loop invariant: for each iteration of the loop, if the predicate is true before the iteration, then it is true after the iteration. Proof. The proof requires induction. Start with proving I(0), that is, that the claimed property holds before the first iteration of the loop. Assume that I(n) holds true at the start of the (n + 1)-th iteration, and that the guard, that is, the while condition, is true: prove that I(n + 1) is true at the end of the iteration. 4.3. Structural Induction. Consider a set U, a subset B of U and functions f 1,..., f n defined from U to U. A subset S of U is defined by structural induction (or generated) from B and the above functions if: (1) P S; (2) for any function f i and s 1,..., s m of S to which f i is applicable, f i (s 1,..., s m ) is in S; (3) nothing else belongs to S. An example of a set defined by structural induction is the set of formulas over a set P of propositions with the connectives defined as functions. For others, see Chapter 5 of [4]. Another is the set of (syntactically correct) RA expressions or queries (see slides 65 67 of the last set of slides of the course teacher). If S is a set defined by structural induction, then one can prove properties of S as follows. We limit our exposition to the case in which S is defined from P and two functions, f that is binary and g that is unary, for clarity sake. Idea of a Proof by Structural Induction. Consider a set S that is defined by structural induction from a set P, a binary function f and a unary function g. Consider a property P r S. In order to prove that P r = S (that is, P r holds for all elements of S) it is sufficient to prove what follows: induction basis: P P r (that is, P r holds true for all elements of P ); induction step: take generic elements s 1, s 2 and s of S; as inductive hypothesis, assume that s 1 P r, s 2 P r and s P r (that is, P r holds true for s 1, s 2 and s); using the inductive hypothesis, prove that f(s 1, s 2 ) P r and g(s) P r (that is, P r holds true for f(s 1, s 2 ) and g(s)). The fact that a proof by structural induction works for proving properties concerning all elements of S can be derived from well-founded induction, providing S with a suitable order, or directly from the structural induction definition of S.

11 A B C 1 4 5 2 5 6 C D 4 7 5 8 6 9 Table 1. Relations R (to the left) and S (to the right) Next, let us see how to conduct structural induction proofs with inductively defined sets. 4.3.1. Exercise. Let P be a non-empty set of propositions and L(P ) be the propositional language over P. Using structural induction, prove the following property concerning interpretations over L(P ): if I 1 (p) = I 2 (p) for all p P, then I 1 = φ iff I 2 = φ for all φ L(P ). (This justifies the fact that for a formula with n propositions you only need to consider 2 n interpretations or, differently stated, truth-table rows.) Proof. We reason by structural induction on L(P ). (Induction basis) The basis case follows from the if-condition. (Induction step) We consider three cases (the others are similarly dealt with): φ = ψ, assuming that the property holds for ψ; φ = ψ 1 ψ 2, assuming that the property holds for ψ 1 and ψ 2 ; φ = ψ 1 ψ 2, assuming that the property holds for ψ 1 and ψ 2. Case 1) I 1 = φ = ψ iff I 1 = ψ iff (by induction hypothesis) I 2 = ψ iff I 2 = ψ = φ. Case 2) I 1 = φ = ψ 1 ψ 2 iff I 1 = ψ 1 or I 1 = ψ 2 iff (by induction hypothesis) I 2 = ψ 2 or I 2 = ψ 2 iff I 2 = ψ 1 ψ 2 = φ. Case 3) I 1 = φ = ψ 1 ψ 2 iff I 1 = ψ 1 and I 1 = ψ 2 iff (by induction hypothesis) I 2 = ψ 2 and I 2 = ψ 2 iff I 2 = ψ 1 ψ 2 = φ. 4.4. Relational Algebras. For this part, refer to Sections 8.1 8.3 of [4] and the course slides. 4.4.1. Exercise. Given the relations R and S in Table 1, compute the following: π A,B (R), π B (S), σ A=1 (R), σ A=1 B=4 (R), R S, σ A=1 B=4 (R S). 4.4.2. Exercise. Compute the transitive closure of the binary relations in Fig. 2.

1), (1, 2), (2, 2), (3, 3)} 1), (1, 2), (1, 3), (2, 2), (2, 3), (3, 3)} 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), 3)} In Exercises 9 11 determine whether the relation with the e relations on {0, 1, 2, 3} are partial orderne directed graph shown is a partial order. the properties of a partial ordering that 9. 10. 12. a b a b 2), (3, 3)} 4.4.3. Exercise. Consider the definition (by structural induction) of I(Q), where Q is a query, as in slides 69 70 of the course teacher. Prove some of the equivalences 1), (2, 0), (2, 2), (2, 3), (3, 3)} in slides 86 88 of the course teacher. 1), (1, 2), (2, 2), (3, 1), (3, 3)} a b a b ca d b c d 1), (1, 2), (1, 3), (2, 0), (2, 2), (2, 3), 3)} 11. a b 1), (0, 2), (0, 3), (1, c 0), (1, 1), d(1, 2), c d c d c d 0), (2, 2), (3, 3)} 12. Let (S, R) be a poset. Show that (S,R set if S is the set of all people in the world 1 ) is also a poset, Figure 2. where Digraphs R, where a and b are people, if 1 of isrelations the inverse of R. The poset (S,R 1 ) is called the dual of (S, R). han b? 13. References Find the duals of these posets. ler than b? a) ({0, 1, 2}, ) b) (Z, ) [1] Lehman, E., Leighton, F. T., and Meyer, A. R. Mathematics for Computer is an ancestor of b? c) (P (Z), ) d) (Z + Science. Online, 2010., ) [2] Michal Walicki. Introduction to ve a common friend? 14. Mathematical Which of Logic. these World pairs Scientific, of elements preprint are comparable from http: in the //www.ii.uib.no/%7emichal/und/i227/book/inf227.pdf, poset (Z set if S is the set of all people in the world +, )? 2011. [3] Rosen, K. Discrete and Its Applications. McGraw Hill, 2011., where a and b are [4] people, SusannaifEpp. Discrete Mathematicsa) with5, Applications. 15 b) BROOKS/COLE, 6, 9 c) 8, 2010. 16 d) 7, 7 rter than b? ore than b? is a descendant of b? not have a common friend? e are posets? b) (Z, =) c) (Z, ) d) (Z, ) e are posets? b) (R, <) c) (R, ) d) (R, =) ether the relations represented by these ices are partial orders. b) 1 1 1 0 1 0 0 0 1 0 0 1 1 c) 1 0 1 0 0 1 1 0 0 0 1 1 1 1 0 1 15. Find two incomparable elements in these posets. a) (P({0, 1, 2}), ) b) ({1, 2, 4, 6, 8}, ) 16. Let S ={1, 2, 3, 4}. With respect to the lexicographic order based on the usual less than relation, a) find all pairs in S S less than (2, 3). b) find all pairs in S S greater than (3, 1). c) draw the Hasse diagram of the poset (S S, ). 17. Find the lexicographic ordering of these n-tuples: a) (1, 1, 2), (1, 2, 1) b) (0, 1, 2, 3), (0, 1, 3, 2) c) (1, 0, 1, 0, 1), (0, 1, 1, 1, 0) 18. Find the lexicographic ordering of these strings of lowercase English letters: a) quack, quick, quicksilver, quicksand, quacking b) open, opener, opera, operand, opened c) zoo, zero, zoom, zoology, zoological 19. Find the lexicographic ordering of the bit strings 0, 01, 11, 001, 010, 011, 0001, and 0101 based on the ordering 0 < 1. 20. Draw the Hasse diagram for the greater than or equal to relation on {0, 1, 2, 3, 4, 5}.