Metadata-Version: 2.2
Name: prolog-env
Version: 0.1.4
Summary: A Python package providing an environment for AI agents to test their Prolog code.
Home-page: https://github.com/NewJerseyStyle/prolog-env
Author: Yuan XU
Author-email: dev.source@outlook.com
License: MIT License
        
        Copyright (c) 2025 David H.
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: gymnasium
Requires-Dist: janus-swi
Provides-Extra: toolbox
Requires-Dist: transformers; extra == "toolbox"
Dynamic: author
Dynamic: author-email
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: summary

# prolog-env
[![PyPI version](https://badge.fury.io/py/prolog-env.svg)](https://badge.fury.io/py/prolog-env)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

A Python package providing an environment for AI agents to test their Prolog code.

## Installation

The package depends on SWI-Prolog, to [install SWI-Prolog from PPA](https://www.swi-prolog.org/build/PPA.html):

```bash
sudo apt-add-repository ppa:swi-prolog/stable
sudo apt-get update
sudo apt-get install swi-prolog libpython3-dev
```

Install the package using pip:

```bash
pip install prolog-env
```

## Get started

This guide provides a quick introduction to using the `prolog_env` package. It demonstrates how to create and interact with the `SimpleEvaluator` environment.

```py
from prolog_env import SimpleEvaluator

env = SimpleEvaluator()

code = """
train('Amsterdam', 'Haarlem').
train('Amsterdam', 'Schiphol').
"""

observation, reward, terminated, truncated, info = env.step(code)

print("Observation:")
print(observation)
print("Reward:", reward)

tests = """
:- begin_tests(test).

test(a) :-
        A is 2^3,
        assertion(float(A)),
        assertion(A == 9).

:- end_tests(test).
"""

observation, reward, terminated, truncated, info = env.step(code, tests)

print("Observation:")
print(observation)
print("Reward:", reward)
```
