why
index
/Users/yosi/CVSROOT/WWW/2000/10/swap/why.py

$Id: why.py,v 1.52 2007/06/26 02:36:16 syosi Exp $
 
A class for storing the reason why something is known.
The dontAsk constant reason is used as a reason for the explanations themselves-
 we could make it more complicated here for the recursively minded but i don't
 see the need at the moment.
 
Assumes wwe are using the process-global store -- uses Namespace() @@@

 
Modules
       
binascii
diag
md5
string
sys
uripath
urllib
weakref

 
Classes
       
Reason
Because
BecauseOfCommandLine
BecauseOfData
BecauseOfExperience
BecauseBuiltIn
BecauseIncludes
BecauseSupports
BecauseOfRule
BecauseSubexpression
KBReasonTracker
BecauseMerge
Premise

 
class Because(Reason)
    For the reason given on the string.
This is a kinda end of the road reason.
 
A nested reason can also be given.
 
  Methods defined here:
__init__(self, str, because=None)
explain(self, ko, flags)
Describe this reason to an RDF store
Returns the value of this reason as interned in the store.

Methods inherited from Reason:
meIn(self, ko)
The representation of this object in the formula ko

 
class BecauseBuiltIn(Reason)
    Because the built-in function given concluded so.
A nested reason for running the function must be given
 
  Methods defined here:
__init__(self, context, subj, pred, obj)
explain(self, ko, flags)
This is just a plain fact - or was at the time.

Methods inherited from Reason:
meIn(self, ko)
The representation of this object in the formula ko

 
class BecauseIncludes(BecauseBuiltIn)
    Because of the speific built-in log:includes
 
 
Method resolution order:
BecauseIncludes
BecauseBuiltIn
Reason

Methods inherited from BecauseBuiltIn:
__init__(self, context, subj, pred, obj)
explain(self, ko, flags)
This is just a plain fact - or was at the time.

Methods inherited from Reason:
meIn(self, ko)
The representation of this object in the formula ko

 
class BecauseMerge(KBReasonTracker)
    Because this formula is a merging of others
 
 
Method resolution order:
BecauseMerge
KBReasonTracker
Reason

Methods defined here:
__init__(self, f, set)
explain(self, ko, flags)
newStatement(self, s, why)

Methods inherited from KBReasonTracker:
explanation(self, ko=None, flags='')
Produce a justification for this formula into the output formula
 
Creates an output formula if necessary.
returns it.
(This is different from reason.explain(ko) which returns the reason)

Methods inherited from Reason:
meIn(self, ko)
The representation of this object in the formula ko

 
class BecauseOfCommandLine(Because)
    Because of the command line given in the string
 
 
Method resolution order:
BecauseOfCommandLine
Because
Reason

Methods defined here:
explain(self, ko, flags)
Describe this reason to an RDF store
Returns the value of this reason as interned in the store.

Methods inherited from Because:
__init__(self, str, because=None)

Methods inherited from Reason:
meIn(self, ko)
The representation of this object in the formula ko

 
class BecauseOfData(Because)
    Directly from data in the resource whose URI is the string.
 
A nested reason can also be given, for why this resource was parsed.
 
 
Method resolution order:
BecauseOfData
Because
Reason

Methods defined here:
__init__(self, source, because=None)
explain(self, ko, flags)
Describe this reason to an RDF store
Returns the value of this reason as interned in the store.

Methods inherited from Reason:
meIn(self, ko)
The representation of this object in the formula ko

 
class BecauseOfExperience(Because)
    Becase of the experience of this agent, as described in the string
 
 
Method resolution order:
BecauseOfExperience
Because
Reason

Methods inherited from Because:
__init__(self, str, because=None)
explain(self, ko, flags)
Describe this reason to an RDF store
Returns the value of this reason as interned in the store.

Methods inherited from Reason:
meIn(self, ko)
The representation of this object in the formula ko

 
class BecauseOfRule(Reason)
     Methods defined here:
__init__(self, rule, bindings, knownExistentials, evidence, kb, because=None)
explain(self, ko, flags)
Describe this reason to an RDF store
Returns the value of this reason as interned in the store.

Methods inherited from Reason:
meIn(self, ko)
The representation of this object in the formula ko

 
class BecauseSubexpression(Reason)
    This was generated as part of a calculatio of a subexpression.
 
It is is not necessarily believed
 
  Methods defined here:
explain(self, ko, flags)
Describe this reason to an RDF store
Returns the value of this reason as interned in the store.

Methods inherited from Reason:
__init__(self)
meIn(self, ko)
The representation of this object in the formula ko

 
class BecauseSupports(BecauseBuiltIn)
    Because of the very special build-in log:supports
 
 
Method resolution order:
BecauseSupports
BecauseBuiltIn
Reason

Methods defined here:
__init__(self, context, subj, conclusion, pred, obj, reason)
__repr__(self)
explain(self, ko, flags)
This is just a plain fact - or was at the time.

Methods inherited from Reason:
meIn(self, ko)
The representation of this object in the formula ko

 
class KBReasonTracker(Reason)
    A reason tracker tracks the reasons for the statements in its formula.
 
Beware that when a new formula is
interned, the proofsOf dict must be informed that its identity has changed.
The ForumulaReason is informed of each statement added to the knowlege
base.
 
A knowledge base (open formula) is made from the addition of forumlae,
which result from, for example parsing a document or doing inference.
Within such added formulae, there are variables, including bnodes, which
have a cetain scope.  It is impossible to consider the process
as being one of simply adding statements, as the cross-reference of
the vaiables within the add formuls mst be preserved. 
Variable renaming may occur as thr formula is added. 
 
When we track these operations for generating a proof, a proof reason
such as an BecauseOfRule or BecauseOfData corresponds to an added formula.
The KBReasonTracker tracks which statements in a  formula came from which
addion operations.
 
  Methods defined here:
__init__(self, formula=None)
explain(self, ko, flags)
explanation(self, ko=None, flags='')
Produce a justification for this formula into the output formula
 
Creates an output formula if necessary.
returns it.
(This is different from reason.explain(ko) which returns the reason)
newStatement(self, s, why)

Methods inherited from Reason:
meIn(self, ko)
The representation of this object in the formula ko

 
class Premise(Reason)
    For the reason given on the string.
This is a kinda end of the road reason.
It contais the info which was literally supplied as a premise.
 
A nested reason can also be given.
Because a premise has to be taken for granted, the tracker
has to tell a Premis what statements it has.
 
  Methods defined here:
__init__(self, str, because=None)
explain(self, ko, flags)
Describe this reason to an RDF store
Returns the value of this reason as interned in the store.

Methods inherited from Reason:
meIn(self, ko)
The representation of this object in the formula ko

 
class Reason
    The Reason class holds a reason for having some information.
Well, its subclasses actually do hold data.  This class should not be used
itself to make instances.  Reasons may be given to any functions which put
data into stores, is tracking or proof/explanation generation may be
required
 
  Methods defined here:
__init__(self)
explain(self, ko, flags)
Describe this reason to an RDF store
Returns the value of this object as interned in the store.
meIn(self, ko)
The representation of this object in the formula ko

 
Functions
       
describeStatement(s_l, ko, flags)
Describe the statement into the output formula ko
explainFormula(f, flags='')
Return the explanation formula for f
explainStatement(s, ko, ss=None, flags='')
explainStatements(s_l, ko, ss=None, flags='')
formulaStandIn(self, ko, f, flags) method of __builtin__.dict instance
getStatementReason(s)
isTopLevel(f)
newTopLevelFormula(f)
report(statement, why)
Report a new statement to the reason tracking software
 
This module stores the reasons.  The store should call this
method to report new data. See the KBReasonTracker class
 
Most formulas don't need collectors. Let's see if we can change that.
smushedFormula(F, G)
The formula F has been replaced by G
 
Because this module tracks formula in stores, if ever the address
of a formula is changed, that is (currently) when it is 
canonicalized, then the fact must be reported here.
sorted(...)
sorted(iterable, cmp=None, key=None, reverse=False) --> new sorted list
subFormulaStandIn(self, ko, f, flags) method of __builtin__.dict instance

 
Data
        MAX_INLINE_SIZE = 10
REIFY_NS = 'http://www.w3.org/2004/06/rei#'
becauseSubexpression = <why.BecauseSubexpression instance>
dontAsk = <why.Because instance>
flagHelp = '\nn use iNdirect formulas when they get...ays give the :gives clause, even when not needed\n'
log = <myStore.Namespace object>
proofsOf = <WeakKeyDictionary at 17029280>
rdf = <myStore.Namespace object>
reason = <myStore.Namespace object>