Technical Questions #411
Replies: 10 comments 13 replies
-
I appreticiate your kind words @ConstantinVasilev ! These are great questions! I'll prepare the answers and will reply soon. |
Beta Was this translation helpful? Give feedback.
-
Let's get going, answering questions gradually :-)
For now there is not way to get it automatically. It's not hard to do it manually for a simple program. Here is an example:
So when we query
It should be straightforward to automate adding this reason column. It's not quite clear how should the reason be represented for aggregating predicates though. Colab with the example is here. |
Beta Was this translation helpful? Give feedback.
-
In CoLab there is always a graph of grounded predicates displayed when a predicate is exectuted. For the example above the graph would look as follows. |
Beta Was this translation helpful? Give feedback.
-
I am guessing that there is a size of the program when compilation starts taking more time then acceptible for interactive devlopment. I did not hit this limit in practice. At some point we'll need to implement the compiler in a faster language like C++, but I did not feel this need in my projects yet. It would be exciting if you grow your Logica codebase to such size. 😄 Indeed, if recursion is unfolded naively then this limit is easy to hit. But now we have "iterative" recursion mode (which is default in DuckDB). With this mode recurison is unfolded in fixed number of SQL statements, which depend on each other via a loop, so there is no need to write a lot of SQL. With this mode we can run recursion of depth of thousands with no compliation difficulty. If compliation gets slow in any of your program, please let me know, we'll see what can be done in that particular case. |
Beta Was this translation helpful? Give feedback.
-
There is automatic type inference in Logica activated when E.g. for program:
An error would be thrown that You can also specify types of variables explicitly using
There is a number type |
Beta Was this translation helpful? Give feedback.
-
Not yet, but this looks like a good feature to have and it would fit organically. In particular it can be used for query optimization - if a predicate is joined by a unique column twice, then the first join can be re-used.
To me this looks exactly like 5. Once we can announce a column to be unique it will work for instances and for relationships. |
Beta Was this translation helpful? Give feedback.
-
Logica has a convention that any predicate that is not specified in the program is assumed to be an existing table. Hence the SQL error. There are pros and cons of not depending on the database at compile time. In many cases it would be a better user experience to get a native Logica error - predicate undefined. Then there can be a question - if a predicate is undefined, should it be an error, or should it be assumed empty? I am pretty sure that it should be an error: when user makes a typo, it would be extremely cryptic behavior to assume misnamed predicate to be empty. If you want an empty predicate for some reason you can define it with a contradiction trick.
|
Beta Was this translation helpful? Give feedback.
-
Yeah, good point. Thank you! We should fix it.
Thanks for bringing those up. It's good to know what happens around :-) |
Beta Was this translation helpful? Give feedback.
-
@EvgSkv these discussions make me think that a nice documentation would be a big contribution. Something like this If you provide guidance for format and place in the repo, I can start writing as I am learning with edits and additions from your side? A lot of this already exists in your colab examples and is just a matter of organising it. This would be also needed for teaching LLM the Logica syntax |
Beta Was this translation helpful? Give feedback.
-
Hello @ConstantinVasilev ,
This is great! Please take a look at the documentation above. If you have ideas how to improve it feel free to let me know, or just set PRs editig it directly. I think it's convenient to develop it in markdown. In the future we can reformat it to something like the example that you gave. Let me know if you have any questions or further comments. |
Beta Was this translation helpful? Give feedback.
-
Thanks @EvgSkv for the great work!
Sharing some Qs and observations here, as the answers might be interesting for the community or for a future documentation:
Cat(x)
and a rule that all Cats are Mammal, we can ask for explanation of how the factMammal(x)
was derived. Example from RDFox. Example from PrometheuxCat(name: str, weight: float)
Mammal(name:) :- Cat(name:) | Dog(name:);
when data has only Cat record:Cat(name:"Tom");
outputtingMammal
gives error "no such table: Dog".Credit(limit:)
injects limit into the SQL without performing reserved keyword checks first.Beta Was this translation helpful? Give feedback.
All reactions