Putting JTMS to work - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Putting JTMS to work

Description:

(i) Declare a premise: (assert! fact Anything else ) (ii) Declare an assumption: (assume! ... Example: Detecting captures in N-Queens problem (see jqrule.lsp) ... – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 15
Provided by: csC5
Category:
Tags: jtms | assert | in | lsp | putting | work

less

Transcript and Presenter's Notes

Title: Putting JTMS to work


1
Putting JTMS to work
  • The JTMS / JTRE relationship is the following

2
JTMS JTRE interface
  • Corresponding JTRE action
  • A. Provides mapping between IE and TMS
  • data structures
  • If a new node is needed, IE must inform TMS about
    it, and ensure a connection between this node and
    the corresponding assertion.
  • To use TMS nodes, IE must be able to retrieve TMS
    nodes associated with assertions that IE works
    with.
  • IE must provide an interface for defining nodes
    as premises, and for enabling/retracting
    assumptions.
  • JTMS action
  • A. Creates nodes with specified properties

3
JTMS JTRE interface
  • Corresponding JTRE action
  • B. Provides facilities for representing
    justifications.
  • C. Provides facilities for inspecting TMS
    beliefs, i.e. accessing label information.
  • JTMS action
  • B. Accepts records of IE deductions (as
    justifications)
  • Computes the correct label for nodes and supplies
    them on request.
  • Derives consequences of assumptions premises
    based on dependency network
  • When assumptions are retracted, their
    consequences are retracted
  • Provides explanations for belief e.g., chains of
    well-founded support

4
JTMS JTRE interface
  • Corresponding JTRE action
  • D. Provides facilities for contradiction
    handling.
  • E. Provides methods for including
    constraints on beliefs in the conditions for rule
    firing, and ensures that rules are fired only
    when belief constraints are satisfied (in
    addition to proper trigger matching).
  • JTMS action
  • D. Detects contradictions, based on
    contradiction nodes and explicit dependencies.
  • E. Accepts rules from IE to be scheduled for
    execution when particular belief conditions are
    met.

5
  • 1. Ensuring a proper mapping between JTRE and
    JTMS
  • structures
  • Assertion i Cash assertion
    i Node i
  • (A LISP form)
    (A complex structure)
  • Note The fact that Assertion i ? JTRE DB is not
    related to its truth status.
  • To define its truth status, JTRE must examine the
    label of Node i.
  • Assertions (similar to nodes) entered in the DB
    stay there forever. They are
  • represented as follows (see JDATA.LSP)
  • (defstruct (datum (PRINT-FUNCTION
    jtre-datum-printer))
  • id
    Unique ID for easy lookup
  • lisp-form Expression
    for pattern-matching

JTRE Data Base
Belief status for Node i
JTMS Network
6
  • Representation of JTMS nodes (see JTMS.LSP)
  • (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.
  • A mapping between JTMS nodes and JTRE assertions
    is implemented
  • by having each JTMS node point to its
    corresponding datum, and each
  • JTRE datum point back to its TMS node (i.e. there
    is 11 correspondence

7
  • 2. Justifying assertions in terms of other
    beliefs
  • There are 3 ways to change the status of a TMS
    node (i) declare it as a
  • premise, (ii) declare it as an assumption, and
    (iii) retract an assumed
  • node. Their counterpart JTRE operations are
  • (i) Declare a premise (assert! ltfactgt
    ltAnything elsegt)
  • (ii) Declare an assumption (assume! ltfactgt
    ltreasongt)
  • (iii) Retract an assumption (retract!
    ltfactgt)
  • Also
  • (iv) To install a justification (assert!
    ltfactgt (ltinformantgt . ltantecedentsgt))
  • To define a new justification, JTRE
    provides procedures for translating the
    assertions (the consequent and the list of
    antecedents) into TMS nodes, and then JTMS
    procedure justify-node (in jtms.lsp file) is
    called to build the actual justification.
  • (v) To install a contradiction
    (contradiction ltfactgt)

8
  • 3. Queries concerning belief states
  • If JTRE can access TMS nodes, then it will get
    all the information related to the
  • belief status of a node label, supporting
    justification, enabled assumptions upon
  • which a node depends. To make this possible, JTRE
    must have procedures for
  • translating assertions into JTMS nodes and
    calling the underlying JTMS
  • primitives (all in jtms.lsp)
  • in?
  • out?
  • why?
  • assumptions-of
  • fetch
  • wfs

9
4. Contradiction handling
  • To declare a contradiction, JTRE uses JTMS
    procedure make-contradiction.
  • To resolve a contradiction, JTRE must provide
    task-specific contradiction
  • handlers through the JTMS macro
  • (with-contradiction-handler ltjtmsgt
    lthandlergt . ltbodygt)
  • JTMS contradiction processing is affected by two
    fields of the JTMS data
  • structure contradictionhandler and checking
    contradictions.
  • At the end of each JTMS operation that may cause
    a new contradiction, the
  • JTMS invokes the procedure check-for-contradiction
    s. If contradiction checking
  • is not enabled, check-for-contradictions returns
    immediately otherwise, it finds
  • all contradictions currently IN and calls the
    JTRE supplied contradiction handler
  • with this set.

10
5. Tying rule execution to belief states
  • Recall that assertions in the JTRE DB may have
    three different statuses
  • There is no indication whether the corresponding
    JTMS node is IN or OUT
  • Believed
  • Retracted
  • Therefore, the rule triggers must say in which of
    the three cases a match occurs.
  • JTRE rules have the following format
  • (rule ltlist of triggersgt ltbodygt), where triggers
    are (ltconditiongt ltpatterngt),
  • and the types of conditions are
  • INTERN A match occurs always when a trigger
    finds a matching pattern
  • in the DB, no matter what
    its belief status is.
  • NOTE Such triggers are
    useful for detecting contradictions in the
  • DB, for example x 5 and
    x 10.
  • IN A pattern matching the trigger must
    be believed for the rule to fire.
  • OUT A pattern matching the trigger must be
    disbelieved for the rule to fire.

11
Tying rule execution to belief states (cont.)
  • Trigger options
  • VAR Binds the entire trigger pattern
  • TEST Additional test for matching
  • Examples of rules
  • (rule ((in (implies ?p ?q) var ?f1)
  • (in ?p))
  • (rassert! ?q (CE ?f1 ?p)))
  • (rule ((in (show ?p) var ?f1)
  • test (not (logical-connective? ?p)))
  • (rassert! ((show ?p) Indirect-Proof
    PRIORITY Low)
  • (BC-IP ?f1)))

12
Tying rule execution to belief states (cont.)
  • Example Detecting captures in N-Queens problem
    (see jqrule.lsp)
  • Assume that the following contradiction is
    declared
  • (contradiction queens-caprure jtre)
  • The following rule is intended to reveal it
  • (rule ((IN (Queen ?column1 ?row1) VAR ?Q1)
  • (IN (Queen ?column2 ?row2) VAR ?Q2
  • TEST (not (or ( ?column1 ?column2)
  • (queens-okay? ?column1 ?row1
  • ?column2 ?row2)))))
  • (rassert! Queens-capture (Death ?Q1 ?Q2)))

13
Tying rule execution to belief states (cont.)
  • Efficiently linking rule firing to changes in the
    labels of TMS nodes is the
  • most important task of JTRE JTMS interface.
  • This can be achieved by representing rule
    instances as JTMS data, and letting
  • JTMS schedule their execution. Such rule
    instantiations are called consumers.
  • Example
  • Socrates is human
  • Humans are mortal
  • JTRE
    JTMS
  • Consumers are stored with JTMS nodes
    corresponding to rule antecedents.
  • When the JTMS algorithm updates the JTMS network,
    it checks for consumers
  • that can be activated.

N1
N2
Rule
Consumer
14
Experimenting with JTMS Running N-Queens
  • Create a loader.lsp to load all necessary files.
    Here is my loader file
  • (load p"c\\...\\cs570-2\\cs570\\jtms\\jtms.lsp")
  • (load p"c\\...\\cs570-2\\cs570\\jtms\\jinter.lsp
    ")
  • (load p"c\\...\\cs570-2\\cs570\\jtms\\jdata.lsp"
    )
  • (load p"c\\...\\cs570-2\\cs570\\jtms\\jrules.lsp
    ")
  • (load p"c\\...\\cs570-2\\cs570\\jtms\\unify.lsp"
    )
  • (load p"c\\...\\cs570-2\\cs570\\jtms\\funify.lsp
    ")
  • (load p"c\\...\\cs570-2\\cs570\\jtms\\jtest.lsp"
    )
  • (load p"c\\...\\cs570-2\\cs570\\jtms\\jtms-ex.ls
    p")
  • (load p"c\\...\\cs570-2\\cs570\\jtms\\jqueens.ls
    p")
  • In fqueens.lsp, modify setup-queens-puzzle to
    load fqrule.lsp file
  • (defun setup-queens-puzzle (n debugging?)
  • (in-ftre
  • (create-ftre (format nil "D queens" n)
  • DEBUGGING debugging?
  • MAX-DEPTH ( n 1)))
Write a Comment
User Comments (0)
About PowerShow.com