Programming "in large" and non-determinism

Hi, everyone.

Please, share you tips and tricks regarding maintaining large Prolog codebase. Specifically - how to you combat unwanted non-determinism. I’ve faced this problem in my project. Typical scenario - there is some error in predicate which makes some goal to wrongly fail. But prolog goes on backtracking and trying other branches until it fails without a hint on what’s really wrong or throws completely unrelated exception from another part of program.

I was frustrated by theese occurrences to such a point that I’ve designed minimalist procedural “extension” (or, more accurately, “narrowation”) language with possibility to invoke vanilla Prolog goals in controllable manner. Procedural code defines larger structure of control flow in my code with logical code blocks doing “smart stuff” here and there. This approach has made by life substantially simpler.

But I feel a bit uneasy about this like I’am putting metal wire in place of a fuse ) I suspect there are other and better ways of dealing with rogue non-determinism in large application.

I’am eager to hear you wisdom )

Hi there,

Check out Debugging and declaring determinism, specifically det/1 and SSU can really help in some cases

2 Likes

I second @oskardrums remarks. Typically, real applications consist of declarative parts that do the application logic and functional parts that deal with the communication, data transformation, etc. Declarative parts may use constraints, tabling, s(CASP), … The functional parts are typically deterministic. SSU and det/1 help a lot writing such code in a reliable way.

2 Likes

Thanks for the answers! I will look into SSUs. Never used them actually.