Skip to content

Commit 5b73290

Browse files
committed
Adapting tests
1 parent 12076ff commit 5b73290

File tree

2 files changed

+219
-2
lines changed

2 files changed

+219
-2
lines changed

src/test/resources/all/issues/silicon/0567.vpr

-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ method test02(i: Int)
1313
requires forall y: Int :: {id(y)} id(y) == i
1414
// ensures id(0) == 0 && id(1) == 1 // Required by Silicon, but not by Carbon
1515
ensures forall y: Int :: {id(y)} id(y) == y && id(y) == i // Holds (in Silicon and Carbon)
16-
//:: UnexpectedOutput(postcondition.violated:assertion.false, /silicon/issue/567/)
1716
ensures forall y: Int :: {id(y)} id(y) == y && y == i // Fails in Silicon
1817
{}
1918

2019
// Analogous to test02
2120
method test03(i: Int) {
2221
inhale forall y: Int :: {id(y)} id(y) == i
23-
//:: UnexpectedOutput(assert.failed:assertion.false, /silicon/issue/567/)
2422
assert forall y: Int :: {id(y)} id(y) == y && y == i // Fails in Silicon
2523
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
// Any copyright is dedicated to the Public Domain.
2+
// http://creativecommons.org/publicdomain/zero/1.0/
3+
4+
domain PyType {
5+
6+
function extends_(sub: PyType, super: PyType): Bool
7+
8+
function issubtype(sub: PyType, super: PyType): Bool
9+
10+
function isnotsubtype(sub: PyType, super: PyType): Bool
11+
12+
function typeof(obj: Ref): PyType
13+
14+
function get_basic(t: PyType): PyType
15+
16+
function union_type_1(arg_1: PyType): PyType
17+
18+
function union_type_2(arg_1: PyType, arg_2: PyType): PyType
19+
20+
function union_type_3(arg_1: PyType, arg_2: PyType, arg_3: PyType): PyType
21+
22+
function union_type_4(arg_1: PyType, arg_2: PyType, arg_3: PyType, arg_4: PyType): PyType
23+
24+
unique function object(): PyType
25+
26+
unique function list_basic(): PyType
27+
28+
function list(arg0: PyType): PyType
29+
30+
unique function set_basic(): PyType
31+
32+
function set(arg0: PyType): PyType
33+
34+
function set_arg(typ: PyType, index: Int): PyType
35+
36+
unique function dict_basic(): PyType
37+
38+
function dict(arg0: PyType, arg1: PyType): PyType
39+
40+
function dict_arg(typ: PyType, index: Int): PyType
41+
42+
unique function int(): PyType
43+
44+
unique function float(): PyType
45+
46+
unique function bool(): PyType
47+
48+
unique function NoneType(): PyType
49+
50+
unique function Exception(): PyType
51+
52+
unique function ConnectionRefusedError(): PyType
53+
54+
unique function traceback(): PyType
55+
56+
unique function str(): PyType
57+
58+
unique function bytes(): PyType
59+
60+
unique function __prim__perm(): PyType
61+
62+
unique function PSeq_basic(): PyType
63+
64+
function PSeq(arg0: PyType): PyType
65+
66+
function PSeq_arg(typ: PyType, index: Int): PyType
67+
68+
unique function PSet_basic(): PyType
69+
70+
function PSet(arg0: PyType): PyType
71+
72+
function PSet_arg(typ: PyType, index: Int): PyType
73+
74+
unique function PMultiset_basic(): PyType
75+
76+
function PMultiset(arg0: PyType): PyType
77+
78+
function PMultiset_arg(typ: PyType, index: Int): PyType
79+
80+
unique function slice(): PyType
81+
82+
unique function range_0(): PyType
83+
84+
unique function Iterator_basic(): PyType
85+
86+
function Iterator(arg0: PyType): PyType
87+
88+
function Iterator_arg(typ: PyType, index: Int): PyType
89+
90+
unique function Thread_0(): PyType
91+
92+
unique function LevelType(): PyType
93+
94+
unique function type(): PyType
95+
96+
unique function Place(): PyType
97+
98+
unique function __prim__Seq_type(): PyType
99+
100+
unique function Node(): PyType
101+
102+
axiom issubtype_transitivity {
103+
(forall sub: PyType, middle: PyType, super: PyType ::
104+
{ issubtype(sub, middle), issubtype(middle, super) }
105+
issubtype(sub, middle) && issubtype(middle, super) ==>
106+
issubtype(sub, super))
107+
}
108+
109+
axiom issubtype_reflexivity {
110+
(forall type_: PyType ::
111+
{ issubtype(type_, type_) }
112+
issubtype(type_, type_))
113+
}
114+
115+
axiom extends_implies_subtype {
116+
(forall sub: PyType, sub2: PyType ::
117+
{ extends_(sub, sub2) }
118+
extends_(sub, sub2) ==> issubtype(sub, sub2))
119+
}
120+
121+
axiom issubtype_exclusion {
122+
(forall sub: PyType, sub2: PyType, super: PyType ::
123+
{ extends_(sub, super), extends_(sub2, super) }
124+
extends_(sub, super) && extends_(sub2, super) && sub != sub2 ==>
125+
isnotsubtype(sub, sub2) && isnotsubtype(sub2, sub))
126+
}
127+
128+
129+
130+
axiom issubtype_exclusion_propagation {
131+
(forall sub: PyType, middle: PyType, super: PyType ::
132+
{ issubtype(sub, middle), isnotsubtype(middle, super) }
133+
issubtype(sub, middle) && isnotsubtype(middle, super) ==>
134+
!issubtype(sub, super))
135+
}
136+
137+
axiom subtype_list {
138+
(forall var0: PyType ::
139+
{ list(var0) }
140+
extends_(list(var0), object()) &&
141+
get_basic(list(var0)) == list_basic())
142+
}
143+
144+
axiom subtype_int {
145+
extends_(int(), float()) && get_basic(int()) == int()
146+
}
147+
148+
axiom subtype_float {
149+
extends_(float(), object()) && get_basic(float()) == float()
150+
}
151+
152+
axiom subtype_bool {
153+
extends_(bool(), int())
154+
}
155+
}
156+
157+
field list_acc: Seq[Ref]
158+
159+
field Node_function_name: Ref
160+
161+
field Node_children: Ref
162+
163+
164+
method mcan_node_be_compressed(marked_execution_tree: Ref)
165+
{
166+
inhale acc(marked_execution_tree.Node_children, write) &&
167+
issubtype(typeof(marked_execution_tree.Node_children), list(Node()))
168+
inhale acc(marked_execution_tree.Node_children.list_acc, write)
169+
170+
//:: ExpectedOutput(inhale.failed:qp.not.injective)
171+
inhale (forall iii: Ref ::
172+
(
173+
typeof(iii) == int() &&
174+
(int___ge__(int___unbox__(iii), 0) &&
175+
int___lt__(int___unbox__(iii), list___len__(marked_execution_tree.Node_children)))) ==>
176+
acc(list___getitem__(marked_execution_tree.Node_children, iii).Node_function_name, write))
177+
}
178+
179+
function __prim__int___box__(prim: Int): Ref
180+
decreases _
181+
ensures typeof(result) == int()
182+
ensures int___unbox__(result) == prim
183+
184+
185+
function int___unbox__(box: Ref): Int
186+
decreases _
187+
requires issubtype(typeof(box), int())
188+
ensures !issubtype(typeof(box), bool()) ==>
189+
__prim__int___box__(result) == box
190+
191+
function int___ge__(self: Int, other: Int): Bool
192+
decreases _
193+
{
194+
self >= other
195+
}
196+
197+
function int___lt__(self: Int, other: Int): Bool
198+
decreases _
199+
{
200+
self < other
201+
}
202+
203+
function list___len__(self: Ref): Int
204+
decreases _
205+
requires acc(self.list_acc, wildcard)
206+
{
207+
|self.list_acc|
208+
}
209+
210+
function list___getitem__(self: Ref, key: Ref): Ref
211+
requires issubtype(typeof(key), int())
212+
requires acc(self.list_acc, wildcard)
213+
requires (let ln ==
214+
(list___len__(self)) in
215+
(int___unbox__(key) < 0 ==> int___unbox__(key) >= -ln) &&
216+
(int___unbox__(key) >= 0 ==> int___unbox__(key) < ln))
217+
218+
219+

0 commit comments

Comments
 (0)