annotate cpack/dml/lib/memo_p2r.pl @ 0:718306e29690 tip

commiting public release
author Daniel Wolff
date Tue, 09 Feb 2016 21:05:06 +0100
parents
children
rev   line source
Daniel@0 1 /* Part of DML (Digital Music Laboratory)
Daniel@0 2 Copyright 2014-2015 Samer Abdallah, University of London
Daniel@0 3
Daniel@0 4 This program is free software; you can redistribute it and/or
Daniel@0 5 modify it under the terms of the GNU General Public License
Daniel@0 6 as published by the Free Software Foundation; either version 2
Daniel@0 7 of the License, or (at your option) any later version.
Daniel@0 8
Daniel@0 9 This program is distributed in the hope that it will be useful,
Daniel@0 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
Daniel@0 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Daniel@0 12 GNU General Public License for more details.
Daniel@0 13
Daniel@0 14 You should have received a copy of the GNU General Public
Daniel@0 15 License along with this library; if not, write to the Free Software
Daniel@0 16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Daniel@0 17 */
Daniel@0 18
Daniel@0 19 :- module(memo_p2r, []).
Daniel@0 20
Daniel@0 21 :- use_module(library(memo)).
Daniel@0 22 :- use_module(entailment(p2r)).
Daniel@0 23
Daniel@0 24 uripattern:def( func(Mod,Pred,Arity), dml:function/enc(Mod)/enc(Pred)/num(Arity)).
Daniel@0 25
Daniel@0 26 % Memoisation schema
Daniel@0 27 :- rdf_register_prefix(memo,'http://dml.org/memo/',[force(true)]).
Daniel@0 28
Daniel@0 29 :- public import/0.
Daniel@0 30 import :- assert_all(memo_p2r).
Daniel@0 31
Daniel@0 32 rdf(memo:'Module', rdfs:subClassOf, owl:'Thing'),
Daniel@0 33 rdf(memo:'Function', rdfs:subClassOf, owl:'Thing'),
Daniel@0 34 rdf(memo:'Computation', rdfs:subClassOf, event:'Event'),
Daniel@0 35 rdf(memo:function, rdfs:domain, memo:'Computation'),
Daniel@0 36 rdf(memo:function, rdfs:range, memo:'Function'),
Daniel@0 37 rdf(memo:module, rdfs:domain, memo:'Function'),
Daniel@0 38 rdf(memo:module, rdfs:range, memo:'Module'),
Daniel@0 39 rdf(time:duration, rdfs:domain, event:'Event'),
Daniel@0 40 rdf(time:duration, rdfs:range, xsd:decimal),
Daniel@0 41 rdf(memo:type, rdfs:domain, memo:'Function') <== true.
Daniel@0 42 rdf(memo:storage, rdfs:domain, memo:'Function') <== true.
Daniel@0 43
Daniel@0 44 rdf(dml: module/prolog/enc(Mod), rdf:type, memo:'Module'),
Daniel@0 45 rdf(\func(Mod,Pred,Arity), rdf:type, memo:'Function'),
Daniel@0 46 rdf(\func(Mod,Pred,Arity), memo:module, dml:module/prolog/enc(Mod)) <==
Daniel@0 47 memo_function(Mod,Pred,Arity).
Daniel@0 48
Daniel@0 49 rdf(\func(Mod,Pred,Arity), rdfs:label, literal(Label)) <==
Daniel@0 50 memo_function(Mod,Pred,Arity),
Daniel@0 51 term_to_atom(Pred/Arity,Label).
Daniel@0 52
Daniel@0 53 rdf(\func(Mod,Pred,Arity), memo:type, literal(TypeAtom)) <==
Daniel@0 54 memo_property(Mod:Head,type(Type)),
Daniel@0 55 functor(Head,Pred,Arity),
Daniel@0 56 Type =.. [_|Types],
Daniel@0 57 term_to_atom(Types,TypeAtom).
Daniel@0 58
Daniel@0 59 rdf(\func(Mod,Pred,Arity), memo:storage, literal(Storage)) <==
Daniel@0 60 memo_property(Mod:Head,storage(Storage)),
Daniel@0 61 functor(Head,Pred,Arity).
Daniel@0 62
Daniel@0 63 % alternative duration type is xsd:duration,
Daniel@0 64 % format as 'PT~fS'
Daniel@0 65 % rdf(dml:computation/enc(Hash), rdf:type, memo:'Computation'),
Daniel@0 66
Daniel@0 67 % REMOVE COMPUTATIONS FOR NOW
Daniel@0 68 % rdf(dml:computation/enc(Hash), time:duration, literal(type(xsd:double,Dur))),
Daniel@0 69 % rdf(dml:computation/enc(Hash), memo:status, literal(StatusAtom)),
Daniel@0 70 % rdf(dml:computation/enc(Hash), memo:function, \func(Mod,Pred,Arity)) <==
Daniel@0 71 % memo:computer(Mod,Head,_,_),
Daniel@0 72 % memo:browse(Mod:Head,Ev-Status),
Daniel@0 73 % variant_sha1(t(Mod,Head,Ev,Status),Hash),
Daniel@0 74 % (Ev=comp(_,_,Dur); Ev=comp(_,Dur)), % for time:duration
Daniel@0 75 % term_to_atom(Status,StatusAtom), % for memo:status
Daniel@0 76 % functor(Head,Pred,Arity). % for memo:function
Daniel@0 77
Daniel@0 78 % rdf(dml:computation/enc(Hash), memo:host, literal(Host)) <==
Daniel@0 79 % memo:computer(Mod,Head,_,_),
Daniel@0 80 % memo:browse(Mod:Head,Ev-Status),
Daniel@0 81 % variant_sha1(t(Mod,Head,Ev,Status),Hash),
Daniel@0 82 % (Ev=comp(Host,_,_); Ev=comp(Host,_)),
Daniel@0 83 % Host\='unknown'.
Daniel@0 84
Daniel@0 85 memo_function(Mod,Pred,Arity) :-
Daniel@0 86 memo_property(Mod:Head,storage(_)),
Daniel@0 87 functor(Head,Pred,Arity).
Daniel@0 88