diff options
-rw-r--r-- | Logic.icl | 10 | ||||
-rw-r--r-- | LogicParser.icl | 2 | ||||
-rw-r--r-- | LogicTest.icl | 2 |
3 files changed, 7 insertions, 7 deletions
@@ -224,9 +224,12 @@ all_atoms (Atom a) = [a] all_atoms (B _) = [] all_atoms (App1 _ e) = all_atoms e all_atoms (App2 e1 _ e2) = removeDup (all_atoms e1 ++ all_atoms e2) + +removeSubOptions :: [[AtomOption]] -> [[AtomOption]] +removeSubOptions opts = filter (\this -> not (any (\that -> all (flip isMember that) this) (removeMember this opts))) opts all_atom_options :: Expr -> [[AtomOption]] -all_atom_options e = removeDup [opt \\ opt <- all_opts (sort (all_atoms e)) []] +all_atom_options e = removeSubOptions [opt \\ opt <- all_opts (sort (all_atoms e)) []] where all_opts :: [AtomName] [AtomOption] -> [[AtomOption]] all_opts [] opts = [opts] @@ -263,16 +266,13 @@ simple_truthtable :: Expr -> TruthTable simple_truthtable e = {exprs = [Atom a \\ a <- all_atoms e] ++ [e], options = all_atom_options e} simple_truthtable_n :: [Expr] -> TruthTable // Simple truthtable with multiple expressions -simple_truthtable_n es = {exprs = removeDup ([Atom a \\ a <- flatten (map all_atoms es)] ++ es), options = removeDup (flatten (map all_atom_options es))} +simple_truthtable_n es = {exprs = removeDup ([Atom a \\ a <- flatten (map all_atoms es)] ++ es), options = removeSubOptions (flatten (map all_atom_options es))} truthtable :: Expr -> TruthTable truthtable e = {exprs = sorted_subexprs e ++ [e], options = all_atom_options e} truthtable_n :: [Expr] -> TruthTable truthtable_n es = {exprs = sort (removeDup (flatten ([[e:subexprs e] \\ e <- es]))), options = removeSubOptions (flatten (map all_atom_options es))} -where - removeSubOptions :: [[AtomOption]] -> [[AtomOption]] - removeSubOptions opts = filter (\this -> not (any (\that -> all (flip isMember that) this) (removeMember this opts))) opts compute :: TruthTable -> FilledTruthTable // Fill in a truthtable compute table=:{exprs,options} = {table=table, values=values} diff --git a/LogicParser.icl b/LogicParser.icl index 46ac605..852a882 100644 --- a/LogicParser.icl +++ b/LogicParser.icl @@ -26,7 +26,7 @@ module LogicParser import StdEnv, StdMaybe, ArgEnv, Logic Start -| isEmpty exprs = abort ("Usage: " +++ argv.[0] +++ " -b -nt [-e] [-html|-latex] <string>\n") +| isEmpty exprs = abort ("Usage: " +++ argv.[0] +++ " [-e] [-html|-latex] <string>\n") | length (removeDup (foldr (++) [] (map all_atoms exprs))) > 8 = abort "You don't need more than 8 atomic expressions." | otherwise = show outputoption (compute (if extended truthtable_n simple_truthtable_n exprs)) where diff --git a/LogicTest.icl b/LogicTest.icl index 4113673..c341b07 100644 --- a/LogicTest.icl +++ b/LogicTest.icl @@ -55,5 +55,5 @@ exprs_assoc = [e10,e11,e12,e13,e14,e15,e16,e17] //Start = map toString exprs_rand //Start = map toString exprs_assoc -Start = /*show Plain (compute*/ (truthtable_n [e1, e4])//) +Start = show Plain (compute (truthtable_n [e1, e4])) |