CSRU 1100 Logic
description
Transcript of CSRU 1100 Logic
CSRU 1100CSRU 1100
LogicLogic
Logic is concerned with Logic is concerned with determining:determining:
Is it True?
Is it False?
Statements we could makeStatements we could makeSome statements are obviously true
1. Barack Obama is the President of the United States
2. We live on the planet Mars
Some statements are obviously false
Some statements we don’t know one way or the other (but we know that have to be one or the other)
3. The integer x is an even number.
Some statements we actually Some statements we actually can’t give a value of true or false can’t give a value of true or false to…to…
How are you feeling?How are you feeling?
So these types of statements are not going So these types of statements are not going to interest us.to interest us.
Using a compact Using a compact representationrepresentation
Sometimes we don’t want to get bogged Sometimes we don’t want to get bogged down with sentences from a language down with sentences from a language like English… or perhaps we don’t even like English… or perhaps we don’t even know what sentence we would use.know what sentence we would use.
In these cases we can refer generically In these cases we can refer generically to such sentences with one letter place to such sentences with one letter place holdersholders
We could represent a sentence as:
p
or
q
So what does the symbol p represent?
It refers to one of the English logic statements we saw earlier.
It could be the logical statement“Pigs are blue”
or it could be
“There are 50 states in the US”
Now we don’t know very much about these generic statements that we just learned to represent (we certainly don’t know what they mean)
But since these all represent logical statements we do know something
Each one of these must have a value that is either TRUE or FALSE
So if I ask you the value of
p
You would say that it is either TRUE or FALSE
And that’s good enough, we really don’t care so much about which one it actually is (at least not yet)
What if we give you more than one generic statement?
p q
What are their values?
Well p is either TRUE or FALSE.
and q is either TRUE or FALSE.
So what are their values when they are together?
p could be TRUE and q could be TRUE
p could be FALSE and q could be FALSE
p could be TRUE and q could be FALSE
p could be FALSE and q could be TRUE
So there are 4 different scenarios to think about when there are 2 generic statements.
What if I have 3 things?
a b c
Ok, each of them individually could be TRUE or FALSE, so what are all of the possibilities when they get together?
Keeping track of all possibilities
• Going back to just p and q for a moment we could make a small table to show all of the possibilities
PP QQOption Option #1#1
TRUETRUE TRUETRUE
Option Option #2#2
TRUETRUE FALSEFALSE
Option Option #3#3
FALSEFALSE TRUETRUE
Option Option #4#4
FALSEFALSE FALSEFALSE
For 3 generic variables we would then have
AA BB CCOption #1Option #1 TRUETRUE TRUETRUE TRUETRUEOption #2Option #2 TRUETRUE TRUETRUE FALSEFALSEOption #3Option #3 TRUETRUE FALSEFALSE TRUETRUEOption #4Option #4 TRUETRUE FALSEFALSE FALSEFALSEOption #5Option #5 FALSEFALSE TRUETRUE TRUETRUEOption #6Option #6 FALSEFALSE TRUETRUE FALSEFALSEOption #7Option #7 FALSEFALSE FALSEFALSE TRUETRUEOption #8Option #8 FALSEFALSE FALSEFALSE FALSEFALSE
• When we arrange things this way it is called a truth table.
• Truth tables allow us to organize our logical statements so that we can examine all of the possible values in an easy to write and easy to read format.
Logical ConnectivesLogical Connectives Logic wouldn’t be any fun if we didn’t have Logic wouldn’t be any fun if we didn’t have
any way of combining different logical any way of combining different logical statementsstatements
I could sayI could say– ““I am going to the movies”I am going to the movies”– ““I am going to the grocery store”I am going to the grocery store”
Each of these on their own would certainly Each of these on their own would certainly have its own logical value but when we add have its own logical value but when we add in logical connectives we have a way of in logical connectives we have a way of discovering other thingsdiscovering other things
Things I could sayThings I could say It is NOT the case that “I am going to It is NOT the case that “I am going to
the movies”the movies” ““I am going to the movies” AND “I I am going to the movies” AND “I
am going to the grocery store”am going to the grocery store” ““I am going to the movies” OR “I am I am going to the movies” OR “I am
going to the grocery store”going to the grocery store” IF “I am going to the movies” THEN “I IF “I am going to the movies” THEN “I
am going to the grocery store”am going to the grocery store”
The connective NOT
• NOT reverses the meaning of whatever statement it is put in front of
• Unfortunately there are lots of different notations for NOT… some of these are
a a a
More NOT
• So I could make a really simple truth table for p and describe what the NOT of it would be
pTRUE FALSE
FALSE TRUE
p
The Connective ANDThe Connective AND And connects things in logic just the And connects things in logic just the
way it does in English.way it does in English. If I ask you whether the statement “I If I ask you whether the statement “I
am going to the movies AND I am going am going to the movies AND I am going to the grocery store” is TRUE or FALSE, to the grocery store” is TRUE or FALSE, you would look at the TRUE and FALSE you would look at the TRUE and FALSE values for each part of the statement.values for each part of the statement.
If both parts were true then the whole If both parts were true then the whole this is TRUE otherwise it is FALSEthis is TRUE otherwise it is FALSE
Truth Table for AND
p q
TRUE TRUE TRUE
TRUE FALSE FALSE
FALSE TRUE FALSE
FALSE FALSE FALSE
qp
The Connective ORThe Connective OR It doesn’t work exactly the way It doesn’t work exactly the way
English does. English does. Two statements that are connected Two statements that are connected
with OR are FALSE if both statements with OR are FALSE if both statements are FASLE, otherwise it is TRUEare FASLE, otherwise it is TRUE
Truth Table for OR
p q
TRUE TRUE TRUE
TRUE FALSE TRUE
FALSE TRUE TRUE
FALSE FALSE FALSE
qp
The Connective IMPLIESThe Connective IMPLIES IMPLIES is basically creating a rule that if something IMPLIES is basically creating a rule that if something
occurs then something else will happen.occurs then something else will happen. Just because it sounds like a rule does not mean it Just because it sounds like a rule does not mean it
actually is a true rule. actually is a true rule. Think about the rule “If you kill someone then you Think about the rule “If you kill someone then you
will go to jail.”will go to jail.” It sounds pretty good but it actually is not a true It sounds pretty good but it actually is not a true
rule.rule. Rules are FALSE if the first part of the statement is Rules are FALSE if the first part of the statement is
TRUE and yet the second part of the statement is TRUE and yet the second part of the statement is FALSE. All other circumstances mean that the rule FALSE. All other circumstances mean that the rule is true. is true.
Truth Table for IMPLIES
p q
TRUE TRUE TRUE
TRUE FALSE FALSE
FALSE TRUE TRUE
FALSE FALSE TRUE
qp
Now we can put it all together and ask questions such as
• What is the value of
)()( qpqp
You can create a corresponding truth table.
p q )( qp )( qp )( qp qpqp ()( )
TRUE TRUE TRUE FALSE TRUE TRUE
TRUE FALSE FALSE TRUE TRUE TRUE
FALSE TRUE FALSE TRUE TRUE TRUE
FALSE FALSE FALSE TRUE FALSE FALSE
Results of Truth TablesResults of Truth Tables Sometimes you find out that Sometimes you find out that
regardless of which TRUE/FALSE regardless of which TRUE/FALSE scenario you are dealing with, the scenario you are dealing with, the answer is always TRUE. These types answer is always TRUE. These types of logical statements are known as of logical statements are known as tautologies.tautologies.
Sometimes all the possibilities end Sometimes all the possibilities end up being FALSE. These are called up being FALSE. These are called contradictionscontradictions..
HoweverHowever Most of the time, you end up with all Most of the time, you end up with all
kinds of different possibilities when kinds of different possibilities when you complete the truth tableyou complete the truth table
That’s perfectly normal and to be That’s perfectly normal and to be expectedexpected
Hints on completing truth Hints on completing truth tablestables
Break each column of your table into Break each column of your table into dealing with only one logical connective dealing with only one logical connective at a time… this will reduce logic errorsat a time… this will reduce logic errors
Use the parentheses as your guide for Use the parentheses as your guide for how to break the statement down.how to break the statement down.
Do not try to perform any Do not try to perform any transformations on the logic statement transformations on the logic statement outside of those that have been taught.outside of those that have been taught.
One more thingOne more thing People and problems often use the People and problems often use the
phrase “show two statements are phrase “show two statements are equivalent”equivalent”
All this means is that when you All this means is that when you complete the truth table for both of complete the truth table for both of them then the have the same values them then the have the same values all the way down the column in the all the way down the column in the truth table.truth table.
Practice
)( ap
Practice
))(( arp
Practice
)]([)( acbba