Crates.io | logical_solver |
lib.rs | logical_solver |
version | 1.0.2 |
source | src |
created_at | 2023-04-18 18:15:30.543963 |
updated_at | 2023-04-18 18:15:30.543963 |
description | Rust based logic parser, evaluator, and truth table constructor! |
homepage | https://github.com/antoKeinanen/logical_solver-rs |
repository | https://github.com/antoKeinanen/logical_solver-rs |
max_upload_size | |
id | 842707 |
size | 72,484 |
Logical solver is a rust library for solving and parsing logical equations.
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.
let expr = parse_expression("true => not false or (true and false)");
let result = enumerate(expr, HashMap::new());
assert_eq!(result, true);
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 folder. Run them with:
cargo run --example <example_name>