SQLthree valued logic - do de Morgan's laws apply?

71 Views Asked by At

de Morgan's laws apply to 2-valued logic. Does it apply to SQL's 3-valued logic?

Experimenting with pen and paper suggests it does but does anyone know of a definitive statement that it really does, given I may have overlooked some corner case.

1

There are 1 best solutions below

0
On

Yes.

# mysql
select
    -- for reference
    true and null,  -- null
    true or null,   -- true
    false and null, -- false
    false or null,  -- null
    not null,       -- null
    
    -- de morgan's laws
    not (true and null),    -- null
    not true or not null,   -- null
    not (false or null),    -- null
    not false and not null, -- null
    
    not (false and null),   -- true
    not false or not null,  -- true
    not (true or null),     -- false
    not true and not null   -- false