DEFINE input:inference 'ariadneplus_rules'

CONSTRUCT {
	<${subjectURL}> crm:P1_is_identified_by ?IDRes .
	?IDRes a crm:E42_Identifier .
	?IDRes rdfs:label ?ID_label .

	<${subjectURL}> crm:P102_has_title ?title .
	<${subjectURL}> crm:P3_has_note ?description .
	<${subjectURL}> a ?type .
    <${subjectURL}> rdfs:label ?label .

    <${subjectURL}> crm:P129_is_about ?about .
    ?about a ?aboutType .
    ?about rdfs:label ?aboutLabel .

    <${subjectURL}> crm:P2_has_type ?e55TypeLabel .

    <${subjectURL}> crmpe:PP7i_is_software_object_hosted_by ?host .
    <${subjectURL}> crmpe:PP32i_is_curated_by ?curatingService .

	<${subjectURL}> crmpe:PP17_has_snapshot ?snapshot1 .
	<${subjectURL}> crmpe:PP17i_is_snapshot_of ?snapshot2 .

	<${subjectURL}> crmpe:PP21_has_software_part ?sw1 .
	<${subjectURL}> crmpe:PP21i_is_software_part_of ?sw2 .
	<${subjectURL}> crmpe:PP22_has_release ?sw3 .
	<${subjectURL}> crmpe:PP22i_is_release_of ?sw4 .

	<${subjectURL}> <usedby> ?adopter .
	<${subjectURL}> <creationtime> ?creationtime .
}
WHERE {
 <${subjectURL}> a crmdig:D14_Software .
 <${subjectURL}> a ?type .
  {
  <${subjectURL}> crm:P1_is_identified_by ?IDRes .
  ?IDRes a crm:E42_Identifier .
  ?IDRes rdfs:label ?ID_label .
  }
  UNION
{
 <${subjectURL}> crm:P1_is_identified_by ?titleRes .
 ?titleRes a crm:E41_Appellation .
 ?titleRes rdfs:label ?title .
}
UNION{
 <${subjectURL}> crm:P3_has_note ?description .
}
UNION{
 <${subjectURL}> rdfs:label ?label .
}
UNION {
  <${subjectURL}> crm:P2_has_type ?e55Type .
  ?e55Type rdfs:label ?e55TypeLabel .
}
 UNION{
  <${subjectURL}> crm:P129_is_about ?about .
  ?about a ?aboutType .
  ?about rdfs:label ?aboutLabel .
 }
 UNION{<${subjectURL}> crmpe:PP7i_is_software_object_hosted_by ?host . }
 UNION{?host crmpe:PP7_hosts_software_object <${subjectURL}> . }
 UNION{<${subjectURL}> crmpe:PP32i_is_curated_by ?curatingService .}
 UNION{?curatingService crmpe:PP32_curates <${subjectURL}> .}
 UNION{
    <${subjectURL}> crmpe:PP32i_is_curated_by ?curatingService .
    ?curatingService crmpe:PP31_uses_curation_plan ?curationplan .
   }
UNION{
    ?curatingService crmpe:PP32_curates <${subjectURL}> .
    ?curatingService crmpe:PP31_uses_curation_plan ?curationplan .
}
 UNION{<${subjectURL}> crmpe:PP17_has_snapshot ?snapshot1 .}
 UNION{ ?snapshot1 crmpe:PP17i_is_snapshot_of <${subjectURL}>  .}
 UNION{<${subjectURL}> crmpe:PP17i_is_snapshot_of ?snapshot2 .}
 UNION{ ?snapshot2 crmpe:PP17_has_snapshot <${subjectURL}>  .}

 UNION{<${subjectURL}> crmpe:PP21_has_software_part ?sw1 .}
 UNION{?sw1 crmpe:PP21i_is_software_part_of  <${subjectURL}>.}

 UNION{ ?sw2 crmpe:PP21_has_software_part <${subjectURL}> .}
 UNION{<${subjectURL}> crmpe:PP21i_is_software_part_of ?sw2 .}

 UNION{<${subjectURL}> crmpe:PP22_has_release ?sw3 .}
 UNION{?sw3 crmpe:PP22i_is_release_of <${subjectURL}> .}

 UNION{<${subjectURL}> crmpe:PP22i_is_release_of ?sw4 .}
 UNION{?sw4 crmpe:PP22_has_release <${subjectURL}> .}

 UNION{
  	?adopter crm:P94i_was_created_by ?event .
    ?event crmdig:L23_used_software_or_firmware <${subjectURL}> .
  }
 UNION {
 <${subjectURL}> crmdig:L23i_was_software_or_firmware_used_by ?event .
 ?adopter crm:P94i_was_created_by ?event .
 }
 UNION{
      <${subjectURL}> crm:P94i_was_created_by ?event1 .
      ?event1 crm:P2_has_type <http://ariadneplus.d4science.org/handle/AriadnePlus/REG/Concept/eventtype/creation> .
      ?event1 crm:P4_has_time-span ?timespan .
      ?timespan crm:P81_ongoing_throughout ?creationtime .
 }
}
LIMIT 1000