离散数学P3 Strong Induction
【P3】 -Mathematics for Computer Science_哔哩哔哩_bilibili
Good Proofs are
correct
complete
clear
brief
elegant
well-organized
in order
Problem:Find a sequence of moves to go From
ABC
DEF
HG 这里只有一个inversion
To
ABC
DEF
GH 这里有0个inversion
Legal Move:Slide a letter into adjacent blank square.
Thm(theorem):There is no sequence of legal moves to revert g and h and also return all other letters to their original positions.
Row moves
引理Lemma 1: A row move does not change the order of the items.
Proof:In a row move we move an item from some cell i into adjacent cell i-1 or i+1, nothing else moves, hence the order of items is preserved.
Column moves
Example1 G向上移动一格,自己改变了3,同时也改变HE的顺序,HE是the two items before G
是HG和EG的顺序变了。现在变为GH和GE了,这样就是两对了。需要留心的是HG是逆序,变为了正序GH;EG是正序,变为了逆序GE。
ABC
DF
HEG
变为
ABC
DFG
HE
Example2 B向下移动一格,自己改变了3,同时也改变了CD的顺序,CD是the two items after B
BC和BD的顺序变了,现在变为CB和DB了。BC是正序,变为了CB逆序;BD也是正序,变为了DB逆序。
ABC
D G
HEF
变为
A C
DBG
HEF
Lemma 2:A column move changes the relative order of precisely 2 pairs of items.
Proof:In a column move we move an item in cell i to a blank spot in cell i-3 or i+3,when an item move 3 positions it changes the order with 2 items i-1, i-2 or i+1,i+2
the 2 pairs of items are i, i+1 and i, i+2 (i, i-1 and i, i-2)
Def: A pair of letters or items L1 and L2 is an inversion(inverted pair) if L1 precedes L2 in the alphabet, but L1 is after L2 in puzzle.
以上面的移动为例子,把B往下移动一格。导致BC变为CB,BD变为DB
ABC
FDG
EH
index: 0 1 2 3 4 5 6 7
letter: A B C F D G E H
有 inversion 的对:
-
F (3) > D (4) → inversion
-
F (3) > E (6) → inversion
-
G (5) > E (6) → inversion
Lemma 3:During a move the number of inversions can only increase by 2, decrease by 2 or stay the same.
Proof:
Row move: no changes(by lemma 1)
Column move: 2 pairs change order(Lemma2)
Case A: Both pairs involved in the move were in order before column move→ move creates 2 new inversions.
Result: inversion count increases by 2.
Case B: Both pairs involved in the move were inverted before column move→ move decreases 2 new inversions.
Result: inversion count decreases by 2.
Case C: One of each, one of the pairs is inverted, another is in order before the column move.→ stay the same
Case C举例,把F往下移动一格,F的后面两个字母顺序受到影响
A B C
D F E
G H
移动之前,FE逆序,FG正序。两对字母,一对逆序,一对正序
A B C
D E
G F H
移动后,EF正序,GF逆序。
Corollary推论: During a move, the parity(even|odd) of # inversions does not change.
Proof:Adding or Subtracting 2 does not change the parity
Lemma4:In every state or configuration reachable from
ABC
DEF
HG
the parity of number inversions is odd,
Proof by induction: invariant is P(n)=After any sequence of n moves
from the start state, the parity of number inversions is odd,
Base Case: n=0, numbe of inversions =1 ->parity is odd
Inductive step: For n>0, show P(n)->P(n+1)
Consider any sequence of n+1 moves(m1,m2,...m(n+1))
By P(n), we know that the parity after m1,m2,...m(n) is odd
By Collary,we know parity of number inversions does not change during m(n+1)->the parity of m1,m2...m(n) is odd. ->P(n+1)
Proof of the theorem: The parity of the number of inversions in desired state is even(0), by lemma 4, the desired state can not be reached
from the start state. because its parity is odd
Strong Induction Axiom:
Let P(n) be any proposition, if P(0) is true,
for all n P(0), P(1), ..., P(n)->P(n+1) is true,
then P(n) is true.
Sample1 for strong induction
Unstacking game
拆分积分游戏,其中每次把一个数拆成两个较小的数,获得一定积分,总分固定为 28,无论怎么拆。我们来一步步抽象这个问题,并指出背后隐含的不变性定理(invariant theorem)
8 split to 5 and 3 get 15 points
5 split 2 and 3 get 6 points
3 split 1 and 2 get 2 point twice =4
2 split to 1 and 1 get 1 points triple =3
15+6+4+3=28
Theorem: All strategies for n-block game produce the same score S(n).
Ex: S(8)=28
Proof by strong induction:
Inductive hypothesis P(n)-->S(n)
Base Case:n=1 S(1)=0, we never take a move, so there is no score.
Inductive Step: Assume P(1),P(2),...,P(n) to prove P(n+1)
Look at n+1 block , get a k<=n, split n+1 to k and n+1-k
Score=k(n+1-k)+P(k)+P(n+1-k) 这里卡住了,那就回到最初的Inductive hypothesis,假设S(n)=(n-1)*n/2
用公式代入Score=k(n+1-k)+(k-1)k/2+(n-k)(n+1-k)/2=n(n+1)/2