COMP 2711H: Lecture 1
Date: 2024-09-01 23:02:24
Reviewed:
Topic / Chapter: Propositional Logic
summary
βQuestions
- Is there any practical difference between logic / boolean algebra?
- Is Boolean algebra "algebra" because we have XYZ?
Notes
Introduction to the Course
-
COMP 2711H
- π¨βπ«Honors, so we will put infinite pressure on you HAHA
- 0 coding, 100% theoretical
- this session: easy (unlike others)
- ~50%: have A's
- but thou shalt suffer before getting it!
- talking about basics: proof, proposition, set of natural numbers
- π¨βπ«Honors, so we will put infinite pressure on you HAHA
Introduction to Propositions
-
Propositional logic
- proposition any statement that can be true / false (not both)
- π¨βπ«or 1 or 0, as we are CS PPL
- if you can't assign Boolean value: not a statement
- e.g. "close the door" not boolean
- usually using for var. names
- atomic proposition prop. that can't be further broken down
- for combination: use operators like ("neg")
- and we often draw truth table to represent the value
- proposition any statement that can be true / false (not both)
-
Logical operators
-
negation: or
-
"it is not the case that "
- read as "not "
-
(!p) ? 1 : 0
-
always opposite of
1 0 0 1 -
examples
- "Prof. Amir uses Kali Linux for his desktop"
- "Prof. Amir doesn't use Kali Linux for his desktop"
-
-
disjunction:
-
" or "
-
(p || q) ? 1 : 0
-
0 only if both and are 0
1 1 1 1 0 1 0 1 1 0 0 0
-
-
conjunction:
-
" and "
-
(p && q) ? 1 : 0
-
1 only if both and are T
-
π¨βπ« logical operator: kind of "promise" on condition
1 1 1 1 0 0 0 1 0 0 0 0
-
-
exclusive or (xor):
-
1 when exactly one of and is T
- 0 otherwise
-
((p && !q) || (!p && q)) ? 1 : 0
- or:
(p ^ q) ? 1 : 0
(bit-wise though)
1 1 0 1 0 1 0 1 1 0 0 0 - or:
-
-
implication
-
cond. state.:
- = prop. "if then "
-
: hypothesis / premise
-
: conclusion / consequence / implication
-
(!p || (p && q)) ? 1 : 0
-
π¨βπ«: any connection in : not needed
- simply depending on its values
-
π¨βπ«: also, kind of promise
- "if you are in classroom 2456, then you are Y1 student"
-
can be combined, like:
1 1 1 1 0 0 0 1 1 0 0 1 -
examples
- if the moon is made of green cheese, then I have more money than Bill Gates
- π¨βπ as the hypothesis is false, the true value of conclusion doesn't matter
- π¨βπ you broke the promise (more like, premise) first!!!
- if the moon is made of green cheese, then I have more money than Bill Gates
-
-
π¨βπ« dual
- let be a statement
- is the statement obtained by following replacement
- example
-
-
Conditional statement
-
necessary / sufficient conditions
- if , then
- : sufficient condition of
- : necessary condition of
- examples
- if I am elected, then taxes will be lowered
- if elected: sufficient to know "tax will be lowered"
- if not "tax will be lowered" it must be that I am not elected
- other ways for
- if , then
- if
- when
- implies
- follows from
- is a sufficient condition for
- is a necessary condition for
- only if (falsity of : implies falsity of )
- if , then
-
converse, contrapositive
-
(below: of )
-
converse:
-
contrapositive:
-
inverse:
-
: equivalent to its contrapositive
T T T T T F F F F T T T F F T T
-
-
bi-conditional statement
-
bicon. state.:
- = prop. " if and only if "
- or: iff
-
T when and have the same truth value
- or
-
equivalent
- if and only if
- iff
- is "necessary and sufficient" for
- if then , and conversely
T T T T F F F T F F F T
-
-
Proof / Propositional Equivalence
-
Tautology and contradiction
- tautology: compound proposition, that is always true
- no matter values of the prop. vars in it
- π¨βπ«: to proof: to show that certain statement is a tautology
- no matter values of the prop. vars in it
- contradiction: compound proposition, that is always false
- contingency: compound proposition that is neither a tautology nor a contradiction
- example
- is a tautology
- as well as
- as premise: always 0
- is a contradiction
- is a contingency
- is a tautology
- tautology: compound proposition, that is always true
-
Boolean algebra
- conjunction, disjunction, or negation: can be implemented in hardware easily
- π¨βπ« but, how can gates output true when all conjunctions are false?
- for simplicity, just imagine there is an extra power line
- π¨βπ« but, how can gates output true when all conjunctions are false?
- conjunction, disjunction, or negation: can be implemented in hardware easily
graph TD; OR(( β¨ )) --> c_1[ ]; a_1[ ] --> OR; b_1[ ] --> OR; AND(( β§ )) --> c_2[ ]; a_2[ ] --> AND; b_2[ ] --> AND; NOT(( Β¬ )) --> c_3[ ]; a_3[ ] --> NOT;
-
let's build a simple adder!
- bit 0 adder:
- : defined as
- read as, "XOR"
- carry:
- bit 1:
- π¨βπuse 2611 knowledge
- π¨βπ«: one thing you can't ask: "where will this course be useful?"
- bit 0 adder:
-
Logical equivalence
- compound prop. always having the same truth values: logically equivalent
- i.e. is a tautology
- notation: (or )
- : not a logical operator
- : not a compound prop., but a statement!
- that is a tautology
- example:
- π¨βπ you can use truth table to compare! (manual)
- use of
- : denotes logical equivalence, regardless of var. values
- : binary logical operator
- : not used on propositions
- only on two mathematical quantities
- compound prop. always having the same truth values: logically equivalent
-
Propositional equivalences
- π¨βπ« many algebraic rules also work here!
- consider as addition, and as multiplication
major equivalences
Name Equivalence Identity laws Domination laws Idempotent laws Double negation laws Commutative laws Associative laws Distributive laws De Morgan's laws Absorption laws Negation laws Involving cond. states Involving bicond. states. - π¨βπ« many algebraic rules also work here!
-
Examples
- Use De Morgan's laws to express the negations of "Alice will send a secret message or Bob will send a secret message" and "today is Saturday and today is a holiday".
- Alice & Bob
- := Alice will send a secret message
- := Bob will send a secret message
expr
:=expr
==- = "Alice will NOT send a secret message and Bob will NOT send a secret message"
- Today is...
- := today is Saturday
- := today is a holiday
expr
:=expr
==
- Alice & Bob
- Show that and are logically equivalent by developing a series of logical equivalences.
- Show that and are logically equivalent by developing a series of logical equivalences.
- =
- Show that is a tautology by developing a series of logical equivalences.
- Use De Morgan's laws to express the negations of "Alice will send a secret message or Bob will send a secret message" and "today is Saturday and today is a holiday".
Rules of Inference
-
Rules of inference
-
theorem: statement that is always true (or: is a tautology)
-
we can write theorem as
-
better, we can define proof
- you can either fill in size table...
- or: you use "inference" from existing tautology
-
proof for is
- a sequence of statements
-
s.t. for each , either is true
- for some
- i.e. the premise
- is a tautology
- i.e. can be implied from prev. statements
- for some
-
π¨βπ« "one rule is actually enough"
- but we introduce multiple for now
-
-
Rules
- modus ponens
- thereafter, you can use as a tautology
- or: " is a tautology"
- π¨βπ« just another way of writing a tautology!
- π¨βπ« the actual, only real rule here
- syllogism
- or: "" is a tautology
- modus tollens
- modus ponens