-
Notifications
You must be signed in to change notification settings - Fork 3
/
AGT.agda
166 lines (155 loc) · 11 KB
/
AGT.agda
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
module AGT where
open import Prelude
open import Poset
open import AGT.Precise
open import AGT.Gradual
--------------
-- Interior --
--------------
-- I : type♯ × type♯ → type♯ × type♯
-- I (⊤ , None) = None , None
-- I (Any , ⊤) = Any , Any
-- I (τ₁ , τ₂) = τ₁ , τ₂
--
-- monotonic[I] : ∀ {τ₁ τ₂ : type♯} → proper ((_≼_ ∧ʷ _≼_) ⇉ (_≼_ ∧ʷ _≼_)) I
-- monotonic[I] = {!!}
--
-- I♮ : ⟪ (type𝄪 ∧♮ type𝄪) ↗ (type𝄪 ∧♮ type𝄪) ⟫
-- I♮ = {!!}
-- -- attempt soundness and completeness after independent attributes abstraction
-- P : ∀ {τ₁₁♯ τ₂₁♯ τ₁₂♯ τ₂₂♯ : type♯}
-- → (τ₁₂♯ , τ₂₂♯) ≼ I (τ₁₁♯ , τ₂₁♯)
-- ↔ (∃ τ₂♯ 𝑠𝑡 ∃ τ₁ 𝑠𝑡 ∃ τ₂ 𝑠𝑡 τ₁ ∈γᵗ[ τ₁₁♯ ] × τ₂ ∈γᵗ[ τ₂♯ ] × τ₁ <: τ₂ × τ₁₂♯ ≼ ηᵗ τ₁ × τ₂♯ ≼ ηᵗ τ₂)
-- × (∃ τ₁♯ 𝑠𝑡 ∃ τ₁ 𝑠𝑡 ∃ τ₂ 𝑠𝑡 τ₁ ∈γᵗ[ τ₁♯ ] × τ₂ ∈γᵗ[ τ₂₁♯ ] × τ₁ <: τ₂ × τ₁♯ ≼ ηᵗ τ₁ × τ₂₂♯ ≼ ηᵗ τ₂)
-- P = LHS , RHS
-- where
-- LHS : ∀ {τ₁₁♯ τ₂₁♯ τ₁₂♯ τ₂₂♯ : type♯}
-- → (τ₁₂♯ , τ₂₂♯) ≼ I (τ₁₁♯ , τ₂₁♯)
-- → (∃ τ₂♯ 𝑠𝑡 ∃ τ₁ 𝑠𝑡 ∃ τ₂ 𝑠𝑡 τ₁ ∈γᵗ[ τ₁₁♯ ] × τ₂ ∈γᵗ[ τ₂♯ ] × τ₁ <: τ₂ × τ₁₂♯ ≼ ηᵗ τ₁ × τ₂♯ ≼ ηᵗ τ₂)
-- × (∃ τ₁♯ 𝑠𝑡 ∃ τ₁ 𝑠𝑡 ∃ τ₂ 𝑠𝑡 τ₁ ∈γᵗ[ τ₁♯ ] × τ₂ ∈γᵗ[ τ₂₁♯ ] × τ₁ <: τ₂ × τ₁♯ ≼ ηᵗ τ₁ × τ₂₂♯ ≼ ηᵗ τ₂)
-- LHS {⊤} {⊤} {τ₁₂♯} {τ₂₂♯} (⊤ , ⊤) with ∃∈γᵗ τ₁₂♯ | ∃∈γᵗ τ₂₂♯
-- ... | ∃ τ₁ ,, ∈₁ | ∃ τ₂ ,, ∈₂ = {!!} , {!!} -- (∃ (ηᵗ τ₁) ,, (∃ τ₁ ,, (∃ τ₁ ,, (⊤ , (sound[ηγᵗ] , (xRx⸢<:⸣ , ({!!} , {!!}))))))) , {!!}
-- LHS {⊤} {Any} (⊤ , Any) = {!!} , {!!}
-- LHS {⊤} {None} x = {!!}
-- LHS {⊤} {⟨𝔹⟩} x = {!!}
-- LHS {⊤} {τ₂₁♯₁ ⟨→⟩ τ₂₁♯₂} x = {!!}
-- LHS {Any} {τ₂} x = {!!}
-- LHS {None} {τ₂} x = {!!}
-- LHS {⟨𝔹⟩} {τ₂} x = {!!}
-- LHS {τ₁₁♯₁ ⟨→⟩ τ₁₁♯₂} {τ₂} x = {!!}
-- RHS : ∀ {τ₁₁♯ τ₂₁♯ τ₁₂♯ τ₂₂♯ : type♯}
-- → (∃ τ₂♯ 𝑠𝑡 ∃ τ₁ 𝑠𝑡 ∃ τ₂ 𝑠𝑡 τ₁ ∈γᵗ[ τ₁₁♯ ] × τ₂ ∈γᵗ[ τ₂♯ ] × τ₁ <: τ₂ × τ₁₂♯ ≼ ηᵗ τ₁ × τ₂♯ ≼ ηᵗ τ₂)
-- × (∃ τ₁♯ 𝑠𝑡 ∃ τ₁ 𝑠𝑡 ∃ τ₂ 𝑠𝑡 τ₁ ∈γᵗ[ τ₁♯ ] × τ₂ ∈γᵗ[ τ₂₁♯ ] × τ₁ <: τ₂ × τ₁♯ ≼ ηᵗ τ₁ × τ₂₂♯ ≼ ηᵗ τ₂)
-- → (τ₁₂♯ , τ₂₂♯) ≼ I (τ₁₁♯ , τ₂₁♯)
-- RHS = {!!}
-- { (η τ₁ , η τ₂) | ∃ τ₁ ∈ γ(τ₁₁♯) , τ₂ ∈ γ(τ₂₁♯) 𝑠𝑡 τ₁ <: τ₂ }
-- { (τ₁₂♯ , τ₂₂♯) | ∀ (τ₁₃♯ , τ₂₃♯), (∀ τ₁ ∈ γ(τ₁₁♯) , τ₂ ∈ γ(τ₂₁♯) → τ₁ <: τ₂ → (η τ₁ , η τ₂) ≼ (τ₁₃♯ , τ₂₃♯)) ↔ (τ₁₂♯ , τ₂₂♯) ≼ (τ₁₃♯ , τ₂₃♯) }
-- soundness
-- P : ∀ {τ₁♯ τ₂♯ τ₁ τ₂} → τ₁ ∈γᵗ[ τ₁♯ ] → τ₂ ∈γᵗ[ τ₂♯ ] → τ₁ <: τ₂ → (ηᵗ τ₁ , ηᵗ τ₂) ≼ I (τ₁♯ , τ₂♯)
-- P ⊤ ⊤ <:₁ = ⊤ , ⊤
-- P ⊤ Any <:₁ = ⊤ , Any
-- P ⊤ None None = None , None
-- P ⊤ ⟨𝔹⟩ <:₁ = ⊤ , ⟨𝔹⟩
-- P ⊤ (∈₁ ⟨→⟩ ∈₂) <:₁ = ⊤ , (complete[ηγᵗ] ∈₁ ⟨→⟩ complete[ηγᵗ] ∈₂)
-- P Any ⊤ Any = Any , Any
-- P Any Any <:₁ = Any , Any
-- P Any None <:₁ = Any , None
-- P Any ⟨𝔹⟩ <:₁ = Any , ⟨𝔹⟩
-- P Any (∈₁ ⟨→⟩ ∈₂) ()
-- P None ⊤ <:₁ = None , ⊤
-- P None Any <:₁ = None , Any
-- P None None <:₁ = None , None
-- P None ⟨𝔹⟩ <:₁ = None , ⟨𝔹⟩
-- P None (∈₁ ⟨→⟩ ∈₂) <:₁ = None , (complete[ηγᵗ] ∈₁ ⟨→⟩ complete[ηγᵗ] ∈₂)
-- P ⟨𝔹⟩ ∈₂ <:₁ = {!∈₂!}
-- P (∈₁ ⟨→⟩ ∈₂) ∈₃ <:₁ = {!!}
-- completeness
-- { I(Y♯) } ⊆ { η(Y) | ∃ Y ∈γ[ Y♯ ] ∧ P(Y)}
--
-- X♯ ≼ I(Y♯) → ∃ Y ∈γ[ Y♯ ] ∧ P(Y) ∧ X♯ ≼ η(Y)
--
-- ∀ Y'♯ 𝑠𝑡 (∀ Y ∈γ[ Y♯ ] → P(Y) → I(Y♯) ≼
--
-- y ∈ ⊔(X) ⇔ (∀ y', (∃ x₁ x₂ ∈ X, y' ≼ x₁ ⊔ x₂) ⇔ y' ≼ y)
--
-- y ∈ ⊔(X) ⇔ (∀ y', (∀ x ∈ X, y' ≼ x') ⇔ y' ≼ y) y = ⊤, y' = ⊤
--
-- ⊔(X) = { y | (∀ y', (∀ x ∈ X, x ≼ y') ↔ y ≼ y') } ✗ consider y = ⊤, y' = ⊤,
--
-- ⊔(X) = { y | (∀ y', (∀ x ∈ X, y' ≼ x) ↔ y' ≼ y) } ✗ consider y = ⊤, y' = -0
--
-- ⊔(X) = { y | (∀ y', (∀ x ∈ X, y' ≼ x) ↔ y' ≼ y) } ✗
--
-- ⊔(❴⊥,-,0❵) = ❴⊥,-,0,-0❵
-- ⊔(❴⊥,-,0❵) = ❴⊥,-,0,-0,⊤❵
--
-- ⊔(X) = { Y | (∀ y → (∃ x₁ x₂ ∈ X, x₁ ⊔ x₂ = y) ↔ (y ∈ Y)) }
--
-- ⊔(X) = { y | (∀ y', (∃ x₁ x₂ ∈ X, y' ≼ x₁ ⊔ x₂) ↔ y' ≼ y) }
-- ⊔(X) = { y | (∀ y', (∃ x₁ x₂ ∈ X, x₁ ⊔ x₂ ≼ y') ↔ y ≼ y') }
--
-- join(XX) = { x | ∃ X ∈ XX 𝑠𝑡 x ∈ X }
--
-- join(⊔(X)) = { x | ∃ Y 𝑠𝑡 (∀ y → (∃ x₁ x₂ ∈ X, x₁ ⊔ x₂ = y) ↔ (y ∈ Y)) 𝑠𝑡 x ∈ Y }
--
-- UB(X)(Y) = ∀ x ∈ X, ∃ y ∈ Y, x ≼ y
--
-- LUB(X) = { y | ∃ Y, UB(X)(Y) ∧ (∀ Y', UB(X)(Y') → Y ⊆ Y') ∧ y ∈ Y }
--
-- LUB(X) = { y | (∀ x ∈ X, x ≼ y) ∧ (∀ y', (∀ x ∈ X, x ≼ y') → y ≼ y') }
--
-- LUB(X) = { y | ∀ y', (∀ x ∈ X, x ≼ y') ↔ y ≼ y' }
-- P : ∀ {τ₁₁♯ τ₂₁♯ τ₁₂♯ τ₂₂♯ : type♯} → ∀ {τ₁₂♯ τ₂₂♯} → ((τ₁₂♯ , τ₂₂♯) ≼ I (τ₁₁♯ , τ₂₁♯)) ↔ (∀ {τ₁ τ₂} → τ₁ ∈γᵗ[ τ₁₁♯ ] → τ₂ ∈γᵗ[ τ₂₂♯ ] → ηᵗ τ₁ ≼ᵗ♯ τ₁₂♯ × ηᵗ τ₂ ≼ τ₂₂♯)
-- P = {!!}
--
-- -- pure I = pure η ⟐ <:P ⟐ γ
-- -- ∀ x. return (I x) = pure η * (<:P * (γ x))
-- -- ∀ τ₁♯ τ₂♯. {I(τ₁♯,τ₂♯)} = {η(τ₁),η(τ₂) | ∃ τ₁ ∈ γ(τ₁♯) , τ₂ ∈ γ(τ₂♯) : τ₁ <: τ₂}
-- -- ∀ τ₁♯ τ₂♯. {π₁(I(τ₁♯,τ₂♯))},{π₂(I(τ₁♯,τ₂♯))} = {η(τ₁) | ∃ τ₁ ∈ γ(τ₁) , τ₂ ∈ γ(τ₂♯) : τ₁ <: τ₂},{η(τ₂) | ∃ τ₁ ∈ γ(τ₁) , τ₂ ∈ γ(τ₂♯) : τ₁ <: τ₂}
--
-- -- ∀ τ₁₁♯ τ₂₁♯ τ₁₂♯ τ₂₂♯
-- -- → (τ₁₂♯,τ₂₂♯) ≼ I(τ₁₁♯,τ₂₁♯)
-- -- ↔ (∃ τ₁ ∈ γ(τ₁₁♯) ∧ τ₂ ∈ γ(τ₂₁♯) 𝑠𝑡 τ₁ <: τ₂ ∧ τ₁₂♯ ≼ η(τ₁)) ∧ (∃ τ₁ ∈ γ(τ₁₁♯) ∧ τ₂ ∈ γ(τ₂₁♯) 𝑠𝑡 τ₁ <: τ₂ ∧ τ₂₂♯ ≼ η(τ₂))
--
-- -- ∀ τ₁₁♯ τ₂₁♯ τ₁₂♯ τ₂₂♯. ((τ₁₂♯,τ₂₂♯) = I(τ₁♯,τ₂♯)) ↔ (∃ τ₁ ∈ γ(τ₁₁♯) , τ₂ ∈ γ(τ₂₁) : τ₁ <: τ₂ ∧ τ₁₂♯ = η(τ₁) ∧ τ₂₂♯ = η(τ₂)
--
-- -- ∀ τ₁₁♯ τ₂₁♯ τ₁₂♯ τ₂₂♯. I(τ₁₁♯,τ₂₁♯) = (τ₁₂♯,τ₂₂♯) → ∃ τ₁ ∈ γ(τ₁₁♯) , τ₂ ∈ γ(τ₂₁♯) : τ₁ <: τ₂ ∧ τ₁₂♯ = η(τ₁) ∧ τ₂₂♯ = η(τ₂)
-- -- ∀ τ₁₁♯ τ₂₁♯ τ₁₂♯ τ₂₂♯ τ₁ τ₂. I(τ₁₁♯,τ₂₁♯) = (τ₁₂♯,τ₂₂♯) → τ₁ ∈ γ(τ₁₁♯) ∧ τ₂ ∈ γ(τ₂₁♯) → τ₁ <: τ₂ → τ₁₂♯ = η(τ₁) ∧ τ₂₂♯ = η(τ₂)
-- -- LHS: ∀ x. ∃ y ∈ γ(x) 𝑠𝑡 ∃ z ∈ <:P y 𝑠𝑡 η(z) = I(x)
-- -- RHS: ∀ x y z. y ∈ γ(x) ∧ z ∈ <:P(y) → η(z) = I(x)
--
-- -- (pure η) ⟐ <:P ⟐ γ = pure I♯
-- -- x ∈ (pure η * (<:P * (γ y))) ↔ x ∈ pure I♯ y
-- --
-- -- x ∈ (pure η * (<:P * (γ y))) ↔ x ⊑ (I♯ y)
--
--
-- -- ∃ z ∈ <:P * (γ y) 𝑠𝑡 x ⊑ η(z) ↔ x ⊑ (I♯ y)
-- -- ∃ v ∈ γ y 𝑠𝑡 ∃ z ∈ <:P v 𝑠𝑡 x ⊑ η(z) ↔ x ⊑ (I♯ y)
--
-- P2 : ∀ {τ₁₁♯ τ₂₁♯ τ₁₂♯ τ₂₂♯ : type♯} → (∃ τ₁ 𝑠𝑡 ∃ τ₂ 𝑠𝑡 τ₁ ∈γᵗ[ τ₁₁♯ ] × τ₂ ∈γᵗ[ τ₂₁♯ ] × τ₁ <: τ₂ × τ₁₂♯ ≼ ηᵗ τ₁ × τ₂₂♯ ≼ ηᵗ τ₂) ↔ (τ₁₂♯ , τ₂₂♯) ≼ I (τ₁₁♯ , τ₂₁♯)
-- P2 = LHS , RHS
-- where
-- LHS : ∀ {τ₁₁♯ τ₂₁♯ τ₁₂♯ τ₂₂♯ : type♯} → (∃ τ₁ 𝑠𝑡 ∃ τ₂ 𝑠𝑡 τ₁ ∈γᵗ[ τ₁₁♯ ] × τ₂ ∈γᵗ[ τ₂₁♯ ] × τ₁ <: τ₂ × τ₁₂♯ ≼ ηᵗ τ₁ × τ₂₂♯ ≼ ηᵗ τ₂) → (τ₁₂♯ , τ₂₂♯) ≼ I (τ₁₁♯ , τ₂₁♯)
-- LHS (∃ .None ,, ∃ .None ,, ⊤ , (None , (None , (≼₁ , ≼₂)))) = ≼₁ , ≼₂
-- -- LHS (∃ τ₁ ,, ∃ (τ₁₂ ⟨→⟩ τ₂₂) ,, ⊤ , ((∈γ₁₂ ⟨→⟩ ∈γ₂₂) , (<:₁ , (≼₁ , (≼₁₂ ⟨→⟩ ≼₂₂))))) = {!!}
-- -- with LHS (∃ None ,, ∃ τ₁₂ ,, ⊤ , (∈γ₁₂ , (None , (None , ≼₁₂))))
-- -- ... | X , Y = {!!} , {!!}
-- -- LHS (∃ (τ₁₁ ⟨→⟩ τ₂₁) ,, ∃ (τ₁₂ ⟨→⟩ τ₂₂) ,, ⊤ , ((∈γ₁₂ ⟨→⟩ ∈γ₂₂) , ((<:₁₂ ⟨→⟩ <:₂₂) , (≼₁ , (≼₁₂ ⟨→⟩ ≼₂₂))))) = {!!}
-- -- -- with LHS (∃ τ₁ ,, ∃ τ₁₂ ,, ⊤ , (∈γ₁₂ , ({!!} , (≼₁ , ≼₁₂))))
-- -- -- ... | X = {!<:₁!}
-- LHS (∃ .Any ,, ∃ .Any ,, Any , (⊤ , (Any , (≼₁ , ≼₂)))) = ≼₁ , ≼₂
-- -- LHS (∃ (τ₁₁ ⟨→⟩ τ₂₁) ,, ∃ τ₂ ,, (∈γ₁₁ ⟨→⟩ ∈γ₂₁) , (⊤ , (<:₁ , (≼₁ , ≼₂)))) = {!!}
-- LHS (∃ τ₁ ,, ∃ τ₂ ,, (⊤ , (∈γ₂ , (<:₁ , (≼₁ , ≼₂))))) = {!∈γ₁!}
-- LHS (∃ τ₁ ,, ∃ τ₂ ,, (∈γ₁ , (∈γ₂ , (<:₁ , (≼₁ , ≼₂))))) = {!∈γ₁!}
-- RHS : ∀ {τ₁₁♯ τ₂₁♯ τ₁₂♯ τ₂₂♯ : type♯} → (τ₁₂♯ , τ₂₂♯) ≼ I (τ₁₁♯ , τ₂₁♯) → (∃ τ₁ 𝑠𝑡 ∃ τ₂ 𝑠𝑡 τ₁ ∈γᵗ[ τ₁₁♯ ] × τ₂ ∈γᵗ[ τ₂₁♯ ] × τ₁ <: τ₂ × τ₁₂♯ ≼ ηᵗ τ₁ × τ₂₂♯ ≼ ηᵗ τ₂)
-- RHS {⊤} {None} (None , None) = ∃ None ,, ∃ None ,, (⊤ , (None , (None , (None , None))))
-- RHS {Any} {⊤} (Any , Any) = ∃ Any ,, ∃ Any ,, (Any , (⊤ , (Any , (Any , Any))))
-- RHS {⊤} {⊤} (≼₁ , ≼₂) = {!!}
-- RHS {⊤} {Any} (≼₁ , ≼₂) = {!!}
-- RHS {⊤} {⟨𝔹⟩} (≼₁ , ≼₂) = {!!}
-- RHS {⊤} {τ₂₁♯₁ ⟨→⟩ τ₂₁♯₂} (≼₁ , ≼₂) = {!!}
-- RHS {Any} {τ} (≼₁ , ≼₂) = {!!}
-- RHS {None} {τ} (≼₁ , ≼₂) = {!!}
-- RHS {⟨𝔹⟩} {τ} (≼₁ , ≼₂) = {!!}
-- RHS {τ₁₁♯₁ ⟨→⟩ τ₁₁♯₂} {τ} (≼₁ , ≼₂) = {!!}