triska / the-power-of-prolog

Introduction to modern Prolog
https://www.metalevel.at/prolog
1.21k stars 75 forks source link

Term Rewriting prolog code #29

Open infogulch opened 2 years ago

infogulch commented 2 years ago

Hi! I liked your video about term rewriting with prolog. This made me curious if it's possible to do term rewriting on prolog code. You mentioned "narrowing" in passing which lead me to some interesting results after some light googling 1, but I'm not sure in which direction to go in to learn more.

My intuition tells me that to do this on a prolog query you'd first need to fold the query and all transitively referenced rules down into one very long query first, and then you could apply rewrite rules to it from there. But I'm not sure if this "folding" procedure could be valid for all possible rules.

Thoughts?

triska commented 2 years ago

Thank you very much for your kind words, and for your interest!

Maybe the Curry programming language could be an interesting starting point, its Wikipedia page also contains a brief section on narrowing, mentioning a specific variant of narrowing called needed narrowing:

https://en.wikipedia.org/wiki/Curry_(programming_language)

The Curry documentation could also be an interesting resource to find further documents and contacts about this topic!

fnogatz commented 2 years ago

btw, the Curry people are active on GitHub as well: :wave: @mihanus, @ichistmeinname, @finnteegen

mihanus commented 2 years ago

You might also have a look at the Curry homepage where you find much more material. A short survey about the advantages of Curry's evaluation strategy (needed narrowing) is also available from Comm. ACM