I am attempting to 'simplify' some smtlib2 files using the z3 Python API via the following:
reading in an SMTLIB2 file
applying some tactics & extracting a simplified goal
adding the simplified goal to a new solver
printing the new solver via to_smt2()
I have an odd use case where it would be ideal if the resulting smtlib file did not contain any let expressions. Is there a way to expand them via the python API?
Creation of let-expressions are controlled by the pretty-printer. Try something like:
set_option(max_args=10000000, max_lines=1000000, max_depth=10000000, max_visited=1000000)
You can play with the actual numbers to find a setting that works for your use case. Essentially, the larger the numbers, the less the sharing/chopping off will be.
Also of importance is the parameter min_alias_size. Also try setting that to a large number. (The default is 10, which forces let-expressions.)
Related
I need write a matrix[n][n] in smt using Z3opt, but I did not find in the rise4fun Guide.
I use Z3opt site to write my code. I can't use c/c++/.net, only smt.
If the matrix dimensions nxn are statically known, you could simply introduce a symbol M_i_j per matrix element. It will probably make sense to automatically generate the corresponding SMT code, e.g. via some script.
According to http://research.microsoft.com/en-us/um/people/leonardo/z3_doc/parallel.html I can set CC_NUM_THREADS=4 from the z3 command line if I'm using a .smt file.
How do I do this if I'm using the z3py api?
The portfolio solver that supports lemma sharing is not part of the latest version of Z3. These parameters are therefore not supported, and the parameter format that allows multiple values for each parameter is not supported either (on the commandline or via python).
That said, there is still a way to utilize multiple cores, which is the par-or tactic; see e.g., the Z3 Strategy Tutorial (search for par-or). The example shows how to run multiple tactics in parallel (in this example with different random seeds) via the SMT2 input language; in z3py we would use the ParOr function to create such a parallel tactic.
I wrote a large-ish library in the Z3 dialect of SMT-LIB. Unfortunately, my use of (declare-datatypes) to create tuples means that I cannot set the logic to QF_AUFBV as I desire. This has the side effect of making my scripts slower (sometimes timing out) than when I manually create the formulas programmatically and solve using QF_ABV. Thus, I want to eliminate (declare-datatypes) from my script. Most of the data types can be encoded as bit vectors. However, the most important sort in the library is a tuple of a bitvector term and three arrays. Is there a solution where I can make a sort like this, while still using QF_AUFBV logic?
You can always concatenate the bitvectors of the tuple and extract the relevant half whenever needed.
I just started learning how to use mahout. I'm not a java programmer however, so I'm trying to stay away from having to use the java library.
I noticed there is a shell tool regexconverter. However, the documentation is sparse and non instructive. Exactly what does specifying a regex option do, and what does the transformer class and formatter class do? The mahout wiki is marvelously opaque. I'm assuming the regex option specifies what counts as a "unit" or so.
The example they list is of using the regexconverter to convert http log requests to sequence files I believe. I have a csv file with slightly altered http log requests that I'm hoping to convert to sequence files. Do I simply change the regex expression to take each entire row? I'm trying to run a Bayes classifier, similar to the 20 newsgroups example which seems to be done completely in the shell without need for java coding.
Incidentally, the arff.vector command seems to allow me to convert an arff file directly to vectors. I'm unfamiliar with arff, thought it seems to be something I can easily convert csv log files into. Should I use this method instead, and skip the sequence file step completely?
Thanks for the help.
I am using Z3 from the API and I'm looking for a way to debug my constraints. My code compiles and Z3 runs on my constraints, but something is wrong with my constraints. I'm hoping to look at the constraints that I gave to Z3 to determine what is wrong or missing, but I'm not sure how to do this in a way that is very readable. The problem is that using facilities like SMTLIB_DUMP_ASSERTIONS does not provide meaningful names in any let bound variables. Since I have many reuses of the same expressions, nearly everything is let-bound with a generated variable.
Is there any way to dump a file of the input constraints, where let-bound variables have a name that I have assigned? I don't particularly care what the format is, but SMTLIB 1 or 2 would be nice.
No, you cannot provide names to let variables automatically created by Z3 AST printers.
One possible solution is to write your own AST printer. In the Z3 distribution, we have an example application examples/c/test_capi.c. It contains the function:
void display_ast(Z3_context c, FILE * out, Z3_ast v)
It shows how to implement a simple AST printer. This example is very simple, but it is a starting point.