Returning unknown not sat/unsat with jsmtlib - smt

Following this tutorial, I tried this first example in the tutorial.
(set-option :print-success false)
(set-logic QF_UF)
(declare-fun p () Bool)
(assert (and p (not p)))
(check-sat)
(exit)
I executed this command
java -jar jsmtlib.jar test1.smt
To get unknown not unsat as in the tutorial.
What might be wrong with this?

I needed to specify what solver do I use. I chose yices as the server, and with java -jar jsmtlib.jar --solver yices --exec ./yices test1.smt, everything works fine.

I believe jsmtlib.jar is some kind of wrapper for SMT solvers. The "unknown" answer has nothing to do with Z3. You should contact jsmtlib.jar authors about this problem.
Have you tried to use Z3 directly?
It returns unsat for this script.
You can try Z3 online at:
http://rise4fun.com/Z3/chyM
We also have online tutorials:
http://rise4fun.com/Z3/tutorial/guide
You can also download and install Z3 in your machine:
http://research.microsoft.com/en-us/um/redmond/projects/z3/download.html

Related

OpenCobol & PostgreSQL on Windows with Visual Studio

I'm currently facing a problem with this team of 4.
Using binaries I downloaded on kiska's site. I'm able to compile cobol to C and run it with cobcrun or compile it to an executable. However I can 't get opencobol to find the postgres commands.
Here is the strat of my cobol script :
identification division.
program-id. pgcob.
data division.
working-storage section.
01 pgconn usage pointer.
01 pgres usage pointer.
01 resptr usage pointer.
01 resstr pic x(80) based.
01 result usage binary-long.
01 answer pic x(80).
procedure division.
display "Before connect:" pgconn end-display
call "PQconnectdb" using
by reference "dbname = postgres" & x"00"
by reference "host = 10.37.180.146" & "00"
returning pgconn
end-call
...
the call PQconnectdb fail with module ont found : PQconnectdb
I noticed that if i rename the libpq.dll the error message change to can't find entry point. So at least I'm sure it can get my dll.
After digging into the code of the call method of the libcob library. I found it it was possible to pre load some dll using an environment variable COB_PRE_LOAD but sitll no results.
Here is what look the script to compile the cobol :
call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat"
set COB_CONFIG_DIR=C:\OpenCobol\config
set COB_COPY_DIR=C:\OpenCobol\Copy
set COB_LIBS=%COB_LIBS% c:\OpenCobol\libpq.lib
set COB_LIBRARY_PATH=C:\OpenCobol\bin
set COB_PRE_LOAD=C:\OpenCobol\libpq.dll
#echo on
cobc -info
cobc -free -o pgcob -L:"C:\OpenCobol" -llibpq.lib test_cobol\postgres.cob
call cobcrun pgcob
I don't see anything missing, I'm using the 64-bit binaries from kiska's site and use the 64-bit cl.exe from Visual Studio, Postgres is a 64 bit version too (checked with dependencyChecker).
I even tryed to compile the generated C from Visual Studio, same result, but I may miss something, I'm pretty rotten in C and never really had to manage DLL or use Visual Studio.
What am I missing ?
COB_PRE_LOAD doesn't take any path or extension, see the short documentation for the available runtime configurations. I guess
set COB_LIBRARY_PATH=C:\OpenCobol\bin;C:\OpenCobol
set COB_PRE_LOAD=libpq
Will work. You can omit the C:\OpenCobol\bin if you did not placed any additional executables there.
If it doesn't work (even if it does) I'd try to get the C functions resolved at compile time. Either use
CALL STATIC "PQconnectdb" using ...
or an appropriate CALL-CONVENTION or leave the program as-is and use
cobc -free -o pgcob -L"C:\OpenCobol" -llibpq -K PQconnectdb test_cobol\postgres.cob
From cobc --help:
-K generate CALL to <entry> as static
In general: the binaries from kiska.net are quite outdated. I highly suggest getting newer ones from the official download site or ideally build them on your own from source, see the documentation for building GnuCOBOL with VisualStudio.

Pyinstaller --onefile warning pyconfig.h when importing scipy or scipy.signal

This is very simple to recreate.
If my script foo.py is:
import scipy
Then run:
python pyinstaller.py --onefile foo.py
When I launch foo.exe I get:
WARNING: file already exists but should not: C:\Users\username\AppData\Local\Temp\_MEI86402\Include\pyconfig.h
I've tested a few versions but the latest I've confirmed is 2.1dev-e958e02 running on Win7, Python 2.7.5 (32 bit), Scipy version 0.12.0
I've submitted a ticket with the Pyinstaller folks but haven't heard anything yet. Any clues how to debug this further?
You can hack the spec file to remove the second instance by adding these lines after a=Analysis:
for d in a.datas:
if 'pyconfig' in d[0]:
a.datas.remove(d)
break
The answer by wtobia# worked for me. See https://github.com/pyinstaller/pyinstaller/issues/783
Go to C:\Python27\Lib\site-packages\PyInstaller\build.py
Find the def append(self, tpl): function.
Change if tpl[2] == "BINARY": to if tpl[2] in ["BINARY", "DATA"]:
Expanding upon Ilya's solution, I think this is a little bit more robust solution to modifying the spec file (again place after the a=Analysis... statement).
a.datas = list({tuple(map(str.upper, t)) for t in a.datas})
I only tested this on a small test program (one with a single import and print statement), but it seems to work. a.datas is a list of tuples of strings which contain the pyconfig.h paths. I convert them all to lowercase and then dedup. I actually found that converting all of them all to lowercase was sufficient to get it to work, which suggests to me that pyinstaller does case-sensitive deduping when it should be case-insensitive on Windows. However, I did the deduping myself for good measure.
I realized that the problem is that Windows is case-insensitive and these 2 statements are source directories are "duplicates:
include\pyconfig.h
Include\pyconfig.h
My solution is to manually tweak the .spec file with after the a=Analysis() call:
import platform
if platform.system().find("Windows")>= 0:
a.datas = [i for i in a.datas if i[0].find('Include') < 0]
This worked in my 2 tests.
A more flexible solution would be to check ALL items for case-insensitive collisions.
I ran the archive_viewer.py utility (from PyInstaller) on one of my own --onefile executables that has the same error and found that pyconfig.h is included twice:
(31374007, 6521, 21529, 1, 'x', 'include\\pyconfig.h'),
(31380528, 6521, 21529, 1, 'x', 'Include\\pyconfig.h'),
(31387049, 984, 2102, 1, 'x', 'pytz\\zoneinfo\\CET'),
Sadly though, I don't know how to fix it.
PyInstaller Manual link:
http://www.pyinstaller.org/export/d3398dd79b68901ae1edd761f3fe0f4ff19cfb1a/project/doc/Manual.html#archiveviewer

CLAPACK: error when testing CBLAS

I am getting an error when i test CBLAS in CLAPACK. When i run the test code
./xblat2d < dblat2.in
I get the error output:
"TransA must be 111, 112 or 113, but is set to -1Parameter 2 to routine cblas_dgemv was incorrect"
Does anyone know what kind of problem this indicates?
Details
I am trying not to use reference CBLAS, and use ATLAS CBLAS instead. So, i compiled wrapper library libcblaswr.a and changed the line in make.inc to
BLASLIB = ../../libcblaswr.a -L/usr/local/atlas/lib -lcblas -L/usr/local/atlas/lib -latlas
CLAPACK installation suggest doing
BLASLIB = ../../libcblaswr.a -lcblas -latlas
But linker doesn't find cblas and atlas without me using -L option, so i included it.
Details of my setup:
Ubunty Lycid Lynx 10.04
CLAPACK-3.2.1
ATLAS.3.9.51
This appears to be a problem with the CLAPACK test in that it passes the wrong parameters to the BLAS routines. In calling dgemv there is an option for the matrix to operate as itself or as the transpose or as the conjugate transpose, corresponding to 111, 112 or 113 (see line 6 of cblas.h). The code in CLAPACK doesn't set the parameter correctly. I haven't looked deep enough to know if this is an issue with just the test or if the issue runs deeper; but I suspect it's just with the test as I haven't run in to this issue using any CLAPACK code.
I have ignored it because 1) I'm not depending on CLAPACK to test the BLAS routines installed by ATLAS and 2) if there's a deeper issue it will cause an error like this rather than produce invalid results, and I'll track it down then.
And yes, the linker won't find -lcblas and -latlas until you install them somewhere normally searched, this is normal.

How do I change directory in command line with Clojure?

What I'm looking for is this kind of command line interaction at the Windows command line:
C:\temp1>clj some_script.clj
C:\temp2>
Where some_script.clj contains something like:
(cd "c:\\temp2")
So the question is - how do I implement the function cd? Have experimented with clojure.java.shell, but it does not look like the lib I need. This might be a simple question, the problem might be that I'm not fluent in Java?!
You can't do this in Java, so you can't do it in Clojure. See Changing the current working directory in Java?
clojure can do this.
You only need to change a dynamic global variable called *sh-dir*. run the following code in your repl:
(use '[clojure.java.sh])
(sh "ls")
=> {:exit 0, :out "LICENSE\nREADME.md\nauto_deploy.iml\ndoc\nproject.clj\nresources\nsrc\ntarget\ntest\n", :err ""}
(binding [*sh-dir* "c:/"] (sh "ls"))
{:exit 0,
:out "$360Section
$GetCurrent
$Recycle.Bin
Boot
Documents and Settings
ImbaMallLog.txt
Intel
MSOCache
OEMSY
PerfLogs
Program Files
Program Files (x86)
ProgramData
Python27
Recovery
System Volume Information
Users
Windows
apache-ant-1.9.3
bootmgr
hiberfil.sys
inetpub
pagefile.sys
",
:err ""}
see the doc for more info. you can use (alter-var-root #'clojure.java.shell/*sh-dir* (constantly "the-cd-path")) to change it constantly. Thanks for isaac telling me about this.
Hope this helps.

Eval not working on unexpanded macro quote

In common lisp I can do this:
src-> (defmacro macro-hello ()
`"hello")
(eval '(macro-hello))
no problem.
In clojure:
(defmacro macro-hello []
`"hello")
(eval '(macro-hello))
gives me an error. Have I done something wrong?
Clojure Error:
Exception in thread "main" java.lang.Exception: Unable to resolve symbol: macro-hello in this context (NO_SOURCE_FILE:12)
at clojure.lang.Compiler.analyze(Compiler.java:4340)
at clojure.lang.Compiler.analyze(Compiler.java:4286)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:2767)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4498)
at clojure.lang.Compiler.analyze(Compiler.java:4325)
at clojure.lang.Compiler.analyze(Compiler.java:4286)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:3862)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:3697)
at clojure.lang.Compiler$FnMethod.access$1100(Compiler.java:3574)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:2963)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4494)
at clojure.lang.Compiler.analyze(Compiler.java:4325)
at clojure.lang.Compiler.eval(Compiler.java:4530)
at clojure.core$eval__3990.invoke(core.clj:1728)
at com.yourcompany.defpackage$_main__4.invoke(defpackage.clj:12)
at clojure.lang.AFn.applyToHelper(AFn.java:171)
at clojure.lang.AFn.applyTo(AFn.java:164)
at com.yourcompany.defpackage.main(Unknown Source)
Caused by: java.lang.Exception: Unable to resolve symbol: macro-hello in this context
at clojure.lang.Compiler.resolveIn(Compiler.java:4682)
at clojure.lang.Compiler.resolve(Compiler.java:4628)
at clojure.lang.Compiler.analyzeSymbol(Compiler.java:4605)
at clojure.lang.Compiler.analyze(Compiler.java:4307)
... 17 more
Java Result: 1
[Edited]: added ending double quote
Your code works for me.
user> (defmacro macro-hello [] `"hello")
#'user/macro-hello
user> (eval '(macro-hello))
"hello"
This is via bleeding-edge Clojure. "Unable to resolve symbol" means it can't find the macro called macro-hello in the current namespace. Are you running this from the REPL or in a source file? I typed your statements at a REPL literally.
Not sure if this is a cause of problems for you, but please note the difference between ` and ' in Clojure. ` does namespace resolution and ' doesn't.
user> `macro-hello
user/macro-hello
user> 'macro-hello
macro-hello
This is different from Common Lisp's behavior. Backtick-quoting a String like `"hello" doesn't make much sense, since Strings don't belong to namespaces, but it also doesn't hurt anything.
(I'm assuming you made a typo in your Clojure code, with the missing double-quote.)
I like to work out of /opt on Mac and Linux boxes. To get the Clojure source. (% is Unix prompt)
% cd /opt
% git clone git://github.com/richhickey/clojure.git; #From Unix command line, you'll have an /opt/clojure dir
% cd /opt/clojure
% /opt/netbeans-6.7.1/java2/ant/bin/ant; # Run ant. It ships with Netbeans.
% cd /opt; # mkdir /opt if it's not there.
% git clone git://github.com/richhickey/clojure-contrib.git; # Get contrib
% /opt/netbeans-6.7.1/java2/ant/bin/ant -Dclojure.jar=../clojure/clojure.jar ; # Tell ant where clojure.jar is located
I rename jars to clojure.jar and clojure-contrib.jar
Copy these jars to your Netbean's project lib directory.