3.11 == : Equal to comparison operator

Format

$zdd1$ == $zdd2$ $\rightarrow $ $zdd3$

Description

Compare terms in $zdd1$ and $zdd2$, select terms with equal weight (terms with same weight and itemset), and return the itemset. Note that the resulting weight of the itemset returned is 1.

The iif function can be used in cases where weight is also selected.

This package can be used with the following comparison operators (functions).

In addition, same?(==) and diff? can be used to evaluate the equivalence on the complete expression.

Examples

Example 1: Basic Example

> require 'zdd'
> a=ZDD::itemset("a")
> b=ZDD::itemset("b")
> c=ZDD::itemset("c")
> x=3*a + 2*b + 2*c
> y=2*a + 2*b + 4*c
> x.show
 3 a + 2 b + 2 c
> y.show
 2 a + 2 b + 4 c
# (x,y is defined above)

# Compare x and y, select itemsets with equal weight.
> (x==y).show
 b

# Compare x and y, select itemsets with weight that is greater than or equal to y.
> (x>=y).show
 a + b

# Compare x and y, select itemsets with unequal weights.
> (x.ne?(y)).show
 a + c

# For itemsets present in zdd1 but absent in zdd2 (or vice versa),
# the weight is considered as 0.
> z=2*a + 2*b
> z.show
 2 a + 2 b

# Since itemset c does not exists in z, the weight is considered as 0. 
> (x>z).show
 a + c
> (x.ne?(z)).show
 a + c
> (x==z).show
 b

See Also

==, $<$, $<=$, $>$, $>=$, ne? : Various comparison operations

iif : Select by comparison of items

same? : Same comparison operator

diff? : Not equal to comparison operator