Giter VIP home page Giter VIP logo

Comments (7)

wintersteiger avatar wintersteiger commented on August 27, 2024

Through the SMT2 file-based interface there is no "easier" way; in general models for arrays are functions (maps) of indices to values. Some of our APIs try to make that a little bit easier by hiding the k! entries and resolving that link to the function, but that's not possible in SMT2. There have been many questions (and bug reports) about this on StackOverflow.

I don't think there is a "correct" way of implementing string constraints. This is subject of ongoing research and there are plans to create an SMT theory for strings, but that's still in a draft state I think.

from z3.

wintersteiger avatar wintersteiger commented on August 27, 2024

Closing this issue, please reopen if necessary.

from z3.

zimmski avatar zimmski commented on August 27, 2024

Thank you! Do you think that this will be addressed with a newer SMT-LIB version?

from z3.

wintersteiger avatar wintersteiger commented on August 27, 2024

Yes, all interested parties are already working on an SMT string logic and solvers. I don't know exactly who's leading the discussion, but I know that Cesare Tinelli knows :)

There is also a Z3-based string solver prototype, but AFAIK it's not available in source code yet. I'll notify those responsible to add any additional information here.

from z3.

zimmski avatar zimmski commented on August 27, 2024

Do you mean https://github.com/z3str/Z3-str ?

from z3.

wintersteiger avatar wintersteiger commented on August 27, 2024

No, that's an independent effort, but it's also based on Z3. I don't know about technical differences between the two, but I'm sure the authors would be happy to point those out.

from z3.

zimmski avatar zimmski commented on August 27, 2024

I have a working solution and I am working on some additional functionality around strings. I noticed something odd (at least odd to me) about Z3.
When I take the example above and just negate the assertion, Z3 does not pick the empty array which would fulfill the assertion. For example this SMTLIB

(set-option :produce-models true)
(declare-const a (Array Int Int))
(assert (not (= a (store (store (store (store ((as const(Array Int Int)) 0) 0 99) 1 111) 2 111) 3 108))))
(check-sat)
(get-value (a))
(get-model)

prints the following

sat
((a (_ as-array k!0)))
(model 
  (define-fun a () (Array Int Int)
    (_ as-array k!0))
  (define-fun k!3 ((x!1 Int)) Int
    (ite (= x!1 1) 111
    (ite (= x!1 0) 99
      0)))
  (define-fun k!0 ((x!1 Int)) Int
    (ite (= x!1 1) 5
      4))
  (define-fun k!4 ((x!1 Int)) Int
    (ite (= x!1 2) 111
    (ite (= x!1 1) 111
    (ite (= x!1 0) 99
      0))))
  (define-fun k!1 ((x!1 Int)) Int
    0)
  (define-fun k!5 ((x!1 Int)) Int
    (ite (= x!1 3) 108
    (ite (= x!1 2) 111
    (ite (= x!1 1) 111
    (ite (= x!1 0) 99
      0)))))
  (define-fun k!2 ((x!1 Int)) Int
    (ite (= x!1 0) 99
      0))
)

So get-value suggests that k!0 should be used which is the array [4, 5]. Why does Z3 use the "odd" numbers [4, 5]? And why does Z3 not suggest the empty array of k!1? Also k!0 to k!4 could be used as witnesses but not k!5. So I am wondering why k!5 in the model at all? Is there a paper on this behavior or should I dive into the Z3 source code to get a better understanding?

from z3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.