Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
J
javawlp
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
Model registry
Operate
Environments
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
impresshs
javawlp
Commits
9f58f2ce
Verified
Commit
9f58f2ce
authored
7 years ago
by
Ogilvie, D.H. (Duncan)
Browse files
Options
Downloads
Patches
Plain Diff
added python z3 example
parent
17afc921
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
src/z3_tests/equivalence.py
+54
-0
54 additions, 0 deletions
src/z3_tests/equivalence.py
with
54 additions
and
0 deletions
src/z3_tests/equivalence.py
0 → 100644
+
54
−
0
View file @
9f58f2ce
# Prove equivalence of two formulas containing 'forall'
from
z3
import
*
# Checks if "x > 0" is equivalent to "x - 1 >= 0" (should print "no solution")
def
eq
():
x
=
Int
(
'
x
'
)
ast1
=
x
>
0
print
"
ast1:
"
,
ast1
ast2
=
x
-
1
>=
0
print
"
ast2:
"
,
ast2
ast
=
ast1
!=
ast2
print
ast
print
"
model:
"
solve
(
ast
)
# Checks if "x > 0" is equivalent to "x + 1 >= 0" (should give a counter example)
def
neq
():
x
=
Int
(
'
x
'
)
ast1
=
x
>
0
print
"
ast1:
"
,
ast1
ast2
=
x
+
1
>=
0
print
"
ast2:
"
,
ast2
ast
=
ast1
!=
ast2
print
ast
print
"
model:
"
solve
(
ast
)
# Checks if "ForAll(x, x > 0) == ForAll(x, x < 0)", should give a counter example but doesn't!
def
neq_forall
():
x
=
Int
(
'
x
'
)
ast1
=
ForAll
(
x
,
x
>
0
)
print
"
ast1:
"
,
ast1
ast2
=
ForAll
(
x
,
x
<
0
)
print
"
ast2:
"
,
ast2
ast
=
ast1
!=
ast2
print
ast
print
"
model:
"
solve
(
ast
)
eq
()
print
""
neq
()
print
""
neq_forall
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Ogilvie, D.H. (Duncan)
@d.h.ogilvie2
mentioned in issue
#7 (closed)
·
7 years ago
mentioned in issue
#7 (closed)
mentioned in issue #7
Toggle commit list
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