Download Document

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Meaning (philosophy of language) wikipedia , lookup

Willard Van Orman Quine wikipedia , lookup

Fuzzy logic wikipedia , lookup

Catuṣkoṭi wikipedia , lookup

History of the function concept wikipedia , lookup

Modal logic wikipedia , lookup

Quantum logic wikipedia , lookup

List of first-order theories wikipedia , lookup

Structure (mathematical logic) wikipedia , lookup

Propositional formula wikipedia , lookup

Axiom wikipedia , lookup

Non-standard analysis wikipedia , lookup

First-order logic wikipedia , lookup

Combinatory logic wikipedia , lookup

History of logic wikipedia , lookup

Mathematical proof wikipedia , lookup

Model theory wikipedia , lookup

Axiom of reducibility wikipedia , lookup

Intuitionistic logic wikipedia , lookup

Argument wikipedia , lookup

Set theory wikipedia , lookup

Jesús Mosterín wikipedia , lookup

Natural deduction wikipedia , lookup

Propositional calculus wikipedia , lookup

Law of thought wikipedia , lookup

Interpretation (logic) wikipedia , lookup

Syllogism wikipedia , lookup

Mathematical logic wikipedia , lookup

Laws of Form wikipedia , lookup

Foundations of mathematics wikipedia , lookup

Truth-bearer wikipedia , lookup

Principia Mathematica wikipedia , lookup

Transcript
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
1
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
2
Mathematical 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?
Discrete Mathematical Structures: Theory and Applications
3
Mathematical 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?
Discrete Mathematical Structures: Theory and Applications
4
Mathematical 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
Discrete Mathematical Structures: Theory and Applications
5
Mathematical Logic
Conjunction
Truth Table for
Conjunction:
Discrete Mathematical Structures: Theory and Applications
6
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
7
Mathematical Logic
Disjunction
Truth Table for
Disjunction:
Discrete Mathematical Structures: Theory and Applications
8
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
9
Mathematical Logic
Implication
Truth Table for Implication:
p is called the hypothesis, q is called the
conclusion
Discrete Mathematical Structures: Theory and Applications
10
Mathematical 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
Discrete Mathematical Structures: Theory and Applications
11
Mathematical 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”
Discrete Mathematical Structures: Theory and Applications
12
Mathematical Logic
Biconditional
Truth Table for the Biconditional:
Discrete Mathematical Structures: Theory and Applications
13
Mathematical Logic
 Statement Formulas
 Definitions
 Symbols p ,q ,r ,...,called statement variables
 Symbols ~, , v, →,and ↔ are called logical
^
connectives
1) A statement variable is a statement formula
2) 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
14
Mathematical Logic
Precedence of logical connectives is:
~ highest

^
second highest
 v third highest
→ fourth highest
↔ fifth highest
Discrete Mathematical Structures: Theory and Applications
15
Mathematical Logic
Example:
Let A be the statement formula (~(p v q )) → (q
Truth Table for A is:
Discrete Mathematical Structures: Theory and Applications
^p)
16
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
17
Mathematical 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
Discrete Mathematical Structures: Theory and Applications
18
Mathematical Logic
Discrete Mathematical Structures: Theory and Applications
19
Mathematical Logic
 Proof of (~p
^q)→
Discrete Mathematical Structures: Theory and Applications
(~(q →p ))
20
Mathematical Logic
Proof of (~p
^
q ) → (~(q →p )) [continued]
Discrete Mathematical Structures: Theory and Applications
21
Validity of Arguments
Proof: an argument or a proof of a theorem
consists of a finite sequence of statements
ending in a conclusion A1 , A2 , A3 , ..., An1 , An
Argument: a finite sequence
of statements.
The final statement, An , is the conclusion, and
the statements
A1 , A2 , A3 , ..., An1 are the
premises of the argument.
An argument is logically valid if the statement
formula A1  A2  A3  ...  An1  An
is a tautology.
Discrete Mathematical Structures: Theory and Applications
22
Validity of Arguments - Example
P  Q  Q  R  P  R
Q
P
R
P  Q
Q  R
Premises
P  R
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
Discrete Mathematical Structures: Theory and Applications
23
Validity of Arguments
Valid Argument Forms
Modus Ponens (Method of Affirming)
Q
P
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
Discrete Mathematical Structures: Theory and Applications
24
Validity of Arguments
Valid Argument Forms
Modus Tollens (Method of Denying)
Q
P
P  Q
Q
Premises
Conclusion
P
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
Discrete Mathematical Structures: Theory and Applications
25
Validity of Arguments
Valid Argument Forms
Disjunctive Syllogisms
Disjunctive Syllogisms
Discrete Mathematical Structures: Theory and Applications
26
Validity of Arguments
 Valid Argument Forms
 Hypothetical Syllogism (proven earlier)
 Dilemma
Discrete Mathematical Structures: Theory and Applications
27
Validity of Arguments
Valid Argument Forms
Conjunctive Simplification
Conjunctive Simplification
Discrete Mathematical Structures: Theory and Applications
28
Validity of Arguments
Valid Argument Forms
Disjunctive Addition
Disjunctive Addition
Discrete Mathematical Structures: Theory and Applications
29
Validity of Arguments
Valid Argument Forms
Conjunctive Addition
Discrete Mathematical Structures: Theory and Applications
30
Validity of Arguments – Formal Derivation
Prove
P  Q  Q  R  P  R
 Formal Derivation
Rule
Comment
1. P  Q
2. Q R
Premise
Premise
3.
4.
5.
Assumption
1,3, MP
2,4, MP
Assume P
DT
Discharge P, ie, P is no
longer to be used, and
conclude that P  R
P
Q
R
6. P R
R is now proved
 Uses Deduction Theorem (DT)
Discrete Mathematical Structures: Theory and Applications
31
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 tails
2. Tom is a cat
3. 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
32
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
33
Quantifiers and First Order Logic
Propositional 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
34
Quantifiers and First Order Logic
Propositional 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
35
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
36
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”
 x P ( x )
 Two-place predicate: xy P( x, y )
Discrete Mathematical Structures: Theory and Applications
37
Quantifiers and First Order Logic
 Universal Quantifier Examples
 Consider the statement
xPx 
 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
real numbers.

x x 2  0

with D being the set of all
 The statement is true because for every real number x, it is
true that the square of x is positive or zero.
 Consider that

x x 2  1  0

with D being the set of
real numbers is false. Why?
Discrete Mathematical Structures: Theory and Applications
38
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”
 x P ( x )
 Bound Variable
The variable appearing in:
Discrete Mathematical Structures: Theory and Applications
x P ( x)
or
x P ( x )
39
Quantifiers and First Order Logic
 Existential Quantifier Example
 Consider
 x
x 2

 x 1
2

5
 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
xPx 
is true.
Discrete Mathematical Structures: Theory and Applications
40
Quantifiers and First Order Logic
Negation of Predicates (DeMorgan’s Laws)

~ x P( x)  x ~ P( x)
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 x P ( x ) , 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: x ~ P ( x)
and so,
~ x P( x)  x ~ P( x)
Discrete Mathematical Structures: Theory and Applications
41
Quantifiers and First Order Logic
Negation of Predicates (DeMorgan’s
Laws)
 ~ x P( x)  x ~ P( x)
Discrete Mathematical Structures: Theory and Applications
42
Quantifiers and First Order Logic
Formulas in Predicate Logic
All statement formulas are considered formulas
Each n, n =1,2,...,n-place predicate P( x1 , x2 , ... , xn )
containing the variables x1 , x2 , ... , xn 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
Discrete Mathematical Structures: Theory and Applications
43
Quantifiers 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)
Discrete Mathematical Structures: Theory and Applications
44
Quantifiers 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
Discrete Mathematical Structures: Theory and Applications
45
Logic 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
Discrete Mathematical Structures: Theory and Applications
46