z3 # command line behaving differently than online - z3

the (rather small) query that I have here:
http://rise4fun.com/Z3/W4sf
works just fine on the website (above) but hangs
when I run it on my mac, with
z3 -in
followed by pasting in the exact text above, which is:
(declare-const x Real)
(assert (not (= 0.0 x)))
(assert (not (< 0.0 (* x x))))
(check-sat)
Any ideas? I thought it might be that I have an old version but its 4.3.2
rjhala#borscht ~/bin [130]> z3 -help
Z3 [version 4.3.2 - 64 bit - build hashcode 5b5a474b5443].
Am I missing some parameters? Or any other suggestions? Many thanks!
Ranjit.

It also seemed not to return for me using that, but it seems to work as:
z3 -in -smt2
Followed by pasting the query, so I think it may need the -smt2 parameter. I tried it on Windows with 4.3.3 (I thought I had 4.3.2, but it seems I updated from the latest unstable branch):
C:\Users\tjohnson>z3 -in -smt2
(declare-const x Real)
(assert (not (= 0.0 x)))
(assert (not (< 0.0 (* x x))))
(check-sat)
unsat
It also worked for me by pasting the query into test.smt and running:
C:\Users\tjohnson>z3 -smt2 test.smt
unsat

Related

batch resize images with gimp

I want to resize every jpg in a directory.
This is the gimp script I've found. Looks sensible to me.
(define (batch-resize pattern)
(let*
((filelist (cadr (file-glob pattern 1))))
(while (not (null? filelist))
(let* (
(filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-active-drawable image)))
(cur-width (car (gimp-image-width image)))
(cur-height (car (gimp-image-height image)))
(width (* 0.25 cur-width))
(height (* 0.25 cur-height))
)
(gimp-message filename)
(gimp-image-scale-full image width height INTERPOLATION-CUBIC)
(let
((nfilename (string-append "thumb_" filename)))
(gimp-file-save RUN-NONINTERACTIVE image drawable nfilename nfilename)
)
(gimp-image-delete image)
)
(set! filelist (cdr filelist))
)
)
)
I saved this as C:\Users\rwb\.gimp-2.8\scripts\batch-resize.scm and then call
"C:\Program Files\GIMP 2\bin\gimp-console-2.8.exe" -i -b '(batch-resize "*.JPG")' -b '(gimp-quit 0)'
The ouptut is
>"C:\Program Files\GIMP 2\bin\gimp-console-2.8.exe" -i -b '(batch-resize "*.JPG")' -b '(gimp-quit 0)'
(gimp-console-2.8.exe:7568): LibGimpBase-WARNING **: gimp-console-2.8.exe: gimp_wire_read(): error
batch command executed successfully
batch command executed successfully
At which point it just hangs.
I was expecting the (gimp-message filename) to print the filenames but nothing!
I really have no idea what is going on here! Can you offer any suggestions? Even printing the filenames would be a start.
The problem arises from the way you are quoting the command-line. This should work:
"c:\Program Files\GIMP 2\bin\gimp-console-2.10.exe" -b "(batch-resize \"*.JPG\")" -b "(gimp-quit 0)"
Note that it is updated for GIMP 2.10. Additionally, user script files now live in:
c:\Users\rwb\AppData\Roaming\GIMP\2.10\scripts
And finally, the code block in your question was formatted with the final parenthesis outside the block, which made it easy to miss. I've updated that.

'Unknown logical symbol map.Map.const' message in Why3

I'm experimenting with why3 by following their tutorial, but I get the message Unknown logical symbol map.Map.const for multiple provers. Here are the contents of the theory I'm trying to prove:
theory List
type list 'a = Nil | Cons 'a (list 'a)
predicate mem(x: 'a) (l: list 'a) = match l with
| Nil -> false
| Cons y r -> x = y || mem x r
end
goal G1: mem 2 (Cons 1 (Cons 2 (Cons 3 Nil)))
end
Here are the results of a variety of provers:
z3:
▶ why3 prove -P z3 demo_logic.why
File "/usr/local/share/why3/drivers/z3_bare.drv", line 172, characters 36-41:
Unknown logical symbol map.Map.const
cvc4:
▶ why3 prove -P cvc4 demo_logic.why
File "/usr/local/share/why3/drivers/cvc4_bare.drv", line 180, characters 36-41:
Unknown logical symbol map.Map.const
pvs:
▶ why3 prove -P pvs demo_logic.why
File "/usr/local/share/why3/drivers/pvs-common.gen", line 41, characters 18-23:
Unknown logical symbol map.Map.const
This is my why3 version information:
▶ why3 --version
Why3 platform, version -n 0.85+git (build date: Tue Mar 10 08:27:47 EDT 2015)
The timestamps on the .drv files mentioned in the error messages match the timestamp on my why3 executable.
Is there something wrong with my theory or my installation?
Edit to add: In the tutorial itself it says to use why3 demo_logic.why to prove the theory, but when I try that I get this result:
▶ why3 demo_logic.why
'demo_logic.why' is not a Why3 command.
If instead I just do why3 prove demo_logic.why, the result is just (approximately) an echo of the theory:
▶ why3 prove demo_logic.why
theory List
(* use why3.BuiltIn.BuiltIn *)
type list 'a =
| Nil
| Cons 'a (list 'a)
predicate mem (x:'a) (l:list 'a) =
match l with
| Nil -> false
| Cons y r -> x = y || mem x r
end
goal G1 : mem 2 (Cons 1 (Cons 2 (Cons 3 (Nil:list int))))
end
Do you installed a previous version of why3? Problems in the execution of provers are often due to a new why3 using a configuration file of an old why3. And I have seen your particular instance fixed by this:
rm ~/.why3.conf
why3 config --detect

How to run datalog in Z3 using commad line

I try to run datalog file (test.dl, from http://rise4fun.com/Z3/tutorialcontent/fixedpoints#h21) as following in Z3 (version:4.3.2).
(set-option :fixedpoint.engine datalog)
(define-sort s () (_ BitVec 3))
(declare-rel edge (s s))
(declare-rel path (s s))
(declare-var a s)
(declare-var b s)
(declare-var c s)
(rule (=> (edge a b) (path a b)))
(rule (=> (and (path a b) (path b c)) (path a c)))
(rule (edge #b001 #b010))
(rule (edge #b001 #b011))
(rule (edge #b010 #b100))
(query (path #b001 #b100))
(query (path #b011 #b100))
(query (path #b001 b)
:print-answer true)
Use the command z3 test.dl, but there is erorr msg:
Can someone help how to run the datalog file?
Thanks.
The input format for this file is SMT2, not Datalog. Even though you want to run the Datalog engine, the file isn't in Datalog format and so the parser gives you the error that you see.
Running Z3 with the command z3 -smt2 test.dl was successful, as this forces Z3 to use the SMT2 parser and not the Datalog one. Alternatively, renaming the file to test.smt2 and running z3 test.smt2 works.
Both commands produced what I believe is the expected output
sat
unsat
sat
(or (= (:var 0) #b011) (= (:var 0) #b010) (= (:var 0) #b100))

Emacs flymake on Mac Yosemite

Flymake in emacs was properly working until update to Yosemite. But now it's complaining:
Flymake: Failed to launch syntax check process 'pychecker' with args (<filename>_flymake.py): Searching for program: no such file or directory, pychecker. Flymake will be switched OFF.
where <filename> is the name of the file in the opened buffer.
Here's my flymake config:
(add-to-list 'load-path "~/.emacs.d/")
;; Setup for Flymake code checking.
(require 'flymake)
(load-library "flymake-cursor")
;; Script that flymake uses to check code. This script must be
;; present in the system path.
(setq pycodechecker "pychecker")
(when (load "flymake" t)
(defun flymake-pycodecheck-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list pycodechecker (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pycodecheck-init)))
(add-hook 'python-mode-hook 'flymake-mode)
here's /usr/local/bin/pychecker:
#! /bin/sh
pyflakes "$1"
pep8 --repeat "$1" --max-line-length=80 --ignore=E123,E133,E226,E501
true
here's $PATH:
/Users/<user>/Envs/<venv>/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin
where <user> is my user name and <venv> is the currently active virtual-env.
pychecker works properly if run from the shell.
I start emacs from shell by typing emacsgui (alias emacsgui='open -a emacs'), usually with the venv activated. I also tried opening emacs without any venv activated but the problem still occur. What is the problem?
I solved by adding this to my .emacs file:
(defun set-exec-path-from-shell-PATH ()
(let ((path-from-shell (replace-regexp-in-string
"[ \t\n]*$"
""
(shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
(setenv "PATH" path-from-shell)
(setq exec-path (split-string path-from-shell path-separator))))
(when (and window-system (eq system-type 'darwin))
;; When started from Emacs.app or similar, ensure $PATH
;; is the same the user would see in Terminal.app
(set-exec-path-from-shell-PATH))

z3py on MacOSX: cannot get a model

I am seeing a strange problem with z3py on Mac, was wondering if anyone has seen this before:
$ cat bug.py
from z3 import *
x = Int('x')
s = Solver()
s.add(x > 5)
print(s.check())
print(s.model())
$ python bug.py
sat
[x = ]
The value of x is missing from the model. I tried both master and unstable branches with the same result. However, z3 itself does give the correct model if run on a similar .smt2 file. My configuration is Mac OSX 10.6.8, Python 2.7.4.
The problem is very specific for my setup, but maybe someone will run into it as well: the root cause is that a wrong version of libgomp was picked up by the dynamic loader -- i.e. the versions used to compile and to run do not match.
Here is a more severe manifestation of this issue:
$ python
Python 2.7.4 (default, May 9 2013, 18:51:46)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from z3 import *
>>> IntVal(1)
>>>
The numeric value is not printed, i.e. the correct output is
>>> IntVal(1)
1
>>>
Setting DYLD_LIBRARY_PATH to point to the correct version of the library fixes the issue.
I don't see any problems with Z3 4.1 and Python 2.7.2 on my Mac OSX 10.8.3. I wonder if it's some sort of terminal issue that eats the characters for whatever reason. What do you see if you redirect the output to a file? (i.e., try "python bug.py > out". Does the contents of the file "out" look OK?)

Resources