Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7951797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:40:13+00:00 2026-06-04T02:40:13+00:00

Does z3 provide a cross product function for two lists? If not is it

  • 0

Does z3 provide a cross product function for two lists? If not is it possible to define one without using higher order functions or using the provided list functions? I have been having trouble trying to define one. I know how to define one using map but I don’t think that is supported in z3.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:40:14+00:00Added an answer on June 4, 2026 at 2:40 am

    You can declare the cross product function in SMT 2.0.
    However, any non-trivial property will require a proof by induction. Z3 currently does not support proofs by induction. Thus, it will only be able to prove very simple facts.
    BTW, by cross-product of lists, I’m assuming you want a function that given the lists [a, b] and [c, d] returns the list or pairs [(a, c), (a, d), (b, c), (b, d)].
    Here is a script that defines the product function.
    The script also demonstrates some limitations of the SMT 2.0 language. For example, SMT 2.0 does not support the definition of parametric axioms or functions. So, I used uninterpreted sorts to “simulate” that. I also had to define the auxiliary functions append and product-aux. You can try this example online at: http://rise4fun.com/Z3/QahiP

    The example also proves the following trivial fact that if l = product([a], [b]), then first(head(l)) must be a.

    If you are insterested in proving non-trivial properties. I see two options. We can try to prove the base case and inductive cases using Z3. The main disadvantage in this approach is that we have to manually create these cases, and mistakes can be made. Another option is to use an interactive theorem prover such as Isabelle. BTW, Isabelle has a much richer input language, and provides tactics for invoking Z3.

    For more information about algebraic datatypes in Z3, go to the online tutorial http://rise4fun.com/Z3/tutorial/guide (Section Datatypes).

    ;; List is a builtin datatype in Z3
    ;; It has the constructors insert and nil
    
    ;; Declaring Pair type using algebraic datatypes
    (declare-datatypes (T1 T2) ((Pair (mk-pair (first T1) (second T2)))))
    
    ;; SMT 2.0 does not support parametric function definitions.
    ;; So, I'm using two uninterpreted sorts.
    (declare-sort T1)
    (declare-sort T2)
    ;; Remark: We can "instantiate" these sorts to interpreted sorts (Int, Real) by replacing the declarations above
    ;; with the definitions
    ;; (define-sort T1 () Int)
    ;; (define-sort T2 () Real)
    
    (declare-fun append ((List (Pair T1 T2)) (List (Pair T1 T2))) (List (Pair T1 T2)))
    ;; Remark: I'm using (as nil (Pair T1 T2)) because nil is overloaded. So, I must tell which one I want.
    (assert (forall ((l (List (Pair T1 T2)))) 
                    (= (append (as nil (List (Pair T1 T2))) l) l)))
    (assert (forall ((h (Pair T1 T2)) (t (List (Pair T1 T2))) (l (List (Pair T1 T2))))
                    (= (append (insert h t) l) (insert h (append t l)))))
    
    ;; Auxiliary definition
    ;; Given [a, b, c], d  returns [(a, d), (b, d), (c, d)] 
    (declare-fun product-aux ((List T1) T2) (List (Pair T1 T2)))
    (assert (forall ((v T2))
                    (= (product-aux (as nil (List T1)) v)
                       (as nil (List (Pair T1 T2))))))
    (assert (forall ((h T1) (t (List T1)) (v T2))
                    (= (product-aux (insert h t) v)
                       (insert (mk-pair h v) (product-aux t v)))))
    
    (declare-fun product ((List T1) (List T2)) (List (Pair T1 T2)))
    
    (assert (forall ((l (List T1)))
                    (= (product l (as nil (List T2))) (as nil (List (Pair T1 T2))))))
    
    (assert (forall ((l (List T1)) (h T2) (t (List T2)))
                    (= (product l (insert h t))
                       (append (product-aux l h) (product l t)))))
    
    (declare-const a T1)
    (declare-const b T2)
    (declare-const l (List (Pair T1 T2)))
    
    (assert (= (product (insert a (as nil (List T1))) (insert b (as nil (List T2))))
               l))
    
    (assert (not (= (first (head l)) a)))
    
    (check-sat)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does Lua provide a function to make the first character in a word uppercase
Silverlight does not provide perfmon counters for GC. How do i get GC Information?
Is there an API (Twitter API does not provide this) that I can use
Since the latest version of NSS does not provide the SSLSample program, I copied
How does Google Chrome command and control multiple cross platform processes and provide a
Does hibernate provide a method that returns an object's state (transient, persistent, detached)?
Does Facebook provide a URL the user can access that will take him to
Does C# provide an effective means of scanning the available COM ports? I would
Does mysql provide a mechanism for storing and retrieving encrypted data? I don't mean
For example, does Apple provide NSString * const kCFBundleDisplayName somewhere? Or do I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.