Ask Your Question
0

How to get the variables present in an boolean expression

asked 2014-08-09 21:21:15 -0500

pp gravatar image

updated 2014-08-10 01:15:41 -0500

Consider the boolean variables x, y and z.

I need something like

 sage: variables(x+yz)
 [x, y, z]
 sage: variables(x+z)
 [x, z]

What should I do?

For a starting point, you may like (copied from the answer given here):

sage: R = BooleanPolynomialRing(3, 'x')
sage: x, y, z = R.gens()
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2014-08-10 03:20:59 -0500

FrédéricC gravatar image

updated 2014-08-10 07:49:57 -0500

You should read the doc before asking such questions here.

In particular, give a name to your object and use the automatic TAB-completion to get the list of available methods. In this way, you can learn about the methods .degree and .variables by hitting the TAB key after too.

sage: sage: R = BooleanPolynomialRing(3, 'x')
sage: sage: x, y, z = R.gens()
sage: too = x+z
sage: sage: too.v   # (pressing TAB key here)
too.variable          too.vars_as_monomial  
too.variables         too.version           
sage: too.variables()
(x0, x2)
sage: len(too.variables())
2
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

1 follower

Stats

Asked: 2014-08-09 21:21:15 -0500

Seen: 85 times

Last updated: Aug 10 '14