Ask Your Question
1

Verifying inequalities

asked 2018-12-12 05:41:14 +0100

Erel Segal-Halevi gravatar image

I would like to give SageMath some inequalities, and then ask it if other inequalities follow from them.

For example, I would like to tell SageMath "a > 2b > 0" and then ask it whether "a - b > b/2" and the answer should be "True", but if I ask whether "a - b > 3b/2" the answer should be "False" (since it is not implied by the given inequalities).

How can I do this?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2018-12-12 09:46:42 +0100

tmonteil gravatar image

If the inequalities are linear (as in your example), you can define a polyhedron P from them. Then given a new inequality, it also defines a polyhedron Q (a half space), and ask wether this new polyhedron Q contains the initial one P.

You can define polytopes fro inequalities using the Polyhedron(ieqs=...) syntax, see, for example:

To test that Q contains P, you can do:

sage: P.intersection(Q) == P

Note that inequalities have to be large (<=), not strict (<). If you absolutely want to test strict inequalities, you can use vertices and test inclusion in the interior, using P.interior_contains method.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-12-12 05:41:14 +0100

Seen: 812 times

Last updated: Dec 12 '18