use of com.vaticle.typedb.core.pattern.Disjunction in project grakn by graknlabs.
the class TypeInferenceTest method matching_rp_in_relation_that_cant_play_that_role_sets_conjunction_not_satisfiable.
@Test
public void matching_rp_in_relation_that_cant_play_that_role_sets_conjunction_not_satisfiable() throws IOException {
define_standard_schema("test-type-inference");
TypeInference typeInference = transaction.logic().typeInference();
String queryString = "match " + " $x isa company;" + " ($x) isa friendship;";
Disjunction disjunction = createDisjunction(queryString);
typeInference.applyCombination(disjunction);
assertFalse(disjunction.isCoherent());
}
use of com.vaticle.typedb.core.pattern.Disjunction in project grakn by graknlabs.
the class Util method resolvedDisjunction.
public static Disjunction resolvedDisjunction(String query, LogicManager logicMgr) {
Disjunction disjunction = Disjunction.create(TypeQL.parsePattern(query).asConjunction().normalise());
logicMgr.typeInference().applyCombination(disjunction);
return disjunction;
}
use of com.vaticle.typedb.core.pattern.Disjunction in project grakn by graknlabs.
the class ResolutionTest method createRootAndAssertResponses.
private void createRootAndAssertResponses(CoreTransaction transaction, Disjunction disjunction, Set<Identifier.Variable.Retrievable> filter, long answerCount, long explainableAnswers) throws InterruptedException {
ResolverRegistry registry = transaction.reasoner().resolverRegistry();
LinkedBlockingQueue<Match.Finished> responses = new LinkedBlockingQueue<>();
AtomicLong doneReceived = new AtomicLong(0L);
Actor.Driver<RootResolver.Disjunction> root;
try {
root = registry.root(disjunction, responses::add, iterDone -> doneReceived.incrementAndGet(), (throwable) -> fail());
} catch (TypeDBException e) {
fail();
return;
}
assertResponses(root, filter, responses, doneReceived, answerCount, explainableAnswers);
}
use of com.vaticle.typedb.core.pattern.Disjunction in project grakn by graknlabs.
the class TypeInferenceTest method branched_isa.
@Test
public void branched_isa() throws IOException {
define_custom_schema("define" + " person sub entity;" + " man sub person, owns man-name;" + " woman sub person, owns woman-name;" + " man-name sub attribute, value string;" + " woman-name sub attribute, value string;" + "");
TypeInference typeInference = transaction.logic().typeInference();
String queryString = "match $x isa $t; $y isa $t; $x has man-name 'bob'; $y has woman-name 'alice';";
Disjunction disjunction = createDisjunction(queryString);
typeInference.applyCombination(disjunction);
Map<String, Set<String>> expectedExhaustive = new HashMap<>() {
{
put("$x", set("man"));
put("$y", set("woman"));
put("$t", set("thing", "entity", "person"));
put("$_0", set("man-name"));
put("$_1", set("woman-name"));
put("$_man-name", set("man-name"));
put("$_woman-name", set("woman-name"));
}
};
assertEquals(expectedExhaustive, resolvedTypeMap(disjunction.conjunctions().get(0)));
}
use of com.vaticle.typedb.core.pattern.Disjunction in project grakn by graknlabs.
the class TypeInferenceTest method infer_is_attribute_from_having_value.
@Test
public void infer_is_attribute_from_having_value() throws IOException {
define_standard_schema("test-type-inference");
TypeInference typeInference = transaction.logic().typeInference();
String queryString = "match $x = $y;";
Disjunction disjunction = createDisjunction(queryString);
typeInference.applyCombination(disjunction);
Map<String, Set<String>> expected = new HashMap<>() {
{
put("$x", set("name", "age", "ref"));
put("$y", set("name", "age", "ref"));
}
};
assertEquals(expected, resolvedTypeMap(disjunction.conjunctions().get(0)));
}
Aggregations