Proviant is a framework which evaluate boolean-expressions with the help of the Shunting-yard algorithm.
- Calculating boolean-algebra expression
- Generating a truth table for a boolean expression
- Create your own expression evaluator for a specific gramma.
| Operatorname | Symbol | Precedence | Is unary |
|---|---|---|---|
| NOT | ¬ | 5 | true |
| AND | ∧ | 4 | false |
| NAND | ⊼ | 4 | false |
| OR | ∨ | 3 | false |
| NOR | ⊽ | 3 | false |
| Implecation | → | 2 | false |
| Converse Implication | ← | 2 | false |
| Eqvivalence | ↔ | 1 | false |
| Antivalence | ⇹ | 1 | false |
Add using:
using Proviant;Till now the tokens in an expression string need to be seperated by a whitespace. Create a new expression:
// A boolean expression.
string expressionString = "false or true and ( false ⇔ false )";
// Create a new BooleanAlgebraExpression instance.
var expr = new BooleanAlgebraExpression(expressionString);
// Evaluate expression.
// Result will be true.
bool result = expr.Evaluate();// A boolean expression.
string expressionString = "A or B and C";
// Create a new BooleanAlgebraExpression instance.
var expr = new BooleanAlgebraExpression(expressionString);
// returns TruthTable class.
var truthTable = expr.GenerateTruthTable();The truth-table would look like:
| A | B | C | Y |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 |
1 = True
0 = False
Y = represents the evaluated result
| Property | Type | Description |
|---|---|---|
TruthRows |
TruthRows |
A truth row contains the state of each variable and the calculated result. |
Rows |
int |
The total count of rows in this truth-table. |
Colums |
int |
The total count of colums in this truth-table. |
| Property | Type | Description |
|---|---|---|
Operands |
Dictionary<string, bool> |
A dictionary of operand and it's current state. The key is the operand. The value represents the state of the operand. |
EvaluatedResult |
bool |
The evaluated result. |
