Mercurial > hg > Members > atton > agda-proofs
annotate cbc/subtype.agda @ 53:6af88ee5c4ca
Prune level
author | atton <atton@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 10 Jan 2017 09:07:07 +0000 |
parents | 4880184e4ab5 |
children | fa95e3070138 |
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 |
53 | 4 module subtype (Context : Set) 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 |
53 | 7 record DataSegment (A : Set) : Set 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 |
53 | 13 data CodeSegment (A B : Set) : Set 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 |
38
a0ca5e29a9dc
Call subtype using user-defined cast operator
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
37
diff
changeset
|
16 |
53 | 17 exec : {I O : Set} {{_ : DataSegment I}} {{_ : DataSegment O}} -> CodeSegment I O -> Context -> Context |
52
4880184e4ab5
Define push/pop using subtype
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
18 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
|
19 |
40
e6b965df2137
Trying define type composition using subtype through DS
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
39
diff
changeset
|
20 |
53 | 21 comp : {con : Context} -> {A B C D : Set} {{_ : 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
|
22 -> (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
|
23 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
|
24 |
53 | 25 csComp : {con : Context} {A B C D : Set} |
51
16e27df74ec5
Split subtype definitions for reuse context
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
50
diff
changeset
|
26 {{_ : 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
|
27 -> 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
|
28 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
|
29 = 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
|
30 |
48
fe5755744071
Trying prove associativity of composition of code segments
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
31 |
47
49de29c12c7b
Define code segment compose operator using type -> ds cast!
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
46
diff
changeset
|
32 |
53 | 33 comp-associative : {A B C D E F : Set} {con : Context} |
51
16e27df74ec5
Split subtype definitions for reuse context
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
50
diff
changeset
|
34 {{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
|
35 {{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
|
36 -> (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
|
37 -> 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
|
38 comp-associative (cs _) (cs _) (cs _) = refl |