How get a a value from a Lambda expression?











up vote
3
down vote

favorite












I'm experimenting with z3 in python. I have the following model:



(set-option :produce-models true)
(set-logic QF_AUFBV )
(declare-fun a () (Array (_ BitVec 32) (_ BitVec 8) ) )
(declare-fun another () (Array (_ BitVec 32) (_ BitVec 8) ) )
(assert (and (= false (= (_ bv77 32) (concat (select a (_ bv3 32) ) (concat (select a (_ bv2 32) ) (concat (select a (_ bv1 32) ) (select a (_ bv0 32) ) ) ) ) ) ) (= false (= (_ bv12 32) (concat (select another (_ bv3 32) ) (concat (select another (_ bv2 32) ) (concat (select another (_ bv1 32) ) (select another (_ bv0 32) ) ) ) ) ) ) ) )


I can load it and check that is sat. At this point how can I get an example value for a and another?



import z3
s = z3.Solver()
s.from_file("first.smt")
"""
s
[And(False ==
(77 == Concat(a[3], Concat(a[2], Concat(a[1], a[0])))),
False ==
(12 ==
Concat(another[3],
Concat(another[2],
Concat(another[1], another[0])))))]
"""
s.check()
"""
sat
"""
m = s.model()
m
[a = Lambda(k!0, 1), another = Lambda(k!0, 1)]


Thanks










share|improve this question




























    up vote
    3
    down vote

    favorite












    I'm experimenting with z3 in python. I have the following model:



    (set-option :produce-models true)
    (set-logic QF_AUFBV )
    (declare-fun a () (Array (_ BitVec 32) (_ BitVec 8) ) )
    (declare-fun another () (Array (_ BitVec 32) (_ BitVec 8) ) )
    (assert (and (= false (= (_ bv77 32) (concat (select a (_ bv3 32) ) (concat (select a (_ bv2 32) ) (concat (select a (_ bv1 32) ) (select a (_ bv0 32) ) ) ) ) ) ) (= false (= (_ bv12 32) (concat (select another (_ bv3 32) ) (concat (select another (_ bv2 32) ) (concat (select another (_ bv1 32) ) (select another (_ bv0 32) ) ) ) ) ) ) ) )


    I can load it and check that is sat. At this point how can I get an example value for a and another?



    import z3
    s = z3.Solver()
    s.from_file("first.smt")
    """
    s
    [And(False ==
    (77 == Concat(a[3], Concat(a[2], Concat(a[1], a[0])))),
    False ==
    (12 ==
    Concat(another[3],
    Concat(another[2],
    Concat(another[1], another[0])))))]
    """
    s.check()
    """
    sat
    """
    m = s.model()
    m
    [a = Lambda(k!0, 1), another = Lambda(k!0, 1)]


    Thanks










    share|improve this question


























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      I'm experimenting with z3 in python. I have the following model:



      (set-option :produce-models true)
      (set-logic QF_AUFBV )
      (declare-fun a () (Array (_ BitVec 32) (_ BitVec 8) ) )
      (declare-fun another () (Array (_ BitVec 32) (_ BitVec 8) ) )
      (assert (and (= false (= (_ bv77 32) (concat (select a (_ bv3 32) ) (concat (select a (_ bv2 32) ) (concat (select a (_ bv1 32) ) (select a (_ bv0 32) ) ) ) ) ) ) (= false (= (_ bv12 32) (concat (select another (_ bv3 32) ) (concat (select another (_ bv2 32) ) (concat (select another (_ bv1 32) ) (select another (_ bv0 32) ) ) ) ) ) ) ) )


      I can load it and check that is sat. At this point how can I get an example value for a and another?



      import z3
      s = z3.Solver()
      s.from_file("first.smt")
      """
      s
      [And(False ==
      (77 == Concat(a[3], Concat(a[2], Concat(a[1], a[0])))),
      False ==
      (12 ==
      Concat(another[3],
      Concat(another[2],
      Concat(another[1], another[0])))))]
      """
      s.check()
      """
      sat
      """
      m = s.model()
      m
      [a = Lambda(k!0, 1), another = Lambda(k!0, 1)]


      Thanks










      share|improve this question















      I'm experimenting with z3 in python. I have the following model:



      (set-option :produce-models true)
      (set-logic QF_AUFBV )
      (declare-fun a () (Array (_ BitVec 32) (_ BitVec 8) ) )
      (declare-fun another () (Array (_ BitVec 32) (_ BitVec 8) ) )
      (assert (and (= false (= (_ bv77 32) (concat (select a (_ bv3 32) ) (concat (select a (_ bv2 32) ) (concat (select a (_ bv1 32) ) (select a (_ bv0 32) ) ) ) ) ) ) (= false (= (_ bv12 32) (concat (select another (_ bv3 32) ) (concat (select another (_ bv2 32) ) (concat (select another (_ bv1 32) ) (select another (_ bv0 32) ) ) ) ) ) ) ) )


      I can load it and check that is sat. At this point how can I get an example value for a and another?



      import z3
      s = z3.Solver()
      s.from_file("first.smt")
      """
      s
      [And(False ==
      (77 == Concat(a[3], Concat(a[2], Concat(a[1], a[0])))),
      False ==
      (12 ==
      Concat(another[3],
      Concat(another[2],
      Concat(another[1], another[0])))))]
      """
      s.check()
      """
      sat
      """
      m = s.model()
      m
      [a = Lambda(k!0, 1), another = Lambda(k!0, 1)]


      Thanks







      python z3 z3py






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago

























      asked Nov 10 at 13:53









      Alberto

      1078




      1078
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          Z3 produces Lambda abstractions for arrays by default; which are useful but hard to see what's going on in a model. I'd recommend turning that off, by putting the following line in your python program:



          z3.set_param('model_compress', False)


          You should do this right after you import z3.



          With this, if you print the model in your program, you get:



          >>> m
          [a = [3 -> 1, else -> 1],
          another = [1 -> 1, else -> 1],
          k!0 = [3 -> 1, else -> 1],
          k!1 = [1 -> 1, else -> 1]]


          which should be more readable. (It's essentially saying both a and another are arrays that map everything to 1; though a bit convoluted.)






          share|improve this answer





















          • Thanks for your answer, I was able to have the model in that format now. I'd ask you another clarification if possible. I edited my original question for that. Could you explain more in details the model. Thanks
            – Alberto
            2 days ago






          • 1




            On stack-overflow, it's always best to start a different question instead of editing the original. Also, "accepting" the answer tells others the issue is resolved; both for people having similar issues and the people trying to help others out. Comments should be reserved only for the original discussion. So, please start a new question and I'm sure someone will answer!
            – Levent Erkok
            2 days ago













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239653%2fhow-get-a-a-value-from-a-lambda-expression%23new-answer', 'question_page');
          }
          );

          Post as a guest
































          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          Z3 produces Lambda abstractions for arrays by default; which are useful but hard to see what's going on in a model. I'd recommend turning that off, by putting the following line in your python program:



          z3.set_param('model_compress', False)


          You should do this right after you import z3.



          With this, if you print the model in your program, you get:



          >>> m
          [a = [3 -> 1, else -> 1],
          another = [1 -> 1, else -> 1],
          k!0 = [3 -> 1, else -> 1],
          k!1 = [1 -> 1, else -> 1]]


          which should be more readable. (It's essentially saying both a and another are arrays that map everything to 1; though a bit convoluted.)






          share|improve this answer





















          • Thanks for your answer, I was able to have the model in that format now. I'd ask you another clarification if possible. I edited my original question for that. Could you explain more in details the model. Thanks
            – Alberto
            2 days ago






          • 1




            On stack-overflow, it's always best to start a different question instead of editing the original. Also, "accepting" the answer tells others the issue is resolved; both for people having similar issues and the people trying to help others out. Comments should be reserved only for the original discussion. So, please start a new question and I'm sure someone will answer!
            – Levent Erkok
            2 days ago

















          up vote
          1
          down vote



          accepted










          Z3 produces Lambda abstractions for arrays by default; which are useful but hard to see what's going on in a model. I'd recommend turning that off, by putting the following line in your python program:



          z3.set_param('model_compress', False)


          You should do this right after you import z3.



          With this, if you print the model in your program, you get:



          >>> m
          [a = [3 -> 1, else -> 1],
          another = [1 -> 1, else -> 1],
          k!0 = [3 -> 1, else -> 1],
          k!1 = [1 -> 1, else -> 1]]


          which should be more readable. (It's essentially saying both a and another are arrays that map everything to 1; though a bit convoluted.)






          share|improve this answer





















          • Thanks for your answer, I was able to have the model in that format now. I'd ask you another clarification if possible. I edited my original question for that. Could you explain more in details the model. Thanks
            – Alberto
            2 days ago






          • 1




            On stack-overflow, it's always best to start a different question instead of editing the original. Also, "accepting" the answer tells others the issue is resolved; both for people having similar issues and the people trying to help others out. Comments should be reserved only for the original discussion. So, please start a new question and I'm sure someone will answer!
            – Levent Erkok
            2 days ago















          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          Z3 produces Lambda abstractions for arrays by default; which are useful but hard to see what's going on in a model. I'd recommend turning that off, by putting the following line in your python program:



          z3.set_param('model_compress', False)


          You should do this right after you import z3.



          With this, if you print the model in your program, you get:



          >>> m
          [a = [3 -> 1, else -> 1],
          another = [1 -> 1, else -> 1],
          k!0 = [3 -> 1, else -> 1],
          k!1 = [1 -> 1, else -> 1]]


          which should be more readable. (It's essentially saying both a and another are arrays that map everything to 1; though a bit convoluted.)






          share|improve this answer












          Z3 produces Lambda abstractions for arrays by default; which are useful but hard to see what's going on in a model. I'd recommend turning that off, by putting the following line in your python program:



          z3.set_param('model_compress', False)


          You should do this right after you import z3.



          With this, if you print the model in your program, you get:



          >>> m
          [a = [3 -> 1, else -> 1],
          another = [1 -> 1, else -> 1],
          k!0 = [3 -> 1, else -> 1],
          k!1 = [1 -> 1, else -> 1]]


          which should be more readable. (It's essentially saying both a and another are arrays that map everything to 1; though a bit convoluted.)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 10 at 17:40









          Levent Erkok

          6,42611025




          6,42611025












          • Thanks for your answer, I was able to have the model in that format now. I'd ask you another clarification if possible. I edited my original question for that. Could you explain more in details the model. Thanks
            – Alberto
            2 days ago






          • 1




            On stack-overflow, it's always best to start a different question instead of editing the original. Also, "accepting" the answer tells others the issue is resolved; both for people having similar issues and the people trying to help others out. Comments should be reserved only for the original discussion. So, please start a new question and I'm sure someone will answer!
            – Levent Erkok
            2 days ago




















          • Thanks for your answer, I was able to have the model in that format now. I'd ask you another clarification if possible. I edited my original question for that. Could you explain more in details the model. Thanks
            – Alberto
            2 days ago






          • 1




            On stack-overflow, it's always best to start a different question instead of editing the original. Also, "accepting" the answer tells others the issue is resolved; both for people having similar issues and the people trying to help others out. Comments should be reserved only for the original discussion. So, please start a new question and I'm sure someone will answer!
            – Levent Erkok
            2 days ago


















          Thanks for your answer, I was able to have the model in that format now. I'd ask you another clarification if possible. I edited my original question for that. Could you explain more in details the model. Thanks
          – Alberto
          2 days ago




          Thanks for your answer, I was able to have the model in that format now. I'd ask you another clarification if possible. I edited my original question for that. Could you explain more in details the model. Thanks
          – Alberto
          2 days ago




          1




          1




          On stack-overflow, it's always best to start a different question instead of editing the original. Also, "accepting" the answer tells others the issue is resolved; both for people having similar issues and the people trying to help others out. Comments should be reserved only for the original discussion. So, please start a new question and I'm sure someone will answer!
          – Levent Erkok
          2 days ago






          On stack-overflow, it's always best to start a different question instead of editing the original. Also, "accepting" the answer tells others the issue is resolved; both for people having similar issues and the people trying to help others out. Comments should be reserved only for the original discussion. So, please start a new question and I'm sure someone will answer!
          – Levent Erkok
          2 days ago




















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239653%2fhow-get-a-a-value-from-a-lambda-expression%23new-answer', 'question_page');
          }
          );

          Post as a guest




















































































          Popular posts from this blog

          Full-time equivalent

          Bicuculline

          さくらももこ