# Mathematica as Answer Set Programming (ASP) engine?

Maybe I need to rephrase this question, so that it might receive some attention:

Are there any packages or examples of how to put Mathematica to good use in the field of ASP (Answer Set Programming) and possibly Truth Maintenance?

## Background

I am deeply involved in product configuration, i.e. in developing a software infrastructure, which ensures, that a customizable product can actually be manufactured.

This involves defining rules for each product's components' existence and inter-component-relations, performing hydrodynamic calculations, limiting the selectable product lines according to the user's choice of intended usage, ...

This also is very tedious if implemented by relying solely on procedural programming. Answer Set Programming (ASP) might ease this by enabling declarative programming.

Since Mathematica would be a fine choice especially for implementing the actual engineering-related (hydrodynamic) calculations, solving boolean equations etc., I intensely searched the web for hints on how to also use it for Answer Set Programming, however: To no avail.

There are some ASP-implementations out there: cmodels, smodels, CLASP, DLV and derivatives..., all either derelict/stale or seemingly more fitting for university lectures than productive work.

• Hmm - looks like this really is a barren field with Mathematica. :( – Jinxed Jan 31 '15 at 9:59

Preamble/Disclaimer:

I will present my thoughts rather than giving a definite answer in the Wolfram language, focused solely on configurator technology/methodology, and will give some humble suggestions. I have NO knowledge about ASP (Answer Set Programming) and in addition have absolutely NO knowledge about the scope and organization of your project. I’m not affiliated with one or more of the mentioned vendors; I’m a mere user of one of them.

Introduction:

Configurators are a software approach to do mass-customization of products and services and are historically an off-spring of AI (artificial intelligence) research and expert systems applications. It needed almost a decade to from the mid 80´ies to the mid- to late 90’ies to make it “mainstream”. However configurator vendors and its users (i.e. developers, who do integrate the framework from vendors, and the modelers, who develop the models) cannot deny that it is still a very special field of application. Configuration as part of the business process needs to consider more things than the mere configuration task, but let's focus on the configuration task. For a little bit of introductory background I suggest [4], where a lot of pages can be read on Google Books. If you like to go deeper I found [5] for the classical TMS and [6] for a link to your desired info on ASP.

Suggestions:

Evaluate commercial configurator solutions (ConfigIT, SAP IPC, ILog, Tacton, Selectica, CAMOS, …) - if not done already - to get a real sense about its power, its weaknesses, its maintainability, about it’s expressiveness on modeling, collaboration capabilities etc. Maybe ASP can be achieved or is somehow self-contained as a feature in those products. An awful lot of money went into the research and optimization of configurators of the big players. ASP is mentioned in research literature for conferences on configuration [6]. Although very theoretical, you may give it a read.

If there is already a configurator in your business: do a prototyping on a fragment of the actual model in Mathematica with the Wolfram Language. Pick a particular constraint on a limited set of components and try to formulate it via Rule, TagSet, Cases etc. in Mathematica. Literature [1], [2], [3] may help.

I would (from experience) go for OO-Methodology for putting together your product structure (component modeling) and PAIR it with with Constraint-based Reasoning Techniques to formulate your knowledge. As far as OO-Methodology goes you need at least simple construct for Part-of-Relationship and Is-a Relationship (Specialization). There will almost also be needed TABULAR relationships from which you can infer order numbers (part names) or do domain restrictions (on characteristics of a certain part instance). These tabular relationships (e.g. variant tables) represent knowledge which have been formulated before-hand by R&D or Product Management.

Other things to consider:

A) Interfaces to other Business process steps:

• Who and how many people are tasked to the modeling?
• How are the users of your potential solution? Sales guys in the field or internal specialists?
• What happens with the outcome of your configuration? Will it passed to ERP-System for sales order or furthermore BOM-explosion or Routing.

B) Performance, Performance, Performance

• Normally, a reasonable management tolerates the trade-offs of the outcome of engineering task like a SW package. But you never can talk about performance, reasonably, even if the sw runs correctly.
• What happens with configurators and big models (no matter if ill-defined or well-defined) is that at runtime the Pattern Matching System (PMS) might spend more time worrying (i.e. exclude invalid solutions from solution space) than actually give a quick valid answer set. That would be a sign of a needed partitioning of you configuration which might not be achieved within the framework of that configurator product but need to be developed by yourself.

Conclusions:

To build a configuration solution exclusively in Mathematica is an interesting and compelling idea, but will it fly in brutal daily business? Is a compelling full-fledged-solution, e.g. in CDF, in a business context doable? Unfortunately, at the moment, I doubt it, it is a barren field as you stated in your question. Others may disagree with me, though, and I like to be proven wrong.

1) If you only need Mathematica to feed your model or map certain aspects of business logic into your model of an existent configurator or you like to verify aspects of your model you can certainly start writing Rule, Assertion or do complex calculations with Solve and NSolve for your domain. Automate the process so that the model or test results for the configurator can be generated.

2) If you intend to build a SOLUTION for your configuration problem with Mathematica and deploy with CDF or WebMathematica or Cloud prepare to take CONSIDERABLE TIME for an investigation and benchmark against what’s on the market already.

References:

[1] Wolfram, Stephen. “Mathematica Book Version 1”, Chapter 4 (about Methodologies – this valuable chapter has been lost in later versions!!), Addison-Wesley 1988

[2] Wagner, David B. “Power Programming with Mathematica”, Chapter on Implementing your own DataType, Mc Graw-Hill 1996

[3] Maeder, Roman. “The Mathematica Programmer: Logic Programming I: The Interpreter”, Wolfram library archive http://library.wolfram.com/infocenter/Articles/898/

[4] Alexander Felfernig, Lothar Hotz, Claire Bagley, Juha Tiihonen. “Knowledge-based Configuration: From Research to Business Cases”, 2014

[5] de Kleer, Johan. “An assumption–based truth maintenance system”, Artificial Intelligence, 28, 127–162, (1986).

[6] Alexander Felfernig, Cipriano Forza, and Albert Haag. “Proceedings of the 16th International Configuration Workshop”. 2014

• I know Camos (which works) and SAP SSC (which does not so much), including real-world use and theoretical background. Thing is: Any package around may deal with configuration tasks in some way, but all of them have no proper means of integrating heavy numerical calculations. Mathematica deals well with calculations and also offers dealing with symbolic logic. However, it completely lacks ASP and TMS-features, which is - as I take from literature - in one way or another at the core of many configurators. I am just astonished, that there is nothing on that topic to be found for Mathematica – Jinxed Feb 6 '15 at 17:52
• Besides: Do you think of SAP IPC as a configurator? Given that you mentioned variant tables, I suppose that is the product you are using. – Jinxed Feb 6 '15 at 18:05
• Yes, I'm using SAP IPC which is the predecessor of SSC and was available as Java standalone deployment option. If you are interested you may read in [4] chapter 27. Regarding you first comment: I absolutely agree that there is simply no "complete" package. The configurator vendors provide no CAS and Mathematica has no TMS, AFAIK. Could you provide an example for you calculations? Did you explore the route to call Mathematica for computational services via LINK technology? – Xacobeo2002 Feb 7 '15 at 10:01
• I am interested in Answer Set Programming in general, as it should be implementable with Mathematica, and then maybe apply it. But the problem is: I feel not adept enough to implement it myself, and am utterly astonished, that no single mention on that topic together with Mathematica can be found anywhere. :( – Jinxed Feb 8 '15 at 14:18