annotate Paper/src/AgdaNPushNPopProof.agda.replaced @ 5:339fb67b4375

INIT rbt.agda
author soto <soto@cr.ie.u-ryukyu.ac.jp>
date Sun, 07 Nov 2021 00:51:16 +0900
parents c59202657321
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1 pop-n-push-type : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! SingleLinkedStack !$\mathbb{N}$! !$\rightarrow$! Set!$\_{1}$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 pop-n-push-type n cn ce s = M.exec (M.csComp (M.cs popOnce) (n-push (suc n))) meta
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
3 !$\equiv$! M.exec (n-push n) meta
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 where
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 meta = id-meta cn ce s
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
7 pop-n-push : (n cn ce : !$\mathbb{N}$!) !$\rightarrow$! (s : SingleLinkedStack !$\mathbb{N}$!) !$\rightarrow$! pop-n-push-type n cn ce s
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 pop-n-push zero cn ce s = refl
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 pop-n-push (suc n) cn ce s = begin
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 M.exec (M.csComp (M.cs popOnce) (n-push (suc (suc n)))) (id-meta cn ce s)
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
11 !$\equiv$!!$\langle$! refl !$\rangle$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 M.exec (M.csComp (M.cs popOnce) (M.csComp (n-push (suc n)) (M.cs pushOnce))) (id-meta cn ce s)
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
13 !$\equiv$!!$\langle$! exec-comp (M.cs popOnce) (M.csComp (n-push (suc n)) (M.cs pushOnce)) (id-meta cn ce s) !$\rangle$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 M.exec (M.cs popOnce) (M.exec (M.csComp (n-push (suc n)) (M.cs pushOnce)) (id-meta cn ce s))
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
15 !$\equiv$!!$\langle$! cong (\x !$\rightarrow$! M.exec (M.cs popOnce) x) (exec-comp (n-push (suc n)) (M.cs pushOnce) (id-meta cn ce s)) !$\rangle$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 M.exec (M.cs popOnce) (M.exec (n-push (suc n))(M.exec (M.cs pushOnce) (id-meta cn ce s)))
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
17 !$\equiv$!!$\langle$! refl !$\rangle$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 M.exec (M.cs popOnce) (M.exec (n-push (suc n)) (id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})))
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
19 !$\equiv$!!$\langle$! sym (exec-comp (M.cs popOnce) (n-push (suc n)) (id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))}))) !$\rangle$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 M.exec (M.csComp (M.cs popOnce) (n-push (suc n))) (id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))}))
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
21 !$\equiv$!!$\langle$! pop-n-push n cn ce (record {top = just (cons ce (SingleLinkedStack.top s))}) !$\rangle$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 M.exec (n-push n) (id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))}))
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
23 !$\equiv$!!$\langle$! refl !$\rangle$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 M.exec (n-push n) (pushOnce (id-meta cn ce s))
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
25 !$\equiv$!!$\langle$! refl !$\rangle$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 M.exec (n-push n) (M.exec (M.cs pushOnce) (id-meta cn ce s))
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
27 !$\equiv$!!$\langle$! refl !$\rangle$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 M.exec (n-push (suc n)) (id-meta cn ce s)
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
29 !$\blacksquare$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
33 n-push-pop-type : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! SingleLinkedStack !$\mathbb{N}$! !$\rightarrow$! Set!$\_{1}$!
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
34 n-push-pop-type n cn ce st = M.exec (M.csComp (n-pop n) (n-push n)) meta !$\equiv$! meta
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 where
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 meta = id-meta cn ce st
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
38 n-push-pop : (n cn ce : !$\mathbb{N}$!) !$\rightarrow$! (s : SingleLinkedStack !$\mathbb{N}$!) !$\rightarrow$! n-push-pop-type n cn ce s
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 n-push-pop zero cn ce s = refl
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 n-push-pop (suc n) cn ce s = begin
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 M.exec (M.csComp (n-pop (suc n)) (n-push (suc n))) (id-meta cn ce s)
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
42 !$\equiv$!!$\langle$! refl !$\rangle$!
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
43 M.exec (M.csComp (M.cs (\m !$\rightarrow$! M.exec (n-pop n) (popOnce m))) (n-push (suc n))) (id-meta cn ce s)
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
44 !$\equiv$!!$\langle$! exec-comp (M.cs (\m !$\rightarrow$! M.exec (n-pop n) (popOnce m))) (n-push (suc n)) (id-meta cn ce s) !$\rangle$!
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
45 M.exec (M.cs (\m !$\rightarrow$! M.exec (n-pop n) (popOnce m))) (M.exec (n-push (suc n)) (id-meta cn ce s))
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
46 !$\equiv$!!$\langle$! refl !$\rangle$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 M.exec (n-pop n) (popOnce (M.exec (n-push (suc n)) (id-meta cn ce s)))
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
48 !$\equiv$!!$\langle$! refl !$\rangle$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 M.exec (n-pop n) (M.exec (M.cs popOnce) (M.exec (n-push (suc n)) (id-meta cn ce s)))
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
50 !$\equiv$!!$\langle$! cong (\x !$\rightarrow$! M.exec (n-pop n) x) (sym (exec-comp (M.cs popOnce) (n-push (suc n)) (id-meta cn ce s))) !$\rangle$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 M.exec (n-pop n) (M.exec (M.csComp (M.cs popOnce) (n-push (suc n))) (id-meta cn ce s))
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
52 !$\equiv$!!$\langle$! cong (\x !$\rightarrow$! M.exec (n-pop n) x) (pop-n-push n cn ce s) !$\rangle$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 M.exec (n-pop n) (M.exec (n-push n) (id-meta cn ce s))
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
54 !$\equiv$!!$\langle$! sym (exec-comp (n-pop n) (n-push n) (id-meta cn ce s)) !$\rangle$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 M.exec (M.csComp (n-pop n) (n-push n)) (id-meta cn ce s)
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
56 !$\equiv$!!$\langle$! n-push-pop n cn ce s !$\rangle$!
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 id-meta cn ce s
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
58 !$\blacksquare$!