-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathappend_spec.k
76 lines (72 loc) · 1.92 KB
/
append_spec.k
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
require "../patterns/list/js-verifier.k"
module APPEND-SPEC
imports JS-VERIFIER
rule [loop-inv]:
<lexicalEnv> @e(I:Int) </lexicalEnv>
<lastNonEmptyValue> _:Val => ?_:Val </lastNonEmptyValue>
<envs>...
<env>
<eid> @e(I) </eid>
<outer> _:Eid </outer>
<strict> _:Bool </strict>
<declEnvRec>...
"x" |-> @ve(OX:NullableObject, true, true, false)
"p" |-> @ve(@o(P1:Int) => @o(?P2:Int), true, true, false)
...</declEnvRec>
</env>
(.Bag => ?_:Bag)
...</envs>
<objs>...
(
lseg(OX, @o(P1:Int))(A:List)
lseg(@o(P1:Int), @NullVal)(B:List)
=>
lseg(OX, @o(?P2:Int))(?C:List)
<obj>
<oid> @o(?P2:Int) </oid>
<properties>
"value" |-> @desc("Value" |-> ?V:Val "Writable" |-> true "Enumerable" |-> true "Configurable" |-> true)
"next" |-> @desc("Value" |-> @NullVal "Writable" |-> true "Enumerable" |-> true "Configurable" |-> true)
</properties>
<internalProperties>
"Class" |-> "Object"
"Extensible" |-> true
"Prototype" |-> @ObjectProtoOid
</internalProperties>
</obj>
)
OBJS:Bag
(.Bag => ?_:Bag)
...</objs>
<k>
%while ( %bop ( %neqs , %mem ( %var ( "p" ) , %con ( "next" ) ) , %con ( %null ) ) , %seq ( %exp ( %bop ( %assign , %var ( "p" ) , %mem ( %var ( "p" ) , %con ( "next" ) ) ) ) , %labelContinue ( "" ) ) )
=>
@Normal
...</k>
requires EID =/=K @NullEid
ensures A B ==K ?C ListItem(?V)
rule [func-spec]:
<envs>...
ENVS:Bag
(.Bag => ?_:Bag)
...</envs>
<objs>...
(
lseg(OX, @NullVal)(A:List)
lseg(OY, @NullVal)(B:List)
=>
lseg(?OP, @NullVal)(A B)
)
OBJS:Bag
(.Bag => ?_:Bag)
...</objs>
<k>
Call(
// %var("append"),
@o(2),
Undefined,
@Cons(OX:NullableObject, @Cons(OY:NullableObject, @Nil)))
=>
?OP:NullableObject
...</k>
endmodule