sp
10 months ago
commit
f7b8d78fe8
9 changed files with 185 additions and 0 deletions
-
52Lecture1/bitvectors_signedness.py
-
17Lecture1/intro_booleans.py
-
6Lecture1/intro_booleans.smt
-
11Lecture1/intro_booleans_solution.py
-
20Lecture1/material_implication.py
-
9Lecture1/material_implication.smt
-
29Lecture1/material_implication_solution.py
-
15Lecture1/weird_xor.py
-
26Lecture1/weird_xor_solution.py
@ -0,0 +1,52 @@ |
|||
from z3 import * |
|||
|
|||
solver = Solver() |
|||
|
|||
bvX = BitVec("bvX", 8) |
|||
|
|||
solver.add(bvX + 1 < bvX - 1) |
|||
print(f"Current 'state' of the solver:\n {solver.sexpr()}") |
|||
input("Hit Enter.") |
|||
result = solver.check() |
|||
print(result) |
|||
if result == sat: |
|||
print("=== Model ===") |
|||
for var in solver.model().decls(): |
|||
print(f"M: {var}: int:{solver.model()[bvX].as_long()}, binary:{bin(solver.model()[bvX].as_long())} \t | type: {type(solver.model()[var])}") |
|||
print("=============") |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
solver.add(BVAddNoOverflow(bvX, 1, True)) |
|||
solver.add(BVSubNoUnderflow(bvX, 1, True)) |
|||
input("Hit Enter.") |
|||
print(f"Current 'state' of the solver:\n {solver.sexpr()}") |
|||
input("Hit Enter.") |
|||
result = solver.check() |
|||
print(result) |
|||
if result == sat: |
|||
print("=== Model ===") |
|||
for var in solver.model().decls(): |
|||
print(f"M: {var}: int:{solver.model()[bvX].as_long()}, binary:{bin(solver.model()[bvX].as_long())} \t | type: {type(solver.model()[var])}") |
|||
print("=============") |
@ -0,0 +1,17 @@ |
|||
from z3 import * |
|||
|
|||
a, b = Bools("a b") |
|||
|
|||
solver = Solver() |
|||
solver.add(Not(a)) |
|||
solver.add(Or(a,b)) |
|||
|
|||
#solver.add(And(Not(a), Or(a,b))) |
|||
|
|||
result = solver.check() |
|||
print(result) |
|||
model = solver.model() |
|||
print(model) |
|||
#for var in model.decls(): |
|||
# print(f"{var}: {model[var]} \t(:{type(model[var])})") |
|||
|
@ -0,0 +1,6 @@ |
|||
(declare-const a Bool) |
|||
(declare-const b Bool) |
|||
(assert (not a)) |
|||
(assert (or a b)) |
|||
(check-sat) |
|||
(get-model) |
@ -0,0 +1,11 @@ |
|||
from z3 import * |
|||
|
|||
a, b = Bools("a b") |
|||
|
|||
solver = Solver() |
|||
solver.add(Not(b)) |
|||
solver.add(Or(a,b)) |
|||
|
|||
result = solver.check() |
|||
model = solver.model() |
|||
print(model) |
@ -0,0 +1,20 @@ |
|||
# coding: utf-8 |
|||
import os, sys |
|||
import time |
|||
from z3 import * |
|||
|
|||
# TODO: Check Equivalence of |
|||
# - p -> q |
|||
# - !p | q |
|||
|
|||
# create the solver |
|||
solver = Solver() |
|||
|
|||
|
|||
|
|||
|
|||
result = solver.check() |
|||
print(solver.sexpr()) |
|||
print(result) |
|||
|
|||
|
@ -0,0 +1,9 @@ |
|||
(declare-fun b () Bool) |
|||
(declare-fun a () Bool) |
|||
(declare-fun l () Bool) |
|||
(declare-fun r () Bool) |
|||
(assert (= l (=> a b))) |
|||
(assert (= r (or (not a) b))) |
|||
(assert (distinct r l)) |
|||
(check-sat) |
|||
(get-model) |
@ -0,0 +1,29 @@ |
|||
# coding: utf-8 |
|||
import os, sys |
|||
import time |
|||
from z3 import * |
|||
|
|||
|
|||
# create the solver |
|||
solver = Solver() |
|||
a, b = Bools("a b") |
|||
l, r = Bools("l r") |
|||
|
|||
solver.add(l == Implies(a, b)) |
|||
solver.add(r == Or(Not(a), b)) |
|||
solver.add(Distinct(r,l)) |
|||
|
|||
result = solver.check() |
|||
print(solver.sexpr()) |
|||
print(result) |
|||
|
|||
### A different way ### |
|||
|
|||
solver = Solver() |
|||
a, b = Bools("a b") |
|||
l = Implies(a,b) |
|||
r = Or(Not(a),b) |
|||
solver.add(Distinct(l,r)) |
|||
result = solver.check() |
|||
print(result) |
|||
|
@ -0,0 +1,15 @@ |
|||
#!/usr/bin/python |
|||
from z3 import * |
|||
|
|||
# TODO: Check for equivalence: |
|||
## - (((y & x)*-2) + (y+x)) |
|||
## - x^y |
|||
|
|||
s= Solver() |
|||
|
|||
|
|||
|
|||
result = s.check() |
|||
print(result) |
|||
if result == sat: |
|||
print(s.model()) |
@ -0,0 +1,26 @@ |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#!/usr/bin/python |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
from z3 import * |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
x = BitVec('x', 32) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
y = BitVec('y', 32) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
s = Solver() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Author | SHA1 | Message | Date |
---|---|---|---|
Thomas Heinemann | 556da4de5e |
Minor changes
|
13 years ago |
Thomas Heinemann | 8e460897f0 |
Minor corrections (Memory initialization in AtomicProposition) and
more test cases |
13 years ago |
Thomas Heinemann | a0e07c2022 |
Parser for labelling files including new data structure managing
different atomic propositions. (Works now as node_array attribute of class Atomic_proposition is now always instantiated with 0) |
13 years ago |
Thomas Heinemann | e5048cabb6 |
Closed memory leaks.
|
13 years ago |
PBerger | 307b85e331 |
Edited static_sparse_matrix.h, replaced all calloc/malloc calls with std::new
Removed calls to exceptions with parameter "const char *", is illegal Fixed a warning in read_tra_file.cpp |
13 years ago |
PBerger | 6f970f27fe |
Added atomic propositions/labels
|
13 years ago |
PBerger | decb6b8006 |
Fixed CMakeLists.txt for Google Test to work with VS2012
Fixed STLSoft to compile under VS2012 Fixed Pantheios to work with VS2012 Fixed CMakeLists.txt for MRMC, removed duplicate code (Thomas?), converted keywords to lowercase |
13 years ago |
PBerger | a21a338a26 |
Included external 3rd Party content for Google Test Framework
Included external 3rd Party content for STLSoft Header Library Included external 3rd Party content for Pantheios Logging Framework |
13 years ago |
Thomas Heinemann | d37b23a5c5 |
- Additional "wrong header" testcase for the tra parser
- Methods of the sparse matrix now throw objects (instead of pointers) - Initializations of the pointer attributes of the sparse matrix with NULL (otherwise strange things may happen...) Note: Test cases for the sparse matrix now work for me. |
13 years ago |
Thomas Heinemann | 395d2822b5 |
CMakeLists.txt: Enable debug symbols only on GCC (as e.g. Visual
Studio creates a debug version automatically...) |
13 years ago |
Thomas Heinemann | b846680445 |
Updated CMakeLists.txt to new location of MRMCConfig.h.in
|
13 years ago |
Thomas Heinemann | 5c7c23f4d6 |
Some minor changes (especially limiting the range of variables if
possible) |
13 years ago |
Thomas Heinemann | 40de04a1fe |
Added missing files (exceptions)
|
13 years ago |
Thomas Heinemann | ebc0db4750 |
Formatting
|
13 years ago |
Thomas Heinemann | a908faf1a1 |
Worked on TODO's (minor stuff)
|
13 years ago |
Thomas Heinemann | 2c44c80bdb |
- Parser
- some changes in CMakeLists.txt and the former code to make it compatible to Linux systems... |
13 years ago |
Thomas Heinemann | 60abde4968 |
Added dependency on thread in CMakeLists.txt
|
13 years ago |
PBerger | 3dac4e4a6a |
Fixed BUILD hints
|
13 years ago |
PBerger | 31d2c70acc |
Added temporary Find* files for CMake
Added custom exceptions Added Sparse Matrix Added Guidelines for Doxygen Added BUILD hints |
13 years ago |
PBerger | 4cd75789ac |
Updated styleguides
Added Test Suite Updated CMake configuration |
13 years ago |
PBerger | 9da2eaf3d1 |
Initial Import into Git
Lacks Doxygen files/integration |
13 years ago |