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

The Archive Base Latest Questions

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

I would like to find c and t coefficients in simple result=x*t+c formula for

  • 0

I would like to find c and t coefficients in simple “result=x*t+c” formula for some given result/x pairs:

from z3 import *

x=Int('x')
c=Int('c')
t=Int('t')

s=Solver()

f = Function('f', IntSort(), IntSort())

# x*t+c = result
# x, result = [(1,55), (12,34), (13,300)]

s.add (f(x)==(x*t+c))
s.add (f(1)==55, f(12)==34, f(13)==300)

t=s.check()
if t==sat:
    print s.model()
else:
   print t

… but the result is obviously wrong. I probably need to find out how to map function arguments.

How should I define function correctly?

  • 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:35:23+00:00Added an answer on June 9, 2026 at 11:35 am

    The assertion f(x) == x*t + c is not defining the function f for all x. It is just saying that the value of f for the given x is x*t + c. Z3 supports universal quantifiers. However, they are very expensive, and Z3 is not complete when a set of constraints contains universal quantifiers since the problem becomes undecidable. That is, Z3 may return unknown for this kind of problem.

    Note that f is essentially a “macro” in your script. Instead of using a Z3 function for encoding this “macro”, we can create a Python function that does the trick. That is, a Python function that, given a Z3 expression, returns a new Z3 expression. Here is a new script. The script is also available online at: http://rise4fun.com/Z3Py/Yoi
    Here is another version of the script where c and t are Real instead of Int: http://rise4fun.com/Z3Py/uZl

    from z3 import *
    
    c=Int('c')
    t=Int('t')
    
    def f(x):
        return x*t + c
    
    # data is a list of pairs (x, r)
    def find(data):
        s=Solver()
        s.add([ f(x) == r for (x, r) in data ])
        t = s.check()
        if s.check() == sat:
            print s.model()
        else:
            print t
    
    find([(1, 55)])
    find([(1, 55), (12, 34)])
    find([(1, 55), (12, 34), (13, 300)])
    

    Remark: In the SMT 2.0 front-end, macros can be defined using the command define-fun.

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

Sidebar

Related Questions

I would like to find the values of some of windows API constants, such
I would like to find any files within a given root that contain arbitrary
I would like to find a simple way to access the maximum value of
I would like to find out if my database is running or not from
I would like to find the size of an ImageView from the start of
I would like to find all changesets that are a merge from branchX to
would like to find all the nearby places for a given place or address.
I would like to find the distance of every pixel coordinate in an image
I would like to find out which version of an executable the CMD shell
I would like to find a way to store multiple addresses for one subject

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.