Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tlatools
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
tlatools
Commits
5d15bde3
Commit
5d15bde3
authored
Feb 20, 2018
by
Markus Alexander Kuppe
Browse files
Options
Downloads
Patches
Plain Diff
IsABag inconsistent with Bags.tla when parameter is not a bag.
[Bug][TLC][Changelog]
parent
bc0f7dbf
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
tlatools/src/tlc2/module/Bags.java
+8
-6
8 additions, 6 deletions
tlatools/src/tlc2/module/Bags.java
tlatools/test-model/BagsTest.cfg
+2
-0
2 additions, 0 deletions
tlatools/test-model/BagsTest.cfg
tlatools/test-model/BagsTest.tla
+12
-2
12 additions, 2 deletions
tlatools/test-model/BagsTest.tla
with
22 additions
and
8 deletions
tlatools/src/tlc2/module/Bags.java
+
8
−
6
View file @
5d15bde3
...
@@ -35,18 +35,20 @@ public class Bags implements ValueConstants
...
@@ -35,18 +35,20 @@ public class Bags implements ValueConstants
return
EmptyFcn
;
return
EmptyFcn
;
}
}
public
static
BoolValue
IsABag
(
Value
b
)
public
static
BoolValue
IsABag
(
final
Value
b
)
{
{
FcnRcdValue
fcn
=
FcnRcdValue
.
convert
(
b
);
final
FcnRcdValue
fcn
=
FcnRcdValue
.
convert
(
b
);
if
(
fcn
==
null
)
if
(
fcn
==
null
)
{
{
throw
new
EvalException
(
EC
.
TLC_MODULE_APPLYING_TO_WRONG_VALUE
,
new
String
[]
{
"IsBag"
,
// MAK 02/23/2018 Changed to return ValFalse instead of exception when Value is not a bag.
"a function with a finite domain"
,
Value
.
ppr
(
b
.
toString
())
});
//throw new EvalException(EC.TLC_MODULE_APPLYING_TO_WRONG_VALUE, new String[] { "IsBag",
// "a function with a finite domain", Value.ppr(b.toString()) });
return
ValFalse
;
}
}
Value
[]
vals
=
fcn
.
values
;
final
Value
[]
vals
=
fcn
.
values
;
for
(
int
i
=
0
;
i
<
vals
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
vals
.
length
;
i
++)
{
{
if
(!(
vals
[
i
]
instanceof
IntValue
)
||
((
IntValue
)
vals
[
i
]).
val
<
0
)
if
(!(
vals
[
i
]
instanceof
IntValue
)
||
((
IntValue
)
vals
[
i
]).
val
<
=
0
)
{
{
return
ValFalse
;
return
ValFalse
;
}
}
...
...
This diff is collapsed.
Click to expand it.
tlatools/test-model/BagsTest.cfg
+
2
−
0
View file @
5d15bde3
SPECIFICATION
SPECIFICATION
Spec
Spec
CONSTANT
C
=
C
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tlatools/test-model/BagsTest.tla
+
12
−
2
View file @
5d15bde3
---------------------------- MODULE BagsTest ----------------------------
---------------------------- MODULE BagsTest ----------------------------
EXTENDS Bags, TLC, Integers
EXTENDS Bags, TLC, Integers
CONSTANT C
strings == {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o"}
strings == {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o"}
s == {"a","b","c"}
s == {"a","b","c"}
...
@@ -26,18 +28,26 @@ ASSUME(IsABag(f))
...
@@ -26,18 +28,26 @@ ASSUME(IsABag(f))
ASSUME(IsABag(g))
ASSUME(IsABag(g))
ASSUME(IsABag(h))
ASSUME(IsABag(h))
ASSUME(IsABag(SetToBag({})))
t == <<0>>
t == <<0>>
u == 2 :> -1
u == 2 :> -1
v == <<0>>
v == <<
1,
0>>
w == <<0,1>>
w == <<0,1>>
x == <<0,0,0>>
x == <<0,0,0>>
y == <<-1,-2,-3>>
y == <<-1,-2,-3>>
z == <<"a","b","c">>
z == <<"a","b","c">>
ASSUME(~IsABag(t))
ASSUME(~IsABag(u))
ASSUME(~IsABag(u))
ASSUME(~IsABag(v))
ASSUME(~IsABag(w))
ASSUME(~IsABag(x))
ASSUME(~IsABag(y))
ASSUME(~IsABag(y))
\*
ASSUME(~IsABag(z)) \* With the standard module TLC fails with "Cannot decide if element "a" is element of Nat"
ASSUME(~IsABag(z)) \* With the standard module TLC fails with "Cannot decide if element "a" is element of Nat"
ASSUME(\A bool \in BOOLEAN : ~IsABag(bool))
ASSUME(~IsABag(C))
\* BagCardinality
\* BagCardinality
ASSUME(BagCardinality(a) = 0)
ASSUME(BagCardinality(a) = 0)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment