Title: Logic: Learning Objectives
1Logic Learning Objectives
- Learn about statements (propositions)
- Learn how to use logical connectives to combine
statements - Explore how to draw conclusions using various
argument forms - Become familiar with quantifiers and predicates
- CS
- Boolean data type
- If statement
- Impact of negations
- Implementation of quantifiers
2Mathematical Logic
- Definition Methods of reasoning, provides rules
and techniques to determine whether an argument
is valid - Theorem a statement that can be shown to be true
(under certain conditions) - Example If x is an even integer, then x 1 is
an odd integer - This statement is true under the condition that x
is an integer is true
3Mathematical Logic
- A statement, or a proposition, is a declarative
sentence that is either true or false, but not
both - Lowercase letters denote propositions
- Examples
- p 2 is an even number (true)
- q 3 is an odd number (true)
- r A is a consonant (false)
- The following are not propositions
- p My cat is beautiful
- q Are you in charge?
4Mathematical Logic
- Truth value
- One of the values truth or falsity assigned
to a statement - True is abbreviated to T or 1
- False is abbreviated to F or 0
- Negation
- The negation of p, written p, is the statement
obtained by negating statement p - Truth values of p and p are opposite
- Symbol is called not p is read as as not
p - Example
- p A is a consonant
- p it is the case that A is not a consonant
- q Are you in charge?
5Mathematical Logic
- Truth Table
- Conjunction
- Let p and q be statements.The conjunction of p
and q, written p q , is the statement formed by
joining statements p and q using the word and - The statement p?q is true if both p and q are
true otherwise p?q is false
6Mathematical Logic
- Conjunction
- Truth Table for
- Conjunction
7Mathematical Logic
- Disjunction
- Let p and q be statements. The disjunction of p
and q, written p v q , is the statement formed by
joining statements p and q using the word or - The statement p v q is true if at least one of
the statements p and q is true otherwise p v q
is false - The symbol v is read or
8Mathematical Logic
- Disjunction
- Truth Table for Disjunction
9Mathematical Logic
- Implication
- Let p and q be statements.The statement if p
then q is called an implication or condition. - The implication if p then q is written p ? q
- p ? q is read
- If p, then q
- p is sufficient for q
- q if p
- q whenever p
-
10Mathematical Logic
- Implication
- Truth Table for Implication
- p is called the hypothesis, q is called the
conclusion
11Mathematical Logic
- Implication
- Let p Today is Sunday and q I will wash the
car. The conjunction p ? q is the statement - p ? q If today is Sunday, then I will wash the
car - The converse of this implication is written q ? p
- If I wash the car, then today is Sunday
- The inverse of this implication is p ? q
- If today is not Sunday, then I will not wash the
car - The contrapositive of this implication is q ? p
- If I do not wash the car, then today is not
Sunday -
12Mathematical Logic
- Biimplication
- Let p and q be statements. The statement p if
and only if q is called the biimplication or
biconditional of p and q - The biconditional p if and only if q is written
p ? q - p ? q is read
- p if and only if q
- p is necessary and sufficient for q
- q if and only if p
- q when and only when p
-
13Mathematical Logic
- Biconditional
- Truth Table for the Biconditional
14Mathematical Logic
- Statement Formulas
- Definitions
- Symbols p ,q ,r ,...,called statement variables
- Symbols , , v, ?,and ? are called logical
connectives - A statement variable is a statement formula
- If A and B are statement formulas, then the
expressions (A ), (A B) , (A v B ), (A ? B )
and (A ? B ) are statement formulas - Expressions are statement formulas that are
constructed only by using 1) and 2) above
15Mathematical Logic
- Precedence of logical connectives is
- highest
- second highest
- v third highest
- ? fourth highest
- ? fifth highest
16Mathematical Logic
- Example
- Let A be the statement formula ((p v q )) ? (q
p ) - Truth Table for A is
17Mathematical Logic
- Tautology
- A statement formula A is said to be a tautology
if the truth value of A is T for any assignment
of the truth values T and F to the statement
variables occurring in A - Contradiction
- A statement formula A is said to be a
contradiction if the truth value of A is F for
any assignment of the truth values T and F to the
statement variables occurring in A
18Mathematical Logic
- Logically Implies
- A statement formula A is said to logically imply
a statement formula B if the statement formula A
? B is a tautology. If A logically implies B,
then symbolically we write A ? B - Logically Equivalent
- A statement formula A is said to be logically
equivalent to a statement formula B if the
statement formula A ? B is a tautology. If A is
logically equivalent to B , then symbolically we
write A B
19Mathematical Logic
20Mathematical Logic
- Proof of (p q ) ? ((q ?p ))
-
21Mathematical Logic
- Proof of (p q ) ? ((q ?p )) continued
22Validity of Arguments
- Proof an argument or a proof of a theorem
consists of a finite sequence of statements
ending in a conclusion - Argument a finite sequence
- of statements.
- The final statement, , is the conclusion,
and the statements
are the premises of the argument. - An argument is logically valid if the statement
formula - is a
tautology.
23Validity of Arguments - Example
P Q R Premises Valid
T T T T T T T T
T T F T F F F T
T F T F T F T T
T F F F T F F T
F T T T T T T T
F T F T F F T T
F F T T T T T T
F F F T T T T T
24Validity of Arguments
- Valid Argument Forms
- Modus Ponens (Method of Affirming)
P Q Premises Conclusion Q Valid
T T T T T T
T F F F F T
F T T F T T
F F T F F T
25Validity of Arguments
- Valid Argument Forms
- Modus Tollens (Method of Denying)
P Q Premises Conclusion Valid
T T T F F F T
T F F T F F T
F T T F F T T
F F T T T T T
26Validity of Arguments
- Valid Argument Forms
- Disjunctive Syllogisms
- Disjunctive Syllogisms
27Validity of Arguments
- Valid Argument Forms
- Hypothetical Syllogism (proven earlier)
- Dilemma
28Validity of Arguments
- Valid Argument Forms
- Conjunctive Simplification
- Conjunctive Simplification
29Validity of Arguments
- Valid Argument Forms
- Disjunctive Addition
- Disjunctive Addition
30Validity of Arguments
- Valid Argument Forms
- Conjunctive Addition
31Validity of Arguments Formal Derivation
- Prove
- Formal Derivation Rule
Comment1. P ? Q
Premise2. Q ?R
Premise3. P
Assumption Assume P4. Q
1,3, MP5. R
2,4, MP R is now proved6. P ?R
DT
Discharge P, ie, P is no
longer to
be used, and
conclude that P ? R - Uses Deduction Theorem (DT)
32Quantifiers and First Order Logic
- Have dealt with Propositional Logic (Calculus) so
far - Propositional variables, constants, expressions
- Dealt with truth or falsity of expressions as a
whole - Consider1. All cats have tails2. Tom is a
cat3. Tom has a tail - Cannot conclude 3, given 1 and 2 using
propositional logic - Predicate Calculus allows us to identify
individuals such as Tom together with properties
and predicates.
33Quantifiers and First Order Logic
- Predicate or Propositional Function
- Let x be a variable and D be a set P(x) is a
sentence - Then P(x) is called a predicate or propositional
function with respect to the set D if for each
value of x in D, P(x) is a statement i.e., P(x)
is true or false - Moreover, D is called the domain of the discourse
and x is called the free variable
34Quantifiers and First Order LogicPropositional
function example 1
- Let P(x) be the statement x is an odd integer
- Let D be the set of all positive integers.
- Then P is a propositional function with domain of
discourse D. - For each x in D , P(x) is a proposition, i.e. a
sentence which is either true or false. - P(1) 1 is an odd integer True
- P(14) 14 is an odd integer - False
35Quantifiers and First Order LogicPropositional
function example 2
- Let P(x) be the statement the baseball player
hit over .300 in 2003 - Let D be the set of all baseball players.
- Then P is a propositional function with domain of
discourse D. - For each x in D , P(x) is a proposition, i.e. a
sentence which is either true or false. - P(Barry Bonds) Barry Bonds hit over .300 in 2003
- True - P(Alex Rodriguez) Alex Rodriguez hit over .300
in 2003 - False
36Quantifiers and First Order Logic
- Predicate or Propositional Function
- Example
- Q(x,y) x gt y, where the Domain is the set of
integers - Q is a 2-place predicate
- Q is T for Q(4,3) and Q is F for Q (3,4)
37Quantifiers and First Order Logic
- Universal Quantifier
- Let P(x) be a predicate and let D be the domain
of the discourse. The universal quantification of
P(x) is the statement - For all x, P(x) or
- For every x, P(x)
- The symbol is read as for all and every
-
- Two-place predicate
38Quantifiers and First Order Logic
- Universal Quantifier Examples
- Consider the statement
- It is true if P(x) is true for every x in D
- It is false if P(x) is false for at least one x
in D - Consider with D being the set of all real
numbers. - The statement is true because for every real
number x, it is true that the square of x is
positive or zero. - Consider that with D being the
set of real numbers is false. Why?
39Quantifiers and First Order Logic
- Existential Quantifier
- Let P(x) be a predicate and let D be the domain
of the discourse. The existential quantification
of P(x) is the statement - There exists x, P(x)
- The symbol is read as there exists
-
- Bound Variable
- The variable appearing in
or
40Quantifiers and First Order Logic
- Existential Quantifier Example
- Consider
- It is true since there is at least one real
number x for which the proposition is true. Try
x2 - Suppose that P is a propositional function whose
domain of discourse consists of the elements
d1,,dn. The following pseudocode determines
whether is true.
41Quantifiers and First Order Logic
- Negation of Predicates (DeMorgans Laws)
-
- Example
- If P(x) is the statement x has won a race
where the domain of discourse is all runners,
then the universal quantification of P(x) is
, i.e., every runner has won a
race. The negation of this statement is it is
not the case that every runner has won a race.
Therefore there exists at least one runner who
has not won a race. Therefore - and so,
42Quantifiers and First Order Logic
- Negation of Predicates (DeMorgans Laws)
-
43Quantifiers and First Order Logic
- Formulas in Predicate Logic
- All statement formulas are considered formulas
- Each n, n 1,2,...,n-place predicate P(
) containing the variables
is a formula. - If A and B are formulas, then the expressions A,
(A?B), (A?B) , A ?B and A?B are statement
formulas, where , ?, ?, ? and ? are logical
connectives - If A is a formula and x is a variable, then ?x
A(x) and ?x A(x) are formulas - All formulas constructed using only above rules
are considered formulas in predicate logic
44Quantifiers and First Order Logic
- Additional Rules of Inference
- If the statement ?x P(x) is assumed to be true,
then P(a) is also true,where a is an arbitrary
member of the domain of the discourse. This rule
is called the universal specification (US) - If P(a) is true, where a is an arbitrary member
of the domain of the discourse, then ?x P(x) is
true. This rule is called the universal
generalization (UG) - If the statement ?x P (x) is true, then P(a) is
true, for some member of the domain of the
discourse. This rule is called the existential
specification (ES) - If P(a) is true for some member a of the domain
of the discourse, then ?x P(x) is also true. This
rule is called the existential generalization (EG)
45Quantifiers and First Order Logic
- Counterexample
- An argument has the form ?x (P(x ) ? Q(x )),
where the domain of discourse is D - To show that this implication is not true in the
domain D, it must be shown that there exists some
x in D such that (P(x ) ? Q(x )) is not
true - This means that there exists some x in D such
that P(x) is true but Q(x) is not true. Such an x
is called a counterexample of the above
implication - To show that ?x (P(x) ? Q(x)) is false by finding
an x in D such that P(x) ? Q(x) is false is
called the disproof of the given statement by
counterexample
46Logic and CS
- Logic is basis of ALU
- Logic is crucial to IF statements
- AND
- OR
- NOT
- Implementation of quantifiers
- Looping
- Database Query Languages
- Relational Algebra
- Relational Calculus
- SQL