Ask Your Question
0

satisfying assignments

asked 10 years ago

Larry Moss gravatar image

updated 10 years ago

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 10 years ago

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]
Preview: (hide)
link

Comments

Thanks very much!

Larry Moss gravatar imageLarry Moss ( 10 years ago )

@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 ( 10 years ago )

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: 10 years ago

Seen: 849 times

Last updated: Sep 02 '14