a little excursion to logic and traffic control. a logical puzzle given situation: three women stand...

31
a little excursion to logic and traffic control

Upload: evelyn-holmes

Post on 20-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

a little excursion to logic

and traffic control

Page 2: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

A logical puzzle

Given situation: Three women standbehind each other. Each one carries a hat on her head and sees only the hats of the person(s) standing in front of her. The hats are either black or white. Not all hats have the same color.

Question: Can one woman tell the color of her own hat? (We assume she doesso, if she is able to.)

Schwarz?

Weiss?

Schwarz?

Weiss?

Black?White?

Page 3: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Yes, it‘s possible!

If the woman at the most back sees two hats of the same color in front of here, she decides for the other color. (Not all hats have the same color.)

If the woman at the most back says nothing, the one in the middle knows, that her hat has another color than the hat of the woman at the top front. (Otherwise the woman at the most back would have seen two equal colors and would have told this.)

…logical?

Page 4: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Idea: logical formulasfor security at crossroads!

Requirement: no collisions at crossroads!

What must hold such that no collisions are possible?

How can this be specified?

Collision possible!...

A

B

Page 5: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Program for today

• Interactive introduction to „logic“ (40‘)– Logic as foundation of rationality– Introduction to propositional logic

• Propositions• Operators• Truth tables

• Exercises to LogicTraffic (45‘)– Autonomous solving of exercises, with Computer– Review of solutions

Page 6: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Logic as the foundationof rationality

This means: We all have to accept certain basic rules of logical reasoning. Otherwise there is no „reasonable“ Thinking (and Acting).

Logic is ultimately the foundation of all sciences and

every kind of rational argumentation.

Page 7: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

The principle of bivalence

– e.g.: „Zurich is a continent.“ und „Zurich is not a continent.“ cannot simultaneously be true.

– This is neither provable nor refutable.

Aristotle, founder of logic* 384 B.C. in Stageira† 322 B.C. in Chalkis

A proposition cannot simultaneously with its opposite be true.

Page 8: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Logical inference

e.g.: proposition 1: „If it rains, the street becomes wet.“

proposition 2: „It is raining.“ inference: „The street becomes wet.“

From the two propositions “if A, then B“ and „A“, the proposition „B“ can be

deduced. Like this we can argue und with common accepted

„rules“ und true propositions deduce new true propositions.

Page 9: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

What are propositions?

• 2+4=6 1• Zurich is the capital of Switzerland. 0• Peter (23) is older than Paul (17). 1

Propositions are sentences, which are either true (1) or

false (0).

No propositions• Where is the station?• Be quiet!

• Berne is a beautiful city.• This water (20° C) is cold.

unclear!

Page 10: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

…are propositions too,i.e. are either true or false as well..

• Peter (23) is older than Paul (17) and 4+4=9.0

• Peter (23) is older than Paul (17) and 2+4=6. 1

• Zurich is the capital of Switzerland or Berne is the capital of Switzerland.

1

Compound propositions…

Page 11: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Propositional logic

Propositions……are represented by variables…have a truth value (true/false or 0/1)

• A = „Zurich is the capital of Switzerland.“ 0• B = „2+4=6“ 1

Propositional logic formulas are compound formulas:– Truth value (true/false or 0/1)

• A AND B 0• A OR B 1• (NOT A) AND B 1

Page 12: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

George Boole

Founder of propositional logic– English mathematician

* 1815 in Lincoln† 1864 in Ballintemple (Ireland)

Boolean variables– Can only take one of two possible values

• true/false, 1/0

– Boolean data type in many programming languages• Used for conditional statements• E.g. in Java, C, PHP, Pascal or VisualBasic

Page 13: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Logical operators

Logical operators connect propositions to new (compound) propositions

Which operators are there?

NOT, AND, OR- are the most common ones. There are more

(e.g. if/then).

Page 14: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

NOT (Negation)

Shorthand notation: ¬

• Truth table: A ¬A

0 1

1 0

Page 15: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

AND (Conjunction)

• Shorthand notation:

• Truth table: A B A B

0 0 0

0 1 0

1 0 0

1 1 1

Page 16: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

OR (Disjunction)

• Shorthand notation:

• Truth table: A B A B

0 0 0

0 1 1

1 0 1

1 1 1

Page 17: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Propositional logic(short reference)

Formulas in propositional logic, e.g.:- (¬AB)(A¬B)- A(¬B¬C)(DB)

VariablesNegation “NOT“

Conjunction

“AND“

Disjunction “OR“

A B ¬A AB AB

0 0 1 0 0

0 1 1 0 1

1 0 0 0 1

1 1 0 1 1

Page 18: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Now propositions in practice:

traffic control & logic

Traffic situation:

Propositions:• A = „Lane A has green.“• B = „Lane B has green.“

Exercise: Describe the situation given above with an compound proposition! (i.e. with the help of logical operators and the two variables A and B.)Remark: Use the table you were given on a separate sheet of paper.

A

B

Page 19: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Now propositions in practice:

traffic control & logic

Traffic situation:

Propositions:• A = „Lane A has green.“• B = „Lane B has green.“

Exercise: Describe the situation given above with an compound proposition! (i.e. with the help of logical operators and the two variables A and B.)Remark: Use the table you were given on a separate sheet of paper.

A

B

Solution: A (¬B)

Page 20: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Solution: A (¬B)

AB

AB

AB

BA

A B A (¬B)

1 0 1

Page 21: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Solution: A (¬B)

AB

AB

AB

BA

A B A (¬B)

0 0 0

1 0 1

Page 22: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Solution: A (¬B)

AB

AB

AB

BA

A B A (¬B)

0 0 0

0 1 0

1 0 1

Page 23: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Solution: A (¬B)

AB

AB

AB

BA

A B A (¬B)

0 0 0

0 1 0

1 0 1

1 1 0

Page 24: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Truth table

Gives for all combinations of values of the variables the truth value of a formula in propositional logic.

A B A (¬B)

0 0 0

0 1 0

1 0 1

1 1 0

AB

Exercise: How do you interpret this row?

Page 25: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Idea: a formula for securityat a crossroad!

Requirements: no collisions at crossroads!

What “rules” need to hold such that no collisions are possible? What does the truth table look like? Is there a formula in propositional logic for that?

collision possible!...

A

B

Page 26: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Program „LogicTraffic“

Idea: Find a formula in propositional logic which makes the given traffic situation secure

Different strategies!

Page 27: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

LogicTraffic

trafficsituation

truthtable

Formula to thetruth table

Formula editor

Page 28: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

not secure(collisions possible)

Status indication

secure(no collisions, but more

green phases possible)

optimal(no collisions and no more

green phases possible)

Page 29: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

LogicTraffic: mouseclickable areas

Page 30: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

LogicTraffic - Demo!

Page 31: A little excursion to logic and traffic control. A logical puzzle Given situation: Three women stand behind each other. Each one carries a hat on her

Your turn…

• Read the instructions

• Work on the exercises in the computer lab