Skip to content

Commit

Permalink
chore: remove comments
Browse files Browse the repository at this point in the history
  • Loading branch information
leogaudin committed Aug 30, 2024
1 parent 5308684 commit 6eeff56
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/ex06.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use crate::{ex05::tree_to_nnf, tree::{create_tree, tree_to_rpn, NodeValue, TreeNode, TreeNodeRef}};

// Distributivity (ABC|& === AB&AC&|), (ABC&| === AB|AC|&)
fn apply_cnf(node: TreeNodeRef) -> TreeNodeRef {
let node: TreeNodeRef = tree_to_nnf(node);
let node = node.borrow();
match node.get_val() {
// (A ∨ (B ∧ C)) ⇔ ((A ∨ B) ∧ (A ∨ C))
Some(NodeValue::Operator('|')) => {
let left: TreeNodeRef = apply_cnf(node.get_left().unwrap());
let right: TreeNodeRef = apply_cnf(node.get_right().unwrap());
Expand Down Expand Up @@ -88,14 +86,9 @@ fn move_conjunctions_to_end(formula: &str) -> String {
}

pub fn conjunctive_normal_form(formula: &str) -> String {

// Implement conjunctive normal form from negation normal form
// Return the conjunctive normal form as a string
let tree: TreeNodeRef = create_tree(formula);
let cnf: TreeNodeRef = apply_cnf(tree);
// let moved: String = tree_to_rpn(cnf).as_str().to_string();
let moved: String = move_conjunctions_to_end(tree_to_rpn(cnf).as_str());
// print_tree(cnf);

return moved;
}

0 comments on commit 6eeff56

Please sign in to comment.