Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
peregrine
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
i7
peregrine
Commits
78815841
Commit
78815841
authored
Aug 08, 2018
by
Philipp Meyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add equality modulo an integer and negation normal form to formulas
parent
81847005
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
4 deletions
+25
-4
src/Parser/PP.hs
src/Parser/PP.hs
+4
-3
src/Property.hs
src/Property.hs
+21
-1
No files found.
src/Parser/PP.hs
View file @
78815841
...
...
@@ -30,10 +30,10 @@ languageDef =
Token
.
identStart
=
letter
<|>
char
'_'
,
Token
.
identLetter
=
alphaNum
<|>
char
'_'
,
Token
.
reservedNames
=
[
"true"
,
"false"
,
"EXISTS"
,
"FORALL"
],
Token
.
reservedOpNames
=
[
"->"
,
"<"
,
"<="
,
"="
,
"!="
,
">="
,
">"
,
Token
.
reservedOpNames
=
[
"->"
,
"<"
,
"<="
,
"="
,
"!="
,
">="
,
">"
,
"=%"
,
"!=%"
,
"+"
,
"-"
,
"*"
,
"&&"
,
"||"
,
"!"
,
":"
]
}
lexer
::
Token
.
TokenParser
()
lexer
=
Token
.
makeTokenParser
languageDef
...
...
@@ -103,7 +103,8 @@ parseOp = (reservedOp "<" *> return Lt) <|>
(
reservedOp
"="
*>
return
Eq
)
<|>
(
reservedOp
"!="
*>
return
Ne
)
<|>
(
reservedOp
">"
*>
return
Gt
)
<|>
(
reservedOp
">="
*>
return
Ge
)
(
reservedOp
"=%"
*>
(
ModEq
<$>
integer
))
<|>
(
reservedOp
"!=%"
*>
(
ModNe
<$>
integer
))
linIneq
::
Parser
(
Formula
String
)
linIneq
=
do
...
...
src/Property.hs
View file @
78815841
...
...
@@ -47,7 +47,7 @@ instance Functor Term where
fmap
f
(
t
:/:
u
)
=
fmap
f
t
:/:
fmap
f
u
fmap
f
(
t
:%:
u
)
=
fmap
f
t
:%:
fmap
f
u
data
Op
=
Gt
|
Ge
|
Eq
|
Ne
|
Le
|
Lt
deriving
(
Eq
)
data
Op
=
Gt
|
Ge
|
Eq
|
Ne
|
Le
|
Lt
|
ModEq
Integer
|
ModNe
Integer
deriving
(
Eq
)
instance
Show
Op
where
show
Gt
=
">"
...
...
@@ -56,6 +56,18 @@ instance Show Op where
show
Ne
=
"≠"
show
Le
=
"≤"
show
Lt
=
"<"
show
(
ModEq
m
)
=
"≡_"
++
show
m
show
(
ModNe
m
)
=
"≢_"
++
show
m
negateOp
::
Op
->
Op
negateOp
Gt
=
Le
negateOp
Ge
=
Lt
negateOp
Eq
=
Ne
negateOp
Ne
=
Eq
negateOp
Le
=
Gt
negateOp
Lt
=
Ge
negateOp
(
ModEq
m
)
=
(
ModNe
m
)
negateOp
(
ModNe
m
)
=
(
ModEq
m
)
data
QuantFormula
a
=
ExQuantFormula
[
a
]
(
Formula
a
)
deriving
(
Eq
)
...
...
@@ -71,6 +83,14 @@ data Formula a =
infixr
3
:&:
infixr
2
:|:
negationNormalForm
::
Formula
a
->
Formula
a
negationNormalForm
(
Neg
(
FTrue
))
=
FFalse
negationNormalForm
(
Neg
(
FFalse
))
=
FTrue
negationNormalForm
(
Neg
(
g
:&:
h
))
=
(
negationNormalForm
(
Neg
g
))
:|:
(
negationNormalForm
(
Neg
h
))
negationNormalForm
(
Neg
(
g
:|:
h
))
=
(
negationNormalForm
(
Neg
g
))
:&:
(
negationNormalForm
(
Neg
h
))
negationNormalForm
(
Neg
(
LinearInequation
u
op
t
))
=
LinearInequation
u
(
negateOp
op
)
t
negationNormalForm
f
=
f
quantifiedVariables
::
QuantFormula
a
->
[
a
]
quantifiedVariables
(
ExQuantFormula
xs
_
)
=
xs
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment