Download p → q

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

Semantic holism wikipedia , lookup

Indeterminacy (philosophy) wikipedia , lookup

Meaning (philosophy of language) wikipedia , lookup

Interpretation (logic) wikipedia , lookup

Propositional formula wikipedia , lookup

Transcript
SSK3003 DISCRETE
STRUCTURES
Prof. Madya Dr.Ali Mamat
Department of Computer Science
1
INTRODUCTION
Discrete mathematics (structures) is the study of mathematical
structures (objects) that are fundamentally discrete rather than
continuous (vary smoothly)
Continuous objects are studied in calculus.
The term discrete means separate, distinct.
Discrete structures include integers, sets, functions, relations, graphs
and trees.
Topics in discrete mathematics include:
• Logic
• Set theory
• Number theory
• Proof Techniques (Mathematic Induction)
• Counting
• Functions and relations
2
INTRODUCTION (cont.)
• Recursions
• Graphs and trees33
Discrete mathematics has become popular in recent years
because of its application to computer science.
• Logic has applications to automated theorem proving
(logic programming) and software development.
• Set theory → software engineering, databases
• Relations → to databases
• Proof techniques → analysis of algorithms
• Number theory → cryptography
• Graphs and trees → data structures
3
CH.1: The Logic of Compound Statements
Learning Outcomes
1. Evaluate logical statements
2. Determine two statements are equivalent
3. Determine the validity of arguments
4
Contents
•
•
•
•
Logical form and logical equivalence
Conditional Statements
Valid and invalid arguments
Application: Digital logic circuits
5
1.1 Logical form and logical equivalence
Logics are formal languages for formalizing reasoning, in particular
for representing information such that conclusion can be drawn.
A logic involves:
• A language with a syntax for specifying what is a legal
expression in the language; syntax defines well formed
sentences in the language
•
Semantics for associating elements of the language with
elements of some subject matter. Semantics defines the
meaning of sentences (link to the domain); i.e., semantics
defines the truth of a sentence with respect to each possible
domain (world). E.g likes(Anas, Azura)
•
Inference rules for manipulating sentences in the language (e.g modus
ponens)
6
Propositional Logic
A statement (or Proposition) is a sentence that is either
true or false but not both.
“Two plus two equals four” is a statement
“He is a university student” is not a statement.
Which one is a statement?
√2>1
1+1=1
What time is it?
Read this sentence carefully.
x+y>0
7
Compound Statements
A statement can be atomic or compound.
Atomic Statement
Peter hates Lewis : p
It is raining outside: q
√ 2 > 1: r
Peter stays at home : t
Compound statements are formed from existing statements using logical
operators, i.e.
¬ (not),
∧ (and),
∨ (or),
→ (imply or if then),
↔ (equivalent if and only if ).
8
Compound Statements
Example
Peter hates Lewis and it is raining outside. :
p∧q
If it is raining outside then Peter stays at
home : q → t
If Peter doesn't hate Lewis then It is
raining or √ 2 > 1 :
¬p → (q ∨ r )
9
Truth Table
• A truth table displays
the
relationships
among
the
truth
values of statements.
In constructing such
truth tables, we write
“0” (F) for false and
“1” (T) for true.
p
q
pvq p∧q
T
T
T
T
T
F
T
F
F
T
T
F
F
F
F
F
10
Truth Table
11
Well-Formed Formulas
Statements and compound statements must follow
syntax.
Statements that follows syntax are called wellformed formulas (wffs) or formula.
A wff is defined as follows:
• Atomic formula is a wff
• If p and q are wffs then
¬p, p∨q, p∧q, p→q, p↔q
are wffs
12
Well-Formed Formulas
13
Type of formula
A statement/proposition: true or false
Atomic:
P, Q, X, Y, …
Unit Formula:
P, ~P,
Conjunctive:
P
Disjunctive:
P v Q, P v (P∧ X),…
Conditional:
PQ
Biconditional:
P
∧
Q, P
∧ ¬Q, …
↔Q
14
Determining truth of a formula
Atomic formulae:
given
Compound formulae:
via meaning of
the connectives
Suppose:P is true
Q is false
How about:
(P v Q)
Truth tables
15
Precedence
• ¬
highest
•∧
• v
• , ↔
lowest
• Avoid confusion - use ‘(‘ and ‘)’:
P∧ QvX
(P ∧ Q) v X
16
Parenthesizing
• Parenthesize & build truth tables
• Similar to arithmetics:
– 3*5+7 = (3*5)+7 but NOT 3*(5+7)
– A ∧ B v C = (A ∧ B) v C but NOT A ∧ (B v
C)
• So start with sub-formulae with highestprecedence connectives and work your
way out
17
Evaluate The Truth Value
• Given a compound statement, how do we compute the truth
value?
18
Translating English Sentence
English (even every other human languages) is
ambiguous. E.g. words such as present,
“sumbang”
Example “If you are under 4 feet tall and you are
younger than 16 years old then you cannot ride
the roller coaster."
You can ride the roller coaster : p
You are under 4 feet tall : q
You are younger than 16 years old : r
(q ∧ r ) → ¬p
19
Logical Equivalences
• Denition : The propositions p and q are called logically equivalent if
they have identical truth values, denoted by p ≡ q.
One way to determine if two propositions are logically equivalent is to
use truth table.
• The truth table can also be used to show that two propositions are not
equivalent.
20
Some Useful Logical Equivalences
21
Logical equivalence (cont.)
Equivalence
Name
p v ¬p ≡ T0
p ∧ ¬p ≡ F0
Inverse laws or negation
laws
p v (p ∧ q) ≡ p
p ∧ (p v q) ≡ p
Absorption laws
T0 is a tautology
F0 is a contradiction
22
Use of Equivalences
• Simplification
• Suppose someone gives you
~P v (AB) v ~(C v D  H) v P v X↔Y
• and asks you to compute it for all possible
input values
• You can either immediately draw a truth
table with 28 = 256 rows
• Or you can simplify it first
23
Simplification
~P v (AB) v ~(C v D  H) v P v X↔Y
~P v P v (AB) v ~(C v D  H) v X↔Y
T v (AB) v ~(C v D  H) v X↔Y
T
The statement is a tautology – always true…
24
Evaluate Logical Equivalences
25
Tautology
• Definition : A tautology (denoted by T0) is a statement
that is always true regardless of the truth values of the
individual statements.
• A contradiction (denoted by F0) is a statement that is
always false regardless of the truth values of the
individual statements.
• A contingency is a statement that is sometimes true and
sometimes false.
26
Equivalence & Tautology
Suppose A and B are logically equivalent
Consider proposition (A ≡ B)
What can we say about it?
It is a tautology!
Why?
A B
A≡B A↔B
F F
T
T
T T
T
T
27
1.2 Conditional Statement
• Conditional statement (or implication), p → q, is only false when q
is false and p is true. E.g.
• If you show up for work Monday morning, then you’ll get the job.
• Related Implications
• The variable p is called the hypothesis (antecedent) and q the
conclusion (or consequent).
• Caution ! : Only the contrapositive form is logically equivalent to
conditional statement. The converse and the inverse are equivalent.
28
Conditional and its contrapositive
p
T
q
T
p→q
T
q
F
p
F
¬q → ¬p
T
T
F
F
T
F
F
F
T
T
F
T
T
F
F
T
T
T
T
29
Bi-conditional
• The biconditional of p and q is “p if and only if q” and is denoted p
↔ q.
• It is true if both p and q have the same truth values and is false if p
and q have opposite truth values.
• p ↔ q is equivalent to p → q ∧ q → p:
• p→q
p is a sufficient condition for q
q is a necessary condition for p. (if q does not occur then p does not
occur too, i,e. ¬q → ¬p )
30
Recall
Learning Outcomes
1. Evaluate logical statements
2. Determine two statements are equivalent
3. Determine the validity of arguments
31
Questions
•
•
•
•
1. What is an argument?
2. What is a premise and a conclusion?
3. When is an argument valid?
4. How to determine whether an argument
is valid.
32
Argument
• An argument is a sequence of statements. All
the statements before the final one are called
premises (or assumption or hypothesis). The
final statement is called the conclusion.
• An argument is valid whenever the truth of all its
premises implies the truth of its conclusion.
• How to show a conclusion q logically follows
from the premises
• Basically, we show that the argument
is tautology.
33
Valid Argument
• Example Show that the argument where premises are p v (q v r )
and ¬r , and the conclusion is p v q, is valid.
34
Valid Argument
• Example Show that the argument where premises are p v (q v r )
and ¬r , and the conclusion is p v q, is valid.
35
Valid Argument
• Example Show that the argument where premises are p v (q v r )
and ¬r , and the conclusion is p v q, is valid.
36
Valid argument
pv(qvr) ^¬ r → (pv q)
p
q
r
qvr
p v (q v r )
¬r
pvq
T
T
T
T
T
F
T
T
T
T
F
T
T
T
T
T
T
F
T
T
T
F
T
T
T
F
F
F
T
T
T
T
F
T
T
T
T
F
T
T
F
T
F
T
T
T
T
T
F
F
T
T
T
F
F
T
F
F
F
F
F
T
F
T
37
Logical Implication
• From the previous table:
p1 : pv(qvr) p2: ¬r q1: q
p1 ^ p2 → q1 is a tautology.
If p, q are arbitrary statements such that p
→ q, then we says p logically implies q,
denoted as p  q
38
Rule of Inferences
• Although the truth table method always works, however, it is not
convenient. Since the appropriate truth table must have 2n lines
where n is the number of atomic propositions.
• Another way to show an argument is valid is to construct a formal
proof. To do the formal proof we use rules of inference.
• A rule of inference is a form of argument that is valid.
• In rules of inference, premise(s) are written in lines and the
conclusion is on the last line preceded with the symbol  which
denotes “therefore".
• For example the following rule is called Modus Ponens.
• In words, if p and p → q are true then q is true.
39
List of Rule of Inferences
40
Recap
•
•
•
•
•
•
•
•
•
•
•
Introduction to logic
Propositions (statement)
Logical Operators
wffs
Truth table
Logical equivalences
Tautologies
Conditional statements
Bi-conditional statements
Valid argument
Rule of inferences
41