0% found this document useful (0 votes)
47 views

Logics in Computer Science (Cosc3141)

The document provides an introduction to propositional logic as it relates to computer science. It discusses: 1) Propositional logic explores logical connections like "and", "or", and "not" between basic statements that can be true or false. 2) Logical connectives like negation, conjunction, disjunction, implication, and bi-implication are used to combine statements and their truth values are determined by truth tables. 3) Propositional logic is important in computer hardware and software because circuits and programs can be described as logical formulas over binary values of 0 and 1.

Uploaded by

Yonathan Berhanu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Logics in Computer Science (Cosc3141)

The document provides an introduction to propositional logic as it relates to computer science. It discusses: 1) Propositional logic explores logical connections like "and", "or", and "not" between basic statements that can be true or false. 2) Logical connectives like negation, conjunction, disjunction, implication, and bi-implication are used to combine statements and their truth values are determined by truth tables. 3) Propositional logic is important in computer hardware and software because circuits and programs can be described as logical formulas over binary values of 0 and 1.

Uploaded by

Yonathan Berhanu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Logics in Computer Science (CoSc3141)

CHAPTER ONE
INTRODUCTION

1.1. Introduction

Mathematical Reasoning is a tool for organizing evidence in a systematic way through


mathematical logic. Mathematical logic is the systematic study of the art of reasoning. In some
ways, mathematics can be thought of as a theory of logic. Logic has a wide range of applications,
particularly in judging the correctness of a chain of reasoning, as in mathematical proofs.

The aim of logic in computer science is to develop languages to model the situations we
encounter as computer science professionals, in such a way that we can reason about them
formally. Reasoning about situations means constructing arguments about them; we want to do
this formally, so that the arguments are valid and can be defended rigorously, or executed on a
machine.

Computer Science has utilized many subfields of Logic in areas such as program verification,
semantics of programming languages, automated theorem proving, and logic
programming. From the very beginning, education in Computer Science supports the idea of
strict separation between syntax and semantics (of programming languages). Also, recursive
definitions, equations and programs are a familiar thing to a Computer Science student.

Propositional logic is central to the design of computer hardware because hardware is usually
designed with components having two voltage levels that are arbitrarily assigned the symbols 0
and 1. Circuits are described by idealized elements called logic gates; for example, an and-gate
produces the voltage level associated with 1 if and only if both its input terminals are held at this
same voltage level.

Propositional logic is widely used in software, too. The reason is that any program is a finite
entity. Mathematicians may consider the natural numbers to be infinite (0, 1, 2, ...), but a word of
a computer’s memory can only store numbers in a finite range. By using an atomic proposition
for each bit of a program’s state, the meaning of a computation can be expressed as a (very large)
formula. Algorithms have been developed to study properties of computations by evaluating
properties of formulas in propositional logic.

1 of 8 Kotebe Metropolitan University Department of Computer Science


Logics in Computer Science (CoSc3141)

1.2. Statements/Propositions
In order to make arguments difficult, we need to develop a language in which we can express
sentences in such a way that brings out their logical structure. The language we begin with is the
language of propositional logic. It is based on propositions, or declarative sentences which one
can, in principle, argue as being true or false.

A sentence which can be said to be true or false (but not both) is said to be a proposition (or
statement). The words True and False, denoted by T and F respectively, are called truth values.
Consider the following examples:
a. Four is less than Ten.
b. Addis Ababa is the capital of Ethiopia.
c. He is very talented.
d. There are life forms on other planets in the universe.

Sentence (a) is a statement because it is True. Sentence (b) is a statement because it is true.
Sentence (c) is neither true nor false because “he” is not specified; therefore (c) is not a
statement. Sentence (d) is a statement because it is either true or false; we do not have to be able
to decide which.

1.3. Logical connectives and truth values

Propositional logic explores simple grammatical connections, like and, or and not, between the
simplest "atomic/indecomposable propositions". In English, simple statements are combined with
connecting words like ‘and’ to make more interesting compound statements. The truth value of a
compound statement depends on the truth values of its components and which connecting words are
used. If we combine the two true statements, “Elephants are big,” and, “Baseballs are round,” we
would consider the resulting statement, “Elephants are big and baseballs are round,” to be true.

Given two or more propositions, you can use connectives to join the sentences to form compound
statement. The fundamental connectives in logic are: not, or, and, if ... then, and if and only if.

To find the truth-value of a statement which is combined by using connectives, you need rules which
give the truth value of the compound statement. You also need symbols for connectives and notations
for propositions. You usually represent propositions by small letters such as p, q, r, s, t, and so on.
Now, let p and q are two different propositions.

2 of 8 Kotebe Metropolitan University Department of Computer Science


Logics in Computer Science (CoSc3141)

Connective Name of the Symbol How to How to read


connective write
not Negation ¬ ¬p The negation
of p
and Conjunction ∧ p∧q p and q
or Disjunction ∨ p∨q p or q
If..., then... Implication → p→q p implies q
If and only if Bi- ↔ p↔q p if and only
implication if q

We assign certain distinct symbols p, q, r, or sometimes p1, p2, p3, to each of these atomic sentences
and we can then code up more complex sentences in a compositional way. For example, given the
atomic sentences:
p:‘I won the lottery last week.’
q:‘I purchased a lottery ticket.’
r:‘I won last week’s sweepstakes.’

a) ¬ p represents: I did not win the lottery last week,’ or equivalently It is not true that I won
the lottery last week.
b) p ∧r represents: Last week I won the lottery and the sweepstakes.
c) p ∨q represents: I won the lottery last week, or I purchased a lottery ticket.
d) p → q represents: If I won the lottery last week, then I purchased a lottery ticket.
e) p ↔ q represents: I won the lottery last week if and only if I purchased a lottery ticket.

Now we will see to the rules that govern us in communicating through logic by using truth tables for
each of the logical operators.

❖ Rule for Negation (“ ¬ ”)

Negation is a unary connective, it is applied to a single statement and does not connect two
statements.
Let p be a proposition.

¬ p is true, if and only if p is false.


The truth table for negation is the following.
p ¬p
T F
F T

3 of 8 Kotebe Metropolitan University Department of Computer Science


Logics in Computer Science (CoSc3141)

❖ Rule for Disjunction (“∨”)

When two propositions p and q are joined with the connective "or"(denoted by p ∨q), the
proposition formed is a logical disjunction. p and q are called the disjuncts of the expression. p
∨ q is false, if and only if both p and q are false.
To determine the truth value of p ∨q, we have to know the truth value of the components p and q.
As mentioned earlier, if we have two propositions to be combined, there are four possibilities of
combinations of the truth values of component propositions.
The truth table for disjunction is given as follows.

p q p ∨q
T T T
T F T
F T T
F F F

❖ Rule for Implication (“→”)

When two propositions p and q are joined with the connective "implies"(denoted by p → q) the
proposition formed is a logical implication. It conveys the meaning that the truth of p implies or
leads to the truth of q. In the implication p → q, p stands for the antecedent statement and q stands
for the consequent statement.
p → q is false, if and only if p is true and q is false.

The truth table for implication is given as follows:

p q p→q
T T T
T F F
F T T
F F T
To understand its definition, let’s suppose your friend remarks, “If I pass my economics test,
then I’ll go to the movie Friday.” If your friend passes the test and goes to the movie, the remark
was true. If your friend passes the test but doesn’t go to the movie, the remark was false. If your
friend doesn’t pass the test, then whether he or she goes to the movie or not, you could not claim
that the remark was false. You would probably want to give the benefit of the doubt and say that
the statement was true. By convention p → q is considered true if p is false, regardless of the
truth value of q.

4 of 8 Kotebe Metropolitan University Department of Computer Science


Logics in Computer Science (CoSc3141)

❖ Rule for Bi-implication (“↔”)

When two propositions p and q are joined with the connective "bi-implication" (denoted by p ↔
q) the proposition formed is a logical bi-implication. Unlike conjunction, disjunction, and
implication, the bi-implication connective is not really a fundamental connective but a
convenient shortcut. The expression p ↔ q stands for (p → q) ∧ (q → p).
p ↔ q is false, if and only if p and q have different truth values.
The truth table for bi–implication is given as follows.

p q p↔q
T T T
T F F
F T F
F F T

The following table summarizes the truth values for all of the above logical connectives. This
information is critical to an understanding of logical reasoning.

p q p∧q p∨q p→q p↔q ¬p


T T T T T T F
T F F T F F F
F T F T T F T
F F F F T T T

Because of the richness of the English language, words that have different shades of meaning are
however represented by the same logical connective. The following table shows the common
English words associated with various logical connectives.

English Word Logical connective Logical expression


and; but; also; in Conjunction p∧q
addition; moreover
or Disjunction p∨q
If p, then q. Implication p→q
p implies q.
p, therefore q.
p only if q.
q follows from p.
p is a sufficient condition
for q.
q is a necessary
condition for p.
p if and only if q. Bi-implication p↔q

5 of 8 Kotebe Metropolitan University Department of Computer Science


Logics in Computer Science (CoSc3141)

p is necessary and
sufficient for q.
not p Negation ¬p
It is false that p ...
It is not true that p ...

Suppose that p → q is true. Then, according to the truth table for implication, the consequent, q,
can be true even though the antecedent, p, is false. So while the truth of p leads to (implies) the
truth of q, the truth of q does not imply the truth of p. The phrase “q is a necessary condition for
p” to describe p → q simply means that if p is true, then q is necessarily true, as well. “p only if
q” describes the same thing, that p implies q.
For example:

The statement, “Fire is a necessary condition for smoke,” can be restated, “If there is smoke, then
there is fire.” The antecedent is “there is smoke,” and the consequent is “there is fire.”
Exercise!

Name the antecedent and consequent in each of the following statements. (Hint: Rewrite each
statement in if-then form.)
a. If the rain continues, then the river will flood.
b. A sufficient condition for network failure is that the central switch goes down.
c. The avocados are ripe only if they are dark and soft.
d. A good diet is a necessary condition for a healthy cat.

Expressing the negation of a statement must be done with care, especially for a compound
statement. The following table gives some examples.

Statement Correct Negation Incorrect Negation


It will rain tomorrow. It is false that it will rain tomorrow.
It will not rain tomorrow.
Peter is tall and thin. It is false that Peter is tall and thin. Peter is short and fat.
Peter is not tall or he is not thin.
Peter is short or fat
The river is shallow or It is false that the river is shallow or The river is not
polluted. polluted. shallow or not
The river is neither shallow nor polluted. polluted.
The river is deep and unpolluted.

6 of 8 Kotebe Metropolitan University Department of Computer Science


Logics in Computer Science (CoSc3141)

1.4. Compound Statements

So far, you have defined statements and logical connectives (or logical operators) and you have
seen the rules that go with the logical connectives. Now you are going to give a name for
statements formed from two or more component propositions by using logical operators. A
statement formed by joining two or more statements by a connective (or connectives) is called a
compound statement.
For example:
(¬ p ∨q) ∧ (q → p)
The truth table for the above compound statement is the following.

p q ¬p ¬p∨q q→p (¬ p ∨ q) ∧ (q → p)
T T F T T T
T F F F T F
F T T T F F
F F T T T T

Some compound propositions have the same truth values for each assignment of the truth values
of component propositions. Such pairs of compound propositions are called equivalent
propositions. We use the symbol “≡” in-between the two propositions to mean they are
equivalent.

Exercise! Show that

a) p → q and ¬ q → ¬ p have the same truth values (equivalent)


b) ¬ ( p∨q ) and ¬ p ∧ ¬ q are equivalent
c) p → q and ¬ q → ¬ p are equivalent

1.5. Properties and Laws of Logical Connectives

For the logical connectives discussed so far, the following properties hold true.

1. Conjunction is commutative; that means for any propositions p and q


p∧q≡q∧p
2. Disjunction is commutative; that means for any propositions p and q
p∨q≡q∨p
3. Conjunction is associative; that means for any propositions p, q and r
(p ∧q )∧ r ≡ p ∧ (q ∧ r )

7 of 8 Kotebe Metropolitan University Department of Computer Science


Logics in Computer Science (CoSc3141)

4. Disjunction is associative; that means for any propositions p, q and r


(p ∨q )∨ r ≡ p ∨ (q ∨ r )
5. Conjunction is distributive over disjunction; that means for any propositions p, q and r
(p ∨q )∧ r ≡ (p ∧ r) ∨ ( q ∧ r )
p ∧( q∨ r ) ≡ (p ∧ q) ∨ ( p ∧ r )
6. Disjunction is distributive over conjunction; that means for any propositions p, q and r
(p ∧q )∨ r ≡ (p ∨ r) ∧ ( q ∨ r )
p ∨( q∧ r ) ≡ (p ∨ q) ∧ ( p ∨ r )
7. De Morgan’s Laws
¬ ( p∨ q ) ≡ ¬ p ∧ ¬ q
¬ ( p∧ q ) ≡ ¬ p ∨ ¬ q

8 of 8 Kotebe Metropolitan University Department of Computer Science

You might also like