annotate paper/src/stack-product.agda @ 72:fd984cfd5425

Add sources
author atton <atton@cr.ie.u-ryukyu.ac.jp>
date Mon, 06 Feb 2017 10:32:49 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 module stack-product where
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 open import product
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 open import Data.Product
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Data.Nat
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 open import Function using (id)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 open import Relation.Binary.PropositionalEquality
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 -- definition based from Gears(209:5708390a9d88) src/parallel_execution
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 goto = executeCS
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 data Bool : Set where
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 True : Bool
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 False : Bool
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 data Maybe (a : Set) : Set where
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 Nothing : Maybe a
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 Just : a -> Maybe a
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 record Stack {a t : Set} (stackImpl : Set) : Set where
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 field
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 stack : stackImpl
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 push : CodeSegment (stackImpl × a × (CodeSegment stackImpl t)) t
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 pop : CodeSegment (stackImpl × (CodeSegment (stackImpl × Maybe a) t)) t
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 data Element (a : Set) : Set where
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 cons : a -> Maybe (Element a) -> Element a
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 datum : {a : Set} -> Element a -> a
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 datum (cons a _) = a
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 next : {a : Set} -> Element a -> Maybe (Element a)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 next (cons _ n) = n
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 record SingleLinkedStack (a : Set) : Set where
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 field
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 top : Maybe (Element a)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 open SingleLinkedStack
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 emptySingleLinkedStack : {a : Set} -> SingleLinkedStack a
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 emptySingleLinkedStack = record {top = Nothing}
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 pushSingleLinkedStack : {a t : Set} -> CodeSegment ((SingleLinkedStack a) × a × (CodeSegment (SingleLinkedStack a) t)) t
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 pushSingleLinkedStack = cs push
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 where
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 push : {a t : Set} -> ((SingleLinkedStack a) × a × (CodeSegment (SingleLinkedStack a) t)) -> t
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 push (stack , datum , next) = goto next stack1
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 where
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 element = cons datum (top stack)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 stack1 = record {top = Just element}
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 popSingleLinkedStack : {a t : Set} -> CodeSegment (SingleLinkedStack a × (CodeSegment (SingleLinkedStack a × Maybe a) t)) t
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 popSingleLinkedStack = cs pop
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 where
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 pop : {a t : Set} -> (SingleLinkedStack a × (CodeSegment (SingleLinkedStack a × Maybe a) t)) -> t
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 pop (record { top = Nothing } , nextCS) = goto nextCS (emptySingleLinkedStack , Nothing)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 pop (record { top = Just x } , nextCS) = goto nextCS (stack1 , (Just datum1))
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 where
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 datum1 = datum x
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 stack1 = record { top = (next x) }
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 createSingleLinkedStack : {a b : Set} -> Stack {a} {b} (SingleLinkedStack a)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 createSingleLinkedStack = record { stack = emptySingleLinkedStack
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 ; push = pushSingleLinkedStack
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 ; pop = popSingleLinkedStack
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 }
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 test01 : {a : Set} -> CodeSegment (SingleLinkedStack a × Maybe a) Bool
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 test01 = cs test01'
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 where
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 test01' : {a : Set} -> (SingleLinkedStack a × Maybe a) -> Bool
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 test01' (record { top = Nothing } , _) = False
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 test01' (record { top = Just x } , _) = True
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 test02 : {a : Set} -> CodeSegment (SingleLinkedStack a) (SingleLinkedStack a × Maybe a)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 test02 = cs test02'
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 where
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 test02' : {a : Set} -> SingleLinkedStack a -> (SingleLinkedStack a × Maybe a)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 test02' stack = goto popSingleLinkedStack (stack , (cs id))
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 test03 : {a : Set} -> CodeSegment a (SingleLinkedStack a)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 test03 = cs test03'
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 where
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 test03' : {a : Set} -> a -> SingleLinkedStack a
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 test03' a = goto pushSingleLinkedStack (emptySingleLinkedStack , a , (cs id))
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 lemma : {A : Set} {a : A} -> goto (test03 ◎ test02 ◎ test01) a ≡ False
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 lemma = refl
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 n-push : {A : Set} {a : A} -> CodeSegment (ℕ × SingleLinkedStack A) (ℕ × SingleLinkedStack A)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 n-push {A} {a} = cs (push {A} {a})
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 where
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 push : {A : Set} {a : A} -> (ℕ × SingleLinkedStack A) -> (ℕ × SingleLinkedStack A)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 push {A} {a} (zero , s) = (zero , s)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 push {A} {a} (suc n , s) = goto pushSingleLinkedStack (s , a , {!!} {- n-push -}) -- needs subtype
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 {-
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 n-push : {A : Set} {a : A} -> Nat -> SingleLinkedStack A -> SingleLinkedStack A
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 n-push zero s = s
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 n-push {A} {a} (suc n) s = pushSingleLinkedStack (n-push {A} {a} n s) a (\s -> s)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 n-pop : {A : Set} {a : A} -> Nat -> SingleLinkedStack A -> SingleLinkedStack A
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 n-pop zero s = s
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 n-pop {A} {a} (suc n) s = popSingleLinkedStack (n-pop {A} {a} n s) (\s _ -> s)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 open ≡-Reasoning
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 push-pop-equiv : {A : Set} {a : A} (s : SingleLinkedStack A) -> popSingleLinkedStack (pushSingleLinkedStack s a (\s -> s)) (\s _ -> s) ≡ s
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 push-pop-equiv s = refl
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 push-and-n-pop : {A : Set} {a : A} (n : Nat) (s : SingleLinkedStack A) -> n-pop {A} {a} (suc n) (pushSingleLinkedStack s a id) ≡ n-pop {A} {a} n s
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 push-and-n-pop zero s = refl
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 push-and-n-pop {A} {a} (suc n) s = begin
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 n-pop (suc (suc n)) (pushSingleLinkedStack s a id)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 ≡⟨ refl ⟩
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 popSingleLinkedStack (n-pop (suc n) (pushSingleLinkedStack s a id)) (\s _ -> s)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 ≡⟨ cong (\s -> popSingleLinkedStack s (\s _ -> s)) (push-and-n-pop n s) ⟩
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 popSingleLinkedStack (n-pop n s) (\s _ -> s)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 ≡⟨ refl ⟩
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 n-pop (suc n) s
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 n-push-pop-equiv : {A : Set} {a : A} (n : Nat) (s : SingleLinkedStack A) -> (n-pop {A} {a} n (n-push {A} {a} n s)) ≡ s
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 n-push-pop-equiv zero s = refl
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 n-push-pop-equiv {A} {a} (suc n) s = begin
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 n-pop (suc n) (n-push (suc n) s)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 ≡⟨ refl ⟩
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 n-pop (suc n) (pushSingleLinkedStack (n-push n s) a (\s -> s))
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 ≡⟨ push-and-n-pop n (n-push n s) ⟩
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 n-pop n (n-push n s)
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 ≡⟨ n-push-pop-equiv n s ⟩
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 s
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 n-push-pop-equiv-empty : {A : Set} {a : A} -> (n : Nat) -> n-pop {A} {a} n (n-push {A} {a} n emptySingleLinkedStack) ≡ emptySingleLinkedStack
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 n-push-pop-equiv-empty n = n-push-pop-equiv n emptySingleLinkedStack
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 -}
fd984cfd5425 Add sources
atton <atton@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158