Tutorial 1: Installation¶
This tutorial guides you through installing Mistaber and verifying your setup.
Learning Objectives¶
- Clone the Mistaber repository
- Install Python dependencies including clingo
- Verify the installation with a simple query
Prerequisites¶
- Python 3.10 or higher
- Git
- Basic command line familiarity
Estimated Time¶
10 minutes
Steps¶
Step 1: Clone the Repository¶
First, clone the Mistaber repository to your local machine:
The repository structure looks like this:
mistaber/
├── mistaber/
│ ├── cli/ # Command-line interface
│ ├── dsl/ # HLL compiler
│ ├── engine/ # Reasoning engine
│ └── ontology/ # Halachic knowledge base
├── docs/ # Documentation
├── examples/ # Example scenarios
└── tests/ # Test suite
Step 2: Create a Virtual Environment¶
It's recommended to use a virtual environment to isolate dependencies:
Step 3: Install Dependencies¶
Install the required Python packages:
The key dependencies are:
| Package | Purpose |
|---|---|
clingo |
Answer Set Programming solver (required) |
click |
CLI framework |
lark |
Parser for HLL DSL (optional, for rule authoring) |
Installing Clingo¶
Clingo is the core ASP solver. Install it via pip:
On some systems, you may need to install additional system packages:
Ubuntu/Debian:
macOS (Homebrew):
Windows: The pip package should work directly on Windows 10/11.
Step 4: Verify Clingo Installation¶
Test that clingo is accessible from Python:
You should see output like:
Step 5: Verify the Engine¶
Test that the HSRS engine loads correctly:
from pathlib import Path
from mistaber.engine import HsrsEngine
# Initialize the engine with the ontology
engine = HsrsEngine(Path("mistaber/ontology"))
# Check that it loaded
print(f"Engine loaded: {engine.is_loaded}")
# Query for all worlds
worlds = engine.query("world(X)")
print(f"Available worlds: {[w['X'] for w in worlds]}")
Expected output:
Engine loaded: True
Available worlds: ['base', 'mechaber', 'rema', 'gra', 'ashk_mb', 'ashk_ah', 'sefardi_yo']
Step 6: Test a Simple Query¶
Run your first halachic query to verify everything works:
from pathlib import Path
from mistaber.engine import HsrsEngine
engine = HsrsEngine(Path("mistaber/ontology"))
# Ask a simple yes/no question
print("Is 'base' a world?", engine.ask("world(base)"))
print("Is 'mechaber' a world?", engine.ask("world(mechaber)"))
# Query with pattern matching
accessible = engine.query("accessible(X, base)")
print(f"Worlds inheriting from base: {[r['X'] for r in accessible]}")
Expected output:
Is 'base' a world? True
Is 'mechaber' a world? True
Worlds inheriting from base: ['mechaber', 'rema', 'gra']
Step 7: Run the Test Suite (Optional)¶
To ensure your installation is complete, run the test suite:
You should see all tests passing:
tests/engine/test_engine.py::test_engine_loads PASSED
tests/engine/test_worlds.py::test_all_worlds_exist PASSED
...
Troubleshooting¶
"ModuleNotFoundError: No module named 'clingo'"¶
Ensure clingo is installed in your active virtual environment:
"ImportError: libclingo.so not found"¶
On Linux, you may need to install the system gringo package first:
"FileNotFoundError: mistaber/ontology"¶
Make sure you're running commands from the repository root directory:
Slow Performance¶
For large queries, ensure you have sufficient memory (2GB+ recommended). The solver can be memory-intensive for complex scenarios.
What You've Learned¶
- How to clone and set up the Mistaber repository
- How to install clingo and other dependencies
- How to verify the installation with basic queries
- How to run the test suite
Next Steps¶
Continue to Tutorial 2: Your First Query to learn how to use Mistaber for halachic reasoning.