public override bool FormulaValue(BooleanFormulaInput input) { switch (type) { case BooleanOperations.AND: return(argument1.FormulaValue(input) && argument2.FormulaValue(input)); case BooleanOperations.OR: return(argument1.FormulaValue(input) || argument2.FormulaValue(input)); case BooleanOperations.IMPLICATION: return(!argument1.FormulaValue(input) || argument2.FormulaValue(input)); case BooleanOperations.XOR: return(argument1.FormulaValue(input) != argument2.FormulaValue(input)); case BooleanOperations.EQUIVALENCE: return(argument1.FormulaValue(input) == argument2.FormulaValue(input)); case BooleanOperations.SHEFFER_STROKE: return(!(argument1.FormulaValue(input) && argument2.FormulaValue(input))); case BooleanOperations.PIERCE_ARROW: return(!(argument1.FormulaValue(input) || argument2.FormulaValue(input))); } return(false); }
public static bool[] FormulaValues(BooleanFormula formula, List <BooleanVariable> variableList) { int variableCount = variableList.Count; if (variableCount == 0) { variableCount = 1; } int length = 1 << variableCount; bool[] values = new bool[length]; bool[] input = new bool[variableCount]; for (int i = 0; i < length; i++) { for (int j = 0; j < variableCount; j++) { input[variableCount - j - 1] = ((i >> j) & 1) == 1; } values[i] = formula.FormulaValue(new BooleanFormulaInput(input, variableList)); } return(values); }
public static bool[] FormulaValues(BooleanFormula formula, List<BooleanVariable> variableList) { int variableCount = variableList.Count; if (variableCount == 0) variableCount = 1; int length = 1 << variableCount; bool[] values = new bool[length]; bool[] input = new bool[variableCount]; for (int i = 0; i < length; i++) { for (int j = 0; j < variableCount; j++) input[variableCount - j - 1] = ((i >> j) & 1) == 1; values[i] = formula.FormulaValue(new BooleanFormulaInput(input, variableList)); } return values; }
public override bool FormulaValue(BooleanFormulaInput input) { return(!argument.FormulaValue(input)); }