Repository navigation
Expand file tree
/
Copy pathGame.lean
More file actions
116 lines (95 loc) · 5.45 KB
/
Copy pathGame.lean
File metadata and controls
116 lines (95 loc) · 5.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
module
public import RandomSystems.Typed.Interface
public import RandomSystems.Game.MBOAttachment
/-!
# Typed games
A typed game on an interface `A` is a typed system on the interface of `A` with the MBO whose
MBO, once set, stays set (`RandomSystem.MonotoneMBO`): a game in the sense of CR18, §3.7.1. A
typed converter attaches to it through its MBO-forwarding lift `PDCBehavior.liftMBO`, which
keeps games games (`RandomSystem.MonotoneMBO.attach_liftMBO`), and its visible typed system is
the visible system `RandomSystem.visible`. Game attachment satisfies the attachment laws:
`id • G = G` and `(comp α β) • G = α • (β • G)`, since the lift is functorial
(`PDCBehavior.liftMBO_id`, `PDCBehavior.liftMBO_comp`).
## Main definitions
* `Interface.withMBO A`: the interface of `A` with the MBO
* `TypedGame A`: typed games on `A`
* `TypedGame.GameEquivalent G H`: equivalence as games on `A`
* `TypedConverter.attachGame α G`: a typed converter attached to a typed game
* `TypedGame.visible G`: the visible typed system of a typed game
## Main results
* `TypedConverter.identity_attachGame`, `TypedConverter.comp_attachGame`: the identity and
serial laws of game attachment
* `TypedConverter.attachGame_gameEquivalent`: converter attachment preserves equivalence as games
-/
@[expose] public section
namespace SystemAlgebra
/-- The interface of `A` with the MBO: its replies carry the MBO. -/
abbrev Interface.withMBO (A : Interface) : Interface where
I := A.I
X := A.X
Y := SystemAlgebra.withMBO A.Y
domain := A.domain
nonempty_prefix := A.nonempty_prefix
bound := A.bound
length_le := A.length_le
/-- **Typed games** on `A`: typed systems on the interface of `A` with the MBO whose MBO, once
set, stays set. -/
def TypedGame (A : Interface) := {G : TypedSystem A.withMBO // G.1.MonotoneMBO}
/-- A typed converter attached to a typed game: its lift attached to the game's typed system. -/
noncomputable def TypedConverter.attachGame {A B : Interface} (α : TypedConverter A B)
(G : TypedGame B) : TypedGame A :=
-- The lift runs `α` on the replies of `G` without their MBO and tags each outside reply
-- with the MBO `a` of the latest reply of `G`:
--
-- ──x────▶ ┌───────────┐ ──u────▶ ┌───┐
-- │ liftMBO α │ │ G │
-- ◀─(y,a)─ └───────────┘ ◀─(v,a)─ └───┘
--
-- The result is again a game, its MBO once set stays set
-- (`RandomSystem.MonotoneMBO.attach_liftMBO`).
⟨TypedConverter.attach (A := A.withMBO) (B := B.withMBO) (PDCBehavior.liftMBO α) G.1,
G.2.attach_liftMBO B.nonempty_prefix A.nonempty_prefix α G.1.2⟩
/-- Attaching the identity converter leaves the game unchanged: `id • G = G`.
The MBO lift preserves identity, so identity attachment applies to the underlying system. -/
lemma TypedConverter.identity_attachGame {A : Interface} (G : TypedGame A) :
TypedConverter.attachGame (TypedConverter.id A) G = G := by
apply Subtype.ext
change TypedConverter.attach (PDCBehavior.liftMBO (TypedConverter.id A)) G.1 = G.1
rw [show PDCBehavior.liftMBO (TypedConverter.id A) = TypedConverter.id A.withMBO from
PDCBehavior.liftMBO_id _]
exact TypedConverter.identity_attach G.1
/-- Serial attachment groups the same wiring from the game end: `(αβ)G = α(βG)`.
The MBO lift preserves composition, so serial attachment applies to the underlying system. -/
lemma TypedConverter.comp_attachGame {A B C : Interface} (α : TypedConverter A B)
(β : TypedConverter B C) (G : TypedGame C) :
TypedConverter.attachGame (TypedConverter.comp α β) G =
TypedConverter.attachGame α (TypedConverter.attachGame β G) := by
-- Lift the serial converter, then apply serial attachment to the underlying typed system.
apply Subtype.ext
change TypedConverter.attach (PDCBehavior.liftMBO (TypedConverter.comp α β)) G.1 =
TypedConverter.attach (A := A.withMBO) (PDCBehavior.liftMBO α)
(TypedConverter.attach (A := B.withMBO) (PDCBehavior.liftMBO β) G.1)
rw [show PDCBehavior.liftMBO (TypedConverter.comp α β) =
TypedConverter.comp (A := A.withMBO) (B := B.withMBO) (C := C.withMBO)
(PDCBehavior.liftMBO α) (PDCBehavior.liftMBO β) from PDCBehavior.liftMBO_comp α β]
exact TypedConverter.comp_smul _ _ G.1
/-- The visible typed system of a typed game. -/
noncomputable def TypedGame.visible {A : Interface} (G : TypedGame A) : TypedSystem A :=
⟨G.1.1.visible, G.1.2.visible⟩
/-- Equivalence as games on typed games: agreement on every transcript with all MBOs unset. -/
def TypedGame.GameEquivalent {A : Interface} (G H : TypedGame A) : Prop :=
G.1.1.GameEquivalent H.1.1
lemma TypedGame.GameEquivalent.refl {A : Interface} (G : TypedGame A) : G.GameEquivalent G :=
fun _ => rfl
lemma TypedGame.GameEquivalent.symm {A : Interface} {G H : TypedGame A}
(h : G.GameEquivalent H) : H.GameEquivalent G :=
fun t => (h t).symm
lemma TypedGame.GameEquivalent.trans {A : Interface} {G H K : TypedGame A}
(h₁ : G.GameEquivalent H) (h₂ : H.GameEquivalent K) : G.GameEquivalent K :=
fun t => (h₁ t).trans (h₂ t)
/-- Attaching a typed converter preserves equivalence as games. -/
lemma TypedConverter.attachGame_gameEquivalent {A B : Interface} (α : TypedConverter A B)
{G H : TypedGame B} (hGH : G.GameEquivalent H) :
(α.attachGame G).GameEquivalent (α.attachGame H) :=
hGH.attach_liftMBO B.nonempty_prefix A.nonempty_prefix α G.1.2 H.1.2 G.2 H.2
end SystemAlgebra