#proposition #calculator #truth-table #logic

logic_tracer

Recognize a logic proposition and trace its truth value, also generate a truth table (still in development)

9 releases

new 0.0.9 Apr 25, 2024
0.0.8 Mar 25, 2024
0.0.7 Jan 1, 2024
0.0.6 Dec 31, 2023

#298 in Math

Download history 1/week @ 2024-02-19 1/week @ 2024-02-26 147/week @ 2024-03-25 40/week @ 2024-04-01 146/week @ 2024-04-22

191 downloads per month

MIT license

45KB
280 lines

Algorithm
Logic Tracer

github crates.io docs.rs

Logic Traces is a simple crate that reads a logical proposition and interprets it to build the truth table and the AST of the proposition.

Makes use of regular expressions are used to validate the input and to tokenize the proposition.
Also implements the Shunting Yard Algorithm (not yet) to build the AST.

Examples

Check the examples direcotry to see how to use the crate.

cargo run --example <example name>

Roadmap

  • Read a logical proposition
  • Tokenize the proposition
  • Validate Input Tokens (only valid tokens)
    • Variables (only letters)
    • Logical Operators (and, or, not, implies, iff)
    • Mathematical Operators (add, sub, mul, div, pow)
    • Compounds (only numbers, variables, variable with subindex)
  • Parse the proposition (make sure it is valid)
  • Build the AST (Shunting Yard Algorithm) (use postfix notation)
  • Add notation to the AST (prefix, infix, postfix)
  • Solve proposition (evaluate the AST)
  • Add good looking output for truth table, ast, function, etc.
  • Reduce a proposition to its simplest form (boolean algebra)
    • Reagrupate Compounds (boolean algebra)
    • Apply De Morgan's laws (boolean algebra)
    • Apply distributive, associative and commutative laws (boolean algebra)
  • Add more examples
  • Add more tests
  • Improve documentation
  • Improve the import/export of the crate (to improve it's usability as a library)

Considerations

  • Add some parallel computation (to improve the performance)

Future

  • Add comlex math iteration (sums, products, etc.) (to be able to solve more complex propositions)
    • Test a proposition with complex math iteration
  • Add combinational logic (multiplexers, decoders, etc.)
  • Add sequential logic (flip-flops, registers, etc.)
  • Add some geometric demonstration (to be able to solve geometric problems)
    • \sum_{i=1}^{n} i = \frac{n(n+1)}{2} or smth like that

License

This project is licensed under the Compounds of the MIT license

Dependencies

~0.3–0.8MB
~11K SLoC