153
|
1 module list-nat0 where
|
|
2
|
|
3 open import Level
|
|
4
|
|
5
|
|
6 postulate a : Set
|
|
7 postulate b : Set
|
|
8 postulate c : Set
|
|
9
|
|
10
|
|
11 infixr 40 _::_
|
300
|
12 data List {a} (A : Set a) : Set a where
|
153
|
13 [] : List A
|
300
|
14 _::_ : A → List A → List A
|
153
|
15
|
|
16
|
|
17 infixl 30 _++_
|
300
|
18 -- _++_ : {a : Level } → {A : Set a} → List A → List A → List A
|
|
19 _++_ : ∀ {a} {A : Set a} → List A → List A → List A
|
153
|
20 [] ++ ys = ys
|
|
21 (x :: xs) ++ ys = x :: (xs ++ ys)
|
|
22
|
|
23
|
|
24 l1 = a :: []
|
|
25 l2 = a :: b :: a :: c :: []
|
|
26
|
|
27 l3 = l1 ++ l2
|
|
28
|
|
29 infixr 20 _==_
|
|
30
|
300
|
31 data _==_ {n} {A : Set n} : List A → List A → Set n where
|
|
32 reflection : {x : List A} → x == x
|
|
33 eq-cons : {x y : List A} { a : A } → x == y → ( a :: x ) == ( a :: y )
|
|
34 trans-list : {x y z : List A} { a : A } → x == y → y == z → x == z
|
153
|
35 -- eq-nil : [] == []
|
|
36
|
300
|
37 list-id-l : { A : Set } → { x : List A} → [] ++ x == x
|
153
|
38 list-id-l = reflection
|
|
39
|
300
|
40 list-id-r : { A : Set } → ( x : List A ) → x ++ [] == x
|
153
|
41 list-id-r [] = reflection
|
|
42 list-id-r (x :: xs) = eq-cons ( list-id-r xs )
|
|
43
|
|
44
|
300
|
45 -- listAssoc : { A : Set } → { a b c : List A} → ( ( a ++ b ) ++ c ) == ( a ++ ( b ++ c ) )
|
153
|
46 -- listAssoc = eq-reflection
|
|
47
|
300
|
48 list-assoc : {A : Set } → ( xs ys zs : List A ) →
|
153
|
49 ( ( xs ++ ys ) ++ zs ) == ( xs ++ ( ys ++ zs ) )
|
|
50 list-assoc [] ys zs = reflection
|
|
51 list-assoc (x :: xs) ys zs = eq-cons ( list-assoc xs ys zs )
|
|
52
|
|
53
|
|
54
|
|
55 open import Relation.Binary.PropositionalEquality
|
|
56 open ≡-Reasoning
|
|
57
|
300
|
58 cong1 : ∀{a} {A : Set a } {b} { B : Set b } →
|
|
59 ( f : A → B ) → {x : A } → {y : A} → x ≡ y → f x ≡ f y
|
153
|
60 cong1 f refl = refl
|
|
61
|
300
|
62 lemma11 : ∀{n} → ( Set n ) IsRelatedTo ( Set n )
|
153
|
63 lemma11 = relTo refl
|
|
64
|
300
|
65 lemma12 : {L : Set} ( x : List L ) → x ++ x ≡ x ++ x
|
153
|
66 lemma12 x = begin x ++ x ∎
|
|
67
|
|
68
|
300
|
69 ++-assoc : {L : Set} ( xs ys zs : List L ) → (xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs)
|
|
70 ++-assoc [] ys zs = -- {A : Set} → -- let open ==-Reasoning A in
|
153
|
71 begin -- to prove ([] ++ ys) ++ zs ≡ [] ++ (ys ++ zs)
|
|
72 ( [] ++ ys ) ++ zs
|
|
73 ≡⟨ refl ⟩
|
|
74 ys ++ zs
|
|
75 ≡⟨ refl ⟩
|
|
76 [] ++ ( ys ++ zs )
|
|
77 ∎
|
|
78
|
300
|
79 ++-assoc (x :: xs) ys zs = -- {A : Set} → -- let open ==-Reasoning A in
|
153
|
80 begin -- to prove ((x :: xs) ++ ys) ++ zs ≡ (x :: xs) ++ (ys ++ zs)
|
|
81 ((x :: xs) ++ ys) ++ zs
|
|
82 ≡⟨ refl ⟩
|
|
83 (x :: (xs ++ ys)) ++ zs
|
|
84 ≡⟨ refl ⟩
|
|
85 x :: ((xs ++ ys) ++ zs)
|
|
86 ≡⟨ cong1 (_::_ x) (++-assoc xs ys zs) ⟩
|
|
87 x :: (xs ++ (ys ++ zs))
|
|
88 ≡⟨ refl ⟩
|
|
89 (x :: xs) ++ (ys ++ zs)
|
|
90 ∎
|
|
91
|
|
92
|
|
93
|
|
94
|
|
95
|
|
96 --data Bool : Set where
|
|
97 -- true : Bool
|
|
98 -- false : Bool
|
|
99
|
|
100
|
|
101 --postulate Obj : Set
|
|
102
|
300
|
103 --postulate Hom : Obj → Obj → Set
|
153
|
104
|
|
105
|
300
|
106 --postulate id : { a : Obj } → Hom a a
|
153
|
107
|
|
108
|
|
109 --infixr 80 _○_
|
300
|
110 --postulate _○_ : { a b c : Obj } → Hom b c → Hom a b → Hom a c
|
153
|
111
|
300
|
112 -- postulate axId1 : {a b : Obj} → ( f : Hom a b ) → f == id ○ f
|
|
113 -- postulate axId2 : {a b : Obj} → ( f : Hom a b ) → f == f ○ id
|
153
|
114
|
300
|
115 --assoc : { a b c d : Obj } →
|
|
116 -- (f : Hom c d ) → (g : Hom b c) → (h : Hom a b) →
|
153
|
117 -- (f ○ g) ○ h == f ○ ( g ○ h)
|
|
118
|
|
119
|
|
120 --a = Set
|
|
121
|
300
|
122 -- ListObj : {A : Set} → List A
|
153
|
123 -- ListObj = List Set
|
|
124
|
300
|
125 -- ListHom : ListObj → ListObj → Set
|
153
|
126
|