GraphBLAS / graphblas-api-c

Other
7 stars 3 forks source link

Missing binary boolean operators #68

Open DrTimothyAldenDavis opened 2 years ago

DrTimothyAldenDavis commented 2 years ago

GraphBLAS does not have the full set of all 16 possible boolean binary operators. It has only 11 of them. See the table below:

                     x: 0 0 1 1
                     y: 0 1 0 1
                     -------------

        z = 0           0 0 0 0     (zero function, not predefined)
        z = (x && y)    0 0 0 1     AND, MIN, TIMES
        z = (x > y)     0 0 1 0     GT
        z = x           0 0 1 1     FIRST

        z = (x < y)     0 1 0 0     LT
        z = y           0 1 0 1     SECOND
        z = (x != y)    0 1 1 0     XOR, MINUS, NE
        z = (x || y)    0 1 1 1     OR, MAX, PLUS

        z = ~(x || y)   1 0 0 0     (nor(x,y) function, not predefined)
        z = (x == y)    1 0 0 1     LXNOR, EQ
        z = ~y          1 0 1 0     (not(y), not predefined as a binary op)
        z = (x >= y)    1 0 1 1     GE, also same as "x implies y"

        z = ~x          1 1 0 0     (not(x), not predefined as a binary op)
        z = (x <= y)    1 1 0 1     LE, also same as "y implies x"
        z = ~(x && y)   1 1 1 0     (nand(x,y) function, not predefined)
        z = 1           1 1 1 1     ONEB

We should add the 5 missing functions, as boolean binary operators:

GrB_ZEROB_BOOL: z = false.  This might also be GrB_ZEROB_T for any domain T.
GrB_NFIRST:  z = not(x)
GrB_NSECOND: z = not(y)
GrB_NAND: z = not (and (x,y))
GrB_NOR: z = not (or (x,y))

All domains for these binary operators are GrB_BOOL. These functions are useful in their own right, but are also required by #67