LOGIC Lesson 2.1. What is an on-the-spot Quiz This quiz is defined by me. While I’m having my...
-
Upload
eleanore-burke -
Category
Documents
-
view
218 -
download
1
Transcript of LOGIC Lesson 2.1. What is an on-the-spot Quiz This quiz is defined by me. While I’m having my...
LOGICLesson 2.1
What is an on-the-spot Quiz This quiz is defined by me. While I’m having my lectures, you have
to be alert. Because there are questions on-the-
spot. Always prepare 1/8 or ¼ size of paper.
LOGIC LOGIC is commonly known as the science of
reasoning. The emphasis here will be on logic as working tool.
We will develop some of the symbolic techniques required for computer logic. Some of the reasons to study logic are the following:
At the hardware level the design of ‘logic’ circuits implement instructions is greatly simplified by the use of symbolic logic.
At the software level a knowledge of symbolic logic is helpful in the design of programs.
RULES OF LOGIC The rules of LOGIC specify the precise
meaning of mathematical statements. These rules are used to distinguish
between valid and invalid mathematical arguments.
These rules are used in the design of computer circuits, the construction of computer programs, the verification of correctness of programs, and in many other ways.
PROPOSITIONS The building blocks of logic. A proposition is a statement that is
either true or false, but not both.
Examples 1&2 Yaoundé is the capital of Cameroon x + 2 = 2 English is the national language spoken
in Cameroon x + y = z All the above examples are
propositions?
Letters are used to denote propositions, just as letters are used to denote variables.
The conventional letters used for this purpose are p,q,r,s…
The truth value of a proposition is true, denoted by T and denoted by F, if it is a false proposition.
Many mathematical statements are constructed by combining one or more propositions.
New propositions, called compound propositions are formed from existing propositions using logical operators.
NEGATION Let p be a
preposition. The statement,“It is not the case that p” is another proposition, called the negation of p, and is denoted by p read as not p.
Find the negation of the proposition
“This month is September” Solution:“It is not the case that this month is September” The negation can be more
simply expressed by“This month is not September”
A truth table displays the relationships between the truth values of propositions.
The negation of a proposition can also be considered the result of the operation of the negation operator on a proposition.
These logical operators are also called connectives
TABLE 1 The Truth Table for the Negation of a Proposition
p p
T F
F T
What is the negation of the following propositions? 1/8
1. Today is Thursday.2. There is no pollution in Douala3. 10 + 5 = 154. Douala is the capital of Cameroon.5. The summer in Yaoundé is hot and
sunny.
CONJUNCTION Let p and q be
propositions. The proposition “p
and q”, denoted by p q
is the proposition that is true when both p and q are TRUE and is FALSE otherwise.
TABLE 2 The Truth Table for the Conjunction of Two Proposition
p q p q
T T T
T F F
F T F
F F F
Example p is the proposition
“Today is Friday” q is the proposition “It is
raining today” Solution: the conjunction
of these p q , is the proposition “Today is Friday and it is raining today.”
The proposition is TRUE on rainy Fridays and is FALSE on any other days and not raining.
1. There is one red apple and a total of two apples.2. The green apple is smaller than the red apple and the
red apple has a leaf.3. The red apple is taller and green apple is not having a
stem.4. Both apples have sprinkled water and none of them is
sliced.5. The green apple is labeled unripe and the red is
labeled ripe.
DISJUNCTION Let p and q be
propositions. The proposition “p
and q”, denoted by p q
is the proposition that is FALSE when both p and q are FALSE and is TRUE otherwise.
TABLE 3 The Truth Table for the Disjunction of Two Proposition
p q p q
T T T
T F T
F T T
F F F
Example The use of the
connective OR in a disjunction corresponds to one of the two ways the word OR is used in English, namely an inclusive way.
Students who have taken calculus or computer science can take this class. (inclusive)
Students who have taken calculus or computer science, but not both, can take this class. (exclusive)
Activity 10 Pts. Search the web or
think of real world scenarios, create the disjunction table.
Cite an example
for each p q.
EXCLUSIVE OR Let p and q be
propositions. The exclusive or
of “p and q”, denoted by p q
is the proposition that is TRUE when exactly one of p and q is TRUE and is FALSE otherwise.
TABLE 4 The Truth Table for the Exclusive Or of Two Proposition
p q p q
T T F
T F T
F T T
F F F
Activity 10 Pts. Search the web,
and create the exclusive or table.
Cite a real world example for each
p q.
IMPLICATION/CONDITIONAL Let p and q be
propositions. The implication of “p
q”, is the proposition that is FALSE when p is true and q is false, and TRUE otherwise.
In this implication p is called the hypothesis (or antecedent or premise)
and q is called the conclusion (or consequence)
TABLE 4 The Truth Table
for the Implication p q
p q p q
T T T
T F F
F T T
F F T
COMMON WAYS OF EXPRESSING IMPLICATIONS: If p then q p implies q If p,q p only if q p is sufficient for q q if p q wherever p q is necessary for p
EXAMPLE statements:
ACTIVITY 10 Pts. Search the web,
and create the implications table.
Cite a real world example for each
p q
BICONDITIONAL Let p and q be
propositions. The biconditional
of “p q”, is the proposition that is TRUE when p and q have the same truth values and is FALSE otherwise.
TABLE 4 The Truth Table
for the Implication p q
p q p q
T T T
T F F
F T F
F F T
ACTIVITY 10 Pts. Search the web,
and create the biconditional table.
Cite a real world example for each
p q
24 Lecture 1
Logical Connectives
Operator Symbol
Usage Java
Negation not !
Conjunction
and &&
Disjunction or ||
Exclusive or
xor (p||q)&&(!p||!q)
Conditional
if,then
p?q:true
Biconditional
iff (p&&q)||(!p&&!q)
NEXT TOPIC:
- LOGIC AND BIT OPERATIONS- PROPOSITIONAL EQUIVALENCES- SETS- FUNCTIONS