Skip to content

Commit 5612df7

Browse files
authored
Merge pull request #70 from pmbittner/IndexedSet-equivalence-equivalence
Embrace constructive logic to proof `≅→≅[]`
2 parents 8c94dbe + 0d52c85 commit 5612df7

File tree

2 files changed

+38
-21
lines changed

2 files changed

+38
-21
lines changed

src/Data/IndexedSet.lagda.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,39 @@ Our new relations can be converted back to the old ones by just forgetting the e
278278
≅[]→≅ (A⊆[f]B , B⊆[f⁻¹]A) = ⊆[]→⊆ A⊆[f]B , ⊆[]→⊆ B⊆[f⁻¹]A
279279
```
280280

281+
282+
As Agda implements constructive logic, the converse is also possible.
283+
```agda
284+
∈-index : ∀ {I : Set iℓ} {A : IndexedSet I} {a : Carrier}
285+
→ a ∈ A
286+
→ I
287+
∈-index (i , eq) = i
288+
289+
∈→∈[] : ∀ {I : Set iℓ} {A : IndexedSet I} {a : Carrier}
290+
→ (p : a ∈ A)
291+
----------
292+
→ a ≈ A (∈-index p)
293+
∈→∈[] (i , eq) = eq
294+
295+
⊆-index : ∀ {I : Set iℓ} {J : Set jℓ} {A : IndexedSet I} {B : IndexedSet J}
296+
→ A ⊆ B
297+
→ I → J
298+
⊆-index A⊆B i = ∈-index (A⊆B i)
299+
300+
⊆→⊆[] : ∀ {I : Set iℓ} {J : Set jℓ} {A : IndexedSet I} {B : IndexedSet J}
301+
→ (subset : A ⊆ B)
302+
-----------
303+
→ A ⊆[ ⊆-index subset ] B
304+
⊆→⊆[] A⊆B i = proj₂ (A⊆B i)
305+
306+
≅→≅[] : ∀ {I : Set iℓ} {J : Set jℓ} {A : IndexedSet I} {B : IndexedSet J}
307+
→ (eq : A ≅ B)
308+
-----------------
309+
→ A ≅[ ⊆-index (proj₁ eq) ][ ⊆-index (proj₂ eq) ] B
310+
≅→≅[] (A⊆B , B⊆A) = (⊆→⊆[] A⊆B) , (⊆→⊆[] B⊆A)
311+
```
312+
313+
281314
If two indexed sets are pointwise equal, they are equivelent in terms of the identify function because
282315
indices do not have to be translated.
283316

src/Framework/Relation/Expressiveness.lagda.md

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -179,31 +179,15 @@ compiler-from-expressiveness : ∀ {L M : VariabilityLanguage V}
179179
→ LanguageCompiler L M
180180
compiler-from-expressiveness {L} {M} exp = record
181181
{ compile = proj₁ ∘ exp
182-
; config-compiler = λ e → record { to = conf e ; from = fnoc e }
183-
; preserves = λ e → ⊆-conf e , ⊆-fnoc e
182+
; config-compiler = λ e → record
183+
{ to = ⊆-index (proj₁ (proj₂ (exp e)))
184+
; from = ⊆-index (proj₂ (proj₂ (exp e)))
185+
}
186+
; preserves = ≅→≅[] ∘ proj₂ ∘ exp
184187
}
185188
where
186-
⟦_⟧₁ = Semantics L
187-
⟦_⟧₂ = Semantics M
188189
open import Data.EqIndexedSet
189190
190-
conf : ∀ {A} → Expression L A → Config L → Config M
191-
conf e c₁ = proj₁ (proj₁ (proj₂ (exp e)) c₁)
192-
193-
fnoc : ∀ {A} → Expression L A → Config M → Config L
194-
fnoc e c₂ = proj₁ (proj₂ (proj₂ (exp e)) c₂)
195-
196-
eq : ∀ {A} → (e : Expression L A) → ⟦ e ⟧₁ ≅ ⟦ proj₁ (exp e) ⟧₂
197-
eq e = proj₂ (exp e)
198-
199-
⊆-conf : ∀ {A} → (e : Expression L A) → ⟦ e ⟧₁ ⊆[ conf e ] ⟦ proj₁ (exp e) ⟧₂
200-
⊆-conf e with eq e
201-
... | ⊆ , _ = proj₂ ∘ ⊆
202-
203-
⊆-fnoc : ∀ {A} → (e : Expression L A) → ⟦ proj₁ (exp e) ⟧₂ ⊆[ fnoc e ] ⟦ e ⟧₁
204-
⊆-fnoc e with eq e
205-
... | _ , ⊇ = proj₂ ∘ ⊇
206-
207191
{-|
208192
When M is not at least as expressive as L,
209193
then L can never be compiled to M.

0 commit comments

Comments
 (0)