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 9311027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:15:42+00:00 2026-06-19T01:15:42+00:00

I wanted to ask a question about assigning distinct values in Z3. suppose that

  • 0

I wanted to ask a question about assigning distinct values in Z3.

suppose that I have 6 variables A,B,C,D,E,F.
Now, I would like to assign distinct values to some of them and some of them will be zero. How many variables will be distinct and how many variables are zero is unknown before-hand. It depends on certain other conditions.

generally for all the variables I shall write

(assert (distinct A B C D E F))

However is it possible to write constraint such as A, B, D are zero and others are distinct? Again remember that A,B, D are just example variables. They can change dynamically depending on the constraints.

Thanks !

  • 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-19T01:15:43+00:00Added an answer on June 19, 2026 at 1:15 am

    As far as I understand, you have a set V of variables v1, …, vn, where each variable vi is either zero or different from all other variables vj, j ≠ i.

    As an example, let V = {a, b, c, d}.

    (declare-const a Int)
    (declare-const b Int)
    (declare-const c Int)
    (declare-const d Int)
    

    You could encode your constraints as

    (assert (or (= a 0) (not (or (= a b) (= a c) (= a d)))))
    (assert (or (= b 0) (not (or (= b a) (= b c) (= b d)))))
    (assert (or (= c 0) (not (or (= c a) (= c b) (= c d)))))
    (assert (or (= d 0) (not (or (= d a) (= d b) (= d c)))))
    

    Adding two constraints and querying Z3 for a model

    (assert (= a 0))
    (assert (not (= b 0)))
    
    (check-sat)
    (get-model)
    

    then yields

    sat
    (model 
      (define-fun b () Int
        (- 2))
      (define-fun c () Int
        (- 1))
      (define-fun d () Int
        0)
      (define-fun a () Int
        0)
    )
    

    Since generating the “zero or distinct” constraints is a tedious task you’d probably want to work with a Z3 front-end such as PyZ3 or Scala^Z3.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to ask you a question about 301 URL redirection. So, I have
I wanted to ask a question about server data. I am new to server
I wanted to ask a clever question about using Canvas as a container, but
I was reading this question , I wanted to ask more about the code
I was about to ask another question on SO that this question popped up
I understand that this is a very long question, but i wanted to ask
I want to ask a question about the JavaScript event. I have an <input
This isn't really a coding question, but I wanted to ask about what is
I am Studying PHP, and i wanted to ask about references, My question: What
(I am sorry, I wanted to ask this question on meta first, but it

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.