Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/antoKeinanen/logical_solver-rs
Rust based logic parser, evaluator, and truth table constructor!
https://github.com/antoKeinanen/logical_solver-rs
Last synced: 3 months ago
JSON representation
Rust based logic parser, evaluator, and truth table constructor!
- Host: GitHub
- URL: https://github.com/antoKeinanen/logical_solver-rs
- Owner: antoKeinanen
- License: gpl-3.0
- Created: 2023-04-16T07:30:33.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-23T16:21:19.000Z (over 1 year ago)
- Last Synced: 2024-05-22T21:34:06.391Z (6 months ago)
- Language: Rust
- Homepage:
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
- awesome-rust-formalized-reasoning - logical_solver - library for solving and parsing logical equations. (Projects / Libraries)
README
# Logical solver
![Crates.io](https://img.shields.io/crates/v/logical_solver)
![docs.rs](https://img.shields.io/docsrs/logical_solver)Logical solver is a rust library for solving and parsing logical equations.
## Supported operations
| Predicate | Usage |
| --------------------------------- | ------ |
| Conjunction(AND) ∧ | and |
| Disjunction(OR) ∨ | or |
| Negation(NOT) ¬ | not |
| Conditional(IF...THEN) ⇒/→ | => |
| Biconditional(IF AND ONLY IF) ⇔/↔ | <=> |
| Variables (for truth tables)\* | [A-Z]+ |\*Variables can be one or more capital letters.
## Usage
```rust
let expr = parse_expression("true => not false or (true and false)");
let result = enumerate(expr, HashMap::new());
assert_eq!(result, true);
``````rust
let vars = vec!(String::from("A"), String::from("B"))
let expr = parse_expression("A => not B");
let states = permutate(vars);
let result = solve_truth_table(expr, vars);
assert_eq!(result, [true, true, true, false]);
```For full examples check [/examples](https://github.com/antoKeinanen/logical_parser/tree/main/examples) folder. Run them with:
`cargo run --example `