Workspace IndexMath › Day 11

Nash Equilibrium and the Prisoner's Dilemma TODO

Math · Day 11 / 52 · August — Game Theory & Protocol Economics (Day 11-17)

Concept

A Nash equilibrium is a strategy profile in which no single participant can gain by unilaterally changing their own strategy. That doesn't mean it's the best outcome — only that there's no incentive to deviate — and the Prisoner's Dilemma is the classic illustration of that gap. In the Prisoner's Dilemma, defecting is the dominant strategy because it's better no matter what the other player does, so mutual defection is the unique Nash equilibrium, even though mutual cooperation would be better for both. In other words, the equilibrium of individual rationality and collective efficiency (Pareto optimality) don't necessarily coincide. In repeated games, if the discount rate on future payoffs is low enough, conditional cooperation strategies can sustain cooperation as an equilibrium — the classic way out of the dilemma.

Protocol design ultimately comes down to arranging rewards and penalties so participants have no incentive to defect, and incentives built without equilibrium concepts easily backfire.

Code & Formula

# 내시균형·죄수의 딜레마 — 2x2 보수행렬을 놓고 최적대응(best response)으로
# 내시균형을 직접 찾는다: 상대가 무엇을 하든 배신이 낫다 -> (배신,배신)이 유일한 균형.

# 행: 나의 선택, 열: 상대의 선택. 값은 (나의 보수, 상대의 보수). 낮을수록 형량이 짧다(=이득이 큼).
COOPERATE, DEFECT = "협력", "배신"
payoff = {
    (COOPERATE, COOPERATE): (-1, -1),
    (COOPERATE, DEFECT):    (-3, 0),
    (DEFECT, COOPERATE):    (0, -3),
    (DEFECT, DEFECT):       (-2, -2),
}

def best_responses(my_options, opp_action, my_index):
    # opp_action 이 고정일 때, 내가 얻는 보수가 가장 좋은(가장 큰) 선택지들을 반환.
    scores = {my: payoff[(my, opp_action)][my_index] if my_index == 0 else payoff[(opp_action, my)][my_index]
              for my in my_options}
    best = max(scores.values())
    return [a for a, s in scores.items() if s == best]

actions = [COOPERATE, DEFECT]

print("A가 최적대응(B의 선택별로 A가 최선인 행동):")
for b in actions:
    br = best_responses(actions, b, my_index=0)
    print(f"  B={b} -> A의 최적대응 = {br}")

print("B가 최적대응(A의 선택별로 B가 최선인 행동):")
for a in actions:
    br = best_responses(actions, a, my_index=1)
    print(f"  A={a} -> B의 최적대응 = {br}")

# 내시균형: 두 사람 모두 상대의 선택에 대해 최적대응 중인 조합.
nash_equilibria = []
for a in actions:
    for b in actions:
        a_is_best = a in best_responses(actions, b, my_index=0)
        b_is_best = b in best_responses(actions, a, my_index=1)
        if a_is_best and b_is_best:
            nash_equilibria.append((a, b))

print("\n내시균형:", nash_equilibria)
print("각자 -1(모두 협력)보다 나쁜 -2(모두 배신)가 균형 -> 개인합리성과 집단효율의 괴리 확인.")

Exercise

Take the Prisoner's Dilemma payoff matrix, parameterize the gains from cooperation and defection, and derive how large the discount factor needs to be for cooperation to hold up as an equilibrium in a repeated game.

Practical Connection

Validator slashing, oracle-dispute challenge bonds, and market-maker rebates are all devices that shift the equilibrium so honesty beats defection, and you only see the actual safety margin once you check that condition with the math.

If you study this on a given day, add a note link and a ✅ to this line in the source curriculum (docs/knowledge/math-50-curriculum.md) and this spot will lead straight to the note body. You can also write directly on this page — but regenerating overwrites it, so it's safer to keep anything you want to save as markdown under docs/algorithms/.


한국어

내시균형·죄수의 딜레마 TODO

Math · Day 11 / 52 · 8월 — 게임이론·프로토콜 경제학 (Day 11–17)

개념

내시균형은 각 참여자의 전략 조합에서, 누구도 혼자만 전략을 바꿔서는 이득을 볼 수 없는 상태이다. 이는 최적의 결과라는 뜻이 아니라 이탈 유인이 없는 안정점이라는 뜻이며, 죄수의 딜레마가 그 차이를 보여 준다. 죄수의 딜레마에서는 상대가 무엇을 하든 배신이 더 낫기 때문에 배신이 우월전략이고, 결과적으로 둘 다 배신하는 조합이 유일한 내시균형이지만 둘 다 협력하는 것보다 모두에게 나쁘다. 즉 개인 합리성의 균형과 집단 효율(파레토 최적)은 일치하지 않을 수 있다. 반복 게임에서 미래 이득의 할인율이 충분히 낮으면 조건부 협력 전략으로 협력이 균형으로 유지될 수 있다는 것이 이 딜레마의 대표적 탈출구이다.

프로토콜 설계는 결국 참여자가 이탈할 유인이 없도록 보상과 벌칙을 배치하는 일이라, 균형 개념 없이 만든 인센티브는 의도와 반대로 작동하기 쉽다.

코드 · 수식

# 내시균형·죄수의 딜레마 — 2x2 보수행렬을 놓고 최적대응(best response)으로
# 내시균형을 직접 찾는다: 상대가 무엇을 하든 배신이 낫다 -> (배신,배신)이 유일한 균형.

# 행: 나의 선택, 열: 상대의 선택. 값은 (나의 보수, 상대의 보수). 낮을수록 형량이 짧다(=이득이 큼).
COOPERATE, DEFECT = "협력", "배신"
payoff = {
    (COOPERATE, COOPERATE): (-1, -1),
    (COOPERATE, DEFECT):    (-3, 0),
    (DEFECT, COOPERATE):    (0, -3),
    (DEFECT, DEFECT):       (-2, -2),
}

def best_responses(my_options, opp_action, my_index):
    # opp_action 이 고정일 때, 내가 얻는 보수가 가장 좋은(가장 큰) 선택지들을 반환.
    scores = {my: payoff[(my, opp_action)][my_index] if my_index == 0 else payoff[(opp_action, my)][my_index]
              for my in my_options}
    best = max(scores.values())
    return [a for a, s in scores.items() if s == best]

actions = [COOPERATE, DEFECT]

print("A가 최적대응(B의 선택별로 A가 최선인 행동):")
for b in actions:
    br = best_responses(actions, b, my_index=0)
    print(f"  B={b} -> A의 최적대응 = {br}")

print("B가 최적대응(A의 선택별로 B가 최선인 행동):")
for a in actions:
    br = best_responses(actions, a, my_index=1)
    print(f"  A={a} -> B의 최적대응 = {br}")

# 내시균형: 두 사람 모두 상대의 선택에 대해 최적대응 중인 조합.
nash_equilibria = []
for a in actions:
    for b in actions:
        a_is_best = a in best_responses(actions, b, my_index=0)
        b_is_best = b in best_responses(actions, a, my_index=1)
        if a_is_best and b_is_best:
            nash_equilibria.append((a, b))

print("\n내시균형:", nash_equilibria)
print("각자 -1(모두 협력)보다 나쁜 -2(모두 배신)가 균형 -> 개인합리성과 집단효율의 괴리 확인.")

연습

죄수의 딜레마 보수행렬을 놓고 협력의 이득과 배신의 이득을 파라미터로 두어, 반복 게임에서 협력이 유지되려면 할인계수가 얼마 이상이어야 하는지 직접 유도해 보기.

실무 · Verex 연결

검증자 슬래싱, 오라클 분쟁 시 이의제기 보증금, 마켓메이커 리베이트는 모두 "정직이 이탈보다 낫도록" 균형을 옮기는 장치이고, 그 조건을 수식으로 확인해야 안전 마진이 보인다.

공부한 날 원본 커리큘럼(docs/knowledge/math-50-curriculum.md)의 이 줄에 노트 링크와 ✅ 를 붙이면, 이 자리는 노트 본문으로 바로 이어집니다. 노트 없이 이 페이지에 바로 적어도 됩니다 — 다만 다시 생성하면 덮어쓰이므로, 남길 글은 docs/algorithms/ 의 마크다운으로 쓰는 편이 안전합니다.

← 10. 재귀관계와 생성함수(가볍게)12. 경매(1·2위가격, 수입동등정리) →