Derived Variables A derived variable v is simply
Derived Variables A derived variable v is simply a function that associate value with state. Die Hard Example: total amount of water in the two jugs v : : = b + l March 3, 2002
Derived Variables For GCD, already have variables x, y. March 3, 2002
Derived Variables Proof of GCD termination: Show that variable y is strictly decreasing and natural number valued. March 3, 2002
Derived Variables Termination follows by least number principle: y must take a least value, and thus the algorithm is stuck. March 3, 2002
Strictly Decreasing Variable 16 N 12 8 4 0 State March 3, 2002
Weakly Decreasing Variable 16 N 12 8 4 0 State March 3, 2002
Weakly Decreasing Variable We used to call weakly decreasing variables “nonincreasing” variables. OK terminology but remember: nondecreasing is NOT EQUAL to “not decreasing. ” March 3, 2002
Stable Marriage There are 5 girls and 5 boys 1 2 3 4 5 A B C D E March 3, 2002
Stable Marriage Preferences: Boys 1: CBEAD 2 : ABECD 3 : DCBAE 4 : ACDBE 5 : ABDEC Girls A: 35214 B : 52143 C : 43512 D : 12345 E : 23415 March 3, 2002
Stable Marriage Preferences: Boys 1: CBEAD 2 : ABECD 3 : DCBAE 4 : ACDBE 5 : ABDEC Marry 1 with C: C 1 March 3, 2002
Stable Marriage Boys 2 : ABED 3 : DBAE 4 : ADBE 5 : ABDE Only 4 boys and 4 girls left. 2 3 4 5 A B D E March 3, 2002
Stable Marriage A problem: Rogue couples 1 4 C B Girl C likes like boy 4 better Boy 4 like girl C better March 3, 2002
Stable marriage The mating algorithm – day by day Morning: boys serenade favorite girls Afternoon: girl rejects all but best Serenader Evening: rejected boys cross off girls March 3, 2002
Stable marriage Termination condition: stop when no rejection is possible. • The algorithm terminates. • Everybody ends up married. • The resulting marriages are stable. March 3, 2002
Infinitely Wide Trees … … March 3, 2002
Infinitely Wide Trees … … March 3, 2002
Infinitely Wide Trees March 3, 2002
Infinitely Wide Trees March 3, 2002
Tutorial Problem 1 March 3, 2002
- Slides: 19