• No results found

Download free eBooks at bookboon.com

79

Consider the negation, “Student StudentId is not enrolled on course CourseId.” Assuming the truth expressed by the ENROLMENT relation depicted in Figure 1.2 of Chapter 1, we can see that the tuple TUPLE { StudentId SID('S1'), CourseId CID('C1') } fails to satisfy this predicate. Here, by contrast, as some that do satisfy it:

TUPLE { StudentId SID('S1'), CourseId CID('C3') } (No tuple in ENROLMENT shows student S1 as being enrolled on course C3) TUPLE { StudentId SID('S2'), CourseId CID('C97') }

(No tuple in ENROLMENT shows S1 as being enrolled on C97 and in fact there is currently no such course, though C97 is a valid course identifier)

TUPLE { StudentId SID('S98'), CourseId CID('C97') }

(No tuple in ENROLMENT shows S98 as being enrolled on C97 and in fact there is currently no such student, though S98 is a valid student identifier)

In Tutorial D, as previously noted, negation is denoted by the key word NOT. For example, the expression NOT (x = 5) evaluates to TRUE for all values of x except 5, when it evaluates to FALSE.

You will have realised by now that the cardinality of a relation representing the extension of “Student

StudentId is not enrolled on course CourseId” is likely to be very high indeed—almost certainly too high to be manageable using a computer. In Chapter 4 you will see that a relational DBMS’s support for relations representing negated predicates is subject to a certain restriction, addressing this problem. But you may also be thinking that relations for negated predicates such as the example at hand would be of little use in practice, in which case you will agree, when you see the restriction I am referring to, that it is of little or no import.

Conjunction (AND)

In English, two sentences may be connected by the conjunction, “and”, yielding a single sentence. For example, “Come in and make yourself at home”, where the conjunction connects two imperatives, meaning that the person being spoken to is being enjoined to do both of those things. When the sentences being connected are statements, denoting propositions, the result is a single statement, denoting a single proposition. For example: “It’s raining and I’m wet through”. If it really is raining, and I really am wet through, then that is a true statement; otherwise—either it’s not raining, or I’m not wet through—it is a false statement. That example illustrates the logical connective AND, usually denoted in formal treatments by the symbol . The connection of two propositions in this particular way is called conjunction. Unfortunately, as previously noted, there are other conjunctions in English whose use does not denote logical conjunction (for example, “or”). There are also other conjunctions that do denote logical conjunction (for example, “but”).

Download free eBooks at bookboon.com

80

The conjunction of propositions p and q is true if and only if p is true and q is true, as shown in Figure 3.2, the truth table for conjunction.

p q pq

T T T

T F F

F T F

F F F

Figure 3.2: The Truth Table for AND

As we have seen, a proposition is a special case of a predicate, namely, a predicate with no parameters (a niladic predicate). Conjunction can be applied to other predicates too, the result being a predicate. Again, a predicate with parameters has no truth value; therefore neither does its conjunction with some other predicate. However, the truth table for conjunction tells us that if tuple t1 satisfies predicate p1

and tuple t2 satisfies predicate p2, then tuple t3, consisting of every element that is an element of either

t1 or t2 (or both) satisfies p1p2; conversely, if either t1 fails to satisfy p1 or t2 fails to satisfy p2 then t3 fails to satisfy p1p2.

Consider the conjunction “Student StudentId is enrolled on course CourseId and student StudentId is called Name”. The predicates being connected are “Student StudentId is enrolled on course CourseId” and “Student StudentId is called Name”. We connect two dyadic predicates to form a triadic one—it has only three parameters because the parameter StudentId is common to both of the dyadic predicates. “Student StudentId is enrolled on course CourseId and student StudentId is called Name” is of course the intended predicate for the ENROLMENT relvar of Figure 1.2 in Chapter 1. Figure 1.2 tells us that TUPLE { StudentId SID('S1'), Name NAME('Anne'), CourseId CID('C1') } satisfies that predicate. That being the case, the truth table for conjunction allows us to conclude that it also satisfies both “Student StudentId is enrolled on course CourseId” and “Student StudentId is called

Name”, for if it failed to satisfy either, then the instantiation of their conjunction under that tuple must be false according to that truth table.

Disjunction (OR)

As previously noted, there are plenty of other words (conjunctions) for connecting sentences, and they do not all denote conjunction. For example, “or” is such a word and it denotes disjunction, usually denoted in formal treatments by the symbol .

The disjunction of propositions p and q is true if either p is true, or q is true, or both are true; otherwise (neither p nor q is true) false. The truth table for disjunction is shown in Figure 3.3.

Download free eBooks at bookboon.com 81 p q pq T T T T F T F T T F F F

Figure 3.3: The Truth Table for Disjunction

The definition I have given for disjunction is surely intuitive and obvious. But note that, having previously defined negation and conjunction (in equally intuitive and obvious ways), I could now define disjunction in terms of those two, like this:

p q ¬(¬p ¬q)

We can use a truth table (Figure 3.4) to prove this equivalence:

p q ¬p ¬q ¬p∧¬q ¬(¬p∧¬q)

T T F F F T

T F F T F T

F T T F F T

F F T T T F

Figure 3.4: Disjunction in Terms of Negation and Conjunction

We used the truth tables for negation and conjunction to obtain the second, third, and fourth columns. As you can see, the final column is the same as in Figure 3.3.

Like conjunction, disjunction can be applied to predicates in general as well as propositions. Consider the disjunction “Student StudentId is enrolled on course CourseIdor student StudentId is called Name”. The predicates being connected are once again “Student StudentId is enrolled on course CourseId” and “Student StudentId is called Name”. Because the first row of the truth table is the same as the first row of the truth table for conjunction, and because the conjunction of these two predicates is the agreed predicate for ENROLMENT, we can conclude that every tuple in ENROLMENT satisfies their disjunction too. However many other tuples, not in ENROLMENT, also satisfy it. For example, TUPLE {StudentId SID('S1'), Name NAME('Eve'), CourseId CID('C1')} satisfies it because it satisfies “Student StudentId is enrolled on course CourseId” (student S1 isn’t called Eve but she is enrolled on course C1). For another example, TUPLE {StudentId SID('S1'), Name NAME('Anne'), CourseId CID('C97')} satisfies it because it satisfies “Student StudentId is called Name” (student S1 isn’t enrolled on course C97—in fact, as it happens there is no such course—but she is called Anne.

Download free eBooks at bookboon.com

Click on the ad to read more

82

You will have realised by now that the cardinality of a relation representing the extension of “Student

StudentId is enrolled on course CourseId or student StudentId is called Name” is likely to be very high indeed—almost certainly too high to be manageable using a computer. In Chapter 4 you will see that a relational DBMS’s support for relations representing disjunctive predicates is subject to a certain restriction, addressing this problem. As with negation, you may also be thinking that relations for disjunctive predicates such as the example at hand would be of little use in practice, in which case you will agree again, when you see the restriction I am referring to, that it is of little or no import.

Conditionals

Consider the sentences shown in Example 3.9.

Example 3.9: conditional sentences

(i) If you ask me nicely, then I will marry you. (ii) I will marry you only if you ask me nicely (iii) I will marry you if and only if you ask me nicely.

American online

LIGS University

enroll by September 30th, 2014 and

save up to 16% on the tuition!

pay in 10 installments / 2 years

Interactive Online education

visitwww.ligsuniversity.comto

find out more!

is currently enrolling in the

Interactive Online BBA, MBA, MSc,

DBA and PhD programs:

Note: LIGS University is not accredited by any

nationally recognized accrediting agency listed

by the US Secretary of Education.

Download free eBooks at bookboon.com

83

Each denotes a predicate derived from two predicates using a connective of a general kind called conditional. Sentence (i) illustrates use of logical implication, usually denoted in formal treatments by the symbol →. Sentence (i) denotes a true proposition in all situations except when the question is asked nicely but results in refusal. In general, pq (“if p then q”) is true except when p is true and q is false.

p q pq

T T T

T F F

F T T

F F T

Figure 3.5: The Truth Table for Logical Implication

As an exercise, you might like to work out the truth table for the expression ¬pq. You should find that

the final column is identical to the final column of Figure 3.5, confirming the equivalence

pq≡¬p q

Sentence (ii) of Example 3.9 is merely another way of saying, “If I marry you, then you will have asked me nicely.” Sentence (iii) illustrates use of the biconditional, also known as equivalence, usually denoted in formal treatments by the symbol ↔. It is true whenever the truth values of “I will marry you” and

“You ask me nicely” are identical—either both TRUE or both FALSE; otherwise it is FALSE. It should be clear, then, that pq is equivalent to (pq)  (qp), as confirmed by the truth table in Figure 3.6.

p q pq qp (pq) (qp) T T T T T T F F T F F T T F F F F T T T Figure 3.6: p ↔ q ≡ (pq ) (qp)

As you can see, the final column indicates TRUE exactly when the first two columns indicate the same truth value.

Quantification

Our final method of deriving a predicate from a predicate does not correspond to anything in propositional calculus and in fact is what distinguishes the predicate calculus from propositional calculus.

Download free eBooks at bookboon.com

84

To quantify something is to state its quantity, to say how many of it there are. Consider the following sentences:

x has been president of the USA.

44 people have been president of the USA.

The first denotes a monadic predicate, the second a niladic one (and is either true or false, depending, as it happens, on when it is uttered—for example, it became true in January 2009). The second sentence is in a sense derived from the first by stating how many x’s there are such that x has been president of the USA. Quantification doesn’t have to be numerically precise. Here are some further examples:

At least 40 people have been president of the USA.

Between 40 and 50 people have been president of the USA. Nobody has been president of the USA.

That last one is precise, of course. It happens to be a false statement, from which it follows that its negation, It is not the case that nobody has been president of the USA.

is a true one. But this uses a “double negative” and is just an awkward way of stating At least one person has been president of the USA.

Or

There is a person x such that x has been president of the USA.

This is derived from “x has been president of the USA” by existential quantification. Like substitution, quantification reduces the number of parameters: one of the parameters of a given n-adic predicate is quantified and the result is an (n-1)-adic predicate.

Note carefully that the symbol x, denoting a variable, appears twice in that last formulation, and yet it is not a parameter. The x in the predicate “x has been president of the USA” is a parameter, of course. As such it is also referred to sometimes as a free variable, when it is then said to be bound, by quantification, in “There is a person x such that x has been president of the USA”.

Download free eBooks at bookboon.com

Click on the ad to read more

85

Existential quantification is denoted in formal treatments by the symbol ∃ (“there exists”), as in

x : x has been president of the USA. As before, the colon can be pronounced “such that”.

Having seen how existential quantification can be expressed in a long-winded way using a double negative, now see what happens when we apply a double negative to an existentially quantified predicate, as in the sentence

It is not the case that somebody doesn’t know who is the current president of the USA. This would be expressed formally as

¬(∃x : ¬(x knows who is the current president of the USA))

Free online Magazines

Click here to download

SpeakMagazines.com

Download free eBooks at bookboon.com

86

“It is not the case that there exists a person x such that it is not the case that x knows who is the current president of the USA.” You have perhaps worked out by now that all we are saying is, “Everybody knows who is the current president of the USA.” Here we are using universal quantification—stating that something is true of everything that is under consideration. Universal quantification is denoted in formal treatments by the symbol ∀ (“for all”), as in

x : x knows who is the current president of the USA

(The colon here clearly cannot be pronounced “such that” but is kept for symmetry with existential quantification.)

That concludes my digression into predicate logic to explain how relations are supposed to be interpreted. In the next chapter I show how the operators of the relational algebra are used to derive relations from relations, relating these to the methods I have described for deriving predicates from predicates. You might like to try the exercises that follow before moving on to that chapter.