Mathematics for Computer Science MIT 6 042 J18
- Slides: 73
Mathematics for Computer Science MIT 6. 042 J/18. 062 J Computational Processes II Copyright © Albert Meyer, 2002. Prof. Albert Meyer & Dr. Radhika Nagpal March 6, 2002 1
Computational Processes Last lecture: Invariants & Partial Correctness. March 6, 2002 2
Computational Processes Today: Termination, Derived Variables, Getting Married. March 6, 2002 3
Derived variables A derived variable, v, is a function giving a value to each state. March 6, 2002 4
Derived variables A derived variable, v, is a function giving a value to each state. Robot example: • Sum of coordinates, v : : = x + y. March 6, 2002 5
Derived variables A derived variable, v, is a function giving a value to each state. Robot example: • Sum of coordinates, v : : = x + y. • Parity of x + y, w : : = v mod 2. March 6, 2002 6
Derived variables For GCD, already have variables x, y. March 6, 2002 7
Derived variables Proof of GCD termination: variable y is strictly decreasing and natural number valued. March 6, 2002 8
Derived variables Termination follows by least number principle: y must take a least value, and thus the algorithm is stuck. March 6, 2002 9
Strictly Decreasing Variable 16 N 12 8 4 0 State March 6, 2002 10
Strictly Decreasing Variable 16 12 N Goes down at every step 8 4 0 State March 6, 2002 11
Weakly Decreasing Variable 16 12 N Down or constant after each step 8 4 0 State March 6, 2002 12
Weakly Decreasing Variable (We used to call weakly decreasing variables “nonincreasing” variables. ) March 6, 2002 13
Weakly Decreasing Variable OK terminology but remember: nonincreasing is NOT SAME as “not increasing. ” March 6, 2002 14
In-class Problem 1 March 6, 2002 15
Stable Marriage A Marriage Problem 1 2 3 4 5 Boys Girls A B C D E March 6, 2002 16
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 6, 2002 17
Stable Marriage Preferences 1: CBEAD 2 : ABECD 3 : DCBAE 4 : ACDBE 5 : ABDEC Try “greedy” strategy for boys March 6, 2002 18
Stable Marriage Preferences 1: CBEAD 2 : ABECD 3 : DCBAE 4 : ACDBE 5 : ABDEC Marry Boy 1 with Girl C (his 1 st choice) 1 C March 6, 2002 19
Stable Marriage Preferences 1: CBEAD 2 : ABECD 3 : DCBAE 4 : ACDBE 5 : ABDEC Marry Boy 1 with Girl C (his 1 st choice) 1 C March 6, 2002 20
Stable Marriage Preferences 2 : ABE D 3 : D BAE 4 : A DBE 5 : ABDE Marry Boy 1 with Girl C (his 1 st choice) 1 C March 6, 2002 21
Stable Marriage Preferences 2 : ABED 3 : DBAE 4 : ADBE 5 : ABDE Marry Boy 1 with Girl C (his 1 st choice) 1 C March 6, 2002 22
Stable Marriage Preferences 1 C 2 : ABED 3 : DBAE 4 : ADBE 5 : ABDE Next: Marry Boy 2 with Girl A: (best remaining choice) 2 A March 6, 2002 23
Stable Marriage Preferences 1 C 2 : ABED 3 : DBAE 4 : ADBE 5 : ABDE Next: Marry Boy 2 with Girl A: (best remaining choice) 2 A March 6, 2002 24
Stable Marriage Final “boy greedy” marriages 1 C 3 D 2 A 4 B 5 E March 6, 2002 25
Stable Marriage Trouble! 1 C 4 B March 6, 2002 26
Stable Marriage Boy 4 likes Girl C better than his wife. 1 C 4 B March 6, 2002 27
Stable Marriage and vice-versa 1 C 4 B March 6, 2002 28
Stable Marriage Rogue Couple 1 C 4 B March 6, 2002 29
Stable Marriage Problem: Marry everyone without any rogue couples! March 6, 2002 30
Stable Marriage Do it! PROBLEM 2 March 6, 2002 31
Stable Marriage More than a puzzle: March 6, 2002 32
Stable Marriage More than a puzzle: • College Admissions (original Gale & Shapley paper, 1962) March 6, 2002 33
Stable Marriage More than a puzzle: • College Admissions (original Gale & Shapley paper, 1962) • Matching Hospitals & Residents. March 6, 2002 34
Stable Marriage More than a puzzle: • College Admissions (original Gale & Shapley paper, 1962) • Matching Hospitals & Residents. • Matching Dance Partners. March 6, 2002 35
Stable Marriage March 6, 2002 36
Stable Marriage The Mating Algorithm March 6, 2002 37
Stable Marriage The Mating Algorithm: day by day March 6, 2002 38
Stable Marriage Morning: boy serenades favorite girl Ted Alice Bob March 6, 2002 39
Stable Marriage Morning: boy serenades favorite girl Afternoon: girl rejects all but favorite Ted Alice Bob March 6, 2002 40
Stable Marriage Morning: boy serenades favorite girl Afternoon: girl rejects all but favorite Evening: rejected boy writes off girl … Alice Ted … March 6, 2002 41
Stable Marriage Morning: boy serenades favorite girl Afternoon: girl rejects all but favorite Evening: rejected boy writes off girl … Alice Ted … March 6, 2002 42
Stable Marriage Stop when no rejects. Girl marries her favorite suitor. March 6, 2002 43
In-class Problem 3 March 6, 2002 44
Stable Marriage Partial Correctness: March 6, 2002 45
Stable Marriage Partial Correctness: • Everyone is married. March 6, 2002 46
Stable Marriage Partial Correctness: • Everyone is married. • Marriages are stable. March 6, 2002 47
Stable Marriage Partial Correctness: • Everyone is married. • Marriages are stable. Termination: there exists a Wedding Day. March 6, 2002 48
Stable Marriage Model as State Machine State q: Each boy’s set of eligible girls q(Bob)={Carole, Alice, …} March 6, 2002 49
Stable Marriage Derived Variable: serenading Bob’s favorite eligible girl. March 6, 2002 50
Stable Marriage Derived Variable: suitors all boys serenading Alice. March 6, 2002 51
Stable Marriage Derived Variable: favorite Carole’s preferred suitor. March 6, 2002 52
Stable Marriage Different girls have different favorites, because boys serenade one girl at a time. March 6, 2002 53
Stable Marriage Lemma: A girl’s favorite tomorrow will be at least as desirable as today’s. March 6, 2002 54
Stable Marriage Lemma: A girl’s favorite tomorrow will be at least as desirable as today’s. favorite(G) is weakly increasing for each G. March 6, 2002 55
Stable Marriage Lemma: A boy’s love tomorrow will be no more desirable than today’s. serenading(B) is weakly decreasing for each B. March 6, 2002 56
Stable Marriage Derived Variable: total-girls-names : : = total number of names not crossed off boy’s lists March 6, 2002 57
Stable Marriage Derived Variable: total-girls-names : : = total number of names not crossed off boy’s lists Strictly decreasing & N-valued. March 6, 2002 58
Stable Marriage Derived Variable: total-girls-names : : = total number of names not crossed off boy’s lists Strictly decreasing & N-valued. So Wedding Day. March 6, 2002 59
Stable Marriage Mating Invariant If G has rejected B, then she has a better current favorite. March 6, 2002 60
Stable Marriage Mating Invariant If G has rejected B, then she has a better current favorite. Proof: favorite(G) is weakly increasing. March 6, 2002 61
Stable Marriage Everyone is Married on the Wedding Day Proof by contradiction: March 6, 2002 62
Stable Marriage Everyone is Married on the Wedding Day Proof by contradiction: If B is not married, can’t be serenading, so list is empty. March 6, 2002 63
Stable Marriage Everyone is Married on the Wedding Day Proof by contradiction: If B is not married, can’t be serenading, so list is empty. By Invariant all girls have favorites better than B. March 6, 2002 64
Stable Marriage Everyone is Married on the Wedding Day Proof by contradiction: If B is not married, can’t be serenading, so list is empty. By Invariant all girls have favorites better than B. So all girls are married. March 6, 2002 65
Stable Marriage Everyone is Married on the Wedding Day Proof by contradiction: If B is not married, can’t be serenading, so list is empty. By Invariant all girls have favorites better than B. So all girls are married. So all boys are married. March 6, 2002 66
Stable Marriage Stability: Similar easy argument using the Invariant. March 6, 2002 67
In-class Problem 4 March 6, 2002 68
Stable Marriage Who does better, boys or girls? Girls’ suitors get better, and boy’s sweethearts get worse, so girls do better? March 6, 2002 69
Stable Marriage Who does better, boys or girls? Girls’ suitors get better, and boy’s sweethearts get worse, so girls do better? No! March 6, 2002 70
Stable Marriage Mating Algorithm is Optimal for all Boys at once. March 6, 2002 71
Stable Marriage Mating Algorithm is Optimal for all Boys at once. Pessimal for all Girls. March 6, 2002 72
Stable Marriage More questions, rich theory: Other stable marriages possible? - Can be many. Can a boy do better by lying? – No! Can a girl do better by lying – Yes! March 6, 2002 73
- S/2005 j18
- Mathematics for computer science mit
- Mathematics for computer science mit
- Mathematics for computer science mit
- Sac country
- 042-68-4425
- Mmt-042
- Mmt-042
- Pad-042
- Nrg-gy018
- Dori-042
- 0 042
- Pad-042
- Why science is my favourite subject
- Definition of mathematics by aristotle
- International journal of science and mathematics education
- Rowan college of science and mathematics
- Fspos vägledning för kontinuitetshantering
- Novell typiska drag
- Nationell inriktning för artificiell intelligens
- Returpilarna
- Varför kallas perioden 1918-1939 för mellankrigstiden
- En lathund för arbete med kontinuitetshantering
- Underlag för särskild löneskatt på pensionskostnader
- Personlig tidbok fylla i
- Sura för anatom
- Densitet vatten
- Datorkunskap för nybörjare
- Stig kerman
- Hur skriver man en tes
- Delegerande ledarstil
- Nyckelkompetenser för livslångt lärande
- Påbyggnader för flakfordon
- Kraft per area
- Publik sektor
- Jag har nigit för nymånens skära
- Presentera för publik crossboss
- Argument för teckenspråk som minoritetsspråk
- Bat mitza
- Klassificeringsstruktur för kommunala verksamheter
- Mjälthilus
- Bästa kameran för astrofoto
- Centrum för kunskap och säkerhet
- Byggprocessen steg för steg
- Bra mat för unga idrottare
- Verktyg för automatisering av utbetalningar
- Rutin för avvikelsehantering
- Smärtskolan kunskap för livet
- Ministerstyre för och nackdelar
- Tack för att ni har lyssnat
- Referatmarkering
- Redogör för vad psykologi är
- Matematisk modellering eksempel
- Tack för att ni har lyssnat
- Borra hål för knoppar
- Vilken grundregel finns det för tronföljden i sverige?
- Varians formel
- Tack för att ni har lyssnat
- Rita perspektiv
- Verksamhetsanalys exempel
- Tobinskatten för och nackdelar
- Blomman för dagen drog
- Handledning reflektionsmodellen
- Egg för emanuel
- Elektronik för barn
- Plagg i gamla rom
- Strategi för svensk viltförvaltning
- Var 1721 för stormaktssverige
- Humanitr
- Romarriket tidslinje
- Tack för att ni lyssnade
- Uppställning multiplikation
- Bra rim texter
- Inköpsprocessen steg för steg