Ask Your Question
0

satisfying assignments

asked 2014-09-02 13:22:13 -0500

Larry Moss gravatar image

updated 2014-09-02 13:53:55 -0500

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()
True

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
1

answered 2014-09-02 13:53:04 -0500

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

Comments

Thanks very much!

Larry Moss gravatar imageLarry Moss ( 2014-09-02 21:56:52 -0500 )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 06:13:52 -0500 )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

Stats

Asked: 2014-09-02 13:22:13 -0500

Seen: 105 times

Last updated: Sep 02 '14