Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
15e7aa77
Commit
15e7aa77
authored
12 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
add buggy versions of functions
parent
12c61388
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
testcases/Sat.scala
+44
-0
44 additions, 0 deletions
testcases/Sat.scala
with
44 additions
and
0 deletions
testcases/Sat.scala
+
44
−
0
View file @
15e7aa77
...
...
@@ -26,6 +26,14 @@ object Sat {
case
Or
(
f1
,
f2
)
=>
eval
(
f1
,
trueVars
)
||
eval
(
f2
,
trueVars
)
}
//buggy version of eval
def
evalWrong
(
formula
:
Formula
,
trueVars
:
Set
[
Int
])
:
Boolean
=
formula
match
{
case
Var
(
n
)
=>
trueVars
.
contains
(
n
)
//bug
case
Not
(
f
)
=>
!
eval
(
f
,
trueVars
)
case
And
(
f1
,
f2
)
=>
eval
(
f1
,
trueVars
)
&&
eval
(
f2
,
trueVars
)
case
Or
(
f1
,
f2
)
=>
eval
(
f1
,
trueVars
)
||
eval
(
f2
,
trueVars
)
}
def
evalCnf
(
clauses
:
ClauseList
,
trueVars
:
Set
[
Int
])
:
Boolean
=
clauses
match
{
case
ClauseCons
(
cl
,
cls
)
=>
evalClauseCnf
(
cl
,
trueVars
)
&&
evalCnf
(
cls
,
trueVars
)
case
ClauseNil
()
=>
true
...
...
@@ -36,6 +44,19 @@ object Sat {
case
ClauseNil
()
=>
false
case
ClauseLit
(
b
)
=>
b
}
//buggy version of evalCnf/Dnf
def
evalCnfWrong
(
clauses
:
ClauseList
,
trueVars
:
Set
[
Int
])
:
Boolean
=
clauses
match
{
case
ClauseCons
(
cl
,
cls
)
=>
evalClauseCnf
(
cl
,
trueVars
)
&&
evalCnf
(
cls
,
trueVars
)
case
ClauseNil
()
=>
false
//bug
case
ClauseLit
(
b
)
=>
b
}
def
evalDnfWrong
(
clauses
:
ClauseList
,
trueVars
:
Set
[
Int
])
:
Boolean
=
clauses
match
{
case
ClauseCons
(
cl
,
cls
)
=>
evalClauseDnf
(
cl
,
trueVars
)
||
evalDnf
(
cls
,
trueVars
)
case
ClauseNil
()
=>
true
//bug
case
ClauseLit
(
b
)
=>
b
}
def
evalClauseCnf
(
clause
:
VarList
,
trueVars
:
Set
[
Int
])
:
Boolean
=
clause
match
{
case
VarCons
(
v
,
vs
)
=>
(
if
(
v
<
0
)
trueVars
.
contains
(-
v
)
else
trueVars
.
contains
(
v
))
||
evalClauseCnf
(
vs
,
trueVars
)
if
(
v
==
1
)
true
...
...
@@ -58,6 +79,29 @@ object Sat {
case
VarLit
(
b
)
=>
b
}
//buggy version of evalClauses
def
evalClauseCnfWrong
(
clause
:
VarList
,
trueVars
:
Set
[
Int
])
:
Boolean
=
clause
match
{
case
VarCons
(
v
,
vs
)
=>
(
if
(
v
<
0
)
trueVars
.
contains
(-
v
)
else
trueVars
.
contains
(
v
))
||
evalClauseCnf
(
vs
,
trueVars
)
if
(
v
==
1
)
true
else
if
(
v
==
-
1
)
evalClauseCnf
(
vs
,
trueVars
)
else
if
(
v
<
-
1
)
trueVars
.
contains
(-
v
)
||
evalClauseCnf
(
vs
,
trueVars
)
//bug
else
if
(
v
>
1
)
trueVars
.
contains
(
v
)
||
evalClauseCnf
(
vs
,
trueVars
)
else
false
case
VarNil
()
=>
false
case
VarLit
(
b
)
=>
b
}
def
evalClauseDnfWrong
(
clause
:
VarList
,
trueVars
:
Set
[
Int
])
:
Boolean
=
clause
match
{
case
VarCons
(
v
,
vs
)
=>
{
if
(
v
==
1
)
evalClauseDnf
(
vs
,
trueVars
)
else
if
(
v
==
-
1
)
false
else
if
(
v
<
-
1
)
trueVars
.
contains
(-
v
)
&&
evalClauseDnf
(
vs
,
trueVars
)
//bug
else
if
(
v
>
1
)
trueVars
.
contains
(
v
)
&&
evalClauseDnf
(
vs
,
trueVars
)
else
false
}
case
VarNil
()
=>
true
case
VarLit
(
b
)
=>
b
}
def
concatClauses
(
cll1
:
ClauseList
,
cll2
:
ClauseList
)
:
ClauseList
=
cll1
match
{
case
ClauseCons
(
cl
,
tail
)
=>
ClauseCons
(
cl
,
concatClauses
(
tail
,
cll2
))
case
ClauseNil
()
=>
cll2
...
...
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