ShapeLogic is trying to develop a framework for declarative programming that works well for the computer vision and image processing domain. This has been growing along a letter match example application. It has been a trail and error process that so far has produced these approaches:
Here is a chronological listing of ShapeLogic's 3 different approaches declarative logic:
For the letter matching example, the lazy stream approach have been both simpler and more powerful than the goal driven logic engine. This is also used with the particle analyzer.
The declarative goal driven logic engine is build around an Artificial Intelligence choice tree that is traversed by hierarchical tasks. This approach was only developed until ShapeLogic 0.8, but it might work well when reasoning under uncertainty.
The logic filter language is used with both lazy streams and goal driven approach.
ShapeLogic is a toolkit, all the 3 approaches are available with unit tests.
For now development is focused on the lazy stream approach.
The idea is that you have definitions of a data stream, say:
The definition does not cause anything to be calculated, but when the data is needed it will be calculated. So it is a generalization of a lazy calculation.
Lazy streams have the following features
Stream used in letter match example:
The streams in ShapeLogic are different than the streams in Haskell, Oz, Scheme and Scala. These are all based on data structures similar to a LISP list.
In ShapeLogic the streams are assumed to be immutable. The data is put in a normal Java List.
Streams can also support parallel or concurrent programming, which is important with the CPU intensive operations in image processing and computer vision. Especially with the advent of cheap multi processor machines.
You define a lazy data stream for this and set a stream property
randomAccess = true
This indicates that individual elements can be calculated independently. The factory creating the stream could create a parallel version of the stream and assign each operation its own thread.
Note that the result would be a stream of polygons for each image.
The Logic filter language allows you to do Boolean combinations of filters with parameters
If you need to do more complex boolean combinations of filter on polygons try the following:
"polygon.filter('PointRightOfFilter(0.3) && PointAboveFilter(0.3)')" "polygon.filter('PointOfTypeFilter(PointType.T_JUNCTION) && PointLeftOfFilter(0.5)').size()"
These will filter:
Currently ShapeLogic is using the standard Java, C, C++ notation:
And use && Or use || Not use !
There is an external definition that determine what type of objects should be created, and how they should be instantiated and create and instantiate all dependent object.
Once the system become more complex this will probably be essential.
The system is currently simple so now this would only add complexity, and is not used yet.