Why does depth-re-search unify prologue and not width-first search?

I just started looking into the prologue and I was wondering why it is dfs instead of bfs and why there is no easy way to change it.

Does this provide a prologue ISO?

+3


source to share


1 answer


First of all, it's pretty easy to change. Most of the Prolog text explains how and how to write a predicate that does BFS, and how to create a meta-interpreter that does it with arbitrary terms. The truth is that students who get an introduction to Prolog at university go through (mostly) the first week or two of using Prolog. This is not exactly the main task of Prolog, but it is not an advanced Prolog technique. If you spend two months on Prolog it won't be a daunting thing. This sounds like a lot of Prolog, but compared to (say) Java, it's really small. For some reason, we expect to be able to get to the finish line with Prolog much faster than we do for systems that are actually much less interesting.

I believe that the ISO search strategy is called SLD Resolution and depth search arises from this resolution mechanism. I have not read the ISO standard, so perhaps someone better informed than me will comment. I think it would be difficult to manage the standardization of Prolog if the resolution method (and therefore the first or the first) were not required, since computations that succeed in one way can introduce an infinite loop the other way. A language standard that does not define the behavior of normal programs would be a rather low standard. There is no reason not to have a built-in to specify an alternative search strategy though.



I don't know the reason for the DFS mandate in particular. For a while using Prolog, the idea of โ€‹โ€‹non-DFS seems ineffective to me. For example, if I add some code to handle the edge case, I will pay for it every time with BFS, but only when needed with DFS. I feel that DFS will be more memory efficient; For example, I don't have to track down a bunch of possible code paths. It seems to me that DFS is probably easier to control because I can prune the search tree easily. But these are just feelings; perhaps my sense of naturalness is the result of what I have used. The lack of a BFS-based competitor to Prolog is sort of an assumption that it might not be a good idea. On the other hand, what was ineffective in 1980,still informs about the implementation of Prolog today, although now everything is completely different.

+2


source







All Articles