16bitmood / prologic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prologic

A propostional logic statement evaluator and truth table generator

Installation:

  1. cd to project root
  2. pip install .

Usage:

[~] >> prologic
=========================
*Prologic :

- A Propositional Logic Statement Evaluator.
- Options:
(d) enable debug mode
(e) for examples
(h) to display this msg
(i) to evaluate at a given input
(q) to quit
>> 

Features:

  • Generate Truth Table of a given logic statement
  • Supports unicode input, p⇒q
  • Evaluate logic statements at given input

Examples:

>> !p
---------------------
         p|        ¬p
---------------------
         1|         0
         0|         1
---------------------

>> p -> q
--------------------------------
         q|         p|       p⇒q
--------------------------------
         1|         1|         1
         1|         0|         1
         0|         1|         0
         0|         0|         1
--------------------------------

>> p & q | r
------------------------------------------------------
         r|         q|         p|       q∨r|   p∧(q∨r)
------------------------------------------------------
         1|         1|         1|         1|         1
         1|         1|         0|         1|         0
         1|         0|         1|         1|         1
         1|         0|         0|         1|         0
         0|         1|         1|         1|         1
         0|         1|         0|         1|         0
         0|         0|         1|         0|         0
         0|         0|         0|         0|         0
------------------------------------------------------

Development

File Structure:

  • propy/
    • tokens.py
      • Var, SYMBOLS
    • lexer.py
      • lex(src)
    • my_parser.py parser is a built-in module, so we name this file my_parser
      • parse(tokens)
    • evaluator.py
      • evaluate(expr)
    • truth_table.py
      • truth_table(expr)

About

License:MIT License


Languages

Language:Python 100.0%