1 | include "utilities/bind_new.ma". |
---|
2 | |
---|
3 | definition bind_list ≝ λB,E.bind_new B (list E). |
---|
4 | |
---|
5 | coercion blist_from_list : |
---|
6 | ∀B,E. ∀l:list E. bind_list B E ≝ λB,E,l.bret … l on _l : list ? to bind_list ??. |
---|
7 | |
---|
8 | unification hint 0 ≔ B,E; |
---|
9 | Es ≟ list E |
---|
10 | (*--------------------------*)⊢ |
---|
11 | bind_list B E ≡ bind_new B Es. |
---|
12 | |
---|
13 | definition bappend : ∀B,E.bind_list B E → bind_list B E → |
---|
14 | bind_list B E ≝ λB,E. m_bin_op … (append ?). |
---|
15 | |
---|
16 | include "ASM/Vector.ma". |
---|
17 | interpretation "append blist" 'vappend l1 l2 = (bappend ?? l1 l2). |
---|
18 | |
---|
19 | definition bcons : ∀B,E.E → bind_list B E → bind_list B E ≝ |
---|
20 | λB,E,e.m_map … (cons … e). |
---|
21 | interpretation "cons blist" 'vcons l1 l2 = (bcons ?? l1 l2). |
---|
22 | |
---|
23 | include "utilities/lists.ma". |
---|
24 | |
---|
25 | theorem bcompile_append : |
---|
26 | ∀U, R, E, fresh, bl1, bl2. |
---|
27 | (bcompile U R (list E) fresh (bl1 @@ bl2)) ≅ |
---|
28 | ( |
---|
29 | ! l1 ← bcompile … fresh bl1 ; |
---|
30 | ! l2 ← bcompile … fresh bl2 ; |
---|
31 | return (l1 @ l2) |
---|
32 | ). |
---|
33 | #U#R#E#fresh#bl1#bl2 |
---|
34 | #u >bcompile_bbind normalize @pair_elim |
---|
35 | #u' #l' normalize @pair_elim |
---|
36 | #u'' #l'' normalize >bcompile_bbind #EQ #EQ' |
---|
37 | normalize >EQ normalize // |
---|
38 | qed. |
---|
39 | |
---|
40 | theorem bcompile_cons : |
---|
41 | ∀U, R, E, fresh, e, bl2. |
---|
42 | (bcompile U R (list E) fresh (e ::: bl2)) ≅ |
---|
43 | ! l ← bcompile … fresh bl2 ; return (e :: l). |
---|
44 | #U#R#E#fresh#e#bl2 #u @bcompile_bbind |
---|
45 | qed. |
---|