annotate list-nat0.agda @ 185:173d078ee443

Yoneda join
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 28 Aug 2013 21:51:59 +0900
parents 3249aaddc405
children d6a6dd305da2
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 _::_
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 data List ∀ {a} (A : Set a) : Set a where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 [] : List A
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 _::_ : A -> List A -> List A
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 _++_
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 -- _++_ : {a : Level } -> {A : Set a} -> List A -> List A -> List A
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 _++_ : ∀ {a} {A : Set a} -> List A -> List A -> List A
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 data _==_ {n} {A : Set n} : List A -> List A -> Set n where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 reflection : {x : List A} -> x == x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 eq-cons : {x y : List A} { a : A } -> x == y -> ( a :: x ) == ( a :: y )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 trans-list : {x y z : List A} { a : A } -> x == y -> y == z -> x == z
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 list-id-l : { A : Set } -> { x : List A} -> [] ++ x == x
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 list-id-r : { A : Set } -> ( x : List A ) -> x ++ [] == x
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 -- listAssoc : { A : Set } -> { a b c : List A} -> ( ( a ++ b ) ++ c ) == ( a ++ ( b ++ c ) )
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 list-assoc : {A : Set } -> ( xs ys zs : List A ) ->
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 cong1 : ∀{a} {A : Set a } {b} { B : Set b } ->
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 ( f : A -> B ) -> {x : A } -> {y : A} -> x ≡ y -> f x ≡ f y
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 lemma11 : ∀{n} -> ( Set n ) IsRelatedTo ( Set n )
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 lemma12 : {L : Set} ( x : List L ) -> x ++ x ≡ x ++ x
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 ++-assoc : {L : Set} ( xs ys zs : List L ) -> (xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 ++-assoc [] ys zs = -- {A : Set} -> -- let open ==-Reasoning A in
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 ++-assoc (x :: xs) ys zs = -- {A : Set} -> -- let open ==-Reasoning A in
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 --postulate Hom : Obj -> Obj -> Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 --postulate id : { a : Obj } -> Hom a a
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 _○_
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 --postulate _○_ : { a b c : Obj } -> Hom b c -> Hom a b -> Hom a c
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 -- postulate axId1 : {a b : Obj} -> ( f : Hom a b ) -> f == id ○ f
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 -- postulate axId2 : {a b : Obj} -> ( f : Hom a b ) -> f == f ○ id
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 --assoc : { a b c d : Obj } ->
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 -- (f : Hom c d ) -> (g : Hom b c) -> (h : Hom a b) ->
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 -- ListObj : {A : Set} -> List A
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
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 -- ListHom : ListObj -> ListObj -> Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126