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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:08:25+00:00 2026-06-09T11:08:25+00:00

I am trying to understand how the bound variables are indexed in z3 .

  • 0

I am trying to understand how the bound variables are indexed in z3.
Here in a snippet in z3py and the corresponding output. ( http://rise4fun.com/Z3Py/plVw1 )

x, y = Ints('x y')
f1 = ForAll(x, And(x == 0, Exists(y, x == y)))
f2 = ForAll(x, Exists(y, And(x == 0, x == y)))
print f1.body()
print f2.body()

Output:

ν0 = 0 ∧ (∃y : ν1 = y)
y : ν1 = 0 ∧ ν1 = y

In f1, why is the same bound variable x has different index.(0 and 1). If I modify the f1 and bring out the Exists, then x has the same index(0).

Reason I want to understand the indexing mechanism:

I have a FOL formula represented in a DSL in scala that I want to send to z3. Now ScalaZ3 has a mkBound api for creating bound variables that takes index and sort as arguments. I am not sure what value should I pass to the index argument. So, I would like to know the following:

If I have two formulas phi1 and phi2 with maximum bound variable indexes n1 and n2, what would be the index of x in ForAll(x, And(phi1, phi2))

Also, is there a way to show all the variables in an indexed form? f1.body() just shows me x in indexed form and not y. (I think the reason is that y is still bound in f1.body())

  • 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-09T11:08:27+00:00Added an answer on June 9, 2026 at 11:08 am

    Z3 encodes bound variables using de Bruijn indices.
    The following wikipedia article describes de Bruijn indices in detail:
    http://en.wikipedia.org/wiki/De_Bruijn_index
    Remark: in the article above the indices start at 1, in Z3, they start at 0.

    Regarding your second question, you can change the Z3 pretty printer.
    The Z3 distribution contains the source code of the Python API. The pretty printer is implemented in the file python\z3printer.py.
    You just need to replace the method:

    def pp_var(self, a, d, xs):
        idx = z3.get_var_index(a)
        sz  = len(xs)
        if idx >= sz:
            return seq1('Var', (to_format(idx),))
        else:
            return to_format(xs[sz - idx - 1])
    

    with

    def pp_var(self, a, d, xs):
        idx = z3.get_var_index(a)
        return seq1('Var', (to_format(idx),))
    

    If you want to redefine the HTML pretty printer, you should also replace.

    def pp_var(self, a, d, xs):
        idx = z3.get_var_index(a)
        sz  = len(xs)
        if idx >= sz:
            # 957 is the greek letter nu
            return to_format('&#957;<sub>%s</sub>' % idx, 1)
        else:
            return to_format(xs[sz - idx - 1])
    

    with

    def pp_var(self, a, d, xs):
        idx = z3.get_var_index(a)
        return to_format('&#957;<sub>%s</sub>' % idx, 1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to understand the Deezer API. When I visit: http://connect.deezer.com/oauth/auth.php?app_id=MY_APP_ID&redirect_uri=http://mydomain.me&perms=basic_access I end up at
Trying to understand the math of this code snippet. A token is provided which
Trying to understand free-identifier=? and bound-identifier=?. Can anyone give me equivalent code examples where
I'm trying to understand some String class functions in Java. So, here's is a
I was trying to understand the Using Messenger in Bound Service example in Android
I am trying understand ViewModels deeper and I have read many articles and blogs
Trying to understand what's the correct way of implementing OpenID authentication with Spring Security.
Trying to understand PNG format. Consider this PNG Image: The Image is taken from
Trying to understand the options for will_paginate's paginate method: :page — REQUIRED, but defaults
Trying to understand Ruby a bit better, I ran into this code surfing the

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.