- Truth Table Language

Truth Table Language

Download source: ttli-1.0.0.tar.gz

Sample example of follow expressions. Logic OR \[T(a,b)=a\vee b\]

>> $T = a+b
>> $T
+----------+-----+
|  a    b  |  R  |
+----------+-----+
|  0    0  |  0  |
|  0    1  |  1  |
|  1    0  |  1  |
|  1    1  |  1  |
+----------+-----+

Upper case letter are negate \[T(a,b)=a\vee (\neg b)\]

>> $T=a+B
>> $T
+----------+-----+
|  a    b  |  R  |
+----------+-----+
|  0    0  |  1  |
|  0    1  |  0  |
|  1    0  |  1  |
|  1    1  |  1  |
+----------+-----+

If, only If \[T(a,b)= a\iff b\]

>> $T=a<->b 
>> $T
+----------+-----+
|  a    b  |  R  |
+----------+-----+
|  0    0  |  1  |
|  0    1  |  0  |
|  1    0  |  0  |
|  1    1  |  1  |
+----------+-----+

Negating \[T(a,b,c,d)=\neg(a\wedge b \wedge c\wedge (\neg d))\]

>> $T=!(abcD)
>> $T        
+--------------------+-----+
|  a    b    c    d  |  R  |
+--------------------+-----+
|  0    0    0    0  |  1  |
|  0    0    0    1  |  1  |
|  0    0    1    0  |  1  |
|  0    0    1    1  |  1  |
|  0    1    0    0  |  1  |
|  0    1    0    1  |  1  |
|  0    1    1    0  |  1  |
|  0    1    1    1  |  1  |
|  1    0    0    0  |  1  |
|  1    0    0    1  |  1  |
|  1    0    1    0  |  1  |
|  1    0    1    1  |  1  |
|  1    1    0    0  |  1  |
|  1    1    0    1  |  1  |
|  1    1    1    0  |  0  |
|  1    1    1    1  |  1  |
+--------------------+-----+

Evaluating a expression \[T(a,b,c)=a\wedge b \vee (\neg c)\] \[T(1,1,0)\]

>> $T=ab+C
>> $T[1,1,0]
1

Using logic AND \[T(a,b,c)=(a\vee b)\wedge c\]

>> $T=(a+b)c
>> $T
+---------------+-----+
|  a    b    c  |  R  |
+---------------+-----+
|  0    0    0  |  0  |
|  0    0    1  |  0  |
|  0    1    0  |  0  |
|  0    1    1  |  1  |
|  1    0    0  |  0  |
|  1    0    1  |  1  |
|  1    1    0  |  0  |
|  1    1    1  |  1  |
+---------------+-----+

Using implication \[T(a,b)=a \to b\]

>> $T=a->b  
>> $T
+----------+-----+
|  a    b  |  R  |
+----------+-----+
|  0    0  |  1  |
|  0    1  |  1  |
|  1    0  |  0  |
|  1    1  |  1  |
+----------+-----+

Using XOR \[T(a,b)=a \oplus b\]

>> $T=a^b
>> $T
+----------+-----+
|  a    b  |  R  |
+----------+-----+
|  0    0  |  0  |
|  0    1  |  1  |
|  1    0  |  1  |
|  1    1  |  0  |
+----------+-----+

Chang logic symbols (1, 0) to (T, F) \[T(a,b)=(\neg a) \wedge (\neg b)\]

>> $T=AB
>> setlogic[T,F]
>> $T           
+----------+-----+
|  a    b  |  R  |
+----------+-----+
|  F    F  |  T  |
|  F    T  |  F  |
|  T    F  |  F  |
|  T    T  |  F  |
+----------+-----+

Compare expressions \[A(a,b)=(\neg a)\wedge(\neg b)\] \[B(a,b)=\neg( a\vee b)\]

>> setlogic[T,F]
>> $A=AB    
>> $B=!(a+b)
>> $A == $B
T