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
e0b90e8e
Commit
e0b90e8e
authored
14 years ago
by
Viktor Kuncak
Browse files
Options
Downloads
Patches
Plain Diff
added test to nnf, re-arranged some functions
parent
c4526f22
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pldi2011-testcases/NNF.scala
+12
-11
12 additions, 11 deletions
pldi2011-testcases/NNF.scala
with
12 additions
and
11 deletions
pldi2011-testcases/NNF.scala
+
12
−
11
View file @
e0b90e8e
...
@@ -9,7 +9,15 @@ object NNF {
...
@@ -9,7 +9,15 @@ object NNF {
case
class
Not
(
f
:
Formula
)
extends
Formula
case
class
Not
(
f
:
Formula
)
extends
Formula
case
class
Literal
(
id
:
Int
)
extends
Formula
case
class
Literal
(
id
:
Int
)
extends
Formula
def
nnf
(
formula
:
Formula
)
:
Formula
=
formula
match
{
def
isNNF
(
f
:
Formula
)
:
Boolean
=
f
match
{
case
And
(
lhs
,
rhs
)
=>
isNNF
(
lhs
)
&&
isNNF
(
rhs
)
case
Or
(
lhs
,
rhs
)
=>
isNNF
(
lhs
)
&&
isNNF
(
rhs
)
case
Not
(
Literal
(
_
))
=>
true
case
Not
(
_
)
=>
false
case
Literal
(
_
)
=>
true
}
def
nnf
(
formula
:
Formula
)
:
Formula
=
(
formula
match
{
case
And
(
lhs
,
rhs
)
=>
And
(
nnf
(
lhs
),
nnf
(
rhs
))
case
And
(
lhs
,
rhs
)
=>
And
(
nnf
(
lhs
),
nnf
(
rhs
))
case
Or
(
lhs
,
rhs
)
=>
Or
(
nnf
(
lhs
),
nnf
(
rhs
))
case
Or
(
lhs
,
rhs
)
=>
Or
(
nnf
(
lhs
),
nnf
(
rhs
))
case
Not
(
And
(
lhs
,
rhs
))
=>
Or
(
nnf
(
Not
(
lhs
)),
nnf
(
Not
(
rhs
)))
case
Not
(
And
(
lhs
,
rhs
))
=>
Or
(
nnf
(
Not
(
lhs
)),
nnf
(
Not
(
rhs
)))
...
@@ -17,10 +25,10 @@ object NNF {
...
@@ -17,10 +25,10 @@ object NNF {
case
Not
(
Not
(
f
))
=>
nnf
(
f
)
case
Not
(
Not
(
f
))
=>
nnf
(
f
)
case
Not
(
Literal
(
_
))
=>
formula
case
Not
(
Literal
(
_
))
=>
formula
case
Literal
(
_
)
=>
formula
case
Literal
(
_
)
=>
formula
}
}
)
ensuring
(
f
=>
isNNF
(
f
))
def
freeVars
(
f
:
Formula
)
:
Set
[
Int
]
=
{
def
freeVars
(
f
:
Formula
)
:
Set
[
Int
]
=
{
require
(
isNNF
(
f
))
require
(
isNNF
(
f
))
f
match
{
f
match
{
case
And
(
lhs
,
rhs
)
=>
freeVars
(
lhs
)
++
freeVars
(
rhs
)
case
And
(
lhs
,
rhs
)
=>
freeVars
(
lhs
)
++
freeVars
(
rhs
)
case
Or
(
lhs
,
rhs
)
=>
freeVars
(
lhs
)
++
freeVars
(
rhs
)
case
Or
(
lhs
,
rhs
)
=>
freeVars
(
lhs
)
++
freeVars
(
rhs
)
...
@@ -28,12 +36,5 @@ object NNF {
...
@@ -28,12 +36,5 @@ object NNF {
case
Literal
(
i
)
=>
Set
[
Int
](
i
)
case
Literal
(
i
)
=>
Set
[
Int
](
i
)
}
}
}
}
def
fv
(
f
:
Formula
)
=
{
freeVars
(
nnf
(
f
))
}
def
isNNF
(
f
:
Formula
)
:
Boolean
=
f
match
{
case
And
(
lhs
,
rhs
)
=>
isNNF
(
lhs
)
&&
isNNF
(
rhs
)
case
Or
(
lhs
,
rhs
)
=>
isNNF
(
lhs
)
&&
isNNF
(
rhs
)
case
Not
(
Literal
(
_
))
=>
true
case
Not
(
_
)
=>
false
case
Literal
(
_
)
=>
true
}
}
}
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