Quantcast
Channel: Keep the gradient flowing
Viewing all articles
Browse latest Browse all 195

Fun with the new Logic module

$
0
0

The logic module is slowly becoming useful. This week I managed to get some basic inference in propositional logic working. This should be enough for the assumption sysmtem (although having first-order inference would be cool). You can pull from my branch: `` git pull http://fseoane.net/git/sympy.git logic`` Here are some examples of what it can do: First, importing and defining our symbols

In [1]: A, B, C = symbols('ABC')
In [2]: from sympy.logic import *

It works with Symbols just as you would expect

In [3]: And(A, B)
Out[3]: And(A, B)

It applies De Morgan Rules automatically

In [4]: Not(Or(A, B))
Out[4]: And(Not(A), Not(B))

converts to conjuntive normal form (CNF)

In [5]: to_cnf(Implies(A, And(B, C)))
Out[5]: And(Or(B, Not(A)), Or(C, Not(A)))

Some basic inference:

In [6]: pl_true( Or(A, B), {A : True})  # what can we say about Or(A, B) if A is True ?
Out[6]: True

In [7]: pl_true ( And(A, B), {B: False}) # what is And(A, B) if B is False
Out[7]: False

To be discussed: - I'm not sure if we should override &&, || on Symbol so that we can do A && B instead of And(A, B). If would make the code cleaner, but also I don't want to bloat Symbol any more. What do you think ? I'm very proud of this in the sense that it is a nice clean module that will hopefully serve as the foundation of the new assumption system.


Viewing all articles
Browse latest Browse all 195

Trending Articles


Girasoles para colorear


mayabang Quotes, Torpe Quotes, tanga Quotes


Tagalog Quotes About Crush – Tagalog Love Quotes


OFW quotes : Pinoy Tagalog Quotes


Long Distance Relationship Tagalog Love Quotes


Tagalog Quotes To Move on and More Love Love Love Quotes


5 Tagalog Relationship Rules


Best Crush Tagalog Quotes And Sayings 2017


Re:Mutton Pies (lleechef)


FORECLOSURE OF REAL ESTATE MORTGAGE


Sapos para colorear


tagalog love Quotes – Tiwala Quotes


Break up Quotes Tagalog Love Quote – Broken Hearted Quotes Tagalog


Patama Quotes : Tagalog Inspirational Quotes


Pamatay na Banat and Mga Patama Love Quotes


Tagalog Long Distance Relationship Love Quotes


BARKADA TAGALOG QUOTES


“BAHAY KUBO HUGOT”


Vimeo 10.7.0 by Vimeo.com, Inc.


Vimeo 10.7.1 by Vimeo.com, Inc.