Skip to content

Commit

Permalink
Add sneaky-avoid-type-encoding trick in a (hopefully) sound way.
Browse files Browse the repository at this point in the history
  • Loading branch information
nick8325 committed Sep 12, 2017
1 parent c83bfde commit 21e2500
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions executable/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Jukebox.Tools.EncodeTypes
import Jukebox.TPTP.Print
import Jukebox.Tools.Clausify(ClausifyFlags(..), clausify)
import Jukebox.Tools.HornToUnit
import qualified Jukebox.Sat as Sat
import qualified Data.IntMap.Strict as IntMap
import System.IO
import System.Exit
Expand Down Expand Up @@ -597,12 +598,41 @@ main = do
expert clausifyBox =>>=
forAllConjecturesBox <*>
(combine <$>
(hornToUnitBox =>>=
toFormulasBox =>>=
hornToUnitBox <*>
(toFormulasBox =>>=
expert (toFof <$> clausifyBox <*> pure (tags True)) =>>=
clausifyBox =>>=
oneConjectureBox) <*>
clausifyBox =>>= oneConjectureBox) <*>
(runTwee <$> globalFlags <*> tstpFlags <*> parseMainFlags <*> parseConfig <*> parsePrecedence)))
where
combine horn prove later prob =
horn prob >>= prove later
combine horn encode prove later prob
| isFof prob = do
prob <- horn prob
sat <- hasSizeOneModel prob
if sat then do
later $ do
putStrLn "The problem has a model of size 1."
putStrLn "In this model, all terms are equal to each other."
putStrLn ""
return (Sat Satisfiable)
else prove later prob
| otherwise =
horn prob >>= encode >>= prove later

-- Check if a problem has a model of size 1.
-- Done by erasing all terms from the problem.
hasSizeOneModel :: Problem Clause -> IO Bool
hasSizeOneModel p = do
s <- Sat.newSolver
let funs = Jukebox.functions p
lits <- replicateM (length funs) (Sat.newLit s)
let
funMap = Map.fromList (zip funs lits)
transClause (Clause (Bind _ ls)) =
map transLit ls
transLit (Pos a) = transAtom a
transLit (Neg a) = Sat.neg (transAtom a)
transAtom (Tru (p :@: _)) =
Map.findWithDefault undefined p funMap
transAtom (_ Jukebox.:=: _) = Sat.true
mapM_ (Sat.addClause s . transClause) (map what p)
Sat.solve s [] <* Sat.deleteSolver s

0 comments on commit 21e2500

Please sign in to comment.