不变式和第二数学归纳法
Good proofs are:
- correct
- complete
- clear
- brief
- elegant
- well-organized
- inorder
introduction:
Legal Move:slide a letter into adjacent square?
A | B | C |
---|---|---|
D | E | F |
H | G |
to
A | B | C |
---|---|---|
D | E | F |
G | H |
Thm:
there is no sequence of legal moves to invert G &H and return all other letters to original position
不变式(invariant)
引理一:(Lemma1)
横向移动不改变字母的相对顺序。
A row move does not change the order
Proof: In a row move, we move an item from cell i into an adjacent cell i-1 or i+1 .Nothing else moves.Hence the order of items is preserved. □ \square □
引理二:(Lemma2)
A column move changes the relative order of precisely 2 pairs of items
Proof: In a column move, we move an item from cell i into an blank spot i-3 or i+3 .
When an item moves three positions,It changes relative order with two other items.(i-1,i-2 or i+1,i+2) □ \square □
Def:一对字母,记作L1和L2,他们表示两个颠倒的字母,叫做一对逆序。也就是如果字母表中L1在L2前面,那么在拼图中L2会出现在L1后面。
(A pair of letters of items,call L1 and L2.they form an inversion,also known as an inverted pair,if L1 precedes L2 in the alphabet,but L1 appears after L2 in the puzzle)
A | B | C |
---|---|---|
D | E | F |
H | G |
1 inversion
to
A | B | C |
---|---|---|
D | E | F |
G | H |
0 inversion
conclusion: 1 inversion can never get 0 inversion
引理三:(Lemma3)
在一次移动中,逆序对的数量一次只能增加或者减少两个或者保持不变。
during a move,the number of inversion can only increase by two ,decrease by two or stay same.
Pf:
Row move : no changes (by lemma1)
column move: 2 pairs change order(by lemma2)
A. both pairs were inorder ⇒ \Rightarrow ⇒inversions ↑2
B. both pairs were inverted ⇒ \Rightarrow ⇒inversions ↓2
C. one pair was inverted ⇒ \Rightarrow