Statistical math and logic engine and solver