@@ -4,53 +4,66 @@ using namespace datalog;
44
55int main () {
66
7+ struct Int : RelationType<int > {
8+ };
9+ struct Int_Int : RelationType<int , int > {
10+ };
11+ struct String_Int : RelationType<string, int > {
12+ };
13+ struct String_Int_String : RelationType<string, int , string> {
14+ };
715 {
8- Relation<int > r1 { { { 1 } } };
9- Relation<int , int > r2 { { { 1 , 2 } } };
10- Relation<string, int > r3 { { { " hello" , 1 } } };
11- Relation<string, int > r4 { { { " hello" , 1 }, { " world" , 2 } } };
12- Relation<int , int > r5 { { { 1 , 2 }, { 3 , 4 } } };
13- Relation<string, int , string> r6 { { { " hello" , 1 , " world" }, { " world" , 2 , " hello" }, { " world" , 3 , " world" } } };
14-
15- Relation<string, int > r7 = merge (r3, r4);
16+ Relation<Int> r1 { { { 1 }, { 2 } } };
17+
18+ Relation<Int_Int> r2 { { { 1 , 2 } } };
19+ Relation<Int_Int> r3 { { { 1 , 2 }, { 3 , 4 } } };
20+
21+ Relation<String_Int> r4 { { { " hello" , 1 } } };
22+ Relation<String_Int> r5 { { { " hello" , 1 }, { " world" , 2 } } };
23+
24+ Relation<String_Int_String> r6 { { { " hello" , 1 , " world" }, { " world" , 2 , " hello" }, { " world" , 3 , " world" } } };
25+
26+ Relation<String_Int> r7 = merge (r4, r5);
1627 }
1728
1829 {
19- Relation<Int> r2 { { { 1 , Id { " 2" } } } };
20- Relation<String, Int> r4 { { { { " hello " }, 1 }, { { " world" }, Id { " 2" } } } };
21- Relation<String, Int, String> r6 { { { { " hello" }, 1 , { Id { " 3" } } }, { { " world " }, 2 , { " hello " } }, { { Id { " 4 " } }, 3 , { " world " } } } };
30+ Atom<Int_Int> r1 { { 1 , Symbol { " 2" } } };
31+ Atom<String_Int> r2 { { { " world" }, Symbol { " 2" } } };
32+ Atom<String_Int_String> r3 { { { " hello" }, 1 , { Symbol { " 3" } } } };
2233 }
2334
2435 {
25- struct Adviser : Relation<String, String> {
26- using Relation<String, String>::Relation;
36+ struct Adviser : RelationType<string, string> {
2737 };
28- Adviser advisers { { { { " Andrew Rice" }, { " Mistral Contrastin" } }, { { " Andy Hopper" }, { " Andrew Rice" } }, { { " Alan Mycroft" }, {
38+ Relation< Adviser> advisers { { { { " Andrew Rice" }, { " Mistral Contrastin" } }, { { " Andy Hopper" }, { " Andrew Rice" } }, { { " Alan Mycroft" }, {
2939 " Dominic Orchard" } }, { { " David Wheeler" }, { " Andy Hopper" } }, { { " Rod Burstall" }, { " Alan Mycroft" } }, { { " Robin Milner" }, {
3040 " Alan Mycroft" } } } };
3141
32- struct AcademicAncestor : Relation<String, String> {
33- using Relation<String, String>::Relation;
42+ struct AcademicAncestor : RelationType<string, string> {
3443 };
3544
3645 // Rule1
37- Atom<AcademicAncestor> head1 { { Id { " x" }, Id { " y" } } };
38- Atom<Adviser> clause1 { { Id { " x" }, Id { " y" } } };
39- Rule<Atom< AcademicAncestor>, Atom< Adviser> > rule1 { head1, { { clause1 } } };
46+ Atom<AcademicAncestor> head1 { { Symbol { " x" }, Symbol { " y" } } };
47+ Atom<Adviser> clause1 { { Symbol { " x" }, Symbol { " y" } } };
48+ Rule<AcademicAncestor, Adviser> rule1 { head1, { { clause1 } } };
4049
4150 // Rule2
42- Atom<AcademicAncestor> head2 { { Id { " x" }, Id { " z" } } };
43- Atom<Adviser> clause21 { { Id { " x" }, Id { " y" } } };
44- Atom<AcademicAncestor> clause22 { { Id { " y" }, Id { " z" } } };
45- Rule<Atom< AcademicAncestor>, Atom< Adviser>, Atom< AcademicAncestor>> rule2 { head2, { { clause21, clause22 } } };
51+ Atom<AcademicAncestor> head2 { { Symbol { " x" }, Symbol { " z" } } };
52+ Atom<Adviser> clause2 { { Symbol { " x" }, Symbol { " y" } } };
53+ Atom<AcademicAncestor> clause3 { { Symbol { " y" }, Symbol { " z" } } };
54+ Rule<AcademicAncestor, Adviser, AcademicAncestor> rule2 { head2, { { clause2, clause3 } } };
4655
4756 // Query1
48- struct Query1 : Relation<String> {
49- using Relation<String>::Relation;
57+ struct Query1 : RelationType<string> {
5058 };
51- Atom<Query1> head3 { { Id { " x" } } };
52- Atom<AcademicAncestor> clause31 { { { " Robin Milner" }, Id { " x" } } };
53- Atom<AcademicAncestor> clause32 { { Id { " x" }, { " Mistral Contrastin" } } };
54- Rule<Atom<Query1>, Atom<AcademicAncestor>> query1 { head3, { { clause31, clause32 } } };
59+ Atom<Query1> head3 { { Symbol { " x" } } };
60+ Atom<AcademicAncestor> clause4 { { { " Robin Milner" }, Symbol { " x" } } };
61+ Atom<AcademicAncestor> clause5 { { Symbol { " x" }, { " Mistral Contrastin" } } };
62+ Rule<Query1, AcademicAncestor> query1 { head3, { { clause4, clause5 } } };
63+
64+ Adviser::GroundType fact1{ { " Andrew Rice" }, { " Mistral Contrastin" } };
65+ auto indexSequence = index_sequence_for<typename Adviser::GroundType>{};
66+ // auto boundAtom = bind(clause1, fact1, indexSequence);
67+
5568 }
5669}
0 commit comments