Skip to content

Getting Started

Installation

pip install pyNMMS

For development:

git clone https://github.com/bradleypallen/pyNMMS.git
cd pyNMMS
pip install -e ".[dev]"

Your First Material Base

A material base encodes defeasible material inferences among atomic sentences.

from pynmms import MaterialBase, NMMSReasoner

# Create a base: "rain" defeasibly implies "wet ground"
base = MaterialBase(
    language={"rain", "wet_ground", "covered"},
    consequences={
        (frozenset({"rain"}), frozenset({"wet_ground"})),
    },
)

Querying Derivability

reasoner = NMMSReasoner(base)

# Does rain derive wet ground?
result = reasoner.derives(frozenset({"rain"}), frozenset({"wet_ground"}))
print(result.derivable)  # True

# Nonmonotonicity: adding "covered" defeats the inference
result = reasoner.derives(
    frozenset({"rain", "covered"}),
    frozenset({"wet_ground"})
)
print(result.derivable)  # False — no weakening!

Using the CLI

# Create a base
pynmms tell -b mybase.json --create "rain |~ wet_ground"

# Query it
pynmms ask -b mybase.json "rain => wet_ground"        # DERIVABLE
pynmms ask -b mybase.json "rain, covered => wet_ground"  # NOT DERIVABLE

# Interactive REPL
pynmms repl -b mybase.json

Next Steps

  • Key Concepts — understand material bases, nonmonotonicity, and sequents
  • Proof Search — how the reasoner works and how to read traces
  • CLI Usage — full guide to the Tell/Ask CLI and REPL