CS 201 Lecture 2 - Logic in Natural Languages
CS 201 Lecture 2 - Logic in Natural Languages
Kholoud Nairoukh
Department of Computer Science
German-Jordanian University
Lecture 2
Topic #1.0 – Propositional Logic: Operators
antecedent consequent
• 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
True or False:
➢ “If this lecture ever ends, then the sun will rise
tomorrow.”
✓ “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.
▪ Its contrapositive: ¬q → ¬ p.
• 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
• Example:
• By convention:
0 represents “false”; 1 represents “true”.
❖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