{-# OPTIONS_HADDOCK hide #-}moduleData.Logic.Propositional.Tables(truthTable,truthTableP)whereimportData.Logic.Propositional.CoreimportData.Map(fold)-- | The 'truthTable' function produces a truth table for the given expression.truthTable::Expr->StringtruthTable=truthTablePshow-- | The 'truthTableP' is a configurable version of 'truthTable' which allows a-- printer function to be selected, so for example one can print ASCII truth-- tables by passing 'showAscii' to 'truthTableP' instead of 'show'.truthTableP::(Expr->String)->Expr->StringtruthTablePprinterexpr=unlines[header,separator,body]whereheader=unwordsvs++" | "++printerexprbody=unlines$map(showAssignmentexpr)asseparator=concat$replicatesepLength"-"sepLength=lengthvs*2+length(printerexpr)+2as=assignmentsexprvs=variablesexprshowAssignment::Expr->Mapping->StringshowAssignmentexpra=showVarValues++" | "++showExprValuewhereshowVarValues=unwords$fold((:).showBool)[]ashowExprValue=showBool$interpretexprashowBool::Bool->StringshowBoolTrue="T"showBoolFalse="F"