Open chansey97 opened 3 years ago
Hi Siyuan,
Thanks for your interest and kind words.
I can't reproduce the issue with model
not being there anymore, I am using Z3 version 4.8.12.
Some of the tests might not have been updated with the latest version of Z3.
You can also get a much faster experience if you use a branch of faster-miniKanren. For example: https://github.com/namin/faster-miniKanren/blob/smt-assumptions/smt-tests.scm
At some point, we had a version compatible with Racket. It shouldn't be too hard to revive it and have a common base for both the Scheme and Racket version as is the case in faster-miniKanren.
I am curious to hear more about how you plan to use clpsmt-miniKanren.
I can't reproduce the issue with model not being there anymore, I am using Z3 version 4.8.12.
It's very strange.
You can reproduce this issue as following:
z3-4.8.12
z3-4.8.7
You can see that z3-4.8.7 has a model
at the top of the result of (get-model)
and this is consistent with z3-server.scm#L66, (cdr m)
. So the current clpsmt-miniKanren can run well in z3-4.8.7 (at least pass many tests) .
However, z3-4.8.12 lacks this model
, so it fails.
At some point, we had a version compatible with Racket. It shouldn't be too hard to revive it and have a common base for both the Scheme and Racket version as is the case in faster-miniKanren.
I tried z3-server.rkt in Racket. It complained:
?: literal data is not allowed;
no #%datum syntax transformer is bound in: 0
at the (eval r)
.
I can workaround this issue by replacing (eval r)
with r
, but I am not sure whether it will affect the result?
Racket version v8.0 [bc].
I am curious to hear more about how you plan to use clpsmt-miniKanren.
Mainly to learn how logic programming combines with SMT solver.
I am self-learning Constraint Logic Programming and Satisfiability Modulo Theories. In Constraint Logic Programming, it is a bit tricky to implement an common efficient domain-specific constraint, e.g. CLP(FD), CLP(Z), CLP(R), CLP(Set), etc. But if we can use an SMT solver as backend, they will be out of the box. It seems that CLP and SMT are very similar, even though they use different theoretical frameworks (Consider CLP(X) vs DPLL(T)).
Another reason is that I'd like to collect some applications for miniKanren variants (especially about program synthesis).
miniKanren has a lot of variants. Different variants have different features and restrictions. (Unfortunately, there is no all-in-one package.) clpsmt-miniKanren is one of such variants. For example, we can use miniKanren to do symbolic execution, but standard miniKanren with symbolic constraints does not support Integer arithmetic. By clpsmt-miniKanren, we can get CLP(Z) out of the box. That is why I said it is great! (Oleg numeral can be extended to negative, but it is another story).
PS. I am also learning rosette. Comparing rosette and miniKanren for program synthesis is an interesting experience as well.
I can't reproduce the issue with model not being there anymore, I am using Z3 version 4.8.12.
It's very strange.
You can reproduce this issue as following:
- z3-4.8.12
- z3-4.8.7
You can see that z3-4.8.7 has a
model
at the top of the result of(get-model)
and this is consistent with z3-server.scm#L66,(cdr m)
. So the current clpsmt-miniKanren can run well in z3-4.8.7 (at least pass many tests) .However, z3-4.8.12 lacks this
model
, so it fails.
OK, I guess the code will ignore the first constraint in the model.
You can change that behavior by removing the cdr
here: https://github.com/namin/clpsmt-miniKanren/blob/master/z3-server.scm#L66
Sorry, the codebase is a bit rotted. We'll try to find some time to clean it up and bring it up to date. If you'd like to help, that would be great.
Hi Nada,
There is test case that I am not sure whether the current clpsmt-miniKanren's behavior correct:
(run* (q)
(fresh (v1 v2)
(z/ `(declare-const ,v1 Bool))
(z/ `(declare-const ,v2 Bool))
(== v1 v2)
(== q v1)))
;; => (#f)
The computed value is (#f)
, but the expected value (_.0)
.
Does this mean that there is a bug in the current clpsmt-miniKanren? (BTW, I think the 3rd possible candidate result is (#t #f)
.)
I don't know which one should be the correct behavior when we combine with SMT solver?
Thanks.
Hi Nada,
There is test case that I am not sure whether the current clpsmt-miniKanren's behavior correct:
(run* (q) (fresh (v1 v2) (z/ `(declare-const ,v1 Bool)) (z/ `(declare-const ,v2 Bool)) (== v1 v2) (== q v1))) ;; => (#f)
The computed value is
(#f)
, but the expected value(_.0)
.Does this mean that there is a bug in the current clpsmt-miniKanren? (BTW, I think the 3rd possible candidate result is
(#t #f)
.)I don't know which one should be the correct behavior when we combine with SMT solver?
Thanks.
Thanks, this is strange. You can enable logging here: https://github.com/namin/clpsmt-miniKanren/blob/master/z3-server.scm#L4 to see what's going on. If you can debug this, that would be great. If not, I'll take a look next month when I'll have more time.
It would be nice, if you can write a paper explains how clpsmt-miniKanren be implemented, e.g. how ==
promoted to (z/assert (= ,a ,b))
, compatible with old symbolic-constraints, constraints subsumption, how SMT combined with minikanren's interleave complete search, etc : )
BTW, You have searched the internet for "SMT and constraint logic programming". There are very few resources about how SMT and CLP connect. It seems that clpsmt-miniKanren is the first opensource project done this idea (bring SMT to CLP). That's a really cool stuff.
I just added you to an old repo with work in progress about the project and its implementation. Eventually, we could turn this into a paper.
I just added you to an old repo with work in progress about the project and its implementation.
Hi, Nada,
I'm sorry...
I don't quite understand the meaning of this sentence.
What do you mean by "old repo" ? Could you explain further?
Thanks.
You should have gotten access to the smt-pearl
repo.
Thank you.
But is the smt-pearl
under your github account? Or just a branch?
I can't find this repo. Is there a link for it?
I just emailed you the repo URL.
Hi,
I am trying to use clpsmt-miniKanren for constraint logic programming, it's great work!
But I am not sure which z3 version should I use?
I initially used z3-4.8.12, but failed. The reason is that clpsmt-miniKanren assumes the result model s-exp has a
model
in the top, but z3-4.8.12 has no thismodel
.So I switched to an older version.
I currently use z3-4.8.7, it can pass many test cases, but some of them still failed.
It seems that there are two kinds of failure:
z3 version relevant clpsmt-basic-tests.scm - Testing "5" clpsmt-tests.scm - Testing "evalo-many-0" clpsmt-tests.scm - Testing "many-1" clpsmt-tests.scm - Testing "many-2" clpsmt-tests.scm - all other
read-sat: unknown
cases.z3 version irrelevant clpsmt-basic-tests.scm - Testing "declare-idempotent"
Could you tell me which z3 version should I use?
Thanks.
My environment:
Windows 7, Chez Scheme Version 9.5, z3-4.8.7, clpsmt-miniKanren-master (4fa74fb)
PS. I used
z3-server.scm
instead ofz3-driver.scm
, becasuez3-driver.scm
doesn't work in windows 7. Is there way to workaround? BTW, does clpsmt-miniKanren support Racket? I saw the source code mixed.scm
and.rkt
, but all the test cases use.scm
andload
. So I don't know whether clpsmt-miniKanren is currently compatible with Racket.