Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or...

25
Are words really logical?

Transcript of Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or...

Page 1: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Are words really logical?

Page 2: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.
Page 3: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Contract

The sum of $10,000 will be paid if either Sue reaches age65 or Sam reaches age 65.

Please complete the followingin order to open a joint checkingaccount:...Valid Checking Signature (check one) ����� party 1 OR party 2 party 1 AND party 2

Does the contract pay if both Sue and Sam turn 65?

What is the differencebetween these two options?

...If the artist cancels, then this ticket isrefundable.

Is this statement false in the event that there is no cancellation?

Page 4: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Aristotle defined a form of logic to define human reasoning.

statementsSimple logical (true-false) statements are called propositions.

1847 - George Boole creates an algebra for logic.

Every proposition has one of two possible values:

true

false

values

examplesMy roommate eats pizza.I am poor.I have a job.My dog has fleas.I have a friend.

1950’s - High-level programming language use constructs based in logic.

Page 5: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

variablesVariables are often used to represent statements.

operationsLogical statements are combined with others logical statements using...

NOT

AND

OR

examplesMy roommate eats pizza.I am poor.I have a job.My dog has fleas.I have a friend.

P ...Q ...J ...D ...F ...

Page 6: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

logical expressionsexamples

My roommate eats pizza.I am poor.I have a job.My dog has fleas.I have a friend.

P ...Q ...J ...D ...F ...

My roommate eats pizza, AND I am poor. ... P AND Q

I am friendless. ... NOT F

I have no job, OR my dog is flea-free.... NOT J OR NOT D

Page 7: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

What do the operations mean?

My roommate eats pizza.I am poor.I have a job.My dog has fleas.I have a friend.

P ...Q ...J ...D ...F ...

I am NOT poor. ... NOT Q

Suppose “I am poor.” is true, then “I am NOT poor.” must be _______.

Suppose “I am poor.” is false, then “I am NOT poor.” must be _______.

I have a job AND my dog has fleas. ... J AND D

What is required for this statement to be true?

Page 8: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Truth Tables

• We can define all propositions as truth tables• A truth table gives the resulting value for all

possible combinations of input values.

Variable 1 Variable … Variable N Expression involving Variables 1..N

False False False Resulting value

False False True Resulting value

All possible combinations are listed

Resulting values for each combination

Page 9: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

P P OR Q

truetrue

Q

truefalse

falsefalse

truefalse

P P AND QQ

We can describe all possible scenarios using truth tables.

Truth tables can be used to describe logical operations.

list of all variables logical expression

resulting expression

valuepotential values

P NOT P

true

false

false

true truefalse

true truetrue false

falsefalse

false truefalse false

truetruetruefalse

inclusive OR

Page 10: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Truth Tables

• Truth tables can describe the meaning of propositions.

• Generate the truth table for these statements– My roommate eats pizza and I'm not poor– I've seen Star Wars 56 times and I have either

a job or five kids– It's not the case that I am both unemployed

and not poor.

P = My roommate eats pizzaQ = I am poorR = I have a jobS = I have five kidsT = I have a German ShepherdU = I've seen Star Wars 56 times

Page 11: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Equivalence

• Consider the statement: It's not the case that I am both unemployed and not poor.

• Notice that there is a simpler statement that has the same truth table:• I am poor or I have a job

• Two different propositions that have the same truth table are said to be equivalent.

Page 12: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

It’s not the case that I am both friendless and without a job.

F

truetrue

J

truefalse

falsefalse

truefalse

NOT((NOT F) AND (NOT J))

true true true false

Notice that there is a simpler expression with the same truth table.

F

truetrue

J

truefalse

falsefalse

truefalse

F OR J

true true true false

Either I have a friend or a job.Equivalent Expression:

NOT((NOT F) AND (NOT J)) F OR J

equivalence

Page 13: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

My roommate eats pizza.I am poor.I have a job.My dog has fleas.I have a friend.

P ...Q ...J ...D ...F ...

Either I’m jobless and poor or I’m jobless and my dog has fleas.

I’m jobless and either I’m poor or my dog has fleas.

((NOT J) AND Q) OR ((NOT J) AND D)

(NOT J) AND (Q OR D)

Page 14: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Truth Tables

• There is another operation that is often used to express "if this then that".

• Examples:– If a student completes all requirements, then the

degree is conferred– If Hunt dies, then his property will be distributed as

follows….• The general form is

– PREMISE IMPLIES CONCLUSION– If the PREMISE is satisfied (true) then the CONCLUSION

is satisfied (true).

Page 15: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Truth Tables• What does implication really mean?• Example: If a student completes all requirements, then the degree is

conferred– Is the contract valid when both premise and conclusion are true?– Is the contract valid when the premise is true and the conclusion is vale?– Is the contract valid when the premise is false and the conclusion is true?– Is the contract valid when the premise is false and the conclusion is false?

P P IMPLIES Q

truetrue

Q

truefalse

falsefalse

truefalse

truefalsetruetrue

Page 16: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Contradictions

• Sometimes a proposition is contradictory– This means that it is nonsense– The result is always false– Consider: I have a job and I don't have a job.– Consider: If I have 5 kids then I am poor; and I

have 5 kids but I am not poor.• (S implies Q) and S and (NOT Q)

P = My roommate eats pizzaQ = I am poorR = I have a jobS = I have five kidsT = I have a German ShepherdU = I've seen Star Wars 56 times

Page 17: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Tautologies

• Sometimes a proposition is always true– This is known as a tautology– Consider: If mom sends money, then my

grades are good; or else my grades stink.• (M implies G) or (NOT G)

G = I have good gradesM = Mom sends money

Page 18: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Suppose your boss wants a list of all elderly male employees,who earn less than $60,000 per year.

LOGIC.

query: Age > 50 AND Gender = ‘M’ AND AnnualWage < 60000

database queries

Suppose the university Registrar needs a list of all students from aLa Crosse high school with GPA above 3.5.

query: (HS=‘Logan’ OR HS=‘Central’ OR HS=‘Aquinas’) AND GPA>3.5

Suppose the government wishes to offer loans to freshmen with a family income less than $30,000 but have no scholarships.

query: Year=1 AND FamilyIncome<30000 AND NOT (hasScholarship)

Page 19: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

LOGIC.

leibniz “ada lovelace”

bit -horse

(holmen OR onalaska) news

“binary numbers” (pdf OR ppt)

AND

NOT

OR

Page 20: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Google queries uses logic

• Consider using Google to search for web pages. What do the following queries mean?– ram– ram memory

• ram AND memory

– ram –truck• ram AND NOT truck

– (ram or dram)• ram OR dram

– ram (pdf or ppt)• ram AND (pdf OR pptx)

Page 21: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Computer Programs use LogicbeginWithFirstExam;while (moreExamsRemain) do { getNextExamScore; if (examScore > 89) then recordScoreAs(“A”); if (79<examScore AND examScore<90) then recordScoreAs(“B”); if (69<examScore AND examScore<80) then recordScoreAs(“C”); if (59<examScore AND examScore<70) then recordScoreAs(“D”); if (examScore<60) then recordScoreAs(“F”);}

Page 22: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Artists use Logic

• Consider two shapes: P (oval) and Q (rect)

Page 23: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Myth #4: digital circuits have nothing to do with logic.

Digital Circuits 101

A NOT A

AB A AND B

AB A OR B

It is typical to consider the following:

true

false

V+

gnd≈

≈ 1

0≈

logic electrical bit

Page 24: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Myth #4: digital circuits have nothing to do with logic.

Equivalence Circuit (NOT A AND NOT B) OR (A AND B)

Page 25: Are words really logical?. Contract The sum of $10,000 will be paid if either Sue reaches age 65 or Sam reaches age 65. Contract The sum of $10,000.

Myth #4: digital circuits have nothing to do with logic.

3-bit Greater than (A > B)

(Aleft AND NOT Bleft) OR (Aleft Bleft) AND (Amid AND NOT Bmid)OR (Aleft Bleft) AND (Amid Bmid) AND (Aright AND NOT Bright)

(suppose A’s bits are Aleft Amid Aright

and B’s bits are Bleft Bmid Bright) )