Awesome. Rules-based programming is one of those things that isn't useful often, but when it is it can dramatically simplify a problem. It's worth learning the basic structure of how prolog solves problems and internalizing it (ie: the four-port model).
My execution model is pretty simplistic. It basically does forward chaining (not backtracking which is what a real Prolog interpreter would do). The reason is that we have the core set of true terms up front, and we can just run the rules to derive more and more terms until we hit the solution, and because of the way the rules are written, we (hopefully!) won't get a combinatorial explosion of terms.
Looks like it's more like Datalog than full Prolog. [0] You are probably using something similar to what is called the "semi-naive" evaluation strategy (which despite the disparaging-sounding name is actually pretty good).
Yes, I think you're right. I'm really exploring this for the first time since university, and I don't have any real formal basis for what I'm doing. Just a real world problem to solve.
I'd say it (rules based programming) is useful quite often and dramatically simplifies cognitive overhead for a lot of problems (UI is actually what comes to mind for me). It isn't used because of the initial sunk cost in learning how to do rules based programming well.
> Rules-based programming is one of those things that isn't useful often
Not to quibble with the part of your post that you immediately qualify, but is this really true? It seems to me like it's one of the most obvious (though maybe not the most successful?) approaches to expert-knowledge systems.
Your point may not be a contradiction i.e. there are not many cases where a rule based expert system is actually useful.
The typical problems are incompleteness, inability to handle ill-structured reality and that you can't add rules without rewriting existing rules making them scale poorly.
I think in this case it's definitely the last one. The C code is difficult to follow and harder to modify (see example link below). The new code may be easier to follow. Although I'm also aware that there's a fixed amount of complexity in the problem, and there may not be any silver bullet.
Is embedding C necessary? I fear it could make the code substantially harder to read, and doesn't really give a big benefit if you are transpiring to C anyway. You could just link against a standard library.