annotate list-nat0.agda @ 757:a4074765abf8

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