Code → | Documentation → | Theory Library →
The ModelChecker provides a programmatic framework for developing and exploring modular semantic theories. Built on the SMT solver Z3, it enables researchers to establish logical consequence over finite models, automatically generating readable countermodels when formulas or inferences are invalid.
This talk at the Topos Institute provides an overview of the project.
pip install model-checkerRequires Python 3.10 or later.
pip install model-checker[jupyter]For Jupyter notebook features and interactive exploration, see the Jupyter Integration Guide.
Z3 is the default solver. The optional cvc5 backend is a separate package:
pip install cvc5Select a backend at run time with --z3 (default) or --cvc5.
git clone https://github.com/benbrastmckie/ModelChecker
cd ModelChecker/code
# Use the development CLI to run locally without installation:
./dev_cli.py src/model_checker/theory_lib/logos/examples.pyFor comprehensive development setup instructions, including virtual environments and platform-specific guidance, see the Developer Setup Guide. NixOS users can use the provided flake.nix configuration (nix develop at the repository root) for automatic environment setup.
For comprehensive installation instructions including platform-specific guides, virtual environments, and troubleshooting, see the Installation Documentation.
Quick Links:
- Basic Installation - Further details
- NixOS Installation - NixOS-specific setup
- Developer Setup - Development environment
- Troubleshooting - Common issues
# Create a copy of the logos semantics (default)
model-checker
# Or load a specific theory
model-checker -l logos # Hyperintensional semantics with all subtheories
model-checker -l exclusion # Unilateral exclusion semantics
model-checker -l imposition # Fine's counterfactual semantics
model-checker -l bimodal # Bimodal logic for tense and circumstantial modalitiesThis creates a project directory with examples.py, a semantic/ package, operators.py,
iterate.py, subtheories/, tests, and docs. To load only some of the logos subtheories, pass
them to get_theory in your examples.py:
from model_checker.theory_lib import logos
theory = logos.get_theory(subtheories=['extensional', 'counterfactual'])# Run the examples file created in your project
model-checker examples.py
# Compare multiple theories
model-checker examples.py --maximize
# Save results in various formats
model-checker examples.py --save # Both formats (markdown and json)
model-checker examples.py --save json # JSON only- New to ModelChecker? Follow the Getting Started Guide
- Ready to develop? See The ModelChecker Methodology below
- Need examples? Check the Examples Guide and example structure
The ModelChecker provides a systematic methodology for developing and studying semantic theories. This section provides an overview of the workflow. For the complete methodology guide, see docs/usage/WORKFLOW.md.
Start by creating a new project or loading an existing theory:
# Create a copy of the logos semantics
model-checker # Creates a logos semantics by default with all subtheories
# Load an existing theory as starting point
model-checker -l logos # Hyperintensional truthmaker semantics
model-checker -l exclusion # Unilateral exclusion semantics
model-checker -l imposition # Fine's counterfactual semantics
model-checker -l bimodal # Bimodal logic for tense and circumstantial modalitiesThis creates a complete project directory with examples.py, a semantic/ package, operators.py, iterate.py, and supporting files. See Project Creation Guide for detailed instructions.
Edit the examples.py file to test logical inferences relevant to your theory:
# Run your examples
model-checker examples.pyDefine a range of examples in order to evaluate their behavior in your theory. See the Examples Guide and Settings Guide for details.
Modify the semantic/ package to implement your specific semantic theory. Add new constraints, modify existing ones, or create entirely new semantic frameworks to capture the logical principles that distinguish your theory. See the Semantics Guide.
Extend your theory's expressive power with new operators:
- Defined operators in
operators.py- shortcuts for combinations of existing operators - Primitive operators requiring semantic interpretation in the
semantic/package
See the Operators Guide for implementation patterns.
Explore the space of models your theory allows and systematically compare with alternative approaches:
# Test single theory
model-checker examples.py
# Compare multiple theories
model-checker examples.py --maximize
# Run the same examples against the cvc5 backend instead of Z3
model-checker examples.py --cvc5See the Tools Guide for model iteration and theory comparison.
Export your findings in formats suitable for analysis or publication:
model-checker examples.py --save # Both formats (markdown and json)
model-checker examples.py --save json # Machine-readable JSON
model-checker examples.py --save markdown # Human-readable markdownSee the Output Guide for format options.
This systematic approach enables you to:
- Start with working theories as foundations
- Test logical inferences computationally
- Customize semantic behavior through constraints
- Extend expressive power with new operators
- Explore the space of possible models
- Compare different theoretical approaches
- Document and share your findings
For the complete step-by-step methodology with detailed examples and advanced techniques, see the full Methodology Guide.
ModelChecker/
├── code/ # Main implementation directory
│ ├── src/ # Source code (the `model_checker` package)
│ ├── docs/ # Technical documentation
│ ├── scripts/ # Development and maintenance scripts
│ └── tests/ # Test suites
├── docs/ # General project documentation
│ ├── installation/ # Installation guides
│ ├── usage/ # Practical usage guides
│ │ ├── PROJECT.md # Project creation
│ │ ├── EXAMPLES.md # Writing examples
│ │ ├── SETTINGS.md # Configuration settings
│ │ ├── SEMANTICS.md # Semantic constraints
│ │ ├── OPERATORS.md # Defining operators
│ │ ├── TOOLS.md # Advanced tools
│ │ ├── OUTPUT.md # Saving results
│ │ └── WORKFLOW.md # Complete methodology
│ ├── architecture/ # System architecture
│ └── theory/ # Theoretical background
├── oracle/ # Standalone differential-oracle tree (not shipped in the wheel)
├── latex/ # Paper sources
├── talks/ # Slides and talk materials
├── images/ # Screenshots and diagrams
├── flake.nix # Nix development environment
└── README.md # This file
code/ - Main implementation directory containing the ModelChecker package source code, development tools, and technical documentation. Includes the core framework, theory library implementations, builder system, iteration engine, and comprehensive test suites. This is where developers work on extending the framework and contributing new theories. See code/README.md for package documentation.
docs/ - Project-level documentation for understanding the ModelChecker's theoretical foundations, development architecture, and advanced usage. Contains guides for installation, development workflows, research architecture, and detailed explanations of the Z3-based implementation approach. Essential reading for researchers and contributors. See docs/README.md for documentation navigation.
oracle/ - Standalone differential-oracle tree used to cross-check the semantics against independently written reference implementations. It is excluded from the published wheel and is not needed to use the package.
images/ - Visual documentation including architecture diagrams, countermodel visualizations, and screenshots demonstrating the framework in action. Helps illustrate complex semantic concepts and usage patterns that are difficult to convey through text alone.
- Installation Guide - Setup instructions for all platforms
- Getting Started Guide - Create your first project
- User Guide - Basic usage patterns
- Interactive Notebooks - Hands-on tutorials
- Architecture - Programmatic semantics approach
- Theory Library - Available semantic theories
- Hyperintensional Logic - Theoretical background
- Development Guide - Comprehensive development workflow
- Architecture Documentation - System design patterns
- Contributing Guidelines - Coding and documentation standards
- Hyperintensional Bilateral Semantics (Logos): 18 operators across 4 subtheories
- Unilateral Exclusion Semantics (4 operators): Solving the False Premise Problem
- Fine's Counterfactual Semantics (13 operators): Imposition semantics for counterfactuals
- Bimodal Logic (17 operators): Intensional semantics for reasoning with both tense and modal operators
- Z3 SMT Integration: Automated model finding and constraint solving
- Dual Solver Backends: Z3 by default, with optional cvc5
- Countermodel Visualization: Understand why formulas fail
- Model Iteration: Find multiple non-isomorphic models satisfying constraints
- Semantic Comparison: Run multiple semantic theories on the same examples
- Theory Templates: Quickly create new semantic theories
- Modular Architecture: Compose operators with automatic dependencies
- Comprehensive Testing: Unit tests, integration tests, and example validation
- Rich Documentation: From API references to theoretical guides
- 18 operators across 4 modular subtheories (extensional, modal, constitutive, counterfactual)
- Sensitive to differences in subject-matter via verifier/falsifier sets
- Distinguishes necessarily equivalent propositions
- Supports modal, counterfactual, constitutive, and relevance reasoning
- Implements Bernard & Champollion's exclusion operator in a unilateral semantic
- Uses witness predicates for proper negation handling
- Evaluates counterfactuals via imposition
- Uses primitive imposition relation on states
- Facilitates reasoning about time and possibility
- World histories as functions from times to world states
- Includes past, future, and modal operators
We welcome contributions! Please:
- Follow the Development Guide for workflow
- Use the standard
examples.pystructure for examples - Ensure all tests pass before submitting PRs — run
./run_tests.pyfromcode/, orPYTHONPATH=src pytest tests/ -vfor pytest directly - Include documentation for new features
- Read code/docs/core/CODE_STANDARDS.md for standards
Brast-McKie, B. (2025). Model-Checker: A Programmatic Semantics Framework. https://github.com/benbrastmckie/ModelChecker
- Brast-McKie, B. (draft). "The Construction of Possible Worlds".
- Brast-McKie, B. (2025). "Counterfactual Worlds". Journal of Philosophical Logic.
- Brast-McKie, B. (2021). "Identity and Aboutness". Journal of Philosophical Logic, 50, 1471-1503.
- Fine, K. (2012). "Counterfactuals without Possible Worlds". Journal of Philosophy, 109(3), 221-246.
- Fine, K. (2017). "Truthmaker Semantics". In A Companion to the Philosophy of Language (2nd ed.). Wiley-Blackwell.
- Fine, K. (2017). "A Theory of Truthmaker Content I: Conjunction, Disjunction and Negation". Journal of Philosophical Logic, 46, 625-674.
- Fine, K. (2017). "A Theory of Truthmaker Content II: Subject-matter, Common Content, Remainder and Ground". Journal of Philosophical Logic, 46, 675-702.
This project is licensed under GPL-3.0. See code/LICENSE for details.
If you find ModelChecker useful, please consider starring the repository to help others discover it. To receive notifications about new releases:
- Click "Watch" on the GitHub repository
- Select "Custom" → "Releases" to be notified only about new versions
We encourage users to report bugs and suggest features by creating issues. When creating an issue, please:
-
Check existing issues to avoid duplicates
-
Provide minimal reproducible examples for bugs
-
See troubleshooting guide for common problems
-
Issues: GitHub Issues
-
Contact: See repository for contact information