0% found this document useful (0 votes)
10 views22 pages

CS 201 Lecture 2 - Logic in Natural Languages

Uploaded by

aljubehjihad
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)
10 views22 pages

CS 201 Lecture 2 - Logic in Natural Languages

Uploaded by

aljubehjihad
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/ 22

Dr.

Kholoud Nairoukh
Department of Computer Science
German-Jordanian University
Lecture 2
Topic #1.0 – Propositional Logic: Operators

• Note that English “or” can be ambiguous


regarding the “both” case!

“Pat is a singer or p q p "or" q


Pat is a writer.” –  F F F
F T T
“Pat is a man or T F T
Pat is a woman.” –  T T ?

• Need context to disambiguate the meaning!


For this class, assume “or” means inclusive.
Dr. Kholoud Nairoukh 2
Topic #1.0 – Propositional Logic: Operators

antecedent consequent

• The implication p → q states that p implies q.


i.e., If p is true, then q is true; but if p is not
true, then q could be either true or false.

• Example, let
p =“You study hard.”
q = “You will get a good grade.”
p → q = “If you study hard, then you will get
a good grade.” (else, it could go either way)
Dr. Kholoud Nairoukh 3
Topic #1.0 – Propositional Logic: Operators

o p → q is false only when


p is true but q is not true. p q p→q
F F T
The
F T T
o p → q does not say T F F
only
that p causes q! T T T
False
case!

o p → q does not require


that p or q are ever true!

o Example “(1=0) → cat can fly” is True


Dr. Kholoud Nairoukh 4
Topic #1.0 – Propositional Logic: Operators

True or False:
➢ “If this lecture ever ends, then the sun will rise
tomorrow.”

➢ “If Tuesday is a day of the week, then I am a lion.”

➢ “If 1+1=10, then a bird can fly.”

➢ “If the cake is made of stone, then a baby is taller


than 3 meters.”

Dr. Kholoud Nairoukh 5


• Consider a sentence like,
“If I wear a red shirt tomorrow, then it will
rain!”
• In logic, we consider the sentence True so
long as either I don’t wear a red shirt, or it
rains.
• But, in normal English conversation, if I were
to make this claim, you would think that I was
lying.
Why this discrepancy between logic &
language?
Dr. Kholoud Nairoukh 6
• In English, a sentence “if p then q” usually really implicitly
means something like,
– “In all possible situations, if p then q.”
✓That is, “For p to be true and q false is impossible.”
✓Or, “I guarantee that no matter what, if p, then q.”

• This can be expressed in predicate logic as:


– “For all situations s, if p is true in situation s, then q is
also true in situation s”
➢ Formally, we could write: s, P(s) → Q(s)

• That sentence is logically False in our example, because


for me to wear a red shirt and for the sky to rain is a
possible (even if not actual) situation.
– Natural language and logic then agree with each other.
Dr. Kholoud Nairoukh 7
Topic #1.0 – Propositional Logic: Operators

✓ “p implies q” ✓ “p only if q”
✓ “if p, then q” ✓ “p is sufficient for
q”
✓ “if p, q” ✓ “q is necessary for
✓ “when p, q” p”
✓ “whenever p, q” ✓ “q follows from p”
✓ “q if p” ✓ “q is implied by p”
We will see some
✓ “q when p” equivalent logic
✓ “q whenever p” expressions later.

Dr. Kholoud Nairoukh 8


Topic #1.0 – Propositional Logic: Operators

Some terminology, for an implication p → q:

▪ Its converse is: q → p.

▪ Its inverse is: ¬p → ¬q.

▪ Its contrapositive: ¬q → ¬ p.

▪ Which one of these three has the same


meaning (same truth table) as p → q ?
Dr. Kholoud Nairoukh 9
Topic #1.0 – Propositional Logic: Operators

• Converses: p → q and q → p
⚫ Example “If it is noon, then I am hungry.”
“If I am hungry, then it is noon.”

• Inverses: p → q and p → q
⚫ Example “If it is noon, then I am hungry.”
“If it is not noon, then I am not hungry.”

• Contrapositives: p → q and q → p
⚫ Example “If it is noon, then I am hungry.”
“If I am not hungry, then it is not noon.”
Dr. Kholoud Nairoukh 10
Topic #1.0 – Propositional Logic: Operators

• Proving the equivalence of p → q and its


contrapositive using truth tables:

Dr. Kholoud Nairoukh 11


Topic #1.0 – Propositional Logic: Operators

• The bi-conditional p  q states that p is true


if and only if (IFF) q is true.

• Example:

p = “You can take the flight.”


q = “You buy a ticket”
p  q = “You can take the flight if and only if
you buy a ticket”

Dr. Kholoud Nairoukh 12


Topic #1.0 – Propositional Logic: Operators

• p  q means that p and q


have the same truth value. p q pq
F F T
• Note this truth table is the F T F
exact opposite of ’s! T F F
Thus, p  q means ¬(p  q) T T T

Dr. Kholoud Nairoukh 13


Topic #1.0 – Propositional Logic: Operators

• We have seen 1 unary operator and 5


binary operators. Their truth tables are
below.

Dr. Kholoud Nairoukh 14


Topic #2 – Bits

• A bit is a binary (base 2) digit: 0 or 1.

• Bits may be used to represent truth values.

• By convention:
0 represents “false”; 1 represents “true”.

• Boolean algebra is like ordinary algebra


except that variables stand for bits, + means
“or”, and multiplication means “and”.

Dr. Kholoud Nairoukh 16


Topic #2 – Bits

❖ A Bit string of length n is an ordered sequence


(series, tuple) of n0 bits.

❖ By convention, bit strings are (sometimes) written


left to right:
Example: the “first” bit of the bit string
“1001101010” is 1.
Another common convention is that the rightmost
bit is bit #0, the 2nd-rightmost is bit #1, etc.

❖ When a bit string represents a base-2 number, by


convention, the first (leftmost) bit is the most
significant bit.
Example: 11012=8+4+1=13.
Dr. Kholoud Nairoukh 17
Topic #2 – Bits

o You can count up to 1,023 just using two hands:


Count in binary! each finger represents 1 bit.(102 =
1024)

o To increment: Flip the rightmost (low-order) bit.


If it changes 1→0, then also flip the next bit to the
left,
o If that bit changes 1→0, then flip the next
one, etc.

o 0000000000, 0000000001, 0000000010, …


…, 1111111101, 1111111110, 1111111111
Dr. Kholoud Nairoukh 18
Topic #2 – Bits

❖Boolean operations can be extended to


operate on bit strings as well as single bits.

❖Example:
01 1011 0110
11 0001 1101
11
11 1011 1111
1011 1111 Bit-wise OR
010001
01 00010100
0100 Bit-wise AND
10 1010
10 10101011
1011 Bit-wise XOR

Dr. Kholoud Nairoukh 19


Topic #1.1 – Propositional Logic: Equivalences

Two syntactically (i.e., textually) different


compound propositions may be semantically
identical (i.e., have the same meaning). We
call them equivalent.

➢ Various equivalence rules or laws.

➢ How to prove equivalences using symbolic


derivations.

Dr. Kholoud Nairoukh 20


Topic #1.1 – Propositional Logic: Equivalences

• A tautology is a compound proposition that is


true no matter what the truth values of its
atomic propositions are!
Example: p  p

• A contradiction is a compound proposition


that is false no matter what values of its
atomic propositions are! Example: p  p

• Other compound props. are contingencies.

Dr. Kholoud Nairoukh 21


Topic #1.1 – Propositional Logic: Equivalences

• Compound proposition p is logically equivalent


to compound proposition q, written pq, IFF
the compound proposition pq is a tautology.

• Compound propositions p and q are logically


equivalent to each other IFF p and q contain
the same truth values as each other in all
rows of their truth tables.

Dr. Kholoud Nairoukh 22


Topic #1.1 – Propositional Logic: Equivalences

Example: Prove that pq  (p  q)

Dr. Kholoud Nairoukh 23

You might also like