Ask Your Question

satisfying assignments

asked 2014-09-02 20:22:13 +0200

Larry Moss gravatar image

updated 2014-09-02 20:53:55 +0200

tmonteil gravatar image

sage.logic.propcalc allows one to see if a sentence in propositional logic is satisfiable.

The documentation has

sage: f = propcalc.formula("a|b")
sage: f.is_satisfiable()

Is there a syntax that would give a satisfying assignment? I'd like something like

sage: f.is_satisfiable(show)
a:=True, b:=True

The documentation doesn't give the syntax, but I'm betting it's there somewhere.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-09-02 20:53:04 +0200

tmonteil gravatar image

As you can see, the is_satisfiable() method uses the truthtable() method to find the answer. You can do the same and print satisfying assignments:

sage: for row in f.truthtable().get_table_list()[1:]:
....:     if row[-1]:
....:         print row[:-1]
[False, True]
[True, False]
[True, True]
edit flag offensive delete link more


Thanks very much!

Larry Moss gravatar imageLarry Moss ( 2014-09-03 04:56:52 +0200 )edit

@Larry Moss: you can click the check-mark at the top-left of the anwser to mark it as the accepted answer.

slelievre gravatar imageslelievre ( 2014-09-04 13:13:52 +0200 )edit

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


Asked: 2014-09-02 20:22:13 +0200

Seen: 396 times

Last updated: Sep 02 '14