Professional Documents
Culture Documents
Definition of logics
oTruth Table
• A combination of Propositional
variables and connectives form a truth
table.
• For example the following table
shows the relationship between the
values of P, Q
Proposition:
- A proposition is a declarative
sentence (that is, a sentence that
declares a fact) that is either true or
false, but not both.
- It is the basic building blocks of logic
Negation:
DEFINITION 1: Let p be a proposition.
The negation of p, denoted by¬p (also
denoted by p), is the statement
- “It is not the case that p.”
The proposition ¬p is read “not p.” The
truth value of the negation of p, ¬p, is the
opposite of the truth value of p.
EXAMPLE 3 Find the negation of the
proposition
- “Michael’s PC runs Linux”
and express this in simple English.
Or/ Disjunction:
A disjunction is true when at least one
of the two propositions is true. For
instance, the inclusive or is being used in
the statement.
p ∨ q means ‘p or q or both’.
- “Students who have taken calculus or
physics can take discrete structures.”
Exclusive or
- Sometimes, we use or in an exclusive
sense. When the exclusive or is used
to connect the propositions p and q,
the proposition “p or q (but not both)”
is obtained.
- This proposition is true when p is true
and q is false, and when p is false and
q is true.
- It is false when both p and q are
false and when both are true.
-
-
- Only those who have taken exactly
one of the two courses can take the
class.
In general:
Exclusive Or:
Conditional statement
If you pass you proceed to the next
year of course
Consider the different possibilities that
could arise.
If you pass the subject and progress to
the next year of your course, then clearly
your lecturer’s statement is true.
If you pass the subject but don’t progress
to the next year of your course, then you
could accuse your lecturer of making a
false statement.
if you fail the subject- Whether or not
you progress to the next year of your
course, you could not accuse your
lecturer of making a false statement.
NB the key to truth is passing
Example
- p: you go, q: I go. pq means “If you
go, then I go” is equivalent to p only
if q “You go only if I go” (not the
same as “I go only if you go” which is
q only if p).
In general
Condition
CONVERSE, CONTRAPOSITIVE,
AND INVERSE:
- We can form some new conditional
statements starting with a conditional
statement p → q.
- In particular, there are three related
conditional statements that occur so
often that they have special names.
The proposition q → p is called
the converse of p → q.
The contrapositive of p → q is
the proposition ¬q →¬p.
The proposition ¬p →¬q is
called the inverse of p → q.
- We will see that of these three
conditional statements formed from p
→ q, only the contrapositive always
has the same truth value as p → q.
In general
Biconditional statement
Example 10:
• P: “you can take the flight”, q: “you
buy a ticket”
• P q: “You can take the flight if
and only if you buy a ticket”
–This statement is true
• If you buy a ticket and take
the flight
• If you do not buy a ticket and
you cannot take the flight
Compound propositions
We now have the notation we need in
order to be able to write compound
propositions in symbolic form
Example 1
Express the proposition ‘Either my
program runs and it contains no bugs, or
my program contains bugs’ in symbolic
form.
Solution
Let p denote the statement: ‘My program
runs.’
Let q denote the statement: ‘My program
contains bugs.’
Exercise
Construct the truth table of the proposition
below
¬(p∧¬q)
TAUTOLOGIES AND
CONTRADICTIONS
TAUTOLOGY
An expression that is always true, regardless
of the truth values of the variables it
contains, is called a tautology
Some propositions P(p, q, . . .) contain
only T in the last column of their truth
tables or, in other words, they are true
for any truth values of their variables.
Such propositions are called
tautologies
Example p ∨¬p, is a tautology
CONTRADICTION
An expression that is always false,
regardless of the truth values of the variables
it contains, is called a contradiction
LOGICAL EQUIVALENCE
Here is a rather complicated proposition:
‘It is not the case that both the input file and
the output file are not on the disk.’
The proposition below expresses the same
idea more simply:
‘Either the input file or the output file is on
the disk.’
Laws of logic
Occasions often arise in practice
where it is desirable to replace a
logical expression with a simpler
expression that is logically equivalent
For example, we have seen how
logical expressions representing
propositions can occur in algorithms
and computer programs.
o By writing these expressions as
simply as possible, we can make a
program more efficient and reduce
the chance of error.
In order to be able to simplify logical
expressions effectively, we need to
establish a list of pairs of expressions
that are logically equivalent.
We will use the symbol placed
between two expressions to indicate
that they are equivalent.
o A statement of the formP Q
where P and Q are logical
expressions is called a law of
logic.
Laws of logic
Solution
Example 2
Use the laws of logic to simplify the
expression:
Solution
Example 3
An algorithm contains the following line:
If not(x > 5 and x<=10) then ..
How could this be written more simply?
Solution
Example
Use the laws of logic to show that
is a tautology
Solution
Example
Determine whether the following
argument is valid:
‘The file is either a binary file or a text
file. If it is a binary file then my
program won’t accept it. My program
will accept the file.
Therefore the file is a text file.’
Solution
oAn argument of this type consists of
some premises (in this example, the
first three sentences), which together
are supposed to imply the conclusion
(the last sentence). The argument
takes the form of the logical
expression:
Logic and Bit Operations
- Computers represent information
using bits.A bit is a symbol with two
possible values, namely,0 (zero) and
1 (one).