Re: 4 MINUS and NOT EXISTS test cases

On 29/06/2010 3:25 PM, Chimezie Ogbuji wrote:
> This discharges my action ( Action-194 ) to collect testcases for negation:
>
> Test case 1.1: Subsets by exclusion (NOT EXISTS)
>
> ==== Data
> @prefix ex<negation/subset-exclusion#>  .

Bad syntax. This is repeated in all the data.

> ex:lifeForm1 a ex:Mammal, ex:Animal .
> ex:lifeForm2 a ex:Reptile, ex:Animal .
> ex:lifeForm3 a ex:Insect, ex:Animal .
> ====
>
> ==== Query
> PREFIX ex:<negation/subset-exclusion#>
> SELECT ?animal {
>    ?animal a ex:Animal
>    FILTER NOT EXISTS { ?animal a ex:Insect }
> }
> ====
>
> ==== Solutions
> ----------------
> | animal       |
> ================
> | ex:lifeForm1 |
> ================
> | ex:lifeForm2 |
> ----------------

Agree

> ====
>
> Test case 1.2: Subsets by exclusion (MINUS)
>
> ==== Data
> @prefix ex<negation/subset-exclusion#>  .
> ex:lifeForm1 a ex:Mammal, ex:Animal .
> ex:lifeForm2 a ex:Reptile, ex:Animal .
> ex:lifeForm3 a ex:Insect, ex:Animal .
> ====
>
> ==== Query
> PREFIX ex:<negation/subset-exclusion#>
> SELECT ?animal {
>    ?animal a ex:Animal MINUS {
>      ?animal a ?type
>      FILTER(?type = ex:Reptile&&  ?type = ex:Insect)
>    }
> }
> ====
>
> ==== Solutions
> ----------------
> | animal       |
> ================
> | ex:lifeForm1 |
> ----------------

I don't agree with this.

FILTER(?type = ex:Reptile&&  ?type = ex:Insect)
can't be true.

----------------
| animal       |
================
| ex:lifeForm3 |
| ex:lifeForm2 |
| ex:lifeForm1 |
----------------

Did you mean ||:
  FILTER(?type = ex:Reptile || ?type = ex:Insect)

----------------
| animal       |
================
| ex:lifeForm1 |
----------------

> ====
>
> Test case 2.1: Medical, temporal proximity by exclusion (NOT EXISTS)
>
> ==== Data
> @prefix ex<negation/temporal-exclusion#>  .
> @prefix dc<http://purl.org/dc/elements/1.1/>  .
> @prefix xsd<http://www.w3.org/2001/XMLSchema#>  .
> ex:examination1 a ex:PhysicalExamination;
>                  dc:date "2010-01-10"^^xsd:date .
> ex:operation1 a ex:SurgicalProcedure;
>                dc:date "2010-01-15"^^xsd:date .
> ex:examination2 a ex:PhysicalExamination;
>                  dc:date "2010-01-02"^^xsd:date .
> ex:examination1 ex:precedes ex:operation1  .
> ex:examination2 ex:precedes ex:operation1  .
> ex:examination2 ex:precedes ex:examintion1 .
> ====
>
> ==== Query
> PREFIX ex:<negation/temporal-exclusion#>
> PREFIX dc:<http://purl.org/dc/elements/1.1/>
> # The closest pre-operative physical examination
> SELECT ?exam ?date {
>    ?exam a ex:PhysicalExamination;
>          dc:date ?date;
>          ex:precedes ex:operation1 .
>    ?op   a ex:SurgicalProcedure; dc:date ?opDT .
>    FILTER NOT EXISTS {
>      ?otherExam a ex:PhysicalExamination;
>                 ex:follows ?exam;
>                 ex:precedes ex:operation1
>    }
> }
> ====
>
> ==== Solutions
> --------------------------------------------
> | exam            | date                   |
> ============================================
> | ex:examination1 | "2010-01-10"^^xsd:date |
> --------------------------------------------
> ====

I don't agree with this.

No predicate ex:follows is in the data so FILTER NOT EXISTS { } can't match.

--------------------------------------------
| exam            | date                   |
============================================
| ex:examination2 | "2010-01-02"^^xsd:date |
| ex:examination1 | "2010-01-10"^^xsd:date |
--------------------------------------------

>
> Test case 2.2: Medical, temporal proximity by exclusion (MINUS)
>
> ==== Data
> @prefix ex<negation/temporal-exclusion#>  .
> @prefix dc<http://purl.org/dc/elements/1.1/>  .
> @prefix xsd<http://www.w3.org/2001/XMLSchema#>  .
> ex:examination1 a ex:PhysicalExamination;
>                  dc:date "2010-02-10"^^xsd:date .
> ex:operation1 a ex:SurgicalProcedure;
>                dc:date "2010-03-20"^^xsd:date .
> ex:examination2 a ex:PhysicalExamination;
>                  dc:date "2010-03-11"^^xsd:date .
> ====
>
> ==== Query
> PREFIX ex:<negation/temporal-exclusion#>
> PREFIX dc:<http://purl.org/dc/elements/1.1/>
> # The closest pre-operative physical examination
> SELECT ?exam ?date {
>    ?exam a ex:PhysicalExamination;
>          dc:date ?date .
>    ?op   a ex:SurgicalProcedure; dc:date ?opDT .
>    MINUS {
>      ?otherExam a ex:PhysicalExamination; dc:date ?otherExDT
>      FILTER(?date<  ?otherExDT&&  ?otherExDT<  ?opDT)
>    }
>    FILTER(?date<  ?opDT)
> }
> ====
>
> ==== Solutions
> --------------------------------------------
> | exam            | date                   |
> ============================================
> | ex:examination2 | "2010-03-11"^^xsd:date |
> --------------------------------------------
> ====

I don't agree with this.

The matching part of the MINUS is:

{ ?otherExam a ex:PhysicalExamination; dc:date ?otherExDT } gives:

and then the FILTER:
FILTER(?date<  ?otherExDT&&  ?otherExDT<  ?opDT)

uses ?date which is out of scope for the clause MINUS so the FILTER is 
error always so nothing matches for MINUS {}

For s/MINUS/FILTER NOT EXISTS/, I get:

--------------------------------------------
| exam            | date                   |
============================================
| ex:examination2 | "2010-03-11"^^xsd:date |
--------------------------------------------

 Andy

Received on Monday, 5 July 2010 21:49:37 UTC