Giter VIP home page Giter VIP logo

truth-table-generator's Introduction

Truth-Table-Generator

This is a very simple truth-table generator for 3 and 4-valued logics that I made for solving homework one evening when I was bored. It also can be used to check entailments, as long as your formula doesn't have too many variables.

It uses lark-parser to parse the input formulas, which was very quick and easy to set up. After parsing the formula, the program will iterate over all possible assignments to the variables in the formula and recursively find the truth values of all connectives, and the entailment.

Suported Logics

  1. CPL - Classical propositional logic, the boolean logic we all know and love.
  2. K3 - Kleen's 3-valued logic
  3. B3 - Bochvar's internal 3-valued logic
  4. LP - Priest's logic of paradox
  5. L3 - Łukasiewicz's 3-valued logic
  6. RM3 - R-mingle 3-valued logic
  7. FDE - Belnap 4-valued logic, first degree entailment

Dependancies

  • python3
  • lark-parser

Instructions

To install the lark-parser dependancy:

$ pip install lark-parser

To run the program:

$ python3 ttable.py

Syntax Reference

operator
~p not p
p & q p and q
p | q p or q
p -> q p implies q
p <-> q p is equivalent to q
atom
p any sequence of lowercase characters is a variable
1 or T true
0 or F false
I or U unspecified for 3-valued logic
B both true and false for 4 valued logic
N neither true nor false for 4 valued logic
entailment
p |= q p entails q in classic propositional logic (CPL)
p |=L q p entails q in logic "L" (see above)
|= p p is a tautology in classical propositional logic
|=L p p is a tautology in logic "L" (see above)

Example

Checks if the entailment ¬p ∨ q ⊨ p → q holds in K3.

> ~p | q |=K3 p -> q

  (~p | q) |=K3 (p -> q)
..........................
   10 1 0   1    0 1  0
   10 1 i   1    0 1  i
   10 1 1   1    0 1  1
   ii i 0   1    i i  0
   ii i i   1    i i  i
   ii 1 1   1    i 1  1
   01 0 0   1    1 0  0
   01 i i   1    1 i  i
   01 1 1   1    1 1  1

entailment always holds

truth-table-generator's People

Contributors

blat-blatnik avatar

Watchers

 avatar

truth-table-generator's Issues

How is this supposed to work?

Hello! I came across this page yesterday and it seemed to me very interesting, but I could not figure out how this program works. For example, I try to generate a table of just "~p & q" and there are issues with code. However your example works... So can this generator help in creating simple CPL truth tables? If so, how do I enter a query into the input line?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.