Mercurial > hg > Members > atton > agda-proofs
annotate cbc/subtype.agda @ 73:a5cac9483f91
Cleanup sample
author | atton <atton@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 01 Feb 2017 05:27:05 +0000 |
parents | 614997a2e21c |
children | f1ab418bc37f |
rev | line source |
---|---|
52
4880184e4ab5
Define push/pop using subtype
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
1 open import Level |
38
a0ca5e29a9dc
Call subtype using user-defined cast operator
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
37
diff
changeset
|
2 open import Relation.Binary.PropositionalEquality |
a0ca5e29a9dc
Call subtype using user-defined cast operator
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
37
diff
changeset
|
3 |
54
fa95e3070138
Define SingleLinkedStack using subtype
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
4 module subtype {l : Level} (Context : Set l) where |
37
60e604972f30
Trying define codesegment using named-product with subtype
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 |
52
4880184e4ab5
Define push/pop using subtype
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
6 |
54
fa95e3070138
Define SingleLinkedStack using subtype
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
7 record DataSegment {ll : Level} (A : Set ll) : Set (l ⊔ ll) where |
39
d8312361afdc
Call subtype using user-defined cast operator with subtype list
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
38
diff
changeset
|
8 field |
d8312361afdc
Call subtype using user-defined cast operator with subtype list
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
38
diff
changeset
|
9 get : Context -> A |
d8312361afdc
Call subtype using user-defined cast operator with subtype list
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
38
diff
changeset
|
10 set : Context -> A -> Context |
51
16e27df74ec5
Split subtype definitions for reuse context
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
50
diff
changeset
|
11 open DataSegment |
38
a0ca5e29a9dc
Call subtype using user-defined cast operator
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
37
diff
changeset
|
12 |
54
fa95e3070138
Define SingleLinkedStack using subtype
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
13 data CodeSegment {l1 l2 : Level} (A : Set l1) (B : Set l2) : Set (l ⊔ l1 ⊔ l2) where |
51
16e27df74ec5
Split subtype definitions for reuse context
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
50
diff
changeset
|
14 cs : {{_ : DataSegment A}} {{_ : DataSegment B}} -> (A -> B) -> CodeSegment A B |
37
60e604972f30
Trying define codesegment using named-product with subtype
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 |
71 | 16 goto : {l1 l2 : Level} {I : Set l1} {O : Set l2} {{_ : DataSegment I}} {{_ : DataSegment O}} |
17 -> CodeSegment I O -> I -> O | |
18 goto (cs b) i = b i | |
38
a0ca5e29a9dc
Call subtype using user-defined cast operator
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
37
diff
changeset
|
19 |
55 | 20 exec : {l1 l2 : Level} {I : Set l1} {O : Set l2} {{_ : DataSegment I}} {{_ : DataSegment O}} |
21 -> CodeSegment I O -> Context -> Context | |
52
4880184e4ab5
Define push/pop using subtype
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
22 exec {l} {{i}} {{o}} (cs b) c = set o c (b (get i c)) |
37
60e604972f30
Trying define codesegment using named-product with subtype
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 |
40
e6b965df2137
Trying define type composition using subtype through DS
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
39
diff
changeset
|
24 |
54
fa95e3070138
Define SingleLinkedStack using subtype
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
25 comp : {con : Context} -> {l1 l2 l3 l4 : Level} |
fa95e3070138
Define SingleLinkedStack using subtype
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
26 {A : Set l1} {B : Set l2} {C : Set l3} {D : Set l4} |
fa95e3070138
Define SingleLinkedStack using subtype
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
27 {{_ : DataSegment A}} {{_ : DataSegment B}} {{_ : DataSegment C}} {{_ : DataSegment D}} |
46
af1fe3bd9f1e
Define code segment compose operator using type -> ds cast
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
45
diff
changeset
|
28 -> (C -> D) -> (A -> B) -> A -> D |
47
49de29c12c7b
Define code segment compose operator using type -> ds cast!
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
46
diff
changeset
|
29 comp {con} {{i}} {{io}} {{oi}} {{o}} g f x = g (get oi (set io con (f x))) |
46
af1fe3bd9f1e
Define code segment compose operator using type -> ds cast
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
45
diff
changeset
|
30 |
54
fa95e3070138
Define SingleLinkedStack using subtype
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
31 csComp : {con : Context} -> {l1 l2 l3 l4 : Level} |
60
bd428bd6b394
Trying define n-push/n-pop
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
32 {A : Set l1} {B : Set l2} {C : Set l3} {D : Set l4} |
51
16e27df74ec5
Split subtype definitions for reuse context
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
50
diff
changeset
|
33 {{_ : DataSegment A}} {{_ : DataSegment B}} {{_ : DataSegment C}} {{_ : DataSegment D}} |
49
8031568638d0
Define composition of codesegment using subtype without constraint list
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
48
diff
changeset
|
34 -> CodeSegment C D -> CodeSegment A B -> CodeSegment A D |
8031568638d0
Define composition of codesegment using subtype without constraint list
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
48
diff
changeset
|
35 csComp {con} {A} {B} {C} {D} {{da}} {{db}} {{dc}} {{dd}} (cs g) (cs f) |
48
fe5755744071
Trying prove associativity of composition of code segments
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
36 = cs {{da}} {{dd}} (comp {con} {{da}} {{db}} {{dc}} {{dd}} g f) |
42
f7916d13e2b1
Trying define type composition using list of subtype...
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
41
diff
changeset
|
37 |
48
fe5755744071
Trying prove associativity of composition of code segments
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
38 |
47
49de29c12c7b
Define code segment compose operator using type -> ds cast!
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
46
diff
changeset
|
39 |
54
fa95e3070138
Define SingleLinkedStack using subtype
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
40 comp-associative : {A B C D E F : Set l} {con : Context} |
51
16e27df74ec5
Split subtype definitions for reuse context
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
50
diff
changeset
|
41 {{da : DataSegment A}} {{db : DataSegment B}} {{dc : DataSegment C}} |
16e27df74ec5
Split subtype definitions for reuse context
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
50
diff
changeset
|
42 {{dd : DataSegment D}} {{de : DataSegment E}} {{df : DataSegment F}} |
49
8031568638d0
Define composition of codesegment using subtype without constraint list
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
48
diff
changeset
|
43 -> (a : CodeSegment A B) (b : CodeSegment C D) (c : CodeSegment E F) |
8031568638d0
Define composition of codesegment using subtype without constraint list
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
48
diff
changeset
|
44 -> csComp {con} c (csComp {con} b a) ≡ csComp {con} (csComp {con} c b) a |
8031568638d0
Define composition of codesegment using subtype without constraint list
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
48
diff
changeset
|
45 comp-associative (cs _) (cs _) (cs _) = refl |