Skip to main content

Samovar

Version 0.6 | Entry @ catseye.tc | See also: The League of Extraordinarily Dull Gentlemen ∘ The Swallows


Samovar is a domain-specific language (DSL) for modelling a world using propositions (facts), and possible events that can occur based on those facts, changing them.

Here is a short example of a Samovar description:

scenario IgnatzWithBrick {
  
    [actor(?A),item(?I),~holding(?A,?I)]  ?A picks up the ?I.   [holding(?A,?I)]
    [actor(?A),item(?I),holding(?A,?I)]   ?A puts down the ?I.  [~holding(?A,?I)]

    actor(Ignatz).
    item(brick).

    goal [].
}

And an implementation of Samovar could take this scenario and use it to, among other things, generate textual descriptions of chains of events like

Ignatz picks up the brick. Ignatz puts down the brick.

Of course, this is a very simple example. (It doesn't even prevent two actors from picking up the same item at the same time!) For more complex examples, and a fuller description of the language, see doc/Samovar.md, which also serves as a test suite.

Implementation

The reference implementation of Samovar, samovar, is written in Python. It can run under either Python 2.7 or Python 3.x (tested with 3.5 or higher.)

Discussion

This looks like logic programming but the internals are actually much simpler, and what it's doing is not logical inference.

The internals are far simpler than an inference engine or a theorem prover: there are no logical rules in the database, only propositions, so they can be selected by simple pattern-matching rather than full unification.

I originally described it as an "assertion-retraction engine", which could be thought of as a highly stylized form of Prolog programming. Alternately, it could be thought of as assigning preconditions and postconditions, like in Hoare logic, to actions in a world-model. Instead of constructing a proof, though, we simply chain actions together, by selecting any next one whose preconditions hold, and altering the world so that its postconditions hold.

In (I think) autumn 2019, I came across the concept of a production system, and I realized that is basically what Samovar implements. Researching it further, I discovered CLIPS, a production system built in 1985, and I realized that Samovar is not essentially different from an inefficiently-implemented, stripped-down version of CLIPS.

The main innovation in Samovar is the ability to "narrate" the choices the production system makes, with human-readable text.

This isn't too surprising, since my goal with Samovar was to make an expressive language, a syntax in which the author could write a story generator without the undue effort of switching context between prose and code. Picking logical propositions for the "code" and placing them before and after each fragment of prose was a reasonably "ergonomic" choice, and happens to coincide with the structure of a production system.

TODO

  • Maybe allow variables to be notated so that they can bind reflexively, e.g. ?*A looks at ?*B can bind both variables to Alice.
  • Make ?_ work such that you can say ¬holding(?_, club) to mean "if no one is holding the club".

Metadata

Release files for samovar-py 0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for samovar-py 0.6
File Size Uploaded Provenance
samovar-py-0.6.tar.gz 16.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for samovar-py 0.6
File Interpreter ABI Platform
samovar_py-0.6-py3-none-any.whl Python 3 none any Details

Total release size: 34.9 kB

Release files / samovar-py-0.6.tar.gz

Download URL samovar-py-0.6.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b755bb723106ab1e2ad4ff1426f6953c6d40495e0ed22ac411952e4199dbe7d4
BLAKE2b-256 checksum
How to use checksums
4601128ee5c182b85c45cd2652705b6077b57396421bf3018c87e5754d942418
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / samovar_py-0.6-py3-none-any.whl

Download URL samovar_py-0.6-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dac448d9ce0378ec1436b7d1304075a9f40a5352b80e2b159f8edcf350cd6238
BLAKE2b-256 checksum
How to use checksums
f72f68a0f2345b5fb0d8b56662b20b63e1f177f408b7f9e6cd9a3d7d3cb29706
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Security for samovar-py 0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.6 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page