PrOM queryoperator

From Knoesis wiki
Jump to: navigation, search

Provenance Query Operators

This is the resource page for the provenance query operators defined as part of the Provenance Management Framework (PrOM). The executable specification of the provenance query operators (in Prolog) are listed below.

provenance ()

/*

  Executable Specification 
  
  Provenance Query Operator: provenance()
  
  ":-" same as "<=" and "," and "/\" 
  All variables universally quantified 
  *****Problem with left-recursion.*****
  • /

provenance(DC,All) :- setof(X, provenance_individual(DC,X), All).

provenance_individual(DC,Dres) :- p_data(DC,Dres). provenance_individual(DC,Pres) :- p_process(DC,Pres). provenance_individual(DC,Ares) :- p_agent(DC,Ares). provenance_individual(DC,Rres) :- p_predicate(DC,Rres).


p_process(DC,Pres) :- triple(Pres,has_participant,DC). p_process(DC,Pres) :- triple(P,preceded_by,Pres),p_process(DC,P). p_process(DC,Pres) :- triple(P,part_of,Pres),p_process(DC,P). p_process(DC,Pres) :- triple(Pres,has_participant,D),p_data(DC,D). p_process(DC,Pres) :- triple(Pres,has_agent,A),p_agent(DC, A).


p_data(DC,Dres) :- triple(DC,part_of, Dres). p_data(DC,Dres) :- triple(Dres,part_of, DC). p_data(DC,Dres) :- triple(DC,contained_in, Dres). p_data(DC,Dres) :- triple(Dres,contained_in, DC). p_data(DC,Dres) :- p_process(DC,P), triple(P,has_participant,Dres), timestamp(DC,DCT), timestamp(Dres,DresT), DresT =< DCT. /*

  The predicate 'transformation_of' and 'derives_from' is traversed in one direction only relying on the implicit temporal ordering.
  • /

p_data(DC,Dres) :- triple(DC,derives_from,Dres). p_data(DC,Dres) :- triple(DC,transformation_of,Dres). /*

  Given all individuals of 'process', the associated parameters are
  searched, hence the relations 'has_parameter' is traversed in one direction only.
  The 'parameter' individuals are not used to retrieve additional 'process' individuals.
  Since, reasoning is not considered as part of the of query operator functionality, sub-properties
  of 'has_parameter' namely 'has_temporal_value' and 'located_in' are not considered by query operator.
  • /

p_data(DC,Dres) :- p_process(DC,P), triple(P,has_parameter,Dres). /*

  Given all individuals of 'agent', the associated parameters are
  searched, hence the relations 'has_parameter' is traversed in one direction only.
  The 'parameter' individuals are not used to retrieve additional 'agent' individuals.
  Since, reasoning is not considered as part of the of query operator functionality, sub-properties
  of 'has_parameter' namely 'has_temporal_value' and 'located_in' are not considered by query operator.
  • /

p_data(DC,Dres) :- p_agent(DC,A), triple(A,has_parameter,Dres).


p_agent(DC,Ares) :- p_process(DC,P), triple(P,has_agent,Ares). p_agent(DC,Ares) :- p_agent(DC,A), triple(A,part_of,Ares). p_agent(DC,Ares) :- p_agent(DC,A), triple(Ares,part_of,A). p_agent(DC,Ares) :- p_agent(DC,A), triple(A,contained_in,Ares). p_agent(DC,Ares) :- p_agent(DC,A), triple(Ares,contained_in,A). p_agent(DC,Ares) :- p_agent(DC,A), triple(A,adjacent_to,Ares). p_agent(DC,Ares) :- p_agent(DC,A), triple(Ares,adjacent_to,A).


p_predicate(DC,Rres) :- provenance_individual(DC,X), triple(DC,Rres,X), triple(X,Rres,DC).


/* Facts */ triple(cubegen535, has_participant, hypercube853). triple(data_collection_process535, has_participant, codar_mnty853). triple(cubegen535, preceded_by, schemagen535). triple(cubegen535, has_parameter, latitude_longitude_time). triple(schemagen535, has_parameter, latitude_longitude_time_ncfloat_nc_double). triple(hypercube853, derives_from, codar_mnty853). triple(data_collection_process535, has_agent, temp_sensor535). triple(data_collection_process535, has_agent, ocean_current_sensor535). triple(temp_sensor535, contained_in, oceanBuoy535). triple(ocean_current_sensor535, contained_in, oceanBuoy535). timestamp(hypercube853,284932328389502). timestamp(codar_mnty853, 284930969878853). timestamp(latitude_longitude_time, 284932113608014). timestamp(latitude_longitude_time_ncfloat_nc_double, 284931854494076).


/* ?- p_process(hypercube853,P).

P = cubegen535 ;

P = schemagen535 ;

  • /


provenance ()

/*

  Executable Specification
  Provenance Query Operator: provenance_context()   
  ":-" same as "<=" and "," and "/\" 
  All variables universally quantified 
  • /

/* Only entities of provenir ontology class 'data_collection' should be in result set. The functionality of this operator is to return 'data_collection'

  values linked directly (1-hop) to the input values or use nodes at max distance of 1-hop from input values that are in turn linked to 'data_collection' values  */

provenance_context(D,P,A,DC) :- pc_datalist(D,DL), pc_processlist(P,PL), pc_agentlist(A,AL), intersection(DL,PL,X), intersection(X, AL, DC).

pc_datalist([],[]). pc_datalist([H|T],DC) :- pc_data(H,DH), pc_datalist(T,DT), append(DH,DT,DC). pc_processlist([],[]). pc_processlist([H|T],DC) :- pc_process(H,PH), pc_processlist(T,PT), append(PH,PT,DC). pc_agentlist([],[]). pc_agentlist([H|T],DC) :- pc_agent(H,AH), pc_agentlist(T,AT), append(AH,AT,DC).

/* The predicates 'derives_from' and 'transformation_of' are traversed in one direction only, since provenance of 'data_collection' values form input of provenance_context()*/ pc_data(D,[DC]) :- triple(DC,derives_from, D). pc_data(D,[DC]) :- triple(DC,transformation_of, D). pc_data(D,[DC]) :- triple(DC,part_of, D). pc_data(D,[DC]) :- triple(D,part_of, DC). pc_data(D,[DC]) :- triple(DC,contained_in, D). pc_data(D,[DC]) :- triple(D,contained_in, DC). /* This rule may be removed in future revision, if domain 'data_collection' and range 'parameter' is removed for predicate 'has_parameter' */ /* pc_data(D,DC) :- triple(DC,has_parameter, D).*/

pc_process(P,[DC]) :- triple(P,has_participant,DC). pc_process(P,[DC]) :- triple(P,preceded_by,Pres), triple(Pres,has_participant,DC). pc_process(P,[DC]) :- triple(Pres,preceded_by,P), triple(Pres,has_participant,DC). pc_process(P,[DC]) :- triple(P,part_of,Pres), triple(Pres,has_participant,DC). pc_process(P,[DC]) :- triple(Pres,part_of,P), triple(Pres,has_participant,DC). /* This rule may be removed in future revision, if domain 'data_collection' and range 'parameter' is removed for predicate 'has_parameter' */ /* pc_process(P,DC) :- triple(P,has_parameter,D), pc_data(D,DC). */

/* List notation used in clause with only triple() structure */ pc_agent(A,DC) :- triple(P,has_agent,A), pc_process(P,DC). pc_agent(A,DC) :- triple(A,contained_in,Ares), triple(P,has_agent,Ares), pc_process(P,DC). pc_agent(A,DC) :- triple(Ares,contained_in,A), triple(P,has_agent,Ares), pc_process(P,DC). pc_agent(A,DC) :- triple(A,part_of,Ares), triple(P,has_agent,Ares), pc_process(P,DC). pc_agent(A,DC) :- triple(Ares,part_of,A), triple(P,has_agent,Ares), pc_process(P,DC). pc_agent(A,DC) :- triple(A,adjacent_to,Ares), triple(P,has_agent,Ares), pc_process(P,DC). pc_agent(A,DC) :- triple(Ares,adjacent_to,A), triple(P,has_agent,Ares), pc_process(P,DC). /* This rule may be removed in future revision, if domain 'data_collection' and range 'parameter' is removed for predicate 'has_parameter' */ /* pc_agent(A,DC) :- triple(A,has_parameter,D), pc_data(D,DC). */



/* Facts */ triple(cubegen535, has_participant, hypercube853). triple(data_collection_process535, has_participant, codar_mnty853). triple(cubegen535, preceded_by, schemagen535). triple(cubegen535, has_parameter, latitude_longitude_time). triple(schemagen535, has_parameter, latitude_longitude_time_ncfloat_nc_double). triple(codar_mnty853, derives_from, hypercube853). triple(data_collection_process535, has_agent, temp_sensor535). triple(data_collection_process535, has_agent, ocean_current_sensor535). triple(temp_sensor535, contained_in, oceanBuoy535). triple(ocean_current_sensor535, contained_in, oceanBuoy535). timestamp(hypercube853,284932328389502). timestamp(codar_mnty853, 284930969878853). timestamp(latitude_longitude_time, 284932113608014). timestamp(latitude_longitude_time_ncfloat_nc_double, 284931854494076).

/* ?- provenance_context([hypercube853],[data_collection_process535],[oceanBuoy535],D). Result:D = [codar_mnty853] ;

  • /