Daniel@0: /* Part of DML (Digital Music Laboratory) Daniel@0: Copyright 2014-2015 Samer Abdallah, University of London Daniel@0: Daniel@0: This program is free software; you can redistribute it and/or Daniel@0: modify it under the terms of the GNU General Public License Daniel@0: as published by the Free Software Foundation; either version 2 Daniel@0: of the License, or (at your option) any later version. Daniel@0: Daniel@0: This program is distributed in the hope that it will be useful, Daniel@0: but WITHOUT ANY WARRANTY; without even the implied warranty of Daniel@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Daniel@0: GNU General Public License for more details. Daniel@0: Daniel@0: You should have received a copy of the GNU General Public Daniel@0: License along with this library; if not, write to the Free Software Daniel@0: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Daniel@0: */ Daniel@0: Daniel@0: :- module(memo_p2r, []). Daniel@0: Daniel@0: :- use_module(library(memo)). Daniel@0: :- use_module(entailment(p2r)). Daniel@0: Daniel@0: uripattern:def( func(Mod,Pred,Arity), dml:function/enc(Mod)/enc(Pred)/num(Arity)). Daniel@0: Daniel@0: % Memoisation schema Daniel@0: :- rdf_register_prefix(memo,'http://dml.org/memo/',[force(true)]). Daniel@0: Daniel@0: :- public import/0. Daniel@0: import :- assert_all(memo_p2r). Daniel@0: Daniel@0: rdf(memo:'Module', rdfs:subClassOf, owl:'Thing'), Daniel@0: rdf(memo:'Function', rdfs:subClassOf, owl:'Thing'), Daniel@0: rdf(memo:'Computation', rdfs:subClassOf, event:'Event'), Daniel@0: rdf(memo:function, rdfs:domain, memo:'Computation'), Daniel@0: rdf(memo:function, rdfs:range, memo:'Function'), Daniel@0: rdf(memo:module, rdfs:domain, memo:'Function'), Daniel@0: rdf(memo:module, rdfs:range, memo:'Module'), Daniel@0: rdf(time:duration, rdfs:domain, event:'Event'), Daniel@0: rdf(time:duration, rdfs:range, xsd:decimal), Daniel@0: rdf(memo:type, rdfs:domain, memo:'Function') <== true. Daniel@0: rdf(memo:storage, rdfs:domain, memo:'Function') <== true. Daniel@0: Daniel@0: rdf(dml: module/prolog/enc(Mod), rdf:type, memo:'Module'), Daniel@0: rdf(\func(Mod,Pred,Arity), rdf:type, memo:'Function'), Daniel@0: rdf(\func(Mod,Pred,Arity), memo:module, dml:module/prolog/enc(Mod)) <== Daniel@0: memo_function(Mod,Pred,Arity). Daniel@0: Daniel@0: rdf(\func(Mod,Pred,Arity), rdfs:label, literal(Label)) <== Daniel@0: memo_function(Mod,Pred,Arity), Daniel@0: term_to_atom(Pred/Arity,Label). Daniel@0: Daniel@0: rdf(\func(Mod,Pred,Arity), memo:type, literal(TypeAtom)) <== Daniel@0: memo_property(Mod:Head,type(Type)), Daniel@0: functor(Head,Pred,Arity), Daniel@0: Type =.. [_|Types], Daniel@0: term_to_atom(Types,TypeAtom). Daniel@0: Daniel@0: rdf(\func(Mod,Pred,Arity), memo:storage, literal(Storage)) <== Daniel@0: memo_property(Mod:Head,storage(Storage)), Daniel@0: functor(Head,Pred,Arity). Daniel@0: Daniel@0: % alternative duration type is xsd:duration, Daniel@0: % format as 'PT~fS' Daniel@0: % rdf(dml:computation/enc(Hash), rdf:type, memo:'Computation'), Daniel@0: Daniel@0: % REMOVE COMPUTATIONS FOR NOW Daniel@0: % rdf(dml:computation/enc(Hash), time:duration, literal(type(xsd:double,Dur))), Daniel@0: % rdf(dml:computation/enc(Hash), memo:status, literal(StatusAtom)), Daniel@0: % rdf(dml:computation/enc(Hash), memo:function, \func(Mod,Pred,Arity)) <== Daniel@0: % memo:computer(Mod,Head,_,_), Daniel@0: % memo:browse(Mod:Head,Ev-Status), Daniel@0: % variant_sha1(t(Mod,Head,Ev,Status),Hash), Daniel@0: % (Ev=comp(_,_,Dur); Ev=comp(_,Dur)), % for time:duration Daniel@0: % term_to_atom(Status,StatusAtom), % for memo:status Daniel@0: % functor(Head,Pred,Arity). % for memo:function Daniel@0: Daniel@0: % rdf(dml:computation/enc(Hash), memo:host, literal(Host)) <== Daniel@0: % memo:computer(Mod,Head,_,_), Daniel@0: % memo:browse(Mod:Head,Ev-Status), Daniel@0: % variant_sha1(t(Mod,Head,Ev,Status),Hash), Daniel@0: % (Ev=comp(Host,_,_); Ev=comp(Host,_)), Daniel@0: % Host\='unknown'. Daniel@0: Daniel@0: memo_function(Mod,Pred,Arity) :- Daniel@0: memo_property(Mod:Head,storage(_)), Daniel@0: functor(Head,Pred,Arity). Daniel@0: