I'm currently taking CSC384 : Introduction to Artificial Intelligence, and it's been fun so far. We use Prolog for all our assignments, which is an interesting language to work with. I first learned Prolog last term, where I struggled tremendously to understand how it works. However, by the end of the assignment, the way Prolog worked fascinated me. The idea of unification and boolean predicates was completely new to me, and a lot of backtrack-search type "queries" were made simple with Prolog.
Our most recent assignment was to implement our own logic puzzle. We're given a series of statements about properties of a house (position, color, who lives in it, what's eaten there, what's drunk there, what pet is kept), and we are to come up with the solution that matches all the statements.
Depending on when we bind the variables and when we test whether they match each sentence greatly affects the number of states expanded. With binding all variables first, the query takes forever (something like 13 hours!), and expands nearly 400,000,000,000 states. With binding one or two variables at a time, then testing sentences with all their variables bound greatly decreases the query time to 0.03 seconds, with about 300,000 states expanded. This is owing to the "emulation" of backtrack search, i.e. it goes back to the first variable that doesn't unify and tries another value for it. If we test sentences immediately when all but one of their variables have been bound, this further decreases the number of expanded states to about 8,000, and takes nearly 0 seconds. This is because it allows for forward-checking, eliminating future variable binding possibilities that are "known" at that point to be impossible, thereby reducing the number of states to be expanded.
As much as I enjoy using Prolog and working on the assignments, I've discovered that debugging in Prolog is not fun. I've run into the mysterious case of the graphical debugger refusing to start. The strangest part is that it used to work, and I didn't do anything to break it (I highly doubt I touched any crucial files anyway), and yet it doesn't work anymore. I've tried on 3 different computers, running on different operating systems (Linux, Vista, OS X), and still nothing. I've tried reinstalling Prolog altogether, to no avail. I'll probably need to seek my professor's guidance about this soon.
On a side note, in CSC343 : Introduction to Databases, we're learning XQuery, and using Saxon-B in our assignment. Lo and behold, the source code uses Prolog! It makes sense though, the way it uses "for" assignments, for example. I was taught that Prolog is mostly a university-level language, and it's not used much in the industry, but I guess they do exist!
Converting PowerPoint to SVG: Help Needed
2 days ago
0 comments:
Post a Comment