项目作者: leomariga

项目描述 :
A python tool for logic clauses analysis and binary operations
高级语言: Jupyter Notebook
项目地址: git://github.com/leomariga/pyTruthTable.git
创建时间: 2019-09-06T16:31:48Z
项目社区:https://github.com/leomariga/pyTruthTable

开源协议:MIT License

下载






PyPI Latest Release
License

What is pyTruthTable?

pyTruthTable is a python library to create logical tables and make relations between its elements. It makes possible prepositional logic clauses analysis and binary operations to be used in classic logical problems.

Features:

  • Uses Pandas Dataframe.
  • Big set of logic operations.
  • Simplified function calls.
  • Automatic column naming.
  • Customizible appearence.

Installation

Requirements: Python 3 and Pandas.

Install with Pypi:

  1. pip3 install pyTruthTable

Take a look:

Example 1 - Binary operations
  1. import pyTruthTable as ptt
  2. # Initialize
  3. t_table = ptt.PyTruthTable(["A", "B"])
  4. # Create relations
  5. t_table.append("not", "A")
  6. t_table.append("and", "A", "B")
  7. t_table.append("or", 2, "B") # Use the column index or name
  8. t_table.append("xor", -2, -1)
  9. t_table.append("nand", -1, 0, name = "C") # Rename column
  10. t_table.append("equals", "C", "A")
A B ¬ A A ^ B ¬ A v B (A ^ B) ⊕ (¬ A v B) C C ↔ A
True True False True True False True True
True False False False False False True True
False True True False True True True False
False False True False True True True False
Example 2 - Prepositional logic clauses
  1. import pyTruthTable as ptt
  2. # Initialize
  3. tt = ptt.PyTruthTable(["Hot", "Wet", "Rains"])
  4. # Append new column with specified operation
  5. tt.append("and", "Hot", "Wet")
  6. tt.append("implies", 3, "Rains")
Hot Wet Rains Hot ^ Wet (Hot ^ Wet) → (Rains)
True True True True True
True True False True False
True False True False True
True False False False True
False True True False True
False True False False True
False False True False True
False False False False True

See more examples here

License

MIT

Contributing is awesome!

See CONTRIBUTING

Contact

Developed with :heart: by Leonardo Mariga

leomariga@gmail.com

Did you like it? Remember to click on :star2: button.