-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Translations of classic Truth Maintenance Systems -- -- Haskell monad transformer-based translations of two classic Truth -- Maintenance System algorithms of Forbus and de Kleer's Building -- Problem Solvers. This version includes justification-based and -- assumption-based TMS (JTMS and ATMS) implementations. See the GitHub -- repository https://github.com/jphmrst/bps/, or the Haddock -- documentation. @package BPS @version 0.1.0.0 -- | The module contains the flag which indicates whether debugging output -- should be compiled into modules using this system for runtime trace -- output. module Data.TMS.ChooseDebugging -- | Flag which indicates whether debugging output should be compiled into -- modules using this system for runtime trace output. debuggingOn :: Bool -- | Macro which expands to definitions which either print debugging -- statements, or do nothing. debugging :: Q [Dec] module Data.TMS.Dbg class Monad m_a7Ud => Debuggable m_a7Ud dbg :: a_a7Ua -> Q Exp instance GHC.Base.Monad m => Data.TMS.Dbg.Debuggable m -- | Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -- implied, for NON-COMMERCIAL use. See the License for the specific -- language governing permissions and limitations under the License. module Data.TMS.Helpers -- | Check whether a list contains a value which, when applied to a -- computation, returns True. anyByM :: Monad m => (a -> m Bool) -> [a] -> m Bool -- | Check whether a returned list contains a value which satisfies some -- monadic predicate. anyMM :: Monad m => (a -> m Bool) -> m [a] -> m Bool -- | Check whether all of the values of a list, when applied to a -- computation, return True. allByM :: Monad m => (a -> m Bool) -> [a] -> m Bool -- | Determine whether one list is a subset of the other, under the -- assumption that both lists are sorted in ascending order. ordSubsetp :: Ord a => [a] -> [a] -> Bool -- | Convert a list to a string, where the converter for each element is a -- monadic computation. formatList :: Monad m => String -> (a -> m String) -> [a] -> m String -- | Like forM_, but with both the elements source as well as the -- loop body as computations over the monad. forMM_ :: (Monad m, Foldable t) => m (t a) -> (a -> m ()) -> m () -- | A while loop, guard at the top. whileDo :: Monad m => m Bool -> m () -> m () -- | A while loop based on stuff, guard at the top. whileDoWith :: Monad m => m a -> (a -> Bool) -> (a -> m ()) -> m () -- | Like forM_, but with an extra check run after the body of the -- loop. If the check fails, the loop exits early. forMwhile_ :: Monad m => [a] -> m Bool -> (a -> m ()) -> m () -- | Like forMwhile_, but the source list is also the result of a -- monadic computation. forMMwhile_ :: Monad m => m [a] -> m Bool -> (a -> m ()) -> m () -- | Like forMM_, except instead of a fixed list, loop over -- Maybe values returned from a subcomputation, until that -- subcomputation returns Nothing. whileReturnJust :: Monad m => m (Maybe a) -> (a -> m ()) -> m () -- | Like unless, expect both the tested value and the body are -- returned from a computation in a monad. unlessMM :: Monad m => m Bool -> m () -> m () -- | Monadic version of null for a list stored in an STRef: -- returns True when the list is empty. nullR :: Monad m => STRef s [a] -> STT s m Bool -- | Opposite of nullR, returning False when the referenced -- list is empty. nonnullR :: Monad m => STRef s [a] -> STT s m Bool -- | Like a combination of whenM and nonnullR, where the body -- receives the (pure) non-null list as an argument. whenNonnullR :: (Monad m0, Monad m) => (forall r. STT s m0 r -> m r) -> STRef s [a] -> ([a] -> m ()) -> m () -- | Map over the values contained within a list of references. mapRefs :: Monad m => (a -> b) -> [STRef s a] -> STT s m [b] -- | Fold (right-associatively) the values contained within a list of -- references. foldrRefs :: Monad m => (a -> b -> b) -> b -> [STRef s a] -> STT s m b -- | Fold (left-associatively) the values contained within a list of -- references. foldlRefs :: Monad m => (b -> a -> b) -> b -> [STRef s a] -> STT s m b -- | Like forM_, but with the list under an STRef. The first -- argument lifts an STT operation into m. forRM_ :: (Monad m, Monad m0, Foldable t) => (STT s m0 (t a) -> m (t a)) -> STRef s (t a) -> (a -> m ()) -> m () -- | Push a value onto the front of the list at the given STT -- reference. push :: Monad m => a -> STRef s [a] -> STT s m () -- | Push the result of a computation onto the front of the list at the -- given STT reference. pushM :: Monad m => m a -> STRef s [a] -> STT s m () -- | Push every value in a collection onto the front of the list at the -- given STT reference. pushAll :: (Monad m, Traversable t) => t a -> STRef s [a] -> STT s m () -- | Push every value in a collection returned from a computation onto the -- front of the list at the given STT reference. pushAllM :: (Monad m, Traversable t) => m (t a) -> STRef s [a] -> STT s m () -- | Pop a value from the given reference to a list if one exists. pop :: Monad m => STRef s [a] -> STT s m (Maybe a) -- | Consumes the elements of a referenced list, one at a time, until the -- list is empty. The first argument is a lift-style function -- which brings STT operations into the top-level monad of -- interest. Intended to be compatible with stack-like behavior (such as -- with push; this function does use pop) where the body of -- the loop may add elements. whileListM_ :: (Monad m0, Monad m) => (forall r. STT s m0 r -> m r) -> STRef s [a] -> (a -> m ()) -> m () -- | Form a comma-separated string from a list. commaList :: (a -> String) -> [a] -> String -- | Remove the Just constructors from the elements of a list, -- discarding elements which are Nothing. unmaybe :: [Maybe a] -> [a] -- | Translation of Forbus and de Kleer's justification-based truth -- maintenance systems (JTMSes) from Common Lisp to Haskell. -- -- This is not a very "Haskelly" implementation; rather, it is a -- translation of the original code with minimal changes. Most of the -- deviations from the original are due to either Haskell's strong -- typing, which necessitates some additional tagging, and to the -- abomination which is Lisp's do macro. The translation relies -- on mutable data structures using STT state thread references. A -- more pure translation, possibly not relying on the ST -- monad/STT transformer, is a significant piece of -- future work. -- -- Note also there are restrictions on the embedded monad m -- which can be wrapped in the STT transformer; see the -- Control.Monad.ST.Trans documentation for details. -- -- See the LICENSE.txt and README-forbus-dekleer.txt -- files distributed with this work for a paragraph stating scope of -- permission and disclaimer of warranty, and for additional information -- regarding copyright ownership. The above copyright notice and that -- paragraph must be included in any separate copy of this file. -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -- implied, for NON-COMMERCIAL use. See the License for the specific -- language governing permissions and limitations under the License. module Data.TMS.JTMS -- | The process of building and using a mutable JTMS. data Monad m => JTMST s m a -- | Errors which can arise from JTMS operations. data JtmsErr -- | Execute a computation in the JTMST monad transformer. runJTMST :: Monad m => (forall s. JTMST s m r) -> m (Either JtmsErr r) -- | Standalone implementation of justification-based truth maintenance -- systems. -- -- -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defstruct (jtms (:PRINT-FUNCTION print-jtms))
--     (title nil)
--     (node-counter 0)             ;; unique namer for nodes.
--     (just-counter 0)             ;; unique namer for justifications.
--     (nodes nil)                  ;; list of all tms nodes.
--     (justs nil)                  ;; list of all justifications
--     (debugging nil)              ;; debugging flag
--     (contradictions nil)         ;; list of contradiction nodes.
--     (assumptions nil)            ;; list of assumption nodes.
--     (checking-contradictions T)  ;; For external systems
--     (node-string nil)
--     (contradiction-handler nil)
--     (enqueue-procedure nil))
--   
data Monad m => JTMS d i r s m -- | Print a simple tag with the title of this JTMS. Forces the enclosed -- monad to be MonadIO. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun print-jtms (jtms stream ignore)
--     (declare (ignore ignore))
--     (format stream "#<JTMS: ~A>" (jtms-title jtms)))
--   
printJTMS :: forall m1 (m2 :: Type -> Type) d i r s. (MonadIO m1, Monad m2) => JTMS d i r s m2 -> m1 () -- | Create and return a new JTMS. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun create-jtms (title &key (node-string 'default-node-string)
--                                  debugging
--                                  (checking-contradictions t)
--                                  (contradiction-handler 'ask-user-handler)
--                                  enqueue-procedure)
--     (make-jtms :TITLE title
--                :NODE-STRING node-string
--                :DEBUGGING debugging
--                :CHECKING-CONTRADICTIONS checking-contradictions
--                :CONTRADICTION-HANDLER contradiction-handler
--                :ENQUEUE-PROCEDURE enqueue-procedure))
--   
createJTMS :: Monad m => String -> JTMST s m (JTMS d i r s m) -- | Name of this JTMS. jtmsTitle :: JTMS d i r s m -> String -- | Set the display function for Nodes in a JTMS. -- -- After change-jtms in jtms.lisp. setNodeString :: Monad m => JTMS d i r s m -> (Node d i r s m -> String) -> JTMST s m () -- | When the node type d implements Show, use this display -- method as the standard for printing the node. nodeStringByDatum :: (Monad m, Show d) => JTMS d i r s m -> JTMST s m () -- | Use the node index for its display. nodeStringByIndex :: Monad m => JTMS d i r s m -> JTMST s m () -- | When the node type d implements Show, use both the -- node index and this display method as the standard for printing the -- node. nodeStringByIndexDatum :: (Monad m, Show d) => JTMS d i r s m -> JTMST s m () -- | Set the display function for the datum associated with each -- Node in a JTMS. setDatumString :: Monad m => JTMS d i r s m -> (d -> String) -> JTMST s m () -- | When the datum type d implements Show, use this -- display method as the standard for printing the datum. datumStringByShow :: (Monad m, Show d) => JTMS d i r s m -> JTMST s m () -- | Set the display function for informants in a JTMS. setInformantString :: Monad m => JTMS d i r s m -> (i -> String) -> JTMST s m () -- | When the informant type i implements Show, use this -- display method as the standard for printing the informant. informantStringByShow :: (Monad m, Show i) => JTMS d i r s m -> JTMST s m () -- | Set the display function for JustRules in a JTMS. -- -- After change-jtms in jtms.lisp. setJustString :: Monad m => JTMS d i r s m -> (JustRule d i r s m -> String) -> JTMST s m () -- | Use the JustRule index when printing the just. justStringByIndex :: Monad m => JTMS d i r s m -> JTMST s m () -- | When the informant type i implements Show, use the -- JustRule index when printing the just. justStringByInformant :: (Monad m, Show i) => JTMS d i r s m -> JTMST s m () -- | When the informant type i implements Show, use the -- JustRule index when printing the just. justStringByIndexInformant :: (Monad m, Show i) => JTMS d i r s m -> JTMST s m () -- | Turn on or turn off debugging in a JTMS. This setting currently has no -- effect. -- -- After change-jtms in jtms.lisp. setDebugging :: Monad m => JTMS d i r s m -> Bool -> JTMST s m () -- | Set whether the JTMS should issue external notifications of -- contradictions. -- -- After change-jtms in jtms.lisp. setCheckingContradictions :: Monad m => JTMS d i r s m -> Bool -> JTMST s m () -- | Set the contradiction handler. The JTMS default is to do -- nothing; the intention is to allow a callback to the external system -- using the JTMS. -- -- After change-jtms in jtms.lisp. setContradictionHandler :: Monad m => JTMS d i r s m -> ([Node d i r s m] -> JTMST s m ()) -> JTMST s m () -- | Set the queuing behavior needed for the external system. -- -- After change-jtms in jtms.lisp. setEnqueueProcedure :: Monad m => JTMS d i r s m -> (r -> JTMST s m ()) -> JTMST s m () -- | Return the current list of Nodes of a JTMS. getJtmsNodes :: Monad m => JTMS d i r s m -> JTMST s m [Node d i r s m] -- | Return the current JustRules of a JTMS. getJtmsJusts :: Monad m => JTMS d i r s m -> JTMST s m [JustRule d i r s m] -- | Return the current designated contradictory Nodes of a -- JTMS. getJtmsContradictions :: Monad m => JTMS d i r s m -> JTMST s m [Node d i r s m] -- | Return the current possible assumption Nodes of a JTMS. -- Note that these nodes will not be used as assumptions unless activated -- by enableAssumption. getJtmsAssumptions :: Monad m => JTMS d i r s m -> JTMST s m [Node d i r s m] -- | Return whether a JTMS is currently invoking its external -- handler for deduced contradictions. getJtmsCheckingContradictions :: Monad m => JTMS d i r s m -> JTMST s m Bool -- | Return the current Node formatter of a JTMS. getJtmsNodeString :: Monad m => JTMS d i r s m -> JTMST s m (Node d i r s m -> String) -- | Return the current JustRule formatter of a JTMS. getJtmsJustString :: Monad m => JTMS d i r s m -> JTMST s m (JustRule d i r s m -> String) -- | Return the current d datum formatter of a JTMS. getJtmsDatumString :: Monad m => JTMS d i r s m -> JTMST s m (d -> String) -- | Return the current i informant formatter of a JTMS. getJtmsInformantString :: Monad m => JTMS d i r s m -> JTMST s m (i -> String) -- | Return the current external queuing procedure of a JTMS. getJtmsEnqueueProcedure :: Monad m => JTMS d i r s m -> JTMST s m (r -> JTMST s m ()) -- | Return the current external handler of a JTMS for reacting to a -- deduced contradiction. getJtmsContradictionHandler :: Monad m => JTMS d i r s m -> JTMST s m ([Node d i r s m] -> JTMST s m ()) -- | Return the current debugging flag setting of a JTMS. getJtmsDebugging :: Monad m => JTMS d i r s m -> JTMST s m Bool -- | Wrapper for one possible belief known to the TMS. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defstruct (tms-node (:PRINT-FUNCTION print-tms-node))
--     (index 0)
--     (datum nil)           ;; pointer to external problem solver
--     (label :OUT)          ;; :IN means believed, :OUT means disbelieved
--     (support nil)         ;; Current justification or premise marker
--     (justs nil)           ;; Possible justifications
--     (consequences nil)    ;; Justifications in which it is an antecedent
--     (mark nil)            ;; Marker for sweep algorithms
--     (contradictory? nil)  ;; Flag marking it as contradictory
--     (assumption? nil)     ;; Flag marking it as an assumption.
--     (in-rules nil)     ;; Rules that should be triggered when node goes in
--     (out-rules nil)    ;; Rules that should be triggered when node goes out
--     (jtms nil))           ;; The JTMS in which this node appears.
--   
data Monad m => Node d i r s m -- | Add a node to a JTMS. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun tms-create-node (jtms datum &key assumptionp contradictoryp)
--     (let ((node (make-tms-node :INDEX (incf (jtms-node-counter jtms))
--                                :DATUM datum
--                                :ASSUMPTION? assumptionp
--                                :CONTRADICTORY? contradictoryp
--                                :JTMS jtms)))
--       (if assumptionp (push node (jtms-assumptions jtms)))
--       (if contradictoryp (push node (jtms-contradictions jtms)))
--       (push node (jtms-nodes jtms))
--       node))
--   
createNode :: Monad m => JTMS d i r s m -> d -> Bool -> Bool -> JTMST s m (Node d i r s m) -- | Returns the piece of data associated with this node. nodeDatum :: Node d i r s m -> d -- | Write one node in the standard way for this JTMS. Forces the wrapped -- monad to be MonadIO. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun print-tms-node (node stream ignore)
--     (declare (ignore ignore))
--     (format stream "#<Node: ~A>" (node-string node)))
--   
printTmsNode :: MonadIO m => Node d i r s m -> JTMST s m () -- | Internal method used to flag this node as an assumption, and to enable -- belief in this assumption. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   ;;; Converts a regular node to an assumption and enables it.
--   (defun assume-node (node &aux (jtms (tms-node-jtms node)))
--     (unless (or (tms-node-assumption? node) (tms-node-premise? node))
--       (debugging-jtms jtms "~%Converting ~A into an assumption" node)
--       (setf (tms-node-assumption? node) t)
--       (push node (jtms-assumptions jtms)))
--     (enable-assumption node))
--   
assumeNode :: Monad m => Node d i r s m -> JTMST s m () -- | Produce a representation of the node in the default manner for its -- JTMS. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun node-string (node)
--     (funcall (jtms-node-string (tms-node-jtms node)) node))
--   
nodeString :: Monad m => Node d i r s m -> JTMST s m String -- | Return whether a Node may currently be used as an assumption. getNodeIsAssumption :: Monad m => Node d i r s m -> JTMST s m Bool -- | Return whether a Node is currently considered a contradiction. getNodeIsContradictory :: Monad m => Node d i r s m -> JTMST s m Bool -- | Return whether a Node is currently believed. getNodeBelieved :: Monad m => Node d i r s m -> JTMST s m Bool -- | Return the JustRules which use a Node as an antecedent. getNodeConsequences :: Monad m => Node d i r s m -> JTMST s m [JustRule d i r s m] -- | Return the current in-rules of a Node. getNodeInRules :: Monad m => Node d i r s m -> JTMST s m [r] -- | Return the current out-rules of a Node. getNodeOutRules :: Monad m => Node d i r s m -> JTMST s m [r] -- | Return the JustRules which currently give a Node as -- their conclusion. getNodeJusts :: Monad m => Node d i r s m -> JTMST s m [JustRule d i r s m] -- | Return the current support for believing a Node. getNodeSupport :: Monad m => Node d i r s m -> JTMST s m (Maybe (Justification d i r s m)) -- | Return whether the given node is an enabled assumption. isEnabledAssumption :: Monad m => Node d i r s m -> JTMST s m Bool -- | Check whether the given node is supported by a JustRule. If it -- is, run the given computation with that JustRule. whenSupportedByRule :: Monad m => Node d i r s m -> (JustRule d i r s m -> JTMST s m a) -> JTMST s m (Maybe a) -- | Check whether the given node is supported by a JustRule. If it -- is, run the thenM computation with that JustRule; if -- not, run the elseM computation. ifSupportedByRule :: Monad m => Node d i r s m -> (JustRule d i r s m -> JTMST s m ()) -> JTMST s m () -> JTMST s m () -- | Add a rule for concluding belief in the consequence. The rule -- is triggered when the antecedents are all believed, and is -- associated with (perhaps named as) the informant. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun justify-node (informant consequence antecedents &aux just jtms)
--     (setq jtms (tms-node-jtms consequence)
--        just (make-just :INDEX (incf (jtms-just-counter jtms))
--                        :INFORMANT informant
--                        :CONSEQUENCE consequence
--                        :ANTECEDENTS antecedents))
--     (push just (tms-node-justs consequence))
--     (dolist (node antecedents) (push just (tms-node-consequences node)))
--     (push just (jtms-justs jtms))
--     (debugging-jtms jtms
--                  "~%Justifying ~A by ~A using ~A."
--                  consequence
--                  informant
--                  (mapcar #'node-string antecedents))
--     (if (or antecedents (out-node? consequence))
--         (if (check-justification just) (install-support consequence just))
--         (setf (tms-node-support consequence) just))
--     (check-for-contradictions jtms))
--   
justifyNode :: Monad m => i -> Node d i r s m -> [Node d i r s m] -> JTMST s m () -- | Forms of data which might signal support for a node. The original Lisp -- does not need this declaration since it is untyped; the latter two -- cases are simply symbols. data Monad m => Justification d i r s m ByRule :: JustRule d i r s m -> Justification d i r s m EnabledAssumption :: Justification d i r s m UserStipulation :: Justification d i r s m -- | Wrapper for one justification relationship between many antecedent -- nodes and one consequent node. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defstruct (just (:PRINT-FUNCTION print-just))
--     (index 0)
--     informant
--     consequence
--     antecedents)
--   
data Monad m => JustRule d i r s m -- | Print the tag of a JTMS justification. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun print-just (just stream ignore)
--     (declare (ignore ignore))
--     (format stream "#<Just ~D>" (just-index just)))
--   
printJustRule :: MonadIO m => JustRule d i r s m -> JTMST s m () -- | Called when the external system chooses to believe the assumption -- represented by node. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun enable-assumption (node &aux (jtms (tms-node-jtms node)))
--     (unless (tms-node-assumption? node)
--       (tms-error "Can't enable the non-assumption ~A" node))
--     (debugging-jtms jtms "~%  Enabling assumption ~A." node)
--     (cond
--        ((out-node? node)
--         (make-node-in node :ENABLED-ASSUMPTION)
--         (propagate-inness node))
--        ((or (eq (tms-node-support node) :ENABLED-ASSUMPTION)
--             (null (just-antecedents (tms-node-support node)))))
--        (t (setf (tms-node-support node) :ENABLED-ASSUMPTION)))
--     (check-for-contradictions jtms))
--   
enableAssumption :: Monad m => Node d i r s m -> JTMST s m () -- | This command is called when the external system chooses to disbelieve -- the assumption represented by node. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun retract-assumption (node &aux jtms)
--     (when (eq (tms-node-support node) :ENABLED-ASSUMPTION)
--       (setq jtms (tms-node-jtms node))
--       (debugging-jtms jtms "~%  Retracting assumption ~A." node)
--       (make-node-out node)
--       (find-alternative-support jtms
--                                 (cons node (propagate-outness node jtms)))))
--   
retractAssumption :: Monad m => Node d i r s m -> JTMST s m () -- | API command used when the external system categorizes this node as -- representing a contradiction. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun make-contradiction (node &aux (jtms (tms-node-jtms node)))
--     (unless (tms-node-contradictory? node)
--       (setf (tms-node-contradictory? node) t)
--       (push node (jtms-contradictions jtms))
--       (check-for-contradictions jtms)))
--   
makeContradiction :: Monad m => Node d i r s m -> JTMST s m () -- | Returns True if the current believed assumptions justify the -- fact represented by the given node. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun in-node? (node) (eq (tms-node-label node) :IN))
--   
isInNode :: Monad m => Node d i r s m -> JTMST s m Bool -- | Returns True if the current believed assumptions do not -- justify the fact represented by the given node. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun out-node? (node) (eq (tms-node-label node) :OUT))
--   
isOutNode :: Monad m => Node d i r s m -> JTMST s m Bool -- | Returns the list of currently enabled assumptions. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun enabled-assumptions (jtms &aux result)
--     (dolist (assumption (jtms-assumptions jtms) result)
--       (if (eq (tms-node-support assumption) :ENABLED-ASSUMPTION)
--        (push assumption result))))
--   
enabledAssumptions :: Monad m => JTMS d i r s m -> JTMST s m [Node d i r s m] -- | Returns True when the node is supported by a JustRule -- with no antecedents. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun tms-node-premise? (node &aux support)
--     (and (setq support (tms-node-support node))
--          (not (eq support :ENABLED-ASSUMPTION))
--          (null (just-antecedents support))))
--   
nodeIsPremise :: Monad m => Node d i r s m -> JTMST s m Bool -- | API command returning the believed assumption nodes used to justify -- belief in this node. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun assumptions-of-node (node &aux assumptions (marker (list :MARK)))
--     (do ((nodes (list node) (append (cdr nodes) new))
--          (new nil nil))
--         ((null nodes) assumptions)
--       (let ((node (car nodes)))
--         (cond
--           ((eq (tms-node-mark node) marker))
--           ((eq (tms-node-support node) :ENABLED-ASSUMPTION)
--            (push node assumptions))
--           ((in-node? node)
--            (setq new (just-antecedents (tms-node-support node)))))
--         (setf (tms-node-mark node) marker))))
--   
assumptionsOfNode :: Monad m => Node d i r s m -> JTMST s m [Node d i r s m] -- | Prints the justifications of all current nodes. Requires that the -- underlying monad m be MonadIO. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun why-nodes (jtms)
--     (dolist (node (jtms-nodes jtms)) (why-node node)))
--   
whyNodes :: MonadIO m => JTMS d i r s m -> JTMST s m () -- | Print the belief state and any justification of this node. Requires -- that the underlying monad m be MonadIO. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun why-node (node &aux justification)
--     (setq justification (tms-node-support node))
--     (cond
--       ((eq justification :ENABLED-ASSUMPTION)
--        (format t "~%~A is an enabled assumption" (node-string node)))
--       (justification (format t "~%~A is IN via ~A on"
--                        (node-string node)
--                        (just-informant justification))
--                      (dolist (anode (just-antecedents justification))
--                        (format t "~%  ~A" (node-string anode))))
--       (T (format t "~%~A is OUT." (node-string node))))
--     node)
--   
whyNode :: MonadIO m => Node d i r s m -> JTMST s m () -- |
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (proclaim '(special *contra-assumptions*))
--   
--   (defun ask-user-handler (jtms contradictions)
--     (handle-one-contradiction (car contradictions))
--     (check-for-contradictions jtms))
--   
-- -- askUserHandler :: MonadIO m => JTMS d i r s m -> [Node d i r s -- m] -> JTMST s m () askUserHandler jtms contradictions = error -- "unimplemented" -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun handle-one-contradiction (contra-node
--                                 &aux the-answer *contra-assumptions*)
--     (setq *contra-assumptions* (assumptions-of-node contra-node))
--     (unless *contra-assumptions*
--       (tms-error "~%There is a flaw in the universe...~A" contra-node))
--     (format t "~%Contradiction found: ~A" (node-string contra-node))
--     (print-contra-list *contra-assumptions*)
--     (format t "~%Call (TMS-ANSWER <number>) to retract assumption.")
--     (setq the-answer
--        (catch 'tms-contradiction-handler
--          (break "JTMS contradiction break")))
--     (if (and (integerp the-answer)
--           (> the-answer 0)
--           (not (> the-answer (length *contra-assumptions*))))
--         (retract-assumption (nth (1- the-answer)
--                               *contra-assumptions*))))
--   
-- -- handleOneContradiction :: Monad m => JTMS d i r s m -> JTMST s m -- () handleOneContradiction node = error "unimplemented" -- -- Print a verbose debugging output list of the contradictions in the -- JTMS. Requires that the underlying monad m be MonadIO. -- --
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun print-contra-list (nodes)
--     (do ((counter 1 (1+ counter))
--          (nn nodes (cdr nn)))
--         ((null nn))
--       (format t "~%~A ~A" counter
--            (node-string (car nn)))))
--   
printContraList :: MonadIO m => [Node d i r s m] -> JTMST s m () -- |
Lisp origins:
-- --
--   ;; In jtms.lisp:
--   (defun tms-answer (num)
--     (if (integerp num)
--         (if (> num 0)
--          (if (not (> num (length *contra-assumptions*)))
--              (throw 'tms-contradiction-handler num)
--              (format t "~%Ignoring answer, too big."))
--          (format t "~%Ignoring answer, too small"))
--         (format t "~%Ignoring answer, must be an integer.")))
--   
-- -- tmsAnswer :: MonadIO m => Int -> JTMST s m () tmsAnswer = error -- "unimplemented" -- -- Print debugging information about a JTMS. debugJTMS :: MonadIO m => String -> JTMS d i r s m -> JTMST s m () -- | Print debugging information about the Nodes of a JTMS. debugNodes :: MonadIO m => JTMS d i r s m -> JTMST s m () -- | Print debugging information about a Node. debugNode :: MonadIO m => Node d i r s m -> JTMST s m () -- | Print debugging information about the JustRules of a -- JTMS. debugJusts :: MonadIO m => JTMS d i r s m -> JTMST s m () -- | Print debugging information about a JustRule. debugJust :: MonadIO m => JTMS d i r s m -> JustRule d i r s m -> JTMST s m () instance GHC.Show.Show Data.TMS.JTMS.JtmsErr instance GHC.Base.Monad m => GHC.Classes.Eq (Data.TMS.JTMS.JTMS d i r s m) instance GHC.Base.Monad m => GHC.Classes.Eq (Data.TMS.JTMS.Node d i r s m) instance GHC.Base.Monad m => GHC.Classes.Eq (Data.TMS.JTMS.JustRule d i r s m) instance GHC.Base.Monad m => GHC.Base.Functor (Data.TMS.JTMS.JTMST s m) instance (GHC.Base.Monad m, GHC.Base.Functor m) => GHC.Base.Applicative (Data.TMS.JTMS.JTMST s m) instance (GHC.Base.Monad m, GHC.Base.Functor m) => GHC.Base.Monad (Data.TMS.JTMS.JTMST s m) instance Control.Monad.Trans.Class.MonadTrans (Data.TMS.JTMS.JTMST s) instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Data.TMS.JTMS.JTMST s m) -- | Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -- implied, for NON-COMMERCIAL use. See the License for the specific -- language governing permissions and limitations under the License. module Data.TMS.MList -- | Singly linked lists! But with mutable CARs and CDRs à la Common Lisp. data MList s a -- | A cons cell with mutable fields. MCons :: STRef s a -> STRef s (MList s a) -> MList s a -- | Regular old nil. MNil :: MList s a -- | Convert a pure list into a mutable list. toMList :: Monad m => [a] -> STT s m (MList s a) -- | Convert an MList to a String. showM :: (Show a, Monad m) => MList s a -> STT s m String -- | Returns True for an empty list. mnull :: MList s a -> Bool -- | Returns True from an STT monad for a reference to an -- empty list. getMnull :: Monad m => STRef s (MList s a) -> STT s m Bool -- | Returns the CAR (element) of the first CONS cell of a non-empty -- mutable list. mcar :: forall (m :: Type -> Type) s a. Applicative m => MList s a -> STT s m a -- | Returns the CDR (next cell) of the first CONS cell of a non-empty -- mutable list. mcdr :: forall (m :: Type -> Type) s a. Applicative m => MList s a -> STT s m (MList s a) -- | Convert a traditional Haskell list into a mutable MList list. mlength :: Monad m => MList s a -> STT s m Int -- | Convert a traditional Haskell list into a mutable MList list. fromList :: Monad m => [a] -> STT s m (MList s a) -- | Convert a traditional Haskell list into a mutable MList list, -- applying the given function to each element. fromListMap :: Monad m => (a -> b) -> [a] -> STT s m (MList s b) -- | Convert a mutable MList list into a traditional Haskell list. toList :: Monad m => MList s a -> STT s m [a] -- | Convert a mutable MList list of Maybe values into a -- traditional Haskell list containing only the values under a -- Just constructor. toUnmaybeList :: Monad m => MList s (Maybe a) -> STT s m [a] -- | A version of map for MLists. mlistMap :: Monad m => (a -> b) -> MList s a -> STT s m (MList s b) -- | A version of filter for MLists. mlistFilter :: Monad m => (a -> Bool) -> MList s a -> STT s m (MList s a) -- | Return a new MList which strips off the Just constructor -- from its elements, dropping and elements which are Nothing. mlistUnmaybe :: Monad m => MList s (Maybe a) -> STT s m (MList s a) -- | Return a new MList which drops elements which are -- Nothing. mlistStripNothing :: Monad m => MList s (Maybe a) -> STT s m (MList s (Maybe a)) -- | Return a new MList which drops elements which are -- Nothing from the MList under the reference argument. getMlistStripNothing :: Monad m => STRef s (MList s (Maybe a)) -> STT s m (MList s (Maybe a)) -- | Treating an MList as a stack, add a new element at the top of -- the stack, and return the new stack top. mlistPush :: Monad m => a -> MList s a -> STT s m (MList s a) -- | Treating an MList as a stack, add a new element at the top of -- the stack, and return the new stack top. mlistRefPush :: Monad m => a -> STRef s (MList s a) -> STT s m () -- | Iterate over the elements of a MList. The body does not -- necessarily need operate in the same monad as where the references -- originate; the lifter parameter brings the latter into the -- former. mlistFor_ :: (Monad m0, Monad m) => (forall r. STT s m0 r -> m r) -> MList s a -> (a -> m ()) -> m () -- | Like mlistFor_, but the body expects an MCons cell -- instead of the list element itself. Useful for mutating the list along -- the way. mlistForCons_ :: (Monad m0, Monad m) => (forall r. STT s m0 r -> m r) -> MList s a -> (MList s a -> m ()) -> m () -- | A combination of mlistForCons_ and forMwhile_: iterate -- over the MCons cell of a list, with a trigger for an early -- exit. Note that the monad for the continuation condition is over the -- overall monad m, not the STT wrapped monad -- m0. mlistForConsWhile_ :: (Monad m0, Monad m) => (forall r. STT s m0 r -> m r) -> MList s a -> m Bool -> (MList s a -> m ()) -> m () -- | Overwrite the car slot of the given MCons with the -- given value. Named after the Common Lisp function with the same -- behavior. rplaca :: Monad m => MList s a -> a -> STT s m () -- | Translation of Forbus and de Kleer's assumption-based truth -- maintenance systems (ATMSes) from Common Lisp to Haskell. -- -- This is not a very "Haskelly" implementation; rather, it is a -- translation of the original code with minimal changes. Most of the -- deviations from the original are due to either Haskell's strong -- typing, which necessitates some additional tagging, and to the -- abomination which is Lisp's do macro. The translation relies -- on mutable data structures using STT state thread references. A -- more pure translation, possibly not relying on the ST -- monad/STT transformer, is a significant piece of -- future work. -- -- Note also there are restrictions on the embedded monad m -- which can be wrapped in the STT transformer; see the -- Control.Monad.ST.Trans documentation for details. -- -- See the LICENSE.txt and README-forbus-dekleer.txt -- files distributed with this work for a paragraph stating scope of -- permission and disclaimer of warranty, and for additional information -- regarding copyright ownership. The above copyright notice and that -- paragraph must be included in any separate copy of this file. -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -- implied, for NON-COMMERCIAL use. See the License for the specific -- language governing permissions and limitations under the License. module Data.TMS.ATMS.ATMST -- | The process of building and using a mutable ATMS. data Monad m => ATMST s m a -- | Errors which can arise from ATMS operations. data AtmsErr -- | It is not possible to remove a Node from an ATMS after a -- JustRule which uses that Node is added to the -- ATMS. CannotRemoveNodeWIthConsequences :: String -> Int -> AtmsErr -- | Internal error called when there is no internal default empty -- Env associated with this ATMS. Should never be signaled -- for an ATMS created with createATMS, since this latter -- function does set up the default empty environment before returning -- the new ATMS. InternalNoEmptyEnv :: AtmsErr -- | Indicates a pattern-matching failure within an ATMST operation. FromMonadFail :: String -> AtmsErr -- | Execute a computation in the ATMST monad transformer. runATMST :: Monad m => (forall s. ATMST s m r) -> m (Either AtmsErr r) -- | Retrieve the current initial Env table size setting. setInitialEnvTableAlloc :: Monad m => Int -> ATMST s m () -- | Retrieve the current initial Env table size setting. setEnvTableIncr :: Monad m => Int -> ATMST s m () -- | Retrieve the current initial Env table size setting. getInitialEnvTableAlloc :: Monad m => ATMST s m Int -- | Retrieve the current initial Env table size setting. getEnvTableIncr :: Monad m => ATMST s m Int -- | Class of type which can be used as the datum underlying Nodes -- in an ATMS. class NodeDatum d -- | The datum associated with the contradiction node in a -- newly-initialized ATMS with Node data of this type. contradictionNodeDatum :: NodeDatum d => d -- | Top-level representation of an assumption-based truth maintenance -- system. data (Monad m, NodeDatum d) => ATMS d i r s m -- | Create a new, empty ATMS. -- -- Translated from create-atms in atms.lisp. createATMS :: (Debuggable m, NodeDatum d) => String -> ATMST s m (ATMS d i r s m) -- | Name of this ATMS. atmsTitle :: ATMS d i r s m -> String -- | Return the ATMS's current Node list. getNodes :: (Monad m, NodeDatum d) => ATMS d i r s m -> ATMST s m [Node d i r s m] -- | Return the ATMS's current JustRule list. getJusts :: (Monad m, NodeDatum d) => ATMS d i r s m -> ATMST s m [JustRule d i r s m] -- | Return the ATMS's current contradictions list. getContradictions :: (Monad m, NodeDatum d) => ATMS d i r s m -> ATMST s m [Node d i r s m] -- | Return the ATMS's current assumptions list. getAssumptions :: (Monad m, NodeDatum d) => ATMS d i r s m -> ATMST s m [Node d i r s m] -- | Return the ATMS's built-in contradiction node. getContradictionNode :: (Monad m, NodeDatum d) => ATMS d i r s m -> ATMST s m (Node d i r s m) -- | Return the ATMS's built-in empty environment. getEmptyEnvironment :: (Monad m, NodeDatum d) => ATMS d i r s m -> ATMST s m (Env d i r s m) -- | Return the ATMS's current Node formatter. getNodeString :: (Monad m, NodeDatum d) => ATMS d i r s m -> ATMST s m (Node d i r s m -> String) -- | Return the ATMS's current JustRule formatter. getJustString :: (Monad m, NodeDatum d) => ATMS d i r s m -> ATMST s m (JustRule d i r s m -> String) -- | Return the ATMS's current datum formatter. getDatumString :: (Monad m, NodeDatum d) => ATMS d i r s m -> ATMST s m (d -> String) -- | Return the ATMS's current informant formatter. getInformantString :: (Monad m, NodeDatum d) => ATMS d i r s m -> ATMST s m (i -> String) -- | Return the ATMS's current rule-queueing procedure. getEnqueueProcedure :: (Monad m, NodeDatum d) => ATMS d i r s m -> ATMST s m (r -> ATMST s m ()) -- | When the data associated with Nodes are all Strings, we -- can direct the ATMS to display each datum as itself. setDatumStringViaString :: Monad m => ATMS String i r s m -> ATMST s m () -- | When the data associated with Nodes are of a type of class -- Show, we can direct the ATMS to display each datum using -- the show instance. setDatumStringViaShow :: (NodeDatum d, Show d, Monad m) => ATMS d i r s m -> ATMST s m () -- | When the informants associated with JustRules are all -- Strings, we can direct the ATMS to display each -- informant as itself. setInformantStringViaString :: (Monad m, NodeDatum d) => ATMS d String r s m -> ATMST s m () -- | When the informants associated with JustRules are of a type of -- class Show, we can direct the ATMS to display each datum -- using the show instance. setInformantStringViaShow :: (Show i, Monad m, NodeDatum d) => ATMS d i r s m -> ATMST s m () -- | Wrapper for the datum associated with a node of the ATMS. -- -- Translated from (tms-node in atms.lisp. data (Monad m, NodeDatum d) => Node d i r s m -- | Retrieve the datum associated with a Node. nodeDatum :: Node d i r s m -> d -- | Create a new Node in an ATMS. -- -- Translated from create-node in atms.lisp. createNode :: (Debuggable m, NodeDatum d) => ATMS d i r s m -> d -> Bool -> Bool -> ATMST s m (Node d i r s m) -- | Retrieve the ATMS associated with a Node. nodeATMS :: Node d i r s m -> ATMS d i r s m -- | Shortcut for retrieving the Node formatter from an ATMS, -- and applying it to the given Node. -- -- Translated from node-string in atms.lisp. nodeString :: (Monad m, NodeDatum d) => Node d i r s m -> ATMST s m String -- | Default formatter for the Nodes of an ATMS. -- -- Translated from default-node-string in atms.lisp. defaultNodeString :: (Monad m, NodeDatum d) => Node d i r s m -> ATMST s m String -- | Return the Node's label. getNodeLabel :: (Monad m, NodeDatum d) => Node d i r s m -> ATMST s m [Env d i r s m] -- | Return the Node's rules. getNodeRules :: (Monad m, NodeDatum d) => Node d i r s m -> ATMST s m [r] -- | Return the Node's consequences. getNodeConsequences :: (Monad m, NodeDatum d) => Node d i r s m -> ATMST s m [JustRule d i r s m] -- | Mark the given Node as to be believed as an assumption by its -- ATMS. -- -- Translated from assume-node in atms.lisp. assumeNode :: (Debuggable m, NodeDatum d) => Node d i r s m -> ATMST s m () -- | Mark the given Node as an additional contradiction node of the -- ATMS. -- -- Translated from make-contradiction in atms.lisp. makeContradiction :: (Monad m, NodeDatum d) => Node d i r s m -> ATMST s m () -- | Remove a Node from the ATMS. -- -- Translated from remove-node in atms.lisp. removeNode :: (Monad m, NodeDatum d) => Node d i r s m -> ATMST s m () -- | The justification of one ATMS Node by zero or more -- others. data (Monad m, NodeDatum d) => JustRule d i r s m JustRule :: Int -> i -> Node d i r s m -> [Node d i r s m] -> JustRule d i r s m -- | The informant associated with applying this inference rule. justInformant :: JustRule d i r s m -> i -- | The conclusion of this inference rule. justConsequence :: JustRule d i r s m -> Node d i r s m -- | The antecedents of this inference rule. justAntecedents :: JustRule d i r s m -> [Node d i r s m] -- | Description of why a Node may be believed by the ATMS. data Justification d i r s m -- | Explanation of why a Node may be believed by the ATMS -- for output to a query. data Explanation d i r s m -- | Direct the ATMS to believe a particular Node when all of -- the given list of Nodes are also believed. The first argument -- is the informant associated with this inference. -- -- Translated from justify-node in atms.lisp. justifyNode :: (Debuggable m, NodeDatum d) => i -> Node d i r s m -> [Node d i r s m] -> ATMST s m () -- | An environment of Nodes which may be used as the basis of -- reasoning in an ATMS. data (Monad m, NodeDatum d) => Env d i r s m -- | Type alias for the array storage of a table of Envs arranged by -- length. data EnvTable d i r s m -- | The unique nomber of this Env within its ATMS. envIndex :: Env d i r s m -> Int -- | The assumptions contained within this Env. envAssumptions :: Env d i r s m -> [Node d i r s m] -- | Shortcut for reading the Nodes of an Env. getEnvNodes :: (Monad m, NodeDatum d) => Env d i r s m -> ATMST s m [Node d i r s m] -- | Returns True if the given Node is axiomatic, following -- from the assumption of zero other nodes. -- -- Translated from true-node? in atms.lisp. isTrueNode :: (Monad m, NodeDatum d) => Node d i r s m -> ATMST s m Bool -- | Returns True if the given Node is justified by some -- labelling Environment of Nodes in the ATMS. -- -- Translated from in-node? in atms.lisp. isInNode :: (Monad m, NodeDatum d) => Node d i r s m -> ATMST s m Bool -- | Returns True if the given Node is justified by some -- subset of the given environment in the ATMS. -- -- Translated from in-node? in atms.lisp. isInNodeByEnv :: (Monad m, NodeDatum d) => Node d i r s m -> Env d i r s m -> ATMST s m Bool -- | Returns True if the given Node is justified by no -- labelling Environment of Nodes in the ATMS. -- -- Translated from out-node? in atms.lisp. isOutNode :: (Monad m, NodeDatum d) => Node d i r s m -> Env d i r s m -> ATMST s m Bool -- | Returns True if some environment justifying the given -- Node is consistent with the given environment, where two -- environments are consistent when their union is not no-good. -- -- Translated from node-consistent-with? in atms.lisp. isNodeConsistentWith :: (Monad m, NodeDatum d) => Node d i r s m -> Env d i r s m -> ATMST s m Bool -- | Return whether the Node's is currently markable as an -- assumption. getNodeIsAssumption :: (Monad m, NodeDatum d) => Node d i r s m -> ATMST s m Bool -- | Return whether the Node's is currently contradictory. getNodeIsContradictory :: (Monad m, NodeDatum d) => Node d i r s m -> ATMST s m Bool -- | Shortcut for testing whether an Env is nogood. envIsNogood :: (Monad m, NodeDatum d) => Env d i r s m -> ATMST s m Bool -- | Give a verbose printout of an ATMS. debugAtms :: (MonadIO m, NodeDatum d) => String -> ATMS d i r s m -> ATMST s m () -- | Print the internal title signifying an ATMS. -- -- Translated from print-atms in atms.lisp. printAtms :: (MonadIO m, NodeDatum d) => ATMS d i r s m -> ATMST s m () -- | Give a verbose printout of the Environments of an ATMS. debugAtmsEnvs :: (MonadIO m, NodeDatum d) => ATMS d i r s m -> ATMST s m () -- | Print statistics about an ATMS. -- -- Translated from print-atms-statistics in atms.lisp. printAtmsStatistics :: (MonadIO m, NodeDatum d) => ATMS d i r s m -> ATMST s m () -- | Computation returning a one-line summary of one Node of an -- ATMS. formatNode :: (Monad m, NodeDatum d) => Node d i r s m -> ATMST s m String -- | Computation returning a one-line summary of the Nodes of an -- ATMS. formatNodes :: (Monad m, NodeDatum d) => String -> [Node d i r s m] -> ATMST s m String -- | Give a verbose printout of a Node of an ATMS. debugNode :: (MonadIO m, NodeDatum d) => Node d i r s m -> ATMST s m () -- | Print a verbose summary of a Node of an ATMS. -- -- Translated from print-tms-node in atms.lisp. printNode :: (MonadIO m, NodeDatum d) => Node d i r s m -> ATMST s m () -- | Print the justifying Environments which label each Node -- of an ATMS. -- -- Translated from why-nodes in atms.lisp. whyNodes :: (MonadIO m, NodeDatum d) => ATMS d i r s m -> ATMST s m () -- | Print the justifying Environments which label a Node. -- -- Translated from why-node in atms.lisp. whyNode :: (MonadIO m, NodeDatum d) => Node d i r s m -> ATMST s m () -- | Give a verbose printout of one Environment of an ATMS. debugEnv :: (MonadIO m, NodeDatum d) => Env d i r s m -> ATMST s m () -- | Give a verbose printout of the Environments of an -- EnvTable of an ATMS. debugEnvTable :: (MonadIO m, NodeDatum d) => ATMS d i r s m -> EnvTable d i r s m -> ATMST s m () -- | Computation returning a one-line summary of the label of a Node -- of an ATMS. formatNodeLabel :: (Monad m, NodeDatum d) => Node d i r s m -> ATMST s m String -- | Give a verbose printout of the no-good Environments of an -- ATMS. debugNogoods :: (MonadIO m, NodeDatum d) => ATMS d i r s m -> ATMST s m () -- | Print an environment. -- -- Translated from print-env in atms.lisp. printEnv :: (MonadIO m, NodeDatum d) => Env d i r s m -> ATMST s m () -- | List the nogood Environments of an ATMS. -- -- Translated from print-nogoods in atms.lisp. printNogoods :: (MonadIO m, NodeDatum d) => ATMS d i r s m -> ATMST s m () -- | Print the Environments of an ATMS. -- -- Translated from print-envs in atms.lisp. printEnvs :: (MonadIO m, NodeDatum d) => ATMS d i r s m -> ATMST s m () -- | Print the Environments contained in the given EnvTable. -- -- Translated from print-env-table in atms.lisp. printEnvTable :: (MonadIO m, NodeDatum d) => EnvTable d i r s m -> ATMST s m () -- | Print the entries of an EnvTable. -- -- Translated from print-table in atms.lisp. printTable :: (MonadIO m, NodeDatum d) => String -> EnvTable d i r s m -> ATMST s m () -- | Give a verbose printout of one Justification rule of an -- ATMS. debugJust :: (MonadIO m, NodeDatum d) => JustRule d i r s m -> ATMST s m () -- | Print a more verbose description of a Justification rule of an -- ATMS. -- -- Translated from print-just in atms.lisp. printJust :: (MonadIO m, NodeDatum d) => JustRule d i r s m -> ATMST s m () -- | Computation returning a one-line summary of the reason an ATMS -- may believe a Node. formatJustification :: (Monad m, NodeDatum d) => Justification d i r s m -> ATMST s m String instance GHC.Show.Show Data.TMS.ATMS.ATMST.AtmsErr instance (GHC.Base.Monad m, Data.TMS.ATMS.ATMST.NodeDatum d) => GHC.Classes.Eq (Data.TMS.ATMS.ATMST.Node d i r s m) instance (GHC.Base.Monad m, Data.TMS.ATMS.ATMST.NodeDatum d) => GHC.Classes.Ord (Data.TMS.ATMS.ATMST.Node d i r s m) instance (GHC.Base.Monad m, Data.TMS.ATMS.ATMST.NodeDatum d) => GHC.Show.Show (Data.TMS.ATMS.ATMST.Node d i r s m) instance (GHC.Base.Monad m, Data.TMS.ATMS.ATMST.NodeDatum d) => GHC.Classes.Eq (Data.TMS.ATMS.ATMST.JustRule d i r s m) instance (GHC.Base.Monad m, Data.TMS.ATMS.ATMST.NodeDatum d) => GHC.Classes.Eq (Data.TMS.ATMS.ATMST.Env d i r s m) instance (GHC.Base.Monad m, Data.TMS.ATMS.ATMST.NodeDatum d) => GHC.Show.Show (Data.TMS.ATMS.ATMST.Env d i r s m) instance Data.TMS.ATMS.ATMST.NodeDatum GHC.Base.String instance Data.TMS.ATMS.ATMST.NodeDatum Data.Symbol.Unsafe.Symbol instance GHC.Base.Monad m => GHC.Base.Functor (Data.TMS.ATMS.ATMST.ATMST s m) instance (GHC.Base.Monad m, GHC.Base.Functor m) => GHC.Base.Applicative (Data.TMS.ATMS.ATMST.ATMST s m) instance (GHC.Base.Monad m, GHC.Base.Functor m) => GHC.Base.Monad (Data.TMS.ATMS.ATMST.ATMST s m) instance Control.Monad.Trans.Class.MonadTrans (Data.TMS.ATMS.ATMST.ATMST s) instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Data.TMS.ATMS.ATMST.ATMST s m) instance GHC.Base.Monad m => Control.Monad.Fail.MonadFail (Data.TMS.ATMS.ATMST.ATMST s m) instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.ST.Trans.Internal.STT s m)