forked from Gradual-Typing/Equivalence-of-Cast-Calculi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chain.agda
30 lines (24 loc) · 1019 Bytes
/
Chain.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
module equivalence-of-cast-calculi.Chain where
open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong)
data Chain {A : Set} (Link : A → A → Set) : A → A → Set where
[] : ∀ {a} → Chain Link a a
_∷_ : ∀ {a b c} → Link a b → Chain Link b c → Chain Link a c
_++_ : ∀ {A Link} → {a b c : A} → Chain Link a b → Chain Link b c → Chain Link a c
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)
++-assoc : ∀ {A Link} → {a b c d : A}
→ (xs : Chain Link a b)
→ (ys : Chain Link b c)
→ (zs : Chain Link c d)
→ (xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs)
++-assoc [] ys zs = refl
++-assoc (x ∷ xs) ys zs = cong (x ∷_) (++-assoc xs ys zs)
++-identityˡ : ∀ {A Link} → {a b : A}
→ (xs : Chain Link a b)
→ [] ++ xs ≡ xs
++-identityˡ xs = refl
++-identityʳ : ∀ {A Link} → {a b : A}
→ (xs : Chain Link a b)
→ xs ++ [] ≡ xs
++-identityʳ [] = refl
++-identityʳ (x ∷ xs) = cong (x ∷_) (++-identityʳ xs)