= 2( u + ) 1. v = 2 t 1, pro ving the inductiv e - - PDF document

2 u 1 v 2 t 1 pro ving the inductiv e step if and only if
SMART_READER_LITE
LIVE PREVIEW

= 2( u + ) 1. v = 2 t 1, pro ving the inductiv e - - PDF document

Inductiv e Pro ofs Pro v e a statemen t ( X ) ab out a family of ob jects S (e.g., in tegers, trees) in t w o parts: X 1. Basis : Pro v e for one or sev eral small v alues of X directly . 2. : Assume


slide-1
SLIDE 1 Inductiv e Pro
  • fs
Pro v e a statemen t S (X ) ab
  • ut
a family
  • f
  • b
jects X (e.g., in tegers, trees) in t w
  • parts:
1. Basis : Pro v e for
  • ne
  • r
sev eral small v alues
  • f
X directly . 2. Inductive step : Assume S (Y ) for Y \smaller than" X ; pro v e S (X ) using that assumption. Example A binary tree with n lea v es has 2n
  • 1
no des.
  • F
  • rmally
, S (T ): if T is a binary tree with n lea v es, then T has 2n
  • 1
no des.
  • Induction
is
  • n
the size = n um b er
  • f
no des
  • f
T . Basis : If T has 1 leaf, it is a
  • ne-no
de tree. 1 = 2
  • 1
  • 1
so OK. Induction : Assume S (U ) for trees with few er no des than T . In particular, assume for the subtrees
  • f
T .
  • T
m ust b e a ro
  • t
plus t w
  • subtrees
U and V .
  • If
U and V ha v e u and v lea v es, resp ectiv ely , and T has t lea v es, then u + v = t.
  • By
the inductiv e h yp
  • thesis,
U and V ha v e 2u
  • 1
and 2v
  • 1
no des, resp ectiv ely .
  • Then
T has 1 + (2u
  • 1)
+ (2v
  • 1)
no des.

= 2(u + v )
  • 1.

= 2t
  • 1,
pro ving the inductiv e step. If-And-Only-If Pro
  • fs
Often, a statemen t w e need to pro v e is
  • f
the form \X if and
  • nly
if Y ." W e are then required to do t w
  • things:
1. Pro v e the if-p art : Assume Y and pro v e X . 2. Pro v e the
  • nly-if-p
art : Assume X , pro v e Y . Remem b er:
  • The
if and
  • nly-if
parts are c
  • nverses
  • f
eac h
  • ther.
  • One
part, sa y \if X then Y ," sa ys nothing ab
  • ut
whether Y is true when X is false.
  • An
equiv alen t form to \if X then Y " is \if not Y then not X "; the latter is the c
  • ntr
ap
  • sitive
  • f
the former. 1
slide-2
SLIDE 2 Equiv alence
  • f
Sets Man y imp
  • rtan
t facts in language theory are
  • f
the form that t w
  • sets
  • f
strings, describ ed in t w
  • dieren
t w a ys, are really the same set. T
  • pro
v e sets S and T are the same, pro v e:
  • x
is in S if and
  • nly
if x is in T . That is:

Assume x is in S ; pro v e x is in T .

Assume x is in T ; pro v e x is in S . Example: Balanced P aren theses Here are t w
  • w
a ys that w e can dene \balanced paren theses": 1. Gr ammatic al ly : a) The empt y string
  • is
balanced. b) If w is balanced, then (w ) is balanced. c) If w and x are balanced, then so is w x. 2. By Sc anning : w is balanced if and
  • nly
if: a) w has an equal n um b er
  • f
left and righ t paren theses. b) Ev ery prex
  • f
w has at least as man y left as righ t paren theses.
  • Call
these GB and SB prop erties, resp ectiv ely .
  • Theorem:
a string
  • f
paren theses w is GB if and
  • nly
if it is SB. If An induction
  • n
jw j (length
  • f
w ). Assume w is SB; pro v e it is GB. Basis : If w =
  • (length
= 0), then w is GB b y rule (a).
  • Notice
that w e do not ev en ha v e to address the question
  • f
whether
  • is
SB (it is, ho w ev er). Induction : Supp
  • se
the statemen t \SB implies GB" is true for strings shorter than w . 1. Case 1: w is not , but has no nonempt y prex that has an equal n um b er
  • f
( and ). Then w m ust b egin with ( and end with ); i.e., w = (x).

x m ust b e SB (wh y?).

By the IH, x is GB.

By rule (b), (x) is GB; but (x) = w , so w is GB. 2
slide-3
SLIDE 3 2. Case 2: w = xy , where x is the shortest, nonempt y prex
  • f
w with an equal n um b er
  • f
( and ), and y 6= .

x and y are b
  • th
SB (wh y)?

By the IH, x and y are GB.

w is GB b y rule (c). Only-If An induction
  • n
jw j. Assume w is GB; pro v e it is SB. Basis : w = . Clearly w
  • b
eys the conditions for b eing SB. Induction : Assume \GB implies SB" for strings shorter than w , and assume w 6= . 1. Case 1: w is GB b ecause
  • f
rule (b); i.e., w = (x) and x is GB.

b y the IH, x is SB.

Since x has equal n um b ers
  • f
('s and )'s, so do es (x).

Since x has no prex with more ('s than )'s, so do es (x). 2. Case 2: w is not
  • and
is GB b ecause
  • f
rule (c); i.e., w = xy , and x and y are GB.

By the IH, x and y are SB.

(Aside) T ric kier than it lo
  • ks:
w e ha v e to argue that neither x nor y could b e , b ecause if
  • ne
w ere, the
  • ther
w
  • uld
b e w , and this rule application could not b e the
  • ne
that rst sho ws w to b e GB.

xy has equal n um b ers
  • f
('s and )'s b ecause x and y b
  • th
do.

If w had a prex with more )'s than ('s, that prex w
  • uld
either b e a prex
  • f
x (con tradicting the fact that x has no suc h prex)
  • r
it w
  • uld
b e x follo w ed b y a prex
  • f
y (con tradicting the fact that y also has no suc h prex).

(Aside) Ab
  • v
e is an example
  • f
pr
  • f
by c
  • ntr
adiction. W e assumed
  • ur
conclusion ab
  • ut
w w as false and sho w ed it w
  • uld
imply something that w e kno w is false. 3
slide-4
SLIDE 4 Languages
  • A
lphab et = nite set
  • f
sym b
  • ls,
e.g., f0; 1g (binary alphab et)
  • r
ASCI I.
  • String
= nite sequence
  • f
sym b
  • ls
c hosen from some alphab et, e.g., 01101
  • r
abracadabra.
  • L
anguage = set
  • f
strings c hosen from some alphab et.

Subtle p
  • in
t: the language ma y b e innite, but there is some nite set
  • f
sym b
  • ls
  • f
whic h all its strings are comp
  • sed.
Example; Languages
  • The
set
  • f
all binary strings consisting
  • f
some n um b er
  • f
0's follo w ed b y an equal n um b er
  • f
1's; that is, f; 01; 0011; 00 0111 ; : : : g.
  • C
(the set
  • f
compilable C programs).
  • English.
Finite Automata An imp
  • rtan
t w a y to describ e certain simple, but highly useful languages called \regular languages."
  • A
graph with a nite n um b er
  • f
no des, called states.
  • Arcs
are lab eled with
  • ne
  • r
more sym b
  • ls
from some alphab et.
  • One
state is designated the start state
  • r
initial state.
  • Some
states are nal states
  • r
ac c epting states.
  • The
language
  • f
the F A is the set
  • f
strings that lab el paths that go from the start state to some accepting state. Example
  • Belo
w F A scans HTML do cumen ts, lo
  • king
for a list
  • f
what could b e title-author pairs, p erhaps in a reading list for some literature course.
  • It
accepts whenev er it nds the end
  • f
a list item. 4
slide-5
SLIDE 5
  • In
an application, the strings that matc hed the title (b efore ' by ') and author (after) w
  • uld
b e stored in a table
  • f
title-author pairs b eing accum ulated. <OL>, <UL> 1 2 3 4 5 6 7 8 9 <LI> space b y space </LI> </OL>, </UL> <LI> an y non-tag an y non-tag Start 5