assume certain properties of the output of a function

asked 2016-06-20 17:11:32 -0500

twosan gravatar image

updated 2016-06-21 14:57:01 -0500


I've just started using SAGE and I want to "declare" a symbolic function f(t) and to be able to hint that f(t) > 5 && f(t) < 100, for any value of t (the values are just for the purpose of example).

I know I can use assume for variables, but it seems it doesn't also work on functions, so I'm trying to see what alternatives I have left.

I have thought of "defining" the function f(t), with some mock values which don't contradict my assumptions(I don't actually know f(t), I only know some of it's properties), but I'm not sure how to force sage not to expand the function. I have tried f(t, hold=True) but it didn't seem to work(while this works for the default functions like sin).

Edit: Upon the comment made by @eric_g I add the following information:

f = function('f') ; t = var('t')
(f(t) > 4).assume()
print('a) bool(f(3)>5) : '+str(bool(f(3)>5)))
print('b) bool(f(3)>4) : '+str(bool(f(3)>4)))
print('c) bool(f(2)>5) : '+str(bool(f(2)>5)))
print('d) bool(f(t)>5) : '+str(bool(f(t)>5)))


[f(t) > 4, f(3) > 5, t > 1, f(t) > 5]
a) bool(f(3)>5) : True
b) bool(f(3)>4) : False
c) bool(f(2)>5) : False
d) bool(f(t)>5) : False

Two things puzzle me:

  • How to get "c)" and "d)" to return true
  • While "a)" returns true probably due to the second assumption, I would expect "b)" to also be true

Is the behavior I'm seeing incorrect, or am I just using SAGE wrong?


edit retag flag offensive close merge delete



What is weird is that the assumption does appear in the list returned by assumtions() but it is not effective:

sage: f = function('f') ; t = var('t')
sage: assume(f(t)>5)
sage: assumptions()
[f(t) > 5]
sage: bool(f(t)>5)
eric_g gravatar imageeric_g ( 2016-06-21 03:19:49 -0500 )edit

I don't think that this is supported, other than that since f(t) is technically symbolic the means by which we assign assumptions don't give an error. Note that assume(f>5) gives an error.

kcrisman gravatar imagekcrisman ( 2016-06-22 12:59:24 -0500 )edit