Skip to content

Data structure representing a logical truth table.

Notifications You must be signed in to change notification settings

programarivm/truth-table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Truth Table

Build Status License: GPL v3

A truth table is a mathematical table used in logic which sets out the functional values of logical expressions on each of their functional arguments. Wikipedia.

Install

Via composer:

$ composer require programarivm/truth-table

Binary Table

Create a binary table with two input variables:

use TruthTable\BinaryTable;

$t = (new BinaryTable(2))->getTable();

Get the result of the table:

use TruthTable\BinaryTable;

$r = (new BinaryTable(2))->getResult();

Set specific indexes to true and get the result:

use TruthTable\BinaryTable;

$true = [0, 1];

$r = (new BinaryTable(2))
		->setTrue($true)
		->getResult();

Set specific indexes to false and get the result:

use TruthTable\BinaryTable;

$false = [0, 1];

$r = (new BinaryTable(2))
		->setFalse($false)
		->getResult();

Ternary Table

Create a ternary table with two input variables:

use TruthTable\TernaryTable;

$t = (new TernaryTable(2))->getTable();

Get the result of the table:

use TruthTable\TernaryTable;

$r = (new TernaryTable(2))->getResult();

Set specific indexes to true and get the result:

use TruthTable\TernaryTable;

$true = [0, 1];

$r = (new TernaryTable(2))
		->setTrue($true)
		->getResult();

Set specific indexes to false and get the result:

use TruthTable\TernaryTable;

$false = [0, 1];

$r = (new TernaryTable(2))
		->setFalse($false)
		->getResult();

Set specific indexes to unknown and get the result:

use TruthTable\TernaryTable;

$unknown = [0, 1];

$r = (new TernaryTable(2))
		->setUnknown($unknown)
		->getResult();

For further details please look at the unit tests.

License

The GNU General Public License.