Skip to main content

A powerfull python tool to create truth tables for logical analysis

Project description



What is pyTruthTable?

This library uses Pandas's dataframe to create logical relations between it's columns. E.g. you can call l_implies(df, n ,m) that will return a dataframe column with the logical operation "implies" between the column m and n (m → n). The function also names header of the column joining both columns' name with the operation symbol.

How to use?

  • Download the file pyTruthTable.py in this repository
  • Import the methods using:
from pyTruthTable import * #Import all methods from pyTruthTable

Examples

Example 1

import pandas as pd
from pyTruthTable import * #Import all methods from pyTruthTable

# intialise firs columns.
df = pd.DataFrame({'A':[True, True, False, False],
                   'B':[True, False, True, False]})

# Create other collumns of the dataframe calling methods
df = df.join(l_implies(df, 0 ,1)) # Thrid   column: a->b
df = df.join(l_not(df, 1))        # Forth   column: not b
df = df.join(l_and(df, 0, 1))     # Fith    column: a and b
df = df.join(l_or(df, 0, 1))      # Sixth   column: a or b
df = df.join(l_equals(df, 4, 5))  # Seventh column: fith column <-> sixth column
print(df)
A B A → B ¬B A ^ B A ∨ B (A ^ B) ↔ (A ∨ B)
0 True True True False True True True
1 True False False True False True False
2 False True True False False True False
3 False False True True False False True

Example 2

import pandas as pd
from pyTruthTable import * #Import all methods from pyTruthTable

data = {'Hot':[True, True,True, True, False, False, False, False], # 0
        'Wet':[True, True, False, False, True, True, False, False], # 1
        'Rains':[True, False, True, False, True, False, True, False]} # 2
df = pd.DataFrame(data)

df = df.join(l_and(df,0,1)) # 3
df = df.join(l_implies(df,3,2)) # 4
df
Hot Wet Rains (Hot) ^ (Wet) ((Hot) ^ (Wet)) → (Rains)
0 True True True True True
1 True True False True False
2 True False True False True
3 True False False False True
4 False True True False True
5 False True False False True
6 False False True False True
7 False False False False True

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyTruthTable-0.0.1.tar.gz (5.5 kB view hashes)

Uploaded Source

Built Distribution

pyTruthTable-0.0.1-py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page