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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:41:17+00:00 2026-06-11T00:41:17+00:00

I’m trying to integrate z3py into my application. There are assertions that involve small

  • 0

I’m trying to integrate z3py into my application. There are assertions that involve small real numbers, such as

solver.add(x <= 1e-6)

Then I got the following error:

File "~/src/solver/z3.py", line 2001, in __le__
  a, b = _coerce_exprs(self, other)
File "~/src/solver/z3.py", line 846, in _coerce_exprs
  b = s.cast(b)
File "~/src/solver/z3.py", line 1742, in cast
  return RealVal(val, self.ctx)
File "~/src/solver/z3.py", line 2526, in RealVal
  return RatNumRef(Z3_mk_numeral(ctx.ref(), str(val), RealSort(ctx).ast), ctx)
File "~/src/solver/z3core.py", line 1774, in Z3_mk_numeral
  raise Z3Exception(lib().Z3_get_error_msg_ex(a0, err))
src.solver.z3types.Z3Exception: 'parser error'

While the assertion

solver.add(x <= 1e-4)

seems to be fine.

Therefore, I’m guessing that there is some sort of precision limitation in z3. If so, is there an option to let the first assertion go through?

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-11T00:41:18+00:00Added an answer on June 11, 2026 at 12:41 am

    There is no precision limitation in Z3. It can represent arbitrary precision rational numbers and algebraic numbers. Here is an example:

    print RealVal('1/10000000000000000000000000000')
    print simplify((RealVal('1/10') ** RealVal('10')) ** RealVal('10'))
    

    You can try it online at: http://rise4fun.com/Z3Py/ahJQ

    The function RealVal(a) converts a Python value into a Z3 real value. It uses the Z3 C API Z3_mk_numeral to accomplish that. This code is available in the z3.py file included in the Z3 distribution. The API Z3_mk_numeral expects a string which encodes a rational number in decimal format (e.g., ‘1.3’) or fractional format (e.g., ‘1/3’). Note that, scientific notation is not supported. To make RealVal(a) convenient for python users, we use the method str(a) to convert a into a string before invoking Z3_mk_numeral.
    Thus, users can also write RealVal(1), RealVal(1.2), etc.

    The second bit of information is that the statement solver.add(x <= 1e-4) is essentially a short hand for solver.add(x <= RealVal(1e-4)).

    Now, we can ask, why does the example works for 1e-4 but it doesn’t for 1e-6. The problem is the implementation of str in Python. str(1e-4) returns the string "0.0001" in decimal notation which is supported by Z3 Z3_mk_numeral, but str(1e-6) returns the string "1e-6" in scientific notation which is not supported by Z3_mk_numeral.

    print str(1e-4)
    print str(1e-6)
    

    Here is a link with the example above: http://rise4fun.com/Z3Py/C02q

    To avoid this issue, we should avoid numbers in scientific notation when creating Z3 expressions.
    I will see if I have time to add support for scientific notation in Z3_mk_numeral for the next version of Z3.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.