Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
i7
peregrine
Commits
e6106f86
Commit
e6106f86
authored
Aug 06, 2018
by
Philipp Meyer
Browse files
Allow usage of division and modulus in predicate terms
parent
6e341e2a
Changes
4
Hide whitespace changes
Inline
Side-by-side
examples/remainder_m3_c1.pp
View file @
e6106f86
...
...
@@ -112,10 +112,10 @@
"_mod1"
,
"_mod2"
],
"predicate"
:
"
EXISTS k :
0 * _mod0 + 1 * _mod1 + 2 * _mod2
= 1 + 3 * k
"
,
"predicate"
:
"
(
0 * _mod0 + 1 * _mod1 + 2 * _mod2
) % 3 = 1
"
,
"trueStates"
:
[
"_mod1"
,
"_modpassivetrue"
],
"title"
:
"Modulo Protocol with m = 3 and c = 1"
}
\ No newline at end of file
}
src/Parser/PP.hs
View file @
e6106f86
...
...
@@ -84,7 +84,7 @@ prefix name fun = Prefix ( reservedOp name *> return fun )
termOperatorTable
::
[[
Operator
String
()
Identity
(
Term
String
)]]
termOperatorTable
=
[
[
prefix
"-"
Minus
]
,
[
binary
"*"
(
:*:
)
AssocLeft
]
,
[
binary
"*"
(
:*:
)
AssocLeft
,
binary
"/"
(
:/:
)
AssocLeft
,
binary
"%"
(
:%:
)
AssocLeft
]
,
[
binary
"+"
(
:+:
)
AssocLeft
,
binary
"-"
(
:-:
)
AssocLeft
]
]
...
...
src/Property.hs
View file @
e6106f86
...
...
@@ -23,6 +23,8 @@ data Term a =
|
Term
a
:+:
Term
a
|
Term
a
:-:
Term
a
|
Term
a
:*:
Term
a
|
Term
a
:/:
Term
a
-- integer division truncated toward negative infinity
|
Term
a
:%:
Term
a
-- integer modulos, satisfying (x / y)*y + (x % y) = x
deriving
(
Eq
)
instance
(
Show
a
)
=>
Show
(
Term
a
)
where
...
...
@@ -32,6 +34,8 @@ instance (Show a) => Show (Term a) where
show
(
t
:+:
u
)
=
"("
++
show
t
++
" + "
++
show
u
++
")"
show
(
t
:-:
u
)
=
"("
++
show
t
++
" - "
++
show
u
++
")"
show
(
t
:*:
u
)
=
show
t
++
" * "
++
show
u
show
(
t
:/:
u
)
=
show
t
++
" / "
++
show
u
show
(
t
:%:
u
)
=
show
t
++
" % "
++
show
u
instance
Functor
Term
where
fmap
f
(
Var
x
)
=
Var
(
f
x
)
...
...
@@ -40,6 +44,8 @@ instance Functor Term where
fmap
f
(
t
:+:
u
)
=
fmap
f
t
:+:
fmap
f
u
fmap
f
(
t
:-:
u
)
=
fmap
f
t
:-:
fmap
f
u
fmap
f
(
t
:*:
u
)
=
fmap
f
t
:*:
fmap
f
u
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
)
...
...
src/Solver/Formula.hs
View file @
e6106f86
...
...
@@ -15,6 +15,8 @@ evaluateTerm (Minus t) m = - evaluateTerm t m
evaluateTerm
(
t
:+:
u
)
m
=
evaluateTerm
t
m
+
evaluateTerm
u
m
evaluateTerm
(
t
:-:
u
)
m
=
evaluateTerm
t
m
-
evaluateTerm
u
m
evaluateTerm
(
t
:*:
u
)
m
=
evaluateTerm
t
m
*
evaluateTerm
u
m
evaluateTerm
(
t
:/:
u
)
m
=
(
evaluateTerm
t
m
)
`
sDiv
`
(
evaluateTerm
u
m
)
evaluateTerm
(
t
:%:
u
)
m
=
(
evaluateTerm
t
m
)
`
sMod
`
(
evaluateTerm
u
m
)
opToFunction
::
Op
->
SInteger
->
SInteger
->
SBool
opToFunction
Gt
=
(
.>
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment