50 lines
1.6 KiB
Haskell
50 lines
1.6 KiB
Haskell
{-# LANGUAGE InstanceSigs #-}
|
|
module Main where
|
|
|
|
import Binding
|
|
import Classes
|
|
import Database
|
|
import Nondeterminism
|
|
import Terms
|
|
|
|
demoProgram :: Database
|
|
demoProgram = Database
|
|
{ clauses =
|
|
[ do
|
|
who <- newVar "who"
|
|
action <- newVar "action"
|
|
return $ Clause (Compound "act" [Var who, Var action])
|
|
[ Compound "is_vampire" [Var who]
|
|
, Compound "vampire_behavior" [Var action]
|
|
]
|
|
, do
|
|
progenitor <- newVar "progenitor"
|
|
progeny <- newVar "progeny"
|
|
return $ Clause (Compound "is_vampire" [Var progeny])
|
|
[ Compound "has_progenitor" [Var progenitor, Var progeny]
|
|
, Compound "is_vampire" [Var progenitor]
|
|
]
|
|
, return $ Clause (Compound "act" [Compound "Sam" [], Compound "goes to law school" []]) []
|
|
|
|
, return $ Clause (Compound "vampire_behavior" [Compound "drinks blood" []]) []
|
|
, return $ Clause (Compound "vampire_behavior" [Compound "spits venom" []]) []
|
|
, return $ Clause (Compound "is_vampire" [Compound "Nyeogmi" []]) []
|
|
, return $ Clause (Compound "has_progenitor" [Compound "Nyeogmi" [], Compound "Pyrex" []]) []
|
|
, return $ Clause (Compound "has_progenitor" [Compound "Sam" [], Compound "Alex" []]) []
|
|
-- , return $ Clause (Compound "is_vampire" [Compound "Sam" []]) []
|
|
]
|
|
}
|
|
|
|
main :: IO ()
|
|
main = do
|
|
thread <- newThread runDemoProgram
|
|
_ <- takeAllRemainingSolutions thread
|
|
return ()
|
|
where
|
|
runDemoProgram = do
|
|
who <- newVar "who"
|
|
what <- newVar "what"
|
|
let goal = Compound "act" [Var who, Var what]
|
|
seek goal demoProgram
|
|
instantiatedGoal <- instantiate goal
|
|
liftIO $ putStrLn ("Got " ++ show instantiatedGoal) |