logic: learning objectives
DESCRIPTION
Logic: 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 - PowerPoint PPT PresentationTRANSCRIPT
Discrete Mathematical Structures: Theory and Applications 1
Logic: 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
Discrete Mathematical Structures: Theory and Applications 2
Mathematical 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
Discrete Mathematical Structures: Theory and Applications 3
Mathematical Logic
A statement, or a proposition, is a declarative sentence that is either true or false, but not both
Lowercase letters denote propositionsExamples:
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?
Discrete Mathematical Structures: Theory and Applications 4
Mathematical Logic Truth value
One of the values “truth” or “falsity” assigned to a statement
True is abbreviated to T or 1False is abbreviated to F or 0
NegationThe negation of p, written ∼p, is the statement obtained
by negating statement p Truth values of p and ∼p are oppositeSymbol ~ 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?
Discrete Mathematical Structures: Theory and Applications 5
Mathematical Logic
Truth Table
ConjunctionLet 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
Discrete Mathematical Structures: Theory and Applications 6
Mathematical Logic
ConjunctionTruth Table for Conjunction:
Discrete Mathematical Structures: Theory and Applications 7
Mathematical 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”
Discrete Mathematical Structures: Theory and Applications 8
Mathematical Logic
DisjunctionTruth Table for
Disjunction:
Discrete Mathematical Structures: Theory and Applications 9
Mathematical 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
Discrete Mathematical Structures: Theory and Applications 10
Mathematical Logic
ImplicationTruth Table for Implication:
p is called the hypothesis, q is called the conclusion
Discrete Mathematical Structures: Theory and Applications 11
Mathematical Logic
ImplicationLet 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 pIf I wash the car, then today is Sunday
The inverse of this implication is ~p ~qIf today is not Sunday, then I will not wash the car
The contrapositive of this implication is ~q ~pIf I do not wash the car, then today is not Sunday
Discrete Mathematical Structures: Theory and Applications 12
Mathematical Logic
BiimplicationLet 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”
Discrete Mathematical Structures: Theory and Applications 13
Mathematical Logic
BiconditionalTruth Table for the Biconditional:
Discrete Mathematical Structures: Theory and Applications 14
Mathematical Logic
Statement Formulas Definitions
Symbols p ,q ,r ,...,called statement variables
Symbols ~, ^, v, →,and ↔ are called logical
connectives1) A statement variable is a statement formula2) 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
Discrete Mathematical Structures: Theory and Applications 15
Mathematical Logic
Precedence of logical connectives is:
~ highest
^ second highest
v third highest
→ fourth highest
↔ fifth highest
Discrete Mathematical Structures: Theory and Applications 16
Mathematical LogicExample:
Let A be the statement formula (~(p v q )) → (q ^
p )Truth Table for A is:
Discrete Mathematical Structures: Theory and Applications 17
Mathematical 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
Discrete Mathematical Structures: Theory and Applications 18
Mathematical Logic
Logically ImpliesA 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 EquivalentA 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
Discrete Mathematical Structures: Theory and Applications 19
Mathematical Logic
Discrete Mathematical Structures: Theory and Applications 20
Mathematical Logic
Proof of (~p ^ q ) → (~(q →p ))
Discrete Mathematical Structures: Theory and Applications 21
Mathematical LogicProof of (~p ^ q ) → (~(q →p )) [continued]
Discrete Mathematical Structures: Theory and Applications 22
Validity 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.
AAAAA nn,...,,,,
1321
An
AAAA n 1321...,,,,
AAAAA nn
1321...
Discrete Mathematical Structures: Theory and Applications 23
Validity of Arguments - Example RPRQQP
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
QP RQ RP
Discrete Mathematical Structures: Theory and Applications 24
Validity of Arguments
Valid Argument FormsModus 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
QP
Discrete Mathematical Structures: Theory and Applications 25
Validity of Arguments
Valid Argument Forms
Modus Tollens (Method of Denying)
QPP 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
Q P
Discrete Mathematical Structures: Theory and Applications 26
Validity of Arguments
Valid Argument FormsDisjunctive Syllogisms
Disjunctive Syllogisms
Discrete Mathematical Structures: Theory and Applications 27
Validity of Arguments Valid Argument Forms
Hypothetical Syllogism (proven earlier)
Dilemma
Discrete Mathematical Structures: Theory and Applications 28
Validity of Arguments
Valid Argument FormsConjunctive Simplification
Conjunctive Simplification
Discrete Mathematical Structures: Theory and Applications 29
Validity of Arguments
Valid Argument FormsDisjunctive Addition
Disjunctive Addition
Discrete Mathematical Structures: Theory and Applications 30
Validity of Arguments
Valid Argument FormsConjunctive Addition
Discrete Mathematical Structures: Theory and Applications 31
Validity of Arguments – Formal Derivation
Prove Formal Derivation Rule Comment
1. P Q Premise2. Q R Premise
3. P Assumption Assume P4. Q 1,3, MP5. R 2,4, MP R is now proved
6. P R DT Discharge P, ie, P is no longer to be used, and conclude that P R
Uses Deduction Theorem (DT)
RPRQQP
Discrete Mathematical Structures: Theory and Applications 32
Quantifiers 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
Consider:1. 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.
Discrete Mathematical Structures: Theory and Applications 33
Quantifiers 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
Discrete Mathematical Structures: Theory and Applications 34
Quantifiers 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
Discrete Mathematical Structures: Theory and Applications 35
Quantifiers 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
Discrete Mathematical Structures: Theory and Applications 36
Quantifiers and First Order Logic
Predicate or Propositional Function
Example: Q(x,y) : x > 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)
Discrete Mathematical Structures: Theory and Applications 37
Quantifiers 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:
)( xPx),( yxPyx
Discrete Mathematical Structures: Theory and Applications 38
Quantifiers 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?
xxP
02 xx
012 xx
Discrete Mathematical Structures: Theory and Applications 39
Quantifiers 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 VariableThe variable appearing in: or
)( xPx
)( xPx )( xPx
Discrete Mathematical Structures: Theory and Applications 40
Quantifiers 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 x=2
Suppose that P is a propositional function whose domain of discourse consists of the elements d1,…,dn. The following pseudocode determines whether
is true.
5
2
12x
xx
xxP
Discrete Mathematical Structures: Theory and Applications 41
Quantifiers and First Order Logic
Negation of Predicates (DeMorgan’s 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,
)(~ )( ~ xPxxPx
)( xPx
)(~ xPx
)(~ )( ~ xPxxPx
Discrete Mathematical Structures: Theory and Applications 42
Quantifiers and First Order Logic
Negation of Predicates (DeMorgan’s Laws)
)(~ )( ~ xPxxPx
Discrete Mathematical Structures: Theory and Applications 43
Quantifiers and First Order Logic
Formulas in Predicate LogicAll statement formulas are considered formulasEach 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
xxx n,...,,
21
xxx n,...,,
21
Discrete Mathematical Structures: Theory and Applications 44
Quantifiers and First Order Logic
Additional Rules of InferenceIf 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)
Discrete Mathematical Structures: Theory and Applications 45
Quantifiers and First Order Logic
CounterexampleAn argument has the form ∀x (P(x ) → Q(x )),
where the domain of discourse is DTo 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
Discrete Mathematical Structures: Theory and Applications 46
Logic and CS
Logic is basis of ALULogic is crucial to IF statements
ANDORNOT
Implementation of quantifiersLooping
Database Query LanguagesRelational AlgebraRelational CalculusSQL