[Task] Contemporary Constraint check
Open, NormalPublic

Description

Implement a check on Wikidata for Contemporary constraint.

Proposed assertions (if true, there isn't a constraint violation; if false, there is a constraint violation):

  • Text: if [item A] has this property (Pn) linked to [item B], then [item A] and [item B] have to coincide or coexist at some point of history according to properties P569 (date of birth), P570 (date of death), P571 (inception), P576 (dissolved or abolished), P580 (start time) and P582 (end time).
  • Formally:
(
    (
        A.P580 ≤ B.P582 OR
        A.P580 ≤ B.P570 OR
        A.P580 ≤ B.P576 OR
        A.P569 ≤ B.P582 OR
        A.P569 ≤ B.P570 OR
        A.P569 ≤ B.P576 OR
        A.P571 ≤ B.P582 OR
        A.P571 ≤ B.P570 OR
        A.P571 ≤ B.P576
    ) OR (
        NOT EXISTS A.P580 AND
        NOT EXISTS A.P569 AND
        NOT EXISTS A.P571
    ) OR (
        NOT EXISTS B.P582 AND
        NOT EXISTS B.P570 AND
        NOT EXISTS B.P576
    )
) AND (
    (
        B.P580 ≤ A.P582 OR
        B.P580 ≤ A.P570 OR
        B.P580 ≤ A.P576 OR
        B.P569 ≤ A.P582 OR
        B.P569 ≤ A.P570 OR
        B.P569 ≤ A.P576 OR
        B.P571 ≤ A.P582 OR
        B.P571 ≤ A.P570 OR
        B.P571 ≤ A.P576
    ) OR (
        NOT EXISTS B.P580 AND
        NOT EXISTS B.P569 AND
        NOT EXISTS B.P571
    ) OR (
        NOT EXISTS A.P582 AND
        NOT EXISTS A.P570 AND
        NOT EXISTS A.P576
    )
)

I would be great that the set of "properties of start" and the set of "properties of end" could be modified somehow over time.

abian created this task.Aug 2 2016, 10:21 AM
Restricted Application added a project: Wikidata. · View Herald TranscriptAug 2 2016, 10:21 AM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
abian updated the task description. (Show Details)Aug 21 2016, 11:05 AM
abian added a comment.Sep 2 2016, 11:33 PM

Example of query that detects Constraint:Contemporary violations:

SELECT ?subject ?value
WHERE {
  ?subject wdt:P${THEPROPERTY} ?value .
  OPTIONAL { ?subject p:P569/psv:P569 [ wikibase:timeValue ?subject_birth ; wikibase:timePrecision "11"^^xsd:integer ] . }
  OPTIONAL { ?value p:P569/psv:P569 [ wikibase:timeValue ?value_birth ; wikibase:timePrecision "11"^^xsd:integer ] . }
  OPTIONAL { ?subject p:P571/psv:P571 [ wikibase:timeValue ?subject_inception ; wikibase:timePrecision "11"^^xsd:integer ] . }
  OPTIONAL { ?value p:P571/psv:P571 [ wikibase:timeValue ?value_inception ; wikibase:timePrecision "11"^^xsd:integer ] . }
  OPTIONAL { ?subject p:P580/psv:P580 [ wikibase:timeValue ?subject_start ; wikibase:timePrecision "11"^^xsd:integer ] . }
  OPTIONAL { ?value p:P580/psv:P580 [ wikibase:timeValue ?value_start ; wikibase:timePrecision "11"^^xsd:integer ] . }
  OPTIONAL { ?subject p:P570/psv:P570 [ wikibase:timeValue ?subject_death ; wikibase:timePrecision "11"^^xsd:integer ] . }
  OPTIONAL { ?value p:P570/psv:P570 [ wikibase:timeValue ?value_death ; wikibase:timePrecision "11"^^xsd:integer ] . }
  OPTIONAL { ?subject p:P576/psv:P576 [ wikibase:timeValue ?subject_dissolution ; wikibase:timePrecision "11"^^xsd:integer ] . }
  OPTIONAL { ?value p:P576/psv:P576 [ wikibase:timeValue ?value_dissolution ; wikibase:timePrecision "11"^^xsd:integer ] . }
  OPTIONAL { ?subject p:P582/psv:P582 [ wikibase:timeValue ?subject_end ; wikibase:timePrecision "11"^^xsd:integer ] . }
  OPTIONAL { ?value p:P582/psv:P582 [ wikibase:timeValue ?value_end ; wikibase:timePrecision "11"^^xsd:integer ] . }
  FILTER (
    (
      !BOUND(?subject_birth) ||
      (
        (
          !BOUND(?value_death) ||
          ?subject_birth>?value_death
        ) &&
        (
          !BOUND(?value_dissolution) ||
          ?subject_birth>?value_dissolution
        ) &&
        (
          !BOUND(?value_end) ||
          ?subject_birth>?value_end
        )
      )
    ) &&
    (
      !BOUND(?value_birth) ||
      (
        (
          !BOUND(?subject_death) || 
          ?value_birth>?subject_death
        ) &&
        (
          !BOUND(?subject_dissolution) || 
          ?value_birth>?subject_dissolution
        ) &&
        (
          !BOUND(?subject_end) || 
          ?value_birth>?subject_end
        )
      )
    ) && 
    (
      !BOUND(?subject_inception) ||
      (
        (
          !BOUND(?value_death) || 
          ?subject_inception>?value_death
        ) &&
        (
          !BOUND(?value_dissolution) || 
          ?subject_inception>?value_dissolution
        ) &&
        (
          !BOUND(?value_end) || 
          ?subject_inception>?value_end
        )
      )
    ) && 
    (
      !BOUND(?value_inception) || 
      (
        (
          !BOUND(?subject_death) || 
          ?value_inception>?subject_death
        ) &&
        (
          !BOUND(?subject_dissolution) || 
          ?value_inception>?subject_dissolution
        ) &&
        (
          !BOUND(?subject_end) || 
          ?value_inception>?subject_end
        )
      )
    ) && 
    (
      !BOUND(?subject_start) || 
      (
        (
          !BOUND(?value_death) || 
          ?subject_start>?value_death
        ) &&
        (
          !BOUND(?value_dissolution) || 
          ?subject_start>?value_dissolution
        ) &&
        (
          !BOUND(?value_end) || 
          ?subject_start>?value_end
        )
      )
    ) && 
    (
      !BOUND(?value_start) || 
      (
        (
          !BOUND(?subject_death) || 
          ?value_start>?subject_death
        ) &&
        (
          !BOUND(?subject_dissolution) || 
          ?value_start>?subject_dissolution
        ) &&
        (
          !BOUND(?subject_end) || 
          ?value_start>?subject_end
        )
      )
    ) && 
    ( 
      ( 
        BOUND(?subject_birth) && 
        ( 
          BOUND(?value_death) || 
          BOUND(?value_dissolution) || 
          BOUND(?value_end) 
        )
      ) || 
      ( 
        BOUND(?value_birth) && 
        ( 
          BOUND(?subject_death) || 
          BOUND(?subject_dissolution) ||
          BOUND(?subject_end) 
        )
      ) || 
      ( 
        BOUND(?subject_inception) && 
        ( 
          BOUND(?value_death) || 
          BOUND(?value_dissolution) || 
          BOUND(?value_end) 
        )
      ) || 
      ( 
        BOUND(?value_inception) &&
        ( 
          BOUND(?subject_death) ||
          BOUND(?subject_dissolution) ||
          BOUND(?subject_end) 
        )
      ) ||
      ( 
        BOUND(?subject_start) &&
        ( 
          BOUND(?value_death) ||
          BOUND(?value_dissolution) ||
          BOUND(?value_end) 
        )
      ) ||
      ( 
        BOUND(?value_start) &&
        ( 
          BOUND(?subject_death) ||
          BOUND(?subject_dissolution) ||
          BOUND(?subject_end) 
        )
      )
    )
  ) 
} LIMIT 500
thiemowmde triaged this task as Normal priority.
thiemowmde added a subscriber: Lydia_Pintscher.

This task was added to Need-volunteer. Could I help with it in some way?