Flowcharts (3 examples)

Mathematics for Computer Science
MIT 6.042J/18.062J
Game Trees;
Planar Graphs
Structural Induction
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-1
Game Trees: Tic-Tac-Toe
…
X
X
X
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-2
Tic-Tac-Toe
X
…
O
X
X
O
X
O
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-3
Tic-Tac-Toe
X
O
…
X
X
X
O
Copyright © Albert R. Meyer, 2004. All rights reserved.
X
O
March 10, 2004
X
X
O
L6.2-4
Tic-Tac-Toe Game Tree
…
…
…
…
Depth  9
win
lose
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-5
Quickies
• Tic-Tac-Toe game tree: what is first
non-uniform level?
• Chess game tree: how many trees at
level 2?
• Why does every Chess game end?
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-6
Bigger Number Game
(Dumb & Dumber)
You pick a number.
Then I pick a number.
I win if my number is bigger.
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-7
Bigger Number Game Tree
Win:
Lose:
Unboundedly Wide
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-8
Forced Move Game

You pick a number, n.
Then I pick n-1.
Then you pick n-2.
no choice
Then I pick n-3.

Then … pick 0. lose
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-9
Forced Move Game Tree
Unboundedly Deep
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
and Wide
L6.2-10
Recursive Game Trees
•Single node
, or
, is an RGT
•If t1, t2, …, tn,

are RGT’s, so is:
t1
t2
…
tn
…
May have infinitely many subtrees
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-11
Recursive Game Trees
RGT games terminate:
every downward path
eventually stops.
No infinite downward path!
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-12
Finite-Path Trees
May be  deep,
but no infinite path
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-13
Recursive Game Trees
Theorem. Every RGT is Finite-path.
Proof: By structural induction on RGT.
Base Case (t is one node):
• Has only a 0 length path.
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-14
RGT’s are Finite-Path
Induction Step (t has subtrees):
Suppose infinite path from root of t.
Then would have infinite path in subtree:
t
t1
Copyright © Albert R. Meyer, 2004. All rights reserved.
t2
…
March 10, 2004
…
tn
L6.2-15
RGT’s are Finite-Path
Induction Step (t has subtrees):
Suppose infinite path from root of t.
Then would have infinite path in subtree.
By hypothesis subtrees are Finite-Path,
a contradiction.
So t is F-P. QED.
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-16
2-Person Games: Fundamental Thm
Fundamental Theorem for
2-person, terminating games of
perfect information:
For any RGT, there is a winning
strategy for Player 1 or Player 2.
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-17
Team Problem
Problem 1
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-18
Structural vs Ordinary Induction
Replace Structural Induction by
Strong Induction on size of
recursive datum?
Not recommended.
(Also, remember F18 Functions:
what is size of the SINE function?)
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-19
Structural vs Ordinary Induction
Replace Structural Induction by
Strong Induction on size of
derivation trees?
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-20
Structural vs Ordinary Induction
derivation tree for x ·sin(ln(x))
*
x sin(ln x)

x id
sin
sin(ln x)
inv ln
exp ex
e cnst
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
id
x
L6.2-21
Structural vs Ordinary Induction
Replace Structural Induction by
Strong Induction on size of
derivation trees?
Still not recommended
(And what is the size of an
infinite derivation tree?)
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-22
Structural vs Ordinary Induction
Structural Induction works
on infinite trees;
cannot be replaced
by induction on size.
(A Meta-Theorem of Formal
Logic.)
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-23
Planar Graphs
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-24
Planar Graphs
A graph is planar if there
is a way to draw it in the plane
without edges crossing.
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-25
Planar Graphs
Draw it edge by edge:
find the faces
the outer face
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-26
Planar Graphs
Edges create boundaries of
faces
the outer face
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-27
Planar Graphs
Edges create boundaries of
faces
the outer face
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-28
Planar Graphs
Edges create boundaries of
faces
the outer face
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-29
Face Creation Rules
1) Add edge to new vertex in face
x
w
v
boundary x
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-30
Face Creation Rules
1) Add edge to new vertex in face
x
w
v
new face is x(v-w)(w-v)
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-31
Face Creation Rules
2) Add edge across face
w
x
y
v
boundary xy
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-32
Face Creation Rules
2) Add edge across face
w
w
x
y
v
v
new faces: x(v-w), (w-v)y
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-33
Structural Induction on Drawings
routine proofs by structural induction:
• every face has ¸ 3 edges
(when e ¸ 3)
• every edge occurs exactly
2 times on faces
• Euler's Formula:
v+e–f = 2
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-34
Team Problem
Problem 2
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-35
Structural Induction on Drawings
Corollaries:
• 3f · 2e
(for e ¸ 2)
• 3v – 6 · e
• K5 not planar
• 9 vertex of degree · 5
• planar graphs are 6-colorable
• planar graphs are 5-colorable
• exactly 5 regular polyhedra
*cf. Rosen 8.7
Copyright © Albert R. Meyer, 2004. All rights reserved.
March 10, 2004
L6.2-36