Problem solving with layered design (domain specific small languages) in Prolog
Bowles and Wilks wrote
A programming methodology often used in AI, as well as in other fields, is stratified or layered design. When faced with a problem, rather than implementing a solution directly in some base language, a new, more appropriate, higher level language is designed in which to express a solution, and this is implemented in the base language. This methodology can have several iterations yielding as a final solution a hierarchy of different languages each more appropriate to expressing the solution than the language below.
This is something that is done quite often by Prolog and Lisp programmers. We've all read the same Prolog books so we've all seen an example of this in those expert system shells that chain backwards from goal to fact.
I thought I'd share another example, something of my own where the idea of creating a little language to solve the problem was quite obvious and very helpful.
In this case the domain is relation semantics used in the field of programming language design. The description with code can be found here:
http://barrywatson.se/lsi/lsi_relational_semantics.html
The thing to know is that in my prolog I can configure the reader so that any sequence of three or more 0'- characters is read as '---'. This is done with the flag 'collapse_multiple_minuses' which your prolog will most likely not have.
The notation used in the description of the semantics may be new to you, it is described here: http://barrywatson.se/lsi/lsi_inductively_defined_subsets.html
Feel free to ask any questions.
Feel free to show me any little languages you've designed yourself as this is an interest of mine.
Posted Mar 24, 2015, 6:22 AM UTC
I dont really understand this idea of domain specific languages.. what would be a really simple example?
It's about reducing the gap between problem and implementation. In the words of Forbus and DeKleer:
.
The one I linked to was a very simple one, probably the simplest I've ever seen.