lunes, 18 de abril de 2016

Comments on "Logic Programming through miniKanren"

Logic Programming is an interesting way to solving problems it’s based on the clojure core.logic namespace, it kind of solves the problems backwards, as described in the lecture, and it’s kind of like magic.

In logical programming you tell the program the basic rules of the problem and an initial state, and the program will find the solution to the problem without much work required from us.

When we code in logical programming, our goal is to match both sides of our expression to try and get a number of possible solutions. We can limit the number of solution provided by writing run followed by a number of maximum number of solution we want to get in return, if the number of solutions is less than the number we specified, we will just get that number. If we use the run* form, this means we will get all the possible solutions to the bounding of our condition. This can be dangerous if we have infinite number of possible solutions.

Expressions in logical programming don’t return true or false, instead, they return succeed or fail if the expression is able to bind our query to our goal.

Some other functions make it possible to bind queries to our goals in parallel ways which is similar to creating “parallel universes”.

Relationships can be created using this schema, creating databases it’s very simple and it will make solution solving very easy. When denoting relationships, an “o” must be added at the end of the name. Example “mothero”.

There are other ways to matching expression, a very useful way is using the matche pattern, which is a version of conde and makes this kind of code much more clear and concise.
Functions like map can be used in logical programming and work pretty much like they do in clojure and are used to match patterns.

There are other ways for matching patterns, such as using conde, condu, and condo, these types of conditionals work in parallel to try and match conditions to its bindings in a proper way.

Logical Programming is a very powerful tool, but can be mind-bending when trying to fully understand it.