Skip to main content

A python prover for evaluating FOL formulas on PDDL

Project description

PDDL-Prover

A python prover for evaluating FOL formulas on PDDL.

PDDL-Prover allows to construct arbitrary formulas in first-order logic (FOL) in Python, using a declarative syntax and including counting quantifiers. Then, the truth values of these formulas can be evaluated on a knowledge base, which represents a set of objects/contants and a set of true atoms (as in PDDL).

This results useful for evaluating conditions on PDDL states. For example, to check if in a given blocksworld state block A is on top of the table and under block B, we can do the following:

(ontable(A) & on(B,A)).evaluate(kb)

where kb is the knowledge base containing the objects and atoms of the blocksworld state. The line above will return True if the condition is met at the state, and False otherwise. You can find a more elaborate example below.

Installation

The package is available in PyPI and can be installed with pip install pddl-prover. Alternatively, you can clone this repository.

Example of use

from pddl-prover import *

b0, b1, b2, b3, b4  =  Constant(0), Constant(1), Constant(2), Constant(3), Constant(4)
x, y  =  Variable('x'), Variable('y')

handempty  =  Predicate('handempty', 0) # The second argument is the arity
ontable  =  Predicate('ontable', 1)
on  =  Predicate('on', 2)
clear  =  Predicate('clear', 1)

# Note: atoms in the knowledge base can be represented either in tuple form or as instances of the class logic.Atom
kb  = ({b0,b1,b2},{('ontable', (0,)), ('on',(1,0)), ('on', (2,1)), ('clear',(2,)),
('handempty', tuple())})

print("Evaluation:", handempty().evaluate(kb)) # True
print("Evaluation:", (ontable(b0) & on(b1,b0)).evaluate(kb)) # True
print("Evaluation:", TE(x, on(x,b0)).evaluate(kb)) # There Exists some x for which on(x,b0) -> True
print("Evaluation:", (TE(x, ontable(x)) == 1).evaluate(kb)) # There exists <only> one object for which ontable(x) is True -> True (counting quantifier)
print("Number of true substitutions:", Count(on(x,y), x, y).evaluate(kb)[0]) # Returns the number of x and y substitutions for which on(x,y) is True -> 2

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PDDL-Prover-1.0.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

PDDL_Prover-1.0.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file PDDL-Prover-1.0.0.tar.gz.

File metadata

  • Download URL: PDDL-Prover-1.0.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for PDDL-Prover-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a37736e20ea93cfdd264de08b68ad7cee9651e2cf6d26b5dce2fad9cf1928b26
MD5 dfdadc27073dddb43e2b21e0be761478
BLAKE2b-256 7437b581229baefc10191c18b33518700a5d72ad6f4a6818e70c5712fcf17cbc

See more details on using hashes here.

File details

Details for the file PDDL_Prover-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: PDDL_Prover-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for PDDL_Prover-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e02d6a928498072f3b25d6f55814c3b048ce8bccc5925fa298817de0e34cc277
MD5 2c837f4f24fcc053424ce2e0b546ca70
BLAKE2b-256 e8b8fafe3d29d432e4714813e440af0daadb0328f1e26ede9723c8620380a09e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page