https://github.com/Yrrrrrf/logic_tracer
Simple crate that reads a logical proposition and interprets it to build the truth table and the AST of the proposition
https://github.com/Yrrrrrf/logic_tracer
Last synced: 2 months ago
JSON representation
Simple crate that reads a logical proposition and interprets it to build the truth table and the AST of the proposition
- Host: GitHub
- URL: https://github.com/Yrrrrrf/logic_tracer
- Owner: Yrrrrrf
- License: mit
- Created: 2023-07-13T04:58:42.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-10T06:58:47.000Z (3 months ago)
- Last Synced: 2025-03-30T10:33:48.165Z (2 months ago)
- Language: Rust
- Size: 1.4 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rust-formalized-reasoning - Logic Tracer - reads a logical proposition and interprets it to build the truth table and the AST. (Propositional logic / Libraries)
README
![]()
Logic Tracer[
](https://github.com/Yrrrrrf/logic_tracer)
[](https://crates.io/crates/logic_tracer)
[](https://docs.rs/logic_tracer)
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](https://en.wikipedia.org/wiki/Shunting-yard_algorithm) (not yet) to build the AST.## Examples
Check the [examples](./examples/) direcotry to see how to use the crate.
```bash
cargo run --example
```## Roadmap
- [x] Read a logical proposition
- [x] Tokenize the proposition
- [x] Validate Input Tokens (only valid tokens)
- [x] Variables (only letters)
- [x] Logical Operators (and, or, not, implies, iff)
- [x] Mathematical Operators (add, sub, mul, div, pow)
- [x] 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`I want to make this crate copletely independent of any other crate.`
`So, I will implement the parser myself...`
But also I'll check the pest crate to see how it works and to see if I can use it in some other project... (maybe in the future)
- Check [PEST](https://docs.rs/pest/latest/pest/) [grammar declaration using `.pest` files](https://docs.rs/pest/latest/pest/index.html#pest-files)----
## License
This project is licensed under the Compounds of the [MIT license](./LICENSE)