diff --git a/src/main.rs b/src/main.rs index 2ca1032..83a0d5c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ mod truth_table; use gray_code::gray_code; use truth_table::print_truth_table; +use negation_normal_form::negation_normal_form; fn main() { println!("Hello, world!"); @@ -22,4 +23,11 @@ fn main() { println!("{}", gray_code(3)); print_truth_table("ZFG|&"); print_truth_table("ABC|&"); + let formula = "AB=CD^|!AD!^!&!"; + println!("{formula}"); + print_truth_table(formula); + let formula = &negation_normal_form(formula); + println!("{formula}"); + print_truth_table(formula); + } diff --git a/src/negation_normal_form.rs b/src/negation_normal_form.rs index 2a63e8d..0bbb0fd 100644 --- a/src/negation_normal_form.rs +++ b/src/negation_normal_form.rs @@ -2,7 +2,7 @@ mod tests; use crate::ast::Node; -fn negation_normal_form(formula: &str) -> String { +pub fn negation_normal_form(formula: &str) -> String { let mut ast = Node::::parse_formula(formula); ast.simplify(); Node::::ast_to_formula(&ast) diff --git a/src/negation_normal_form/tests.rs b/src/negation_normal_form/tests.rs index 11a1f9c..d99a0a5 100644 --- a/src/negation_normal_form/tests.rs +++ b/src/negation_normal_form/tests.rs @@ -63,6 +63,6 @@ mod tests { #[test] fn complex_tests() { - assert_eq!("A", "A"); + assert_eq!(negation_normal_form("AB=CD^|!AD!^!&!"), "A!B|B!A|&CD|C!D!|&|AD!|A!D|&|"); } }