static void EvaluateTruth(string[] args) { if (args.Length == 0) { throw new ArgumentException("Expected expression."); } var expression = string.Join(' ', args); if (!LogicExpression.IsValid(expression, out string validationMessage)) { Console.WriteLine($"Invalid expression: {validationMessage}"); return; } var argument = new LogicArgument(); foreach (var definition in Definitions) { argument.AddPremise(LogicExpression.Create(definition.Value)); } argument.SetConclusion(LogicExpression.Create(expression)); Console.WriteLine(argument.IsValid()); var truthTableBuilder = new TruthTableBuilder(); truthTableBuilder.WriteTruthTable(LogicExpression.Create(argument.ToExpression()), new AsciiTruthTableWriter(Console.Out)); }
static void PrintTruthTable(string[] args) { if (args.Length == 0) { throw new ArgumentException("Expected expression."); } var expressionSyntax = string.Join(' ', args); if (!LogicExpression.IsValid(expressionSyntax, out string validationMessage)) { Console.WriteLine($"Invalid expression: {validationMessage}"); return; } var expression = LogicExpression.Create(expressionSyntax); var truthTableBuilder = new TruthTableBuilder(); truthTableBuilder.WriteTruthTable(expression, new AsciiTruthTableWriter(Console.Out)); }