1 1/6/2016 math 224 – discrete mathematics predicate calculus some of the statements that are...

16
1 01/28/22 MATH 224 – Discrete Mathematics Predicate Calculus Some of the statements that are important in mathematics and computer science are not propositions. For example, X % 2 == 0 is not true for all integers, but only even integers. In order to make statements about the truth of this type of statement it is necessary to introduce the quantifiers for all and there exists . So for example, we can make a statement about an array of integers such as the upper bound below. is of course true for every element of A. Given an array of integers A, a statement such as

Upload: karin-moore

Post on 19-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

104/21/23

MATH 224 – Discrete MathematicsPredicate Calculus

Some of the statements that are important in mathematics and computer science are not propositions. For example, X % 2 == 0 is not true for all integers, but only even integers. In order to make statements about the truth of this type of statement it is necessary to introduce the quantifiers for all and there exists . So for example,

we can make a statement about an array of integers such as the upper bound below.

is of course true for every element of A.

Given an array of integers A, a statement such as

204/21/23

MATH 224 – Discrete MathematicsPredicate Calculus

Predicate calculus allows us to make precise statements about the properties of a specific data structure. Consider the example below. *

Can you rewrite the predicate above using the conditional connective?

*Note that the set of allowable values for i is called the domain. Thus in this example the domain is the set of integers for i between 0 and N – 2.

304/21/23

MATH 224 – Discrete MathematicsPredicate Calculus

Predicate calculus allows us to make precise statements about the properties of a specific data during the execution of an algorithm. Consider the example below.

What is the domain for Y? What about the domain for X? How would you quantify X?

404/21/23

MATH 224 – Discrete MathematicsPredicate Calculus

What are some values for n0 and c that will make the predicate clause above true?

504/21/23

MATH 224 – Discrete Mathematics

Substitution of Quantifiers

What are the equivalent predicates for the following with replaced by and

replaced by .

604/21/23

MATH 224 – Discrete MathematicsOrder of Quantifiers

Look back at Slide 1. How would express the fact that there is one upper bound for all elements in the array A? Now look at Slide 3. How would express the invariant for the bean algorithm using quantifiers for both X and Y?

704/21/23

MATH 224 – Discrete Mathematics

Order of Quantifiers

804/21/23

MATH 224 – Discrete MathematicsProofs

In the predicate calculus, it is not possible to use truth tables to prove most results since statements depend on one or more variables. This makes the job of proving results quite a bit more difficult. Would it be possible to use truth tables if the domain of the variable(s) are finite?

Logical systems consists of a set of definitions, axioms, and rules of inference. The axioms, also called postulates, are taken to be true without proof. The rules of inference tell us how to derive new results from axioms and theorems that have already been proven. This mimics the way people make decisions about the “real” world. We have already seen examples of the use of inference in deriving a sequence of equivalences in order to show that a compound proposition is a tautology.

904/21/23

MATH 224 – Discrete MathematicsProofs

Let’s consider a simple example. We observe that whenever water is boiling if we measure it’s temperature it will be 100o C. This then becomes one of our axioms. Later we find a pot of water that is boiling. Without measuring its temperature we conclude that the temperature is 100o C. This is an example of the rule of inference called modus pones.

In table 1, on Page 66, 8 rules of inference for the propositional calculus are listed, but only the first one is needed if we start with an appropriate set of axioms. The three axioms listed below are sufficient to prove any result in the propositional calculus. Of course it is almost always easier to use truth table.

1. A → (B → A)

2. (A → (B → C)) → ((A → B) → (A → C))

3. (¬B → ¬A) → ((¬B → A) → B)

Show that each of these is a tautology using truth tables.

1004/21/23

MATH 224 – Discrete MathematicsProofs

With quantifiers additional axioms and rules of inference are needed. We will not consider the technical details of the predicate calculus but will proceed to consider several informal proofs using the rules of inference in Table 1 on page 66 and Table 2 on page 70 from our text book.

Modus pones states that given p is true and given that p → q it follows that q is true. This rule corresponds to the definition of the conditional statement. In fact, all the other rules of inference for the propositional calculus can be proved from this one and the axioms.

Table 2 shows the additional rules need for the predicate calculus. In

1104/21/23

MATH 224 – Discrete MathematicsPropositional Calculus Proof

Example 7 on page 67 - 68 from our textbook: Given p → q, ¬p → r, r → s, prove that ¬q → s

1.p → q Given (or Hypothesis)2.¬q → ¬ p Contrapositve (an equivalence from section 1.2)3.¬p → r Given4.¬q → r Hypothetical syllogism from steps 2 and 3 (transitive)5.r → s Given6.¬q → s Hypothetical syllogism from steps 4 and 5

1204/21/23

MATH 224 – Discrete MathematicsProofs

Example of a direct proof: Prove that the sum of two even numbers is even.

1. Let X and Y be even numbers.

2. Then by the definition of even A(X = 2A) and B(Y = 2B).

3. Thus X + Y = 2A + 2B = 2(A+B).

4. By the definition of even, 2(A+B) is even and thus X plus Y is even.

Using formal notation we have

( X, Y)( X even Y even → X + Y is even)

1304/21/23

MATH 224 – Discrete MathematicsProof Strategies

Direct proofs are the most obvious, but sometimes other techniques are useful. These include:

Indirect proofs – instead of p → q prove the contrapositive that ¬q → ¬p

Proof by contradiction – instead proving p is true assume that p is false. Then show this leads to a contradiction. An example would be to show that the √2 is irrational by assuming that it is rational. This will lead to a contradiction.

Proof by cases – here the proof is broken down in to separate cases. This is a common techniques used with algorithms.

Existence proofs – prove that something is true by providing an example. For example, prove that there is a prime number larger than 100 by giving an example. Or in some other cases it is easier to prove that something exists, but difficult to find an example.

Counter examples – are used to prove that something is not true. For example, if asked to prove that the square root of every rational number is rational, show that the integer 5 contradicts this statement

1404/21/23

MATH 224 – Discrete MathematicsExamples

Direct Proof:

Proof that opposite angles of two intersection lines are equal. Use the premise that angles forming a straight line are always 180O.

α

θ β

λ

Angles α + β = 180O and angles α + θ = 180O. Hypothesis

Angle β = 180O ─ α and angle θ = 180O ─ α . Algebra

Therefore opposite angles β and θ are equal.

1504/21/23

MATH 224 – Discrete MathematicsExamples

Proof by Contradiction:

Proof that opposite angles of two intersection lines are equal. Use the premise that angles forming a straight line are always 180O.

α

θ β

λ

Angles α + β = 180O and angles α + θ = 180O. Hypothesis

Assume that β ≠ θ. Assumption

Angle β = 180O ─ α and angle θ = 180O ─ α . Algebra

Then 180O ─ α ≠ 180O ─ α. Algebra

But the previous statement cannot be true and is a contradiction.

Therefore the opposite angles α and β must be equal.

1604/21/23

MATH 224 – Discrete MathematicsExamples

Existence Proof (Non constructive): (Often non constructive proofs assume something does not exist and then show a contradiction.)

Prove that there are computational problems that cannot be solved by a computer .

Computer memory can be viewed as one large integer, and thus the maximum number of programs that may be constructed is equal to 2B, where B is the total number of bits of memory. (Even with infinite memory, this number is countable as long as no program uses an infinite number of bits.)

The number of different problems that require different programs to solve is infinite, and in fact uncountable. In fact, there are an uncountable number of problems with a yes or no answer.

Therefore, there exist problems that cannot be solved by a computer.

Here is an example of a problem that cannot be solved by a computer. Find a program that takes as input a problem description and a student’s programming solution. Determine if the student’s program is correct.