3-valued logic (T, F, U) (U)ndefined means (T v F) ^ -(T ^ F)
Coerces a Bool, None, or int into Bit/Propositional form. If value is an int, must be -1, 0, or 1.
Note
T, F, and U can be used in place of True, False, and 'UNKNOWN', respectively.
| Parameters: | value (bool, int) – The value to coerce |
|---|---|
| Returns: | BoolCell |
| Raises: | CellConstructionFailure, CoercionFailure |
>>> f1 = BoolCell.coerce(0)
>>> f1
False
>>> f2 = BoolCell.coerce(F)
>>> f2
False
>>> t1 = BoolCell.coerce(1)
>>> t1
True
>>> t2 = BoolCell.coerce(T)
>>> t2
True
Returns True if the other is as or more specific than self
| Parameters: | other (BoolCell, bool, int) – The BoolCell or coercible value that may entail self |
|---|---|
| Returns: | bool |
| Raises: | CellConstructionFailure, CoercionFailure |
>>> x = BoolCell(T)
>>> y = BoolCell(F)
>>> z = BoolCell(U)
>>> x.is_entailed_by(U)
False
>>> y.is_entailed_by(F)
True
>>> y.is_entailed_by(U)
False
>>> z.is_entailed_by(x)
True
Inverse of is_entailed_by. Returns True if self is as or more specific than other.
| Parameters: | other (BoolCell, bool, int) – The BoolCell or coercible value to check if it is entailed by self |
|---|---|
| Returns: | bool |
| Raises: | CellConstructionFailure, CoercionFailure |
>>> x = BoolCell(T)
>>> y = BoolCell(F)
>>> z = BoolCell(U)
>>> x.entails(T)
True
>>> x.entails(U)
True
>>> y.entails(T)
False
>>> y.entails(F)
True
>>> z.entails(U)
True
>>> z.entails(F)
False
Determines if two cells are contradictory. Returns a boolean.
| Parameters: | other (BoolCell, bool, int) – The BoolCell or value that may contradict self. |
|---|---|
| Returns: | bool |
| Raises: | CellConstructionFailure, CoercionFailure |
>>> x = BoolCell(T)
>>> y = BoolCell(F)
>>> z = BoolCell(U)
>>> x.is_contradictory(y)
True
>>> y.is_contradictory(x)
True
>>> z.is_contradictory(x)
False
>>> z.is_contradictory(y)
False
>>> z.is_contradictory(U)
False
Tests whether two Cells are equal. Returns a boolean.
| Parameters: | other (BoolCell, bool, int) – BoolCell or coercible value to be tested |
|---|---|
| Returns: | bool |
| Raises: | CoercionFailure |
>>> x = BoolCell(T)
>>> y = BoolCell(F)
>>> x.is_equal(x)
True
>>> x.is_equal(T)
True
>>> y.is_equal(x)
False
Merges two BoolCells. A Contradiction is raised if the two BoolCells are contradictory.
| Parameters: | other (BoolCell, bool, int) – BoolCell or coerce-able value to be merged |
|---|---|
| Returns: | BoolCell |
| Raises: | CellConstructionFailure, CoercionFailure, Contradiction |
>>> v = BoolCell(U)
>>> w = BoolCell(U)
>>> z = BoolCell(U)
>>> v.merge(T)
True
>>> z.merge(F)
False
>>> w.merge(U)
'UNKNOWN'