Week 5 - Propositional Logic A
3.101 Introduction to propositional logic
- Propositional Logic
- A branch of logic that is interested in studying mathematical statements.
- The basis of reasoning and the rules used to construct mathematical theories.
- Original purpose of propositional logic dates back to Aristotle. Used to model reasoning.
- "An algebra of propositions".
- Variables are unknown propositions not unknown real numbers.
- Instead of
+
,-
,x
,%
, the operators used are:and
or
not
implies
if
if and only if
- Used in:
- computer circuit design.
- programming languages and systems, such as language Prolog.
- logic-based programming languages:
- languages use "predicate logic", a more powerful form of logic that extends the capabilities of propositional logic
3.103 Propositions
- Proposition
- A declarative sentence that is either true or false but not both.
- The most basic element of logic.
- Examples
- London is the capital of the United Kingdom
- A true proposition.
- Another true proposition.
- Madrid is the capital of France.
- A false proposition.
- 10 is an odd number
- Another false proposition.
- London is the capital of the United Kingdom
- Examples that aren't propositions
- Since we don't know the value of x, we don't know if it's true or false.
- What time is it?
- Not a declarative sentence, so not a proposition.
- Read this carefully.
- This coffee is strong
- Subjective meaning: not true or false.
- Propositional variables
- Use variables for propositional shorthand.
- Typically uses letter like: , ,
- Examples
- p: London is the capital of United Kingdom
- q : 1 + 1 = 2
- r : 2 < 3
3.105 Truth tables and truth sets
-
- A tabular representation of possible combinations of constituent variables.
- To construct the truth table for n propositions:
- Create table with rows and n columns.
- Fill the first n columns with all the possible combinations.
- Example
-
Two propositional variables p and q:
p q FALSE FALSE FALSE TRUE TRUE FALSE TRUE TRUE
-
-
Truth Set
- Let be a proposition of set .
- The truth set of is the set of elements of for which is true.
- We use the capital letter to refer to truth set of a proposition.
- Truth set of is
- Example
- Let
- Let and be 2 propositions concerning an integer n in S, defined as follows:
- : is even
- : is odd
- The truth set of written as is:
- The truth of set q is:
- Q = {1, 3, 5, 7, 9}
3.107 Compound propositions
- Compound Statements
- Statements build by combining multiple propositions using certain rules.
- Negation
- Not : Defined by
- "It is not the case that "
- The truth value of the negation of , , is the opposite of truth value of .
- Example
- : John's program is written in Python
- : John's program is not written in Python
- Conjunction
- Symbol:
- and
- Let and be propositions.
- Conjunction of and are denoted by
- Conjunction is only true when both and are true. False if it isn't the case.
- Example:
- : John's program is written in Python
- : John's program has less than 20 lines of code.
- : John's program is written in Python and has < 20 lines of code.
- Disjunction * Symbol:
- or
- Let and be propositions.
- The disjunction of and denoted by is only false when both and are false, otherwise true.
- Example:
- : John's program is written in Python.
- : John's program is < 20 lines of code.
- : John's prgram is written in Python or has less than 20 lines of code.
- Exclusive-Or
- Symbol:
- or (but not both)
- Precedence of logical operations
- To build complex compound propositions, we need to use parentheses.
- Example:
- is different from
-
To reduce the number of parentheses, we can use order of precedence.
Operator Precedence 1 2 3