https://github.com/leomariga/pytruthtable
A python tool for logic clauses analysis and binary operations
https://github.com/leomariga/pytruthtable
pandas pandas-dataframe python table truth truth-table truth-table-generator
Last synced: 6 months ago
JSON representation
A python tool for logic clauses analysis and binary operations
- Host: GitHub
- URL: https://github.com/leomariga/pytruthtable
- Owner: leomariga
- License: mit
- Created: 2019-09-06T16:31:48.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-02T00:32:47.000Z (over 5 years ago)
- Last Synced: 2025-04-02T00:38:11.625Z (6 months ago)
- Topics: pandas, pandas-dataframe, python, table, truth, truth-table, truth-table-generator
- Language: Jupyter Notebook
- Homepage: https://leomariga.github.io/pyTruthTable/
- Size: 610 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
-----------------
[](https://pypi.org/project/pyTruthTable/)
[](https://github.com/leomariga/pyTruthTable/blob/master/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](https://github.com/pandas-dev/pandas).Install with [Pypi](https://pypi.org/project/pyTruthTable/):
```sh
pip3 install pyTruthTable
```### Take a look:
##### Example 1 - Binary operations
``` python
import pyTruthTable as ptt# Initialize
t_table = ptt.PyTruthTable(["A", "B"])# Create relations
t_table.append("not", "A")
t_table.append("and", "A", "B")
t_table.append("or", 2, "B") # Use the column index or name
t_table.append("xor", -2, -1)
t_table.append("nand", -1, 0, name = "C") # Rename column
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
``` python
import pyTruthTable as ptt# Initialize
tt = ptt.PyTruthTable(["Hot", "Wet", "Rains"])# Append new column with specified operation
tt.append("and", "Hot", "Wet")
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
## Documentation & other links
- The [amazing documentation is this Ṕage](https://leomariga.github.io/pyTruthTable/).
- Source code in the [Github repository](https://github.com/leomariga/pyTruthTable).
- [Pypi pakage installer](https://pypi.org/project/pyTruthTable/)## License
[MIT](https://github.com/leomariga/pyTruthTable/blob/master/LICENSE)## Contributing is awesome!
See [CONTRIBUTING](https://github.com/leomariga/pyTruthTable/blob/master/CONTRIBUTING.md)
## Contact
Developed with :heart: by [Leonardo Mariga](https://github.com/leomariga)
leomariga@gmail.com
Did you like it? Remember to click on :star2: button.