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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:56:28+00:00 2026-05-27T07:56:28+00:00

How do I calculate attributed values? Here’s an example: (declare-fun x () bool) (declare-fun

  • 0

How do I calculate attributed values?
Here’s an example:

(declare-fun x () bool)
(declare-fun y () bool)
(declare-fun z () bool)
(assert (AND x (OR y z)))

With this I would get 2 models:

x=true and y=true
x=true and z=true

Now, what I want is something like this:

(declare-fun x () bool)
(declare-fun y () bool)
(declare-fun z () bool)
(declare-fun x.val () Int)
(declare-fun y.val () Int)
(declare-fun z.val () Int)
(assert (= x.val 2))
(assert (= y.val 3))
(assert (= z.val 5))
(assert (AND x (OR y z)))
(assert (> sum 6))

So, I would like to get the model where the sum of the attributes is larger than 6:

x=true and z=true

Maybe working with arrays is a way to achieve this…

  • 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-05-27T07:56:28+00:00Added an answer on May 27, 2026 at 7:56 am

    I’m not sure if I understood your question correctly.
    It seems you want to associate an (integer) attribute to each Boolean variable.
    So, each variable is a pair: a Boolean value, and an integer attribute.
    I’m assuming that by sum , you meant the sum of the attributes of the variables assigned to true.
    If that is the case, you can model it in Z3 in the following way:

    ;; Enable model construction
    (set-option :produce-models true)
    
    ;; Declare a new type (sort) that is a pair (Bool, Int).
    ;; Given a variable x of type/sort WBool, we can write
    ;;  - (value x) for getting its Boolean value
    ;;  - (attr x)  for getting the integer "attribute" value
    (declare-datatypes () ((WBool (mk-wbool (value Bool) (attr Int)))))
    
    ;; Now, we declare a macro int-value that returns (attr x) if
    ;; (value x) is true, and 0 otherwise
    (define-fun int-value ((x WBool)) Int
      (ite (value x) (attr x) 0))
    
    (declare-fun x () WBool)
    (declare-fun y () WBool)
    (declare-fun z () WBool)
    
    ;; Set the attribute values for x, y and z
    (assert (= (attr x) 2))
    (assert (= (attr y) 3))
    (assert (= (attr z) 5))
    
    ;; Assert Boolean constraint on x, y and z.
    (assert (and (value x) (or (value y) (value z))))
    
    ;; Assert that the sum of the attributes of the variables assigned to true is greater than 6.
    (assert (> (+ (int-value x) (int-value y) (int-value z)) 6))
    (check-sat)
    (get-model)
    
    (assert (not (value z)))
    (check-sat)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of p-values and I would like to calculate the adjust
I need to calculate Math.exp() from java very frequently, is it possible to get
RSpec newbie here. I'm trying to test my models, which have methods that uses
I have the following model: class A(models.Model): name = models.CharField(max_length=50) content_type = models.ForeignKey(ContentType) This
HI, I need to calculate values of two textboxex in gridview and display the
I have a table like this (basic example, not the real thing): FKEY |
To calculate a top position for an element of variable height, I was thinking
How can I calculate the value of PI using C#? I was thinking it
How do I calculate the distance between two points specified by latitude and longitude?
How do I calculate the CRC32 (Cyclic Redundancy Checksum) of a string in .NET?

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.