annotate agda/chap0.agda @ 53:f443cd9de556

add
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Oct 2019 16:05:34 +0900
parents
children ff4f57e17df5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
53
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 module chap0 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 Data.List
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 open import Data.Nat hiding (_⊔_)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Data.Integer hiding (_⊔_)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 open import Data.Product
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 A : List ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 A = 1 ∷ 2 ∷ []
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 data Literal : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 x : Literal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 y : Literal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 z : Literal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 B : List Literal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 B = x ∷ y ∷ z ∷ []
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 ListProduct : {A B : Set } → List A → List B → List ( A × B )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 ListProduct = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 ex05 : List ( ℕ × Literal )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 ex05 = ListProduct A B -- (1 , x) ∷ (1 , y) ∷ (1 , z) ∷ (2 , x) ∷ (2 , y) ∷ (2 , z) ∷ []
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 ex06 : List ( ℕ × Literal × ℕ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 ex06 = ListProduct A (ListProduct B A)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 ex07 : Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 ex07 = ℕ × ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 data ex08-f : ℕ → ℕ → Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 ex08f0 : ex08-f 0 1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 ex08f1 : ex08-f 1 2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 ex08f2 : ex08-f 2 3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 ex08f3 : ex08-f 3 4
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 ex08f4 : ex08-f 4 0
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 data ex09-g : ℕ → ℕ → ℕ → ℕ → Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 ex09g0 : ex09-g 0 1 2 3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 ex09g1 : ex09-g 1 2 3 0
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 ex09g2 : ex09-g 2 3 0 1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 ex09g3 : ex09-g 3 0 1 2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 open import Data.Nat.DivMod
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 open import Relation.Binary.PropositionalEquality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 _≡7_ : ℕ → ℕ → Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 n ≡7 m = (n % 7) ≡ (m % 7 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 refl7 : { n : ℕ} → n ≡7 n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 refl7 = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 sym7 : { n m : ℕ} → n ≡7 m → m ≡7 n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 sym7 = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 trans7 : { n m o : ℕ} → n ≡7 m → m ≡7 o → n ≡7 o
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 trans7 = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 open import Level renaming ( zero to Zero ; suc to Suc )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 record Graph { v v' : Level } : Set (Suc v ⊔ Suc v' ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 vertex : Set v
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 edge : vertex → vertex → Set v'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 data edge012a : ℕ → ℕ → Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 e012a-1 : edge012a 1 2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 e012a-2 : edge012a 2 3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 e012a-3 : edge012a 3 4
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 e012a-4 : edge012a 4 5
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 e012a-5 : edge012a 5 1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 graph012a : Graph {Zero} {Zero}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 graph012a = record { vertex = ℕ ; edge = edge012a }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 data edge012b : ℕ → ℕ → Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 e012b-1 : edge012b 1 2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 e012b-2 : edge012b 1 3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 e012b-3 : edge012b 1 4
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 e012b-4 : edge012b 2 3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 e012b-5 : edge012b 2 4
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 e012b-6 : edge012b 3 4
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 graph012b : Graph {Zero} {Zero}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 graph012b = record { vertex = ℕ ; edge = edge012b }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 data connected { V : Set } ( E : V -> V -> Set ) ( x y : V ) : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 direct : E x y -> connected E x y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 indirect : { z : V } -> E x z -> connected {V} E z y -> connected E x y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 open import Data.Empty
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 open import Relation.Nullary
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 -- data Dec (P : Set) : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 -- yes : P → Dec P
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 -- no : ¬ P → Dec P
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 reachable : { V : Set } ( E : V -> V -> Set ) ( x y : V ) -> Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 reachable {V} E X Y = Dec ( connected {V} E X Y )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 dag : { V : Set } ( E : V -> V -> Set ) -> Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 dag {V} E = ∀ (n : V) → ¬ ( connected E n n )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105