(Z3Py) declaring function

Viewed 4105

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 Answers
Related