Duplicates invasion - Bug or I missed something?


#1

First query I have 9 pairs with name = ‘ff’; (it is what i expect)
Second query I have 18 pairs (9 duplicates) ??
bug or my queries are not well-formed?

>>> match $p isa pair, has name $n;
$p id "81928" (pobj: id "57528", prep: id "61496") isa pair; $n value "fo" isa name;
$p id "118808" (pobj: id "57528", prep: id "98512") isa pair; $n value "fo" isa name;
$p id "151560" (pobj: id "45240", prep: id "24712") isa pair; $n value "fo" isa name;
$p id "155704" (pobj: id "16408", prep: id "24712") isa pair; $n value "fo" isa name;
$p id "213200" (pobj: id "45240", prep: id "61496") isa pair; $n value "fo" isa name;
$p id "237648" (pobj: id "16408", prep: id "61496") isa pair; $n value "fo" isa name;
$p id "266448" (pobj: id "57528", prep: id "24712") isa pair; $n value "fo" isa name;
$p id "335952" (pobj: id "16408", prep: id "98512") isa pair; $n value "fo" isa name;
$p id "348240" (pobj: id "45240", prep: id "98512") isa pair; $n value "fo" isa name;
$p id "262352" (pobj: id "24712", prep: id "24712") isa pair; $n value "ff" isa name; ---------a
$p id "344144" (pobj: id "24712", prep: id "98512") isa pair; $n value "ff" isa name; ----------b
$p id "65560" (pobj: id "24712", prep: id "61496") isa pair; $n value "ff" isa name;-------c
$p id "163896" (pobj: id "98512", prep: id "24712") isa pair; $n value "ff" isa name; ------------d
$p id "250040" (pobj: id "98512", prep: id "98512") isa pair; $n value "ff" isa name; ----------e
$p id "90120" (pobj: id "98512", prep: id "61496") isa pair; $n value "ff" isa name; ---------------f
$p id "159800" (pobj: id "61496", prep: id "24712") isa pair; $n value "ff" isa name; ------------g
$p id "122904" (pobj: id "61496", prep: id "98512") isa pair; $n value "ff" isa name; -----------h
$p id "118840" (pobj: id "61496", prep: id "61496") isa pair; $n value "ff" isa name; --------------- i
$p id "65672" (pobj: id "16408", prep: id "45240") isa pair; $n value "oo" isa name;
$p id "94232" (pobj: id "57528", prep: id "16408") isa pair; $n value "oo" isa name;
$p id "98312" (pobj: id "45240", prep: id "57528") isa pair; $n value "oo" isa name;
$p id "102408" (pobj: id "57528", prep: id "57528") isa pair; $n value "oo" isa name;
$p id "110648" (pobj: id "45240", prep: id "45240") isa pair; $n value "oo" isa name;
$p id "114744" (pobj: id "57528", prep: id "45240") isa pair; $n value "oo" isa name;
$p id "122936" (pobj: id "16408", prep: id "57528") isa pair; $n value "oo" isa name;
$p id "151608" (pobj: id "45240", prep: id "16408") isa pair; $n value "oo" isa name;
$p id "299088" (pobj: id "16408", prep: id "16408") isa pair; $n value "oo" isa name;
$p id "106504" (pobj: id "61496", prep: id "57528") isa pair; $n value "of" isa name;
$p id "168120" (pobj: id "61496", prep: id "45240") isa pair; $n value "of" isa name;
$p id "196816" (pobj: id "98512", prep: id "45240") isa pair; $n value "of" isa name;
$p id "213072" (pobj: id "24712", prep: id "45240") isa pair; $n value "of" isa name;
$p id "213176" (pobj: id "98512", prep: id "16408") isa pair; $n value "of" isa name;
$p id "221392" (pobj: id "24712", prep: id "57528") isa pair; $n value "of" isa name;
$p id "250064" (pobj: id "24712", prep: id "16408") isa pair; $n value "of" isa name;
$p id "258128" (pobj: id "98512", prep: id "57528") isa pair; $n value "of" isa name;
$p id "303184" (pobj: id "61496", prep: id "16408") isa pair; $n value "of" isa name;
>>> match $p isa pair, has name 'ff';
$p id "90120" (pobj: id "98512", prep: id "61496") isa pair; --------------f 
$p id "262352" (pobj: id "24712", prep: id "24712") isa pair; -------------a
$p id "344144" (pobj: id "24712", prep: id "98512") isa pair; ---------b
$p id "65560" (pobj: id "24712", prep: id "61496") isa pair; ---------c
$p id "122904" (pobj: id "61496", prep: id "98512") isa pair; ----------- h 
$p id "118840" (pobj: id "61496", prep: id "61496") isa pair; -------------i 
$p id "163896" (pobj: id "98512", prep: id "24712") isa pair; -------------d
$p id "250040" (pobj: id "98512", prep: id "98512") isa pair; ---------------e
$p id "159800" (pobj: id "61496", prep: id "24712") isa pair; ------------ g
$p id "159800" (pobj: id "61496", prep: id "24712") isa pair; ------------------g DUPLICATE 
$p id "163896" (pobj: id "98512", prep: id "24712") isa pair; --------- d DUPLICATE
$p id "262352" (pobj: id "24712", prep: id "24712") isa pair; -----------a DUPLICATE
$p id "122904" (pobj: id "61496", prep: id "98512") isa pair; ------------h DUPLICATE
$p id "250040" (pobj: id "98512", prep: id "98512") isa pair; -------------e DUPLICATE
$p id "344144" (pobj: id "24712", prep: id "98512") isa pair; -----------b DUPLICATE
$p id "65560" (pobj: id "24712", prep: id "61496") isa pair; ------------ c DUPLICATE
$p id "90120" (pobj: id "98512", prep: id "61496") isa pair; -------------f DUPLICATE

#2

I run the same query in A) and C) and it returns the right answer the first time but returns duplicates the second time

A) first query: 9 (ok)

>>> match $p isa pair, has name 'ff';
$p id "385032" (pobj: id "24712", prep: id "61496") isa pair;
$p id "360472" (pobj: id "61496", prep: id "61496") isa pair;
$p id "782416" (pobj: id "98512", prep: id "61496") isa pair;
$p id "405512" (pobj: id "24712", prep: id "24712") isa pair;
$p id "782520" (pobj: id "61496", prep: id "24712") isa pair;
$p id "786616" (pobj: id "98512", prep: id "24712") isa pair;
$p id "368776" (pobj: id "24712", prep: id "98512") isa pair;
$p id "876624" (pobj: id "61496", prep: id "98512") isa pair;
$p id "426008" (pobj: id "98512", prep: id "98512") isa pair;

B) second query…

>>> match $p isa pair, has name $n;
$p id "360472" (pobj: id "61496", prep: id "61496") isa pair; $n value "ff" isa name;
$p id "368776" (pobj: id "24712", prep: id "98512") isa pair; $n value "ff" isa name;
$p id "376840" (pobj: id "45240", prep: id "45240") isa pair; $n value "oo" isa name;
$p id "380936" (pobj: id "16408", prep: id "61496") isa pair; $n value "fo" isa name;
$p id "385032" (pobj: id "24712", prep: id "61496") isa pair; $n value "ff" isa name;
$p id "405512" (pobj: id "24712", prep: id "24712") isa pair; $n value "ff" isa name;
$p id "409608" (pobj: id "45240", prep: id "24712") isa pair; $n value "fo" isa name;
$p id "413752" (pobj: id "45240", prep: id "61496") isa pair; $n value "fo" isa name;
$p id "417800" (pobj: id "57528", prep: id "98512") isa pair; $n value "fo" isa name;
$p id "417848" (pobj: id "16408", prep: id "57528") isa pair; $n value "oo" isa name;
$p id "426008" (pobj: id "98512", prep: id "98512") isa pair; $n value "ff" isa name;
$p id "704696" (pobj: id "57528", prep: id "61496") isa pair; $n value "fo" isa name;
$p id "712888" (pobj: id "45240", prep: id "57528") isa pair; $n value "oo" isa name;
$p id "717008" (pobj: id "16408", prep: id "45240") isa pair; $n value "oo" isa name;
$p id "721104" (pobj: id "24712", prep: id "45240") isa pair; $n value "of" isa name;
$p id "729296" (pobj: id "57528", prep: id "45240") isa pair; $n value "oo" isa name;
$p id "753872" (pobj: id "57528", prep: id "57528") isa pair; $n value "oo" isa name;
$p id "761936" (pobj: id "61496", prep: id "45240") isa pair; $n value "of" isa name;
$p id "766136" (pobj: id "61496", prep: id "16408") isa pair; $n value "of" isa name;
$p id "766160" (pobj: id "98512", prep: id "57528") isa pair; $n value "of" isa name;
$p id "770128" (pobj: id "98512", prep: id "45240") isa pair; $n value "of" isa name;
$p id "770232" (pobj: id "98512", prep: id "16408") isa pair; $n value "of" isa name;
$p id "782416" (pobj: id "98512", prep: id "61496") isa pair; $n value "ff" isa name;
$p id "782520" (pobj: id "61496", prep: id "24712") isa pair; $n value "ff" isa name;
$p id "786616" (pobj: id "98512", prep: id "24712") isa pair; $n value "ff" isa name;
$p id "794808" (pobj: id "16408", prep: id "98512") isa pair; $n value "fo" isa name;
$p id "798800" (pobj: id "24712", prep: id "57528") isa pair; $n value "of" isa name;
$p id "802896" (pobj: id "61496", prep: id "57528") isa pair; $n value "of" isa name;
$p id "811216" (pobj: id "57528", prep: id "24712") isa pair; $n value "fo" isa name;
$p id "815184" (pobj: id "16408", prep: id "16408") isa pair; $n value "oo" isa name;
$p id "819280" (pobj: id "24712", prep: id "16408") isa pair; $n value "of" isa name;
$p id "823376" (pobj: id "45240", prep: id "16408") isa pair; $n value "oo" isa name;
$p id "827472" (pobj: id "57528", prep: id "16408") isa pair; $n value "oo" isa name;
$p id "847952" (pobj: id "16408", prep: id "24712") isa pair; $n value "fo" isa name;
$p id "872528" (pobj: id "45240", prep: id "98512") isa pair; $n value "fo" isa name;
$p id "876624" (pobj: id "61496", prep: id "98512") isa pair; $n value "ff" isa name;

C) third query (same query as first query), now returns 18 with duplicates (that is a problem)

>>> match $p isa pair, has name 'ff';
$p id "360472" (pobj: id "61496", prep: id "61496") isa pair;
$p id "360472" (pobj: id "61496", prep: id "61496") isa pair;
$p id "368776" (pobj: id "24712", prep: id "98512") isa pair;
$p id "368776" (pobj: id "24712", prep: id "98512") isa pair;
$p id "385032" (pobj: id "24712", prep: id "61496") isa pair;
$p id "385032" (pobj: id "24712", prep: id "61496") isa pair;
$p id "405512" (pobj: id "24712", prep: id "24712") isa pair;
$p id "405512" (pobj: id "24712", prep: id "24712") isa pair;
$p id "426008" (pobj: id "98512", prep: id "98512") isa pair;
$p id "426008" (pobj: id "98512", prep: id "98512") isa pair;
$p id "782416" (pobj: id "98512", prep: id "61496") isa pair;
$p id "782416" (pobj: id "98512", prep: id "61496") isa pair;
$p id "782520" (pobj: id "61496", prep: id "24712") isa pair;
$p id "782520" (pobj: id "61496", prep: id "24712") isa pair;
$p id "786616" (pobj: id "98512", prep: id "24712") isa pair;
$p id "786616" (pobj: id "98512", prep: id "24712") isa pair;
$p id "876624" (pobj: id "61496", prep: id "98512") isa pair;
$p id "876624" (pobj: id "61496", prep: id "98512") isa pair;
>>>

#3

v 0.13 github

this ontology also produce similar result though only contains ‘ff’ and ‘fo’ names

insert

##################################################################
# Schema
##################################################################

word sub entity
    plays subtype
    plays supertype
    plays prep
    plays pobj
    has name;

f sub word;
o sub word;

pobj sub role;
prep sub role;
subtype sub role;
supertype sub role;

inheritance sub relation
    relates supertype
    relates subtype;

pair sub relation
    relates prep
    relates pobj
    has typ
    has name;

name sub resource datatype string;
typ sub resource datatype string;


##################################################################
# Data
##################################################################

$f isa f, has name "f";
$o isa o, has name "o";

$aa isa word, has name "aa";
$bb isa word, has name "bb";
$cc isa word, has name "cc";

(supertype: $o, subtype: $aa) isa inheritance;
(supertype: $o, subtype: $bb) isa inheritance;
(supertype: $o, subtype: $cc) isa inheritance;

$pp isa word, has name "pp";
$qq isa word, has name "qq";
$rr isa word, has name "rr";

(supertype: $f, subtype: $pp) isa inheritance;
(supertype: $f, subtype: $qq) isa inheritance;
(supertype: $f, subtype: $rr) isa inheritance;

##################################################################
# Inference: all pairs;
##################################################################

isa inference-rule
    lhs {
        $x isa word;
        $y isa word;
        $x has name != 'f';
        $x has name != 'o';
    }
    rhs {
        (prep: $x, pobj: $y) isa pair;
    };

##################################################################
# Inference: pairs FF
##################################################################

isa inference-rule
    lhs {
        $f isa f;
        (subtype: $prep, supertype: $f) isa inheritance;
        (subtype: $pobj, supertype: $f) isa inheritance;
        $p (prep: $prep, pobj: $pobj) isa pair;
    }
    rhs {
        $p has name 'ff';
    };

##################################################################
# Inference: pairs FO
##################################################################

isa inference-rule
    lhs {
        $f isa f;
        $o isa o;
        (subtype: $prep, supertype: $f) isa inheritance;
        (subtype: $pobj, supertype: $o) isa inheritance;
        $p (prep: $prep, pobj: $pobj) isa pair;
    }
    rhs {
        $p has name 'fo';
    };

#4

In case anyone stumbles across this later the resolution is here: https://github.com/graknlabs/grakn/issues/1515