Friday, May 13, 2016

Continuous logic

Boolean operations where 0 is false and 1 is true can be extended to real numbers between 0 and 1.
Lets take two independent variables x and y.

and their ven diagram of all possibilities

The space of all possibilities adds up to one (because 1 is true),
We can avoid mentioning a, b, c, and d and just work with arithmetic operations on x and y.

not x = (1 - x)
x and y = (x*y)
x or y = (x + y - x*y)
x xor y = (x + y - 2xy)


DeMorgan's laws

x and y = not (not x or not y)
x or y = not (not y and not x)

There is one bug, "x and not x" should be 0 because not x is true only to the degree that x is false, however our formula gives us "x and not x = x - x*x".
Similarly "x or not x" should be always true because "x" and "not x" are exactly complementary. But when we plug it in we get "1 - x + x*x".

The solution is is to disallow higher powers, whenever we see something like x^2 or "x*x" we replace it with just plain x. This works because information from the source x should only be counted once, even if we receive it through two different paths.

examples

x xor y = (x or y) and not (x and y) = x + y - 2x*y
if we allowed higher powers we would have the incorrect result of x xor y = x + y - x*y - x*x*y - x*y*y + x*x*y*y

it works just as well when the two variables are not independent

w = 1/3x + 2/3y
z = 3/4x + 1/4y
w or z = 10/12x + 9/12y - 7/12y*x

No comments: