Skip to content

Commit

Permalink
add negation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinzwang committed Dec 19, 2024
1 parent e0b4d53 commit 7febe13
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/daft-algebra/src/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,24 @@ mod tests {
assert_eq!(expected, to_cnf(expr));
}

#[test]
fn dnf_neg() {
// !(a & ((!b) | c)) -> (!a) | (b & (!c))
let expr = col("a").and(col("b").not().or(col("c"))).not();
let expected = col("a").not().or(col("b").and(col("c").not()));

assert_eq!(expected, to_dnf(expr));
}

#[test]
fn cnf_neg() {
// !(a | ((!b) & c)) -> (!a) & (b | (!c))
let expr = col("a").or(col("b").not().and(col("c"))).not();
let expected = col("a").not().and(col("b").or(col("c").not()));

assert_eq!(expected, to_cnf(expr));
}

#[test]
fn dnf_nested() {
// a & b & ((c & d) | (e & f)) -> (a & b & c & d) | (a & b & e & f)
Expand Down

0 comments on commit 7febe13

Please sign in to comment.