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

CHAPTER 1: Propositional Logic

This document provides an introduction to propositional logic. It begins by defining propositions as declarative sentences that are either true or false. Some examples of propositions and non-propositions are given. Propositional variables are introduced to represent propositions, with truth values of True (T) or False (F). Negation, conjunction, disjunction, conditional, biconditional, and other logical connectives are defined. Truth tables are used to determine the truth values of compound propositions. Applications of propositional logic to computer circuits and programming are briefly discussed. Predicates and quantifiers are introduced as ways to represent more complex statements involving variables.

Uploaded by

SULTAN Sksa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

CHAPTER 1: Propositional Logic

This document provides an introduction to propositional logic. It begins by defining propositions as declarative sentences that are either true or false. Some examples of propositions and non-propositions are given. Propositional variables are introduced to represent propositions, with truth values of True (T) or False (F). Negation, conjunction, disjunction, conditional, biconditional, and other logical connectives are defined. Truth tables are used to determine the truth values of compound propositions. Applications of propositional logic to computer circuits and programming are briefly discussed. Predicates and quantifiers are introduced as ways to represent more complex statements involving variables.

Uploaded by

SULTAN Sksa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

CHAPTER 1 : propositional Logic

1.Introduction
The rules of logic give precise meaning to mathematical statements. These rules are used
to distinguish between valid and invalid mathematical arguments. Because a major goal
of this CORSE is to teach the reader how to understand and how to construct correct
mathematical arguments, we begin our study of discrete mathematics with an
introduction to logic. Besides the importance of logic in understanding mathematical
reasoning, logic has numerous applications to computer science. These rules are used in
the design of computer circuits, the construction of computer programs, the veri?cation of
the correctness of programs, and in many other ways. Furthermore, software systems
have been developed for constructing some, but not all, types of proofs automatically.
We will discuss these applications of logic in this and later chapters.

1.Propositions
Our discussion begins with an introduction to the basic building blocks of
logic propositions. A proposition is a declarative sentence (that is, a sentence
that declares a fact) that is either true or false, but not both.
EXAMPLE 1 All the following declarative sentences are propositions.
1. Washington, D.C., is the capital of the United States of America.
2. Toronto is the capital of Canada.
3. 1+1 = 2.
4. 2+2 = 3.
Propositions 1 and 3 are true, whereas 2 and 4 are false.

Some sentences that are not propositions are given in in following Example

EXAMPLE 2 Consider the following sentences.


1. What time is it?
2. Read this carefully.
3. x +1 = 2.
4. x +y = z.

We use letters to denote propositional variables (or statement variables), that


is, variables that represent propositions, just as letters are used to denote
numerical variables.
propositional variables are p,q,r,s,... .The truth value of a proposition is true,
denoted by T, if it is a true proposition, and the truth value of a proposition is
false, denoted by F, if it is a false proposition.

DEFINITION 1 Let p be a proposition.The negation of p,denoted by ¬p


(also denoted by p),is the statement
It is not the case that p. The proposition¬p is read not p. The truth value of
the negation of p,¬p, is the opposite of the truth value of p.

Exercise
Find the negation of the proposition
Vandana's smartphone has at least 32GB of memory
and express this in simple English.

Solution: The negation is


It is not the case that Vandana's smartphone has at least 32GB of memory.

This negation can also be expressed as


Vandana's smartphone does not have at least 32GB of memory

or even more simply as


Vandana's smartphone has less than 32GB of memory.
Table 1 displays the truth table for the negation of a proposition p

DEFINITION 2 Let p and q be propositions.The conjunction of p and q,


denoted by p ^ q, is the proposition p and q. The conjunction p ^ q is true
when both p and q are true and is false otherwise.

DEFINITION 3 Let p and q be propositions. The disjunction of p and q,


denoted by pVq, is the proposition p or q.The disjunction pVq is false when
both p and q are false and is true otherwise
exercice
prove that not( p or q) = not p and not q
prove that not(p and q) = not p or not q

DEFINITION 4 Let p and q bepropositions.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.
2. Conditional Statements
We will discuss several other important ways in which propositions can be
combined

DEFINITION 5 Let p and q be propositions.The conditional statement p→ q


is the proposition if p, then q.The conditional statement p → q is false when
p is true and q is false,and true otherwise.
In the conditional statement p → q, p is called the hypothesis (or antecedent
or premise) and q is called the conclusion (or consequence).

If Juan has a smartphone, then 2+3 = 5

EXAMPLE What is the value of the variable x after the statement


if 2+2 = 4 then x := x +1 if x = 0 before this statement is encountered (The
symbol := stands for assignment. The statement x := x +1 means the
assignment of the value of x +1 to x.)
Solution: Because 2+2 = 4 is true, the assignment statement x := x +1 is
executed. Hence, x has the value 0+1 = 1 after this statement is encountered
EXAMPLE 9
What are the contrapositive, the converse, and the inverse of the conditional
statement
“The home team wins whenever it is raining?”
Solution: Because “q whenever p” is one of the ways to express the
conditional statement
p → q, the original statement can be rewritten as
“If it is raining, then the home team wins.”
Consequently, the contrapositive of this conditional statement is
“If the home team does not win, then it is not raining.”
The converse is
“If the home team wins, then it is raining.”
The inverse is
“If it is not raining, then the home team does not win.”
Only the contrapositive is equivalent to the original statement.

“p is necessary and sufficient for q”
“if p then q, and conversely”
“p iff q
“p iff q.”
The last way of expressing the biconditional statement p ↔ q uses the
abbreviation “iff” for
“if and only if.” Note that p ↔ q has exactly the same truth value as (p → q)
∧ (q → p).
EXAMPLE
Construct the truth table of the compound proposition
(p V ¬q) → (p ^ q).
Solution :
3. Logic and Bit Operations

this is done, operations on the bit strings can be used to manipulate this
information.
DEFINITION 7
A bit string is a sequence of zero or more bits. The length of this string is the
number of bitsbin the string.
EXAMPLE
101010011 is a bit string of length nine.

Exercice
Find the bitwise OR, bitwise AND, and bitwise XOR of the bit strings
01 1011 0110 and 11 0001 1101. (Here, and throughout this book, bit strings
will be split into blocks of four bits to make them easier to read.)
Solution: The bitwise OR, bitwise AND, and bitwise XOR of these strings
are obtained by taking the OR, AND, and XOR of the corresponding bits,
respectively. This gives us
01 1011 0110
11 0001 1101
--------------------------
11 1011 1111 OR
01 0001 0100 AND
10 1010 1011 XOR

EXERCICE 1

Determine whether these biconditionals are true or false.


a) 2 + 2 = 4 if and only if 1 + 1 = 2.
b) 1 + 1 = 2 if and only if 2 + 3 = 4.
c) 1 + 1 = 3 if and only if monkeys can fly.
d) 0 > 1 if and only if 2 > 1.
EXERCICE 2
4. Applications of Propositional Logic

EXAMPLE 1
How can this English sentence be translated into a logical expression?
“You can access the Internet from campus only if you are a computer
science major or you are not a freshman.”
Solution: There are many ways to translate this sentence into a logical
expression. Although it is possible to represent the sentence by a single
propositional variable, such as p, this would not be useful when analyzing its
meaning or reasoning with it. Instead, we will use propositional variables to
represent each sentence part and determine the appropriate logical
connectives between them.
In particular, we let a, c, and f represent “You can access the Internet from
campus,”
“You are a computer science major,” and “You are a freshman,” respectively.
Noting that “only if” is one way a conditional statement can be expressed,
this sentence can be represented as
a → (c V ¬f ).

exercise : replace only if by if
exercise : replace only if by if and only if
EXAMPLE 2
How can this English sentence be translated into a logical expression?
“You cannot ride the roller coaster if you are under 4 feet tall unless you are
older than 16
years old.”
Solution: Let q, r, and s represent “You can ride the roller coaster,” “You are
under 4 feet tall,”
and “You are older than 16 years old,” respectively. Then the sentence can
be translated to
(r V ¬s) → ¬q.
Of course, there are other ways to represent the original sentence as a logical
expression,
but the one we have used should meet our needs.

Logic Circuits
Propositional logic can be applied to the design of computer hardware. This
was first observed
in 1938 by Claude Shannon in his MIT master’s thesis. we will study this
topic
in depth. We give a brief introduction to this application here.
A logic circuit (or digital circuit) receives input signals p1 , p2 , . . . , pn ,
each a bit [either
0 (off) or 1 (on)], and produces output signals s1 , s2 , . . . , sn, each a bit. In
this section we will
restrict our attention to logic circuits with a single output signal; in general,
digital circuits may
have multiple outputs.
If p=1 , q=1 and r=0 then result of the logice circuit behind is 1
------------------------------------------------------------------------------------------
EXAMPLE 10
Build a digital circuit that produces the output (p V ¬r) ^ (¬p V (q V¬r))
when given input bits p, q, and r.

question 2 : p=1 , q= 0 and r= 0 whats the value of the output ?


Question 3 / is it possible to obtain 0 as output value ?
Question 4 : give all solution to obtain 0 as a output of the digital circuit

1.3
Propositional Equivalences
1.4 Predicates and Quantifiers

1,
Let Q(x, y) denote the statement “x = y + 3.” What are the truth values of the
propositions Q(1, 2) and Q(3, 0)?

2,
Similarly, we can let R(x, y, z) denote the statement `‘x + y = z.” When
values are assigned
to the variables x, y, and z, this statement has a truth value.
What are the truth values of the propositions R(1, 2, 3) and R(0, 0, 1)?
3,
Consider the statement
if x > 0 then x := x + 1.
When this statement is encountered in a program, the value of the variable x
at that point in the
execution of the program is inserted into P (x), which is “x > 0.” If P (x) is
true for this value
of x, the assignment statement x := x + 1 is executed, so the value of x is
increased by 1. If
P (x) is false for this value of x, the assignment statement is not executed, so
the value of x is
not changed.


Consider these statements. The first two are called premises and the third is
called the conclusion.
The entire set is called an argument.
“All lions are fierce.”
“Some lions do not drink coffee.”
“Some fierce creatures do not drink coffee.”

Solution: We can express these statements as:


Logic Programming :

Consider a Prolog program given facts telling it the instructor of each class
and in which classes students are enrolled. The program uses these facts to
answer queries concerning the professors who teach particular students.
Such a program could use the predicates instructor(p, c) and enrolled(s, c) to
represent that professor p is the instructor of course c and that student s is
enrolled in course c, respectively. For example, the Prolog facts in such a
program might include:

instructor(chan,math273)
instructor(patel,ee222)
instructor(grossman,cs301)
enrolled(kevin,math273)
enrolled(juana,ee222)
enrolled(juana,cs301)
enrolled(kiko,math273)
enrolled(kiko,cs301)
(Lowercase letters have been used for entries because Prolog considers
names beginning with an uppercase letter to be variables.)
A new predicate teaches(p, s), representing that professor p teaches student
s, can be
defined using the Prolog rule
teaches(P,S) :- instructor(P,C) , enrolled(S,C)
which means that teaches(p, s) is true if there exists a class c such that
professor p is the instructor of class c and student s is enrolled in class c.
(Note that a comma is used to represent
a conjunction of predicates in Prolog. Similarly, a semicolon is used to
represent a disjunction of predicates.)
Prolog answers queries using the facts and rules it is given. For example,
using the factsand rules listed, the query
?enrolled(kevin,math273)
produces the response
yes
because the fact enrolled(kevin, math273) was provided as input. The query
?enrolled(X,math273)
produces the response
kevin
kiko
To produce this response, Prolog determines all possible values of X for
which
enrolled(X, math273) has been included as a Prolog fact. Similarly, to find
all the professors
who are instructors in classes being taken by Juana, we use the query
?teaches(X,juana)
This query returns
patel
grossman

Given the Prolog facts in previous Example, what would Prolog


return when given these queries?
a) ?enrolled(kevin,ee222)
b) ?enrolled(kiko,math273)
c) ?instructor(grossman,X)
d) ?instructor(X,cs301)
e) ?teaches(X,kevin)

You might also like