Quantifier-free way to specify constructor of Z3 sum typeWhat methods does Z3 use to solve quantifier-free bit-vector formulas (QF_BV)?Equivalent Quantifier Free FormulasWhat is the correct way to handle quantified formulas with respect to empty models?Quantifier elimination for enumeration types in Z3Is z3 the most efficient solver for quantifier-free integer propositional logic?Is there a way to maximize sum using minimum entries from a list?What's the decision procedure for quantifier-free recursive lists in z3?z3 datatype matching without a quantifierWhat does “quantifier free logic” mean in SMT context?

Is it possible to have the age of the universe be unknown?

Extreme flexible working hours: how to control people and activities?

What setting controls moving the cursor on the command line?

How is water heavier than petrol, even though its molecular weight is less than petrol?

What speaks against investing in precious metals?

SQL counting distinct over partition

Geopandas and QGIS Calulating Different Polygon Area Values?

How can this tool find out registered domains from an IP?

Teaching a class likely meant to inflate the GPA of student athletes

Is using haveibeenpwned to validate password strength rational?

Are there any important biographies of nobodies?

How did old MS-DOS games utilize various graphic cards?

I have a problem assistant manager, but I can't fire him

How to use memset in c++?

Rebus with 20 song titles

Switch "when" cannot see constants?

Is it expected that a reader will skip parts of what you write?

Why we don’t make use of the t-distribution for constructing a confidence interval for a proportion?

Check if three arrays contains the same element

Why can my keyboard only digest 6 keypresses at a time?

How do I prevent employees from either switching to competitors or opening their own business?

Bent Peugeot Carbolite 103 Frame

What to do when surprise and a high initiative roll conflict with the narrative?

When would it be advantageous not apply Training Ground's cost reduction?



Quantifier-free way to specify constructor of Z3 sum type


What methods does Z3 use to solve quantifier-free bit-vector formulas (QF_BV)?Equivalent Quantifier Free FormulasWhat is the correct way to handle quantified formulas with respect to empty models?Quantifier elimination for enumeration types in Z3Is z3 the most efficient solver for quantifier-free integer propositional logic?Is there a way to maximize sum using minimum entries from a list?What's the decision procedure for quantifier-free recursive lists in z3?z3 datatype matching without a quantifierWhat does “quantifier free logic” mean in SMT context?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Let's say I have a simple sum type in Z3 with several constructors of different arities:



(declare-datatypes ()
((Foo bar
(baz (unbaz String))
(quux (unquux1 String) (unquux2 Int)))))


How can I assert that I know value of type Foo is a quux? I could introduce an existential over quux1 and quux2 but I'm wary of introducing seemingly unnecessary quantifiers. Is there a better way to assert this?










share|improve this question




























    0















    Let's say I have a simple sum type in Z3 with several constructors of different arities:



    (declare-datatypes ()
    ((Foo bar
    (baz (unbaz String))
    (quux (unquux1 String) (unquux2 Int)))))


    How can I assert that I know value of type Foo is a quux? I could introduce an existential over quux1 and quux2 but I'm wary of introducing seemingly unnecessary quantifiers. Is there a better way to assert this?










    share|improve this question
























      0












      0








      0








      Let's say I have a simple sum type in Z3 with several constructors of different arities:



      (declare-datatypes ()
      ((Foo bar
      (baz (unbaz String))
      (quux (unquux1 String) (unquux2 Int)))))


      How can I assert that I know value of type Foo is a quux? I could introduce an existential over quux1 and quux2 but I'm wary of introducing seemingly unnecessary quantifiers. Is there a better way to assert this?










      share|improve this question














      Let's say I have a simple sum type in Z3 with several constructors of different arities:



      (declare-datatypes ()
      ((Foo bar
      (baz (unbaz String))
      (quux (unquux1 String) (unquux2 Int)))))


      How can I assert that I know value of type Foo is a quux? I could introduce an existential over quux1 and quux2 but I'm wary of introducing seemingly unnecessary quantifiers. Is there a better way to assert this?







      z3 smt






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 24 at 17:52









      copumpkincopumpkin

      2,2921321




      2,2921321






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Existentials are rather harmless when assumed because the existentially quantified variables are directly instantiated and thus only entail additional symbols. That is, the second half of the snippet



          (declare-datatypes ()
          ((Foo bar
          (baz (unbaz String))
          (quux (unquux1 String) (unquux2 Int)))))

          (declare-const f Foo)

          (assert (exists ((s String) (i Int)) ;; Let f be a quux
          (= f (quux s i))
          ))

          (assert (= f (baz "test"))) ;; Also let f be a baz
          (check-sat) ;; UNSAT - as expected


          is equivalent to



          ...
          (declare-const _s String)
          (declare-const _i Int)
          (assert (= f (quux _s _i))) ;; Let f be a quux

          (assert (= f (baz "test"))) ;; Also let f be a baz
          (check-sat) ;; UNSAT - as expected


          If you're wary of existentials but not of foralls, then you could tag Foo values by axiomatising a mapping from Foo constructors to distinct tags:



          (set-option :smt.mbqi false)

          (declare-datatypes ()
          ((Foo bar
          (baz (unbaz String))
          (quux (unquux1 String) (unquux2 Int)))))

          ;; Declare a finite sort Foo_tag with three distinct elements
          (declare-datatypes () ((Foo_tag Foo_tag.bar Foo_tag.baz Foo_tag.quux)))

          ;; Alternatively, three distinct elements from an infinite sort such
          ;; as Int can be used. Either by choosing distinct but unspecified
          ;; values, as done below, or by directly choosing concrete values,
          ;; e.g. 1, 2, 3.
          ; (define-sort Foo_tag () Int)
          ; (declare-const Foo_tag.bar Foo_tag)
          ; (declare-const Foo_tag.baz Foo_tag)
          ; (declare-const Foo_tag.quux Foo_tag)
          ; (assert (distinct Foo_tag.bar Foo_tag.baz Foo_tag.quux))

          ;; Tagging function
          (declare-fun tag_of (Foo) Foo_tag)

          ;; Tagging axiom for bar ...
          (assert (= (tag_of bar) Foo_tag.bar))

          ;; ... baz ...
          (assert (forall ((s String)) (!
          (= (tag_of (baz s)) Foo_tag.baz)
          :pattern ((baz s))
          )))

          ;; ... and quux
          (assert (forall ((s String) (i Int)) (!
          (= (tag_of (quux s i)) Foo_tag.quux)
          :pattern ((quux s i))
          )))

          ;; Let's do some testing

          (declare-const f Foo)

          (assert (= (tag_of f) Foo_tag.quux)) ;; Tag f as a quux

          (push)
          (assert (= f bar))
          (check-sat) ;; UNSAT - as expected
          (pop)

          (push)
          (assert (= f (baz "test")))
          (check-sat) ;; UNSAT - as expected
          (pop)





          share|improve this answer























            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',
            autoActivateHeartbeat: false,
            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%2f55326751%2fquantifier-free-way-to-specify-constructor-of-z3-sum-type%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Existentials are rather harmless when assumed because the existentially quantified variables are directly instantiated and thus only entail additional symbols. That is, the second half of the snippet



            (declare-datatypes ()
            ((Foo bar
            (baz (unbaz String))
            (quux (unquux1 String) (unquux2 Int)))))

            (declare-const f Foo)

            (assert (exists ((s String) (i Int)) ;; Let f be a quux
            (= f (quux s i))
            ))

            (assert (= f (baz "test"))) ;; Also let f be a baz
            (check-sat) ;; UNSAT - as expected


            is equivalent to



            ...
            (declare-const _s String)
            (declare-const _i Int)
            (assert (= f (quux _s _i))) ;; Let f be a quux

            (assert (= f (baz "test"))) ;; Also let f be a baz
            (check-sat) ;; UNSAT - as expected


            If you're wary of existentials but not of foralls, then you could tag Foo values by axiomatising a mapping from Foo constructors to distinct tags:



            (set-option :smt.mbqi false)

            (declare-datatypes ()
            ((Foo bar
            (baz (unbaz String))
            (quux (unquux1 String) (unquux2 Int)))))

            ;; Declare a finite sort Foo_tag with three distinct elements
            (declare-datatypes () ((Foo_tag Foo_tag.bar Foo_tag.baz Foo_tag.quux)))

            ;; Alternatively, three distinct elements from an infinite sort such
            ;; as Int can be used. Either by choosing distinct but unspecified
            ;; values, as done below, or by directly choosing concrete values,
            ;; e.g. 1, 2, 3.
            ; (define-sort Foo_tag () Int)
            ; (declare-const Foo_tag.bar Foo_tag)
            ; (declare-const Foo_tag.baz Foo_tag)
            ; (declare-const Foo_tag.quux Foo_tag)
            ; (assert (distinct Foo_tag.bar Foo_tag.baz Foo_tag.quux))

            ;; Tagging function
            (declare-fun tag_of (Foo) Foo_tag)

            ;; Tagging axiom for bar ...
            (assert (= (tag_of bar) Foo_tag.bar))

            ;; ... baz ...
            (assert (forall ((s String)) (!
            (= (tag_of (baz s)) Foo_tag.baz)
            :pattern ((baz s))
            )))

            ;; ... and quux
            (assert (forall ((s String) (i Int)) (!
            (= (tag_of (quux s i)) Foo_tag.quux)
            :pattern ((quux s i))
            )))

            ;; Let's do some testing

            (declare-const f Foo)

            (assert (= (tag_of f) Foo_tag.quux)) ;; Tag f as a quux

            (push)
            (assert (= f bar))
            (check-sat) ;; UNSAT - as expected
            (pop)

            (push)
            (assert (= f (baz "test")))
            (check-sat) ;; UNSAT - as expected
            (pop)





            share|improve this answer



























              0














              Existentials are rather harmless when assumed because the existentially quantified variables are directly instantiated and thus only entail additional symbols. That is, the second half of the snippet



              (declare-datatypes ()
              ((Foo bar
              (baz (unbaz String))
              (quux (unquux1 String) (unquux2 Int)))))

              (declare-const f Foo)

              (assert (exists ((s String) (i Int)) ;; Let f be a quux
              (= f (quux s i))
              ))

              (assert (= f (baz "test"))) ;; Also let f be a baz
              (check-sat) ;; UNSAT - as expected


              is equivalent to



              ...
              (declare-const _s String)
              (declare-const _i Int)
              (assert (= f (quux _s _i))) ;; Let f be a quux

              (assert (= f (baz "test"))) ;; Also let f be a baz
              (check-sat) ;; UNSAT - as expected


              If you're wary of existentials but not of foralls, then you could tag Foo values by axiomatising a mapping from Foo constructors to distinct tags:



              (set-option :smt.mbqi false)

              (declare-datatypes ()
              ((Foo bar
              (baz (unbaz String))
              (quux (unquux1 String) (unquux2 Int)))))

              ;; Declare a finite sort Foo_tag with three distinct elements
              (declare-datatypes () ((Foo_tag Foo_tag.bar Foo_tag.baz Foo_tag.quux)))

              ;; Alternatively, three distinct elements from an infinite sort such
              ;; as Int can be used. Either by choosing distinct but unspecified
              ;; values, as done below, or by directly choosing concrete values,
              ;; e.g. 1, 2, 3.
              ; (define-sort Foo_tag () Int)
              ; (declare-const Foo_tag.bar Foo_tag)
              ; (declare-const Foo_tag.baz Foo_tag)
              ; (declare-const Foo_tag.quux Foo_tag)
              ; (assert (distinct Foo_tag.bar Foo_tag.baz Foo_tag.quux))

              ;; Tagging function
              (declare-fun tag_of (Foo) Foo_tag)

              ;; Tagging axiom for bar ...
              (assert (= (tag_of bar) Foo_tag.bar))

              ;; ... baz ...
              (assert (forall ((s String)) (!
              (= (tag_of (baz s)) Foo_tag.baz)
              :pattern ((baz s))
              )))

              ;; ... and quux
              (assert (forall ((s String) (i Int)) (!
              (= (tag_of (quux s i)) Foo_tag.quux)
              :pattern ((quux s i))
              )))

              ;; Let's do some testing

              (declare-const f Foo)

              (assert (= (tag_of f) Foo_tag.quux)) ;; Tag f as a quux

              (push)
              (assert (= f bar))
              (check-sat) ;; UNSAT - as expected
              (pop)

              (push)
              (assert (= f (baz "test")))
              (check-sat) ;; UNSAT - as expected
              (pop)





              share|improve this answer

























                0












                0








                0







                Existentials are rather harmless when assumed because the existentially quantified variables are directly instantiated and thus only entail additional symbols. That is, the second half of the snippet



                (declare-datatypes ()
                ((Foo bar
                (baz (unbaz String))
                (quux (unquux1 String) (unquux2 Int)))))

                (declare-const f Foo)

                (assert (exists ((s String) (i Int)) ;; Let f be a quux
                (= f (quux s i))
                ))

                (assert (= f (baz "test"))) ;; Also let f be a baz
                (check-sat) ;; UNSAT - as expected


                is equivalent to



                ...
                (declare-const _s String)
                (declare-const _i Int)
                (assert (= f (quux _s _i))) ;; Let f be a quux

                (assert (= f (baz "test"))) ;; Also let f be a baz
                (check-sat) ;; UNSAT - as expected


                If you're wary of existentials but not of foralls, then you could tag Foo values by axiomatising a mapping from Foo constructors to distinct tags:



                (set-option :smt.mbqi false)

                (declare-datatypes ()
                ((Foo bar
                (baz (unbaz String))
                (quux (unquux1 String) (unquux2 Int)))))

                ;; Declare a finite sort Foo_tag with three distinct elements
                (declare-datatypes () ((Foo_tag Foo_tag.bar Foo_tag.baz Foo_tag.quux)))

                ;; Alternatively, three distinct elements from an infinite sort such
                ;; as Int can be used. Either by choosing distinct but unspecified
                ;; values, as done below, or by directly choosing concrete values,
                ;; e.g. 1, 2, 3.
                ; (define-sort Foo_tag () Int)
                ; (declare-const Foo_tag.bar Foo_tag)
                ; (declare-const Foo_tag.baz Foo_tag)
                ; (declare-const Foo_tag.quux Foo_tag)
                ; (assert (distinct Foo_tag.bar Foo_tag.baz Foo_tag.quux))

                ;; Tagging function
                (declare-fun tag_of (Foo) Foo_tag)

                ;; Tagging axiom for bar ...
                (assert (= (tag_of bar) Foo_tag.bar))

                ;; ... baz ...
                (assert (forall ((s String)) (!
                (= (tag_of (baz s)) Foo_tag.baz)
                :pattern ((baz s))
                )))

                ;; ... and quux
                (assert (forall ((s String) (i Int)) (!
                (= (tag_of (quux s i)) Foo_tag.quux)
                :pattern ((quux s i))
                )))

                ;; Let's do some testing

                (declare-const f Foo)

                (assert (= (tag_of f) Foo_tag.quux)) ;; Tag f as a quux

                (push)
                (assert (= f bar))
                (check-sat) ;; UNSAT - as expected
                (pop)

                (push)
                (assert (= f (baz "test")))
                (check-sat) ;; UNSAT - as expected
                (pop)





                share|improve this answer













                Existentials are rather harmless when assumed because the existentially quantified variables are directly instantiated and thus only entail additional symbols. That is, the second half of the snippet



                (declare-datatypes ()
                ((Foo bar
                (baz (unbaz String))
                (quux (unquux1 String) (unquux2 Int)))))

                (declare-const f Foo)

                (assert (exists ((s String) (i Int)) ;; Let f be a quux
                (= f (quux s i))
                ))

                (assert (= f (baz "test"))) ;; Also let f be a baz
                (check-sat) ;; UNSAT - as expected


                is equivalent to



                ...
                (declare-const _s String)
                (declare-const _i Int)
                (assert (= f (quux _s _i))) ;; Let f be a quux

                (assert (= f (baz "test"))) ;; Also let f be a baz
                (check-sat) ;; UNSAT - as expected


                If you're wary of existentials but not of foralls, then you could tag Foo values by axiomatising a mapping from Foo constructors to distinct tags:



                (set-option :smt.mbqi false)

                (declare-datatypes ()
                ((Foo bar
                (baz (unbaz String))
                (quux (unquux1 String) (unquux2 Int)))))

                ;; Declare a finite sort Foo_tag with three distinct elements
                (declare-datatypes () ((Foo_tag Foo_tag.bar Foo_tag.baz Foo_tag.quux)))

                ;; Alternatively, three distinct elements from an infinite sort such
                ;; as Int can be used. Either by choosing distinct but unspecified
                ;; values, as done below, or by directly choosing concrete values,
                ;; e.g. 1, 2, 3.
                ; (define-sort Foo_tag () Int)
                ; (declare-const Foo_tag.bar Foo_tag)
                ; (declare-const Foo_tag.baz Foo_tag)
                ; (declare-const Foo_tag.quux Foo_tag)
                ; (assert (distinct Foo_tag.bar Foo_tag.baz Foo_tag.quux))

                ;; Tagging function
                (declare-fun tag_of (Foo) Foo_tag)

                ;; Tagging axiom for bar ...
                (assert (= (tag_of bar) Foo_tag.bar))

                ;; ... baz ...
                (assert (forall ((s String)) (!
                (= (tag_of (baz s)) Foo_tag.baz)
                :pattern ((baz s))
                )))

                ;; ... and quux
                (assert (forall ((s String) (i Int)) (!
                (= (tag_of (quux s i)) Foo_tag.quux)
                :pattern ((quux s i))
                )))

                ;; Let's do some testing

                (declare-const f Foo)

                (assert (= (tag_of f) Foo_tag.quux)) ;; Tag f as a quux

                (push)
                (assert (= f bar))
                (check-sat) ;; UNSAT - as expected
                (pop)

                (push)
                (assert (= f (baz "test")))
                (check-sat) ;; UNSAT - as expected
                (pop)






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 24 at 10:22









                Malte SchwerhoffMalte Schwerhoff

                9,49043061




                9,49043061





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55326751%2fquantifier-free-way-to-specify-constructor-of-z3-sum-type%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

                    밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

                    1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴