Nash Equilibrium and the Prisoner's Dilemma TODO
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.
Where it lands in Jayverse
- Rabbit: derive the discount-factor threshold for session-key/mandate slashing, don't assume it. Compute how large the probability of future interaction needs to be for honest behavior to beat one-shot defection, the way the exercise derives it for the repeated prisoner's dilemma.
- Verex: check market-maker rebates for a dominant defection strategy. Before shipping a rebate scheme, verify spoofing or wash-trading isn't the dominant strategy regardless of what other makers do — that's the condition the dominant-strategy analysis is built to catch.
- Auditor: document the actual safety margin as a checked number, not an assumption. Any slashing or bond design should state the discount factor or repetition probability it relies on, since that's the number that turns "should deter" into "does deter."
Key expressions
| Expression | 뜻 · 쓰이는 자리 |
|---|---|
| unilaterally | 일방적으로, 혼자서 · 한 참가자만 전략을 바꿔서는 이득이 없다는 뜻. "no single participant can gain by unilaterally changing" |
| dominant strategy | 우월 전략 · 상대가 무엇을 하든 항상 유리한 전략. "defecting is the dominant strategy" |
| backfire | 의도와 반대로 역효과를 내다 · 균형 개념 없이 만든 인센티브가 실패한다는 뜻. "incentives built without equilibrium concepts easily backfire" |
| discount factor | 할인율 · 미래 보상을 현재 가치로 낮춰 계산하는 비율. "if the discount rate on future payoffs is low enough" |
| hold up | 이론·전략이 유지되다, 버티다 · 협력이 균형으로서 지속될 수 있는지. "for cooperation to hold up as an equilibrium" |
| safety margin | 안전 여유분, 안전 마진 · 실제로 얼마나 여유가 있는지 계산해봐야 보인다는 뜻. "you only see the actual safety margin" |
| Nash equilibrium | 내쉬 균형(Nash equilibrium) · 누구도 혼자 전략을 바꿔서 이득 볼 수 없는 전략 조합, 이 카드의 핵심 개념. "A Nash equilibrium is a strategy profile in which no single participant can gain" |
| Pareto optimality | 파레토 최적(Pareto optimality) · 누군가의 손해 없이는 더 나아질 수 없는 집단적 효율성 상태. "individual rationality and collective efficiency (Pareto optimality) don't necessarily coincide" |
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/.