Skip to content

Commit

Permalink
Documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
daveraja committed Jul 22, 2019
1 parent e63b0ae commit bca1f5b
Showing 1 changed file with 12 additions and 32 deletions.
44 changes: 12 additions & 32 deletions docs/clorm/background.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,18 @@ Object Relational Mapping (ORM)
-------------------------------

`ORM <https://en.wikipedia.org/wiki/Object-relational_mapping>`_ interfaces are
a common way of interacting with relational databases and there are some
well-known Python ORMs (e.g., SQLAlchemy and Peewee). Fundamentally all ORMs
provide a way of matching rows in a database table (or database view) to Python
objects whose member variables correspond to the fields of the database table.
a common way (especially in Python) of interacting with relational databases and
there are some well-known Python ORMs (e.g., SQLAlchemy and
Peewee). Fundamentally all ORMs provide a way of matching rows in a database
table (or database view) to Python objects whose member variables correspond to
the fields of the database table.

As well as mapping table rows to program objects, ORMs also provide facilities
for building SQL queries using high-level primitives; rather than dealing with
raw SQL strings.

Answer Set Programming (ASP) and Clingo
---------------------------------------

`Answer Set Programming (ASP)
<https://en.wikipedia.org/wiki/Answer_set_programming>`_, not to be confused
with Microsoft Active Server Pages or ASP.NET, is an AI/logic based language for
modelling and solving combinatorial optimisation problems. ASP has a
Prolog-style language for specifying problems in terms of predicates and the
relations between them. The solver then generates solutions (called *models* or
*answer sets*) consisting of a sets of ground facts that are (minimally)
consistent with these definitions.

`Clingo <https://potassco.org>`_ is the leading open-source ASP solver. It can
be run as a stand-alone executable or integrated as a library into other
languages. It has very good support for Python with an extensive API for
interacting with the solver.

Clingo supports Python in two ways:

* running Clingo from within a Python application.
* calling Python functions from within an ASP program,

An ORM Interface to Clingo
--------------------------
An ORM Interface for Clingo
---------------------------

While the Clingo Python API is both extensive and flexible it is also fairly
low-level when it comes to getting data into, and out of, the solver. As a
Expand All @@ -55,8 +34,9 @@ that are difficult to detect.

An ORM interface can help to alleviate these problems. The ORM definitions that
map ASP predicates to Python objects are defined in a single location and the
ASP to Python translation is made clear; since it is not written directly by
the developer but instead is generated from the ORM class definitions.
ASP to Python translations are all generated automatically from the ORM class
definitions.

Hence a Clingo ORM interface can make it easier to integrate Clingo and Python
and to write Python code that is more readable and easier to maintain.
Hence, we would argue that a Clingo ORM interface can make it easier to
integrate Clingo and Python and to write Python code that is more readable and
easier to maintain.

0 comments on commit bca1f5b

Please sign in to comment.