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