Z3 Theorem Prover with Functional Programming

by javergar

5 314 downloads Not rated yet
GitHub

About

A Python MCP server that wraps the Z3 Theorem Prover using functional programming principles—immutable data structures, monadic error handling, and pure functions—to solve constraint satisfaction problems and analyze entity relationships.

Explore

- Constraint Satisfaction Problems: Solve complex problems with variables and constraints
- Relationship Analysis: Analyze and infer relationships between entities
- Functional Programming: Uses pure functions, immutable data structures, and monadic error handling
- MCP Server: Exposes Z3 capabilities through a standardized interface

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Z3 Theorem Prover with Functional Programming
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

This project uses uv for dependency management.


uv pip install -e .

uv pip install -e ".[dev]"

The project includes several examples that demonstrate the capabilities of the Z3 solver:


Start the MCP server to expose Z3 capabilities through the Model Context Protocol:

bash

The server provides the following tools:

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "z3 theorem prover with functional programming": {
            "z3_mcp": {
                "command": "uv",
                "args": [
                    "pip",
                    "install",
                    "-e",
                    "."
                ]
            }
        }
    }
}

McpServers

{
    "z3_mcp": {
        "command": "uv",
        "args": [
            "pip",
            "install",
            "-e",
            "."
        ]
    }
}

A Python implementation of abstactions over the Z3 Theorem Prover capabilities using functional programming principles, exposed through a Model Context Protocol (MCP) server.

Overview

This project demonstrates how to use the Z3 Theorem Prover with a functional programming approach to solve complex constraint satisfaction problems and analyze relationships between entities. It leverages the returns library for functional programming abstractions and exposes its capabilities through an MCP server.

Features

- Constraint Satisfaction Problems: Solve complex problems with variables and constraints
- Relationship Analysis: Analyze and infer relationships between entities
- Functional Programming: Uses pure functions, immutable data structures, and monadic error handling
- MCP Server: Exposes Z3 capabilities through a standardized interface

Project Structure

z3_mcp/
├── core/                  # Core implementation
│   ├── solver.py          # Constraint satisfaction problem solving
│   └── relationships.py   # Relationship analysis
├── models/                # Data models
│   ├── constraints.py     # Models for constraint problems
│   └── relationships.py   # Models for relationship analysis
├── server/                # MCP server
│   └── main.py            # Server implementation
└── examples/              # Example usage
    └── main.py            # Demonstration of capabilities

Technical Stack

- Z3 Solver: Microsoft's theorem prover for constraint solving
- Returns: Functional programming library for monadic operations and error handling
- Pydantic: Data validation and serialization
- FastMCP: Implementation of the Model Context Protocol

Installation

This project uses uv for dependency management.

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.