Thanks and relations between columns with non-enumerable domains. #24
Replies: 1 comment 1 reply
-
David, Logica can work with columns with non-enumerable domains right now, but what it can do with them is limited to what's achievable by injection and equality resolution. This is briefly discussed in section Infinite predicates of the tutorial. In particular this allows Logica treat regular functions as predicates and helps keep the syntax clean. In your article you discuss predicate # Implementing addition that works in multi-way inference.
Add(x, y) = z :-
x + y == z,
z - x == y,
z - y == x;
# Now we can use Add by setting any pair of variables.
# Compiled SQL would have redundant WHERE clause qualities, but the result
# should be mathematically correct.
P1(a, b, c) :- a in Range(10), b in Range(10), c == Add(a, b);
P2(a, b, c) :- a in Range(10), c in Range(10), c == Add(a, b);
P3(a, b, c) :- b in Range(10), c in Range(10), c == Add(a, b); It is an interesting direction of development of the language to add automatic solvers, which would analyze definitions of predicate, so we could do something like this. # WARNING: This is a hypothetical feature that enables linear equations solver,
# there is no such annotation at the moment.
@EnableSolver("LinearEquations");
# LinearEquations solver is turned on, so the compiler would figure out that a = b = c = 0.5.
# At the moment this would result in an error stating that no way to assign a, b, c was found.
MyNumbers(a, b, c) :- a + b == 1, a + c == 1, b + c == 1; Let me know if this fits your vision. |
Beta Was this translation helpful? Give feedback.
-
Hi Evgeny and Konstantin,
I've been dreaming about the possibility of this language for some time. Thankyou.
My intuition has been that the declarative relation-based SELECT + VIEW + CTE way of expressing complex algorithms (e.g. graph algorithms) is unique and extremely useful but is held back by the lack of:
Logica addresses modularisation and encapsulation of queries.
An example relation between columns with non-enumerable domains might be
If such a computed relation was implemented, the developer could SELECT over it, just like any table without being able to tell that this relation was never materialised.
JOINs over such computed relations may require delegation to a constraint solver. So the (under the hood) language for specifying such computed relations should be easily translatable as input into a constraint solver.
Here are my musings on this topic from last month ... Table Valued Contrained Functions (TVCF) - Constraint Programming and SQL
Your thoughts?
David
Beta Was this translation helpful? Give feedback.
All reactions