Example #1
0
    def 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)"""

        if ko == None: ko = self.formula.store.newFormula()
        ko.bind("n3", "http://www.w3.org/2004/06/rei#")
        ko.bind("log", "http://www.w3.org/2000/10/swap/log#")
        ko.bind("pr", "http://www.w3.org/2000/10/swap/reason#")
        ko.bind("run", runNamespace())
        me = self.explain(ko, flags)
        ko.add(me, rdf.type, reason.Proof, why=dontAsk)
        return ko
Example #2
0
def formulaStandIn(self, ko, f, flags):
    if 'n' not in flags:
        return f
    if len(f) <= MAX_INLINE_SIZE:
        return f
    try:
        m = self[(ko, f)]
        #progress('cache hit, we save $$!')
        return m
    except KeyError:
        from formula import Formula, StoredStatement
        if 'l' in flags:
            standIn = ko.newBlankNode(why=dontAsk)
        else:
            self[id(self)] += 1
            standIn = ko.newSymbol(runNamespace() + '_efm' +
                                   str(self[id(self)]))
        self[(ko, f)] = standIn

        ko.add(subj=f, pred=ko.store.sameAs, obj=standIn, why=dontAsk)
        return standIn
Example #3
0
def subFormulaStandIn(self, ko, f, flags):
    if 'n' not in flags:
        return f
    from formula import Formula
    if isinstance(f, List):
        return ko.store.newList([subFormulaStandIn(ko, x, flags) for x in f])
    if not isinstance(f, Formula) or len(f) <= MAX_INLINE_SIZE:
        return f
    try:
        m = self[(ko, f)]
        #progress('cache hit, we save $$!')
        return m
    except KeyError:
        if 'l' in flags:
            standIn = ko.newBlankNode(why=dontAsk)
        else:
            self[id(self)] += 1
            standIn = ko.newSymbol(runNamespace() + '_fm' +
                                   str(self[id(self)]))
        self[(ko, f)] = standIn
        ko.add(subj=f, pred=reason.representedBy, obj=standIn, why=dontAsk)
        return standIn
Example #4
0
File: thing.py Project: weyls/swap
 def uriref(self):
     return runNamespace() + "li" + ` self._id `