Skip to main content

A quantum-classical hybrid reasoning engine for uncertainty-aware AI inference

Project description

Probabilistic Quantum Reasoner

PyPI Documentation Status License: MIT Python 3.10+

A quantum-classical hybrid reasoning engine for uncertainty-aware AI inference, fusing quantum probabilistic graphical models (QPGMs) with classical probabilistic logic.

🎯 Overview

The Probabilistic Quantum Reasoner implements a novel approach to AI reasoning by encoding knowledge using quantum amplitude distributions over Hilbert space, modeling uncertainty through entanglement and non-commutative conditional graphs, and enabling hybrid Quantum Bayesian Networks with causal, counterfactual, and abductive reasoning capabilities.

🧩 Key Features

  • Quantum Bayesian Networks: Hybrid classical-quantum probabilistic graphical models
  • Quantum Belief Propagation: Unitary message passing with amplitude-weighted inference
  • Causal Quantum Reasoning: Do-calculus analog for quantum intervention logic
  • Multiple Backends: Support for Qiskit, PennyLane, and classical simulation
  • Uncertainty Modeling: Entanglement-based uncertainty representation
  • Counterfactual Reasoning: Quantum counterfactuals using unitary interventions

🚀 Quick Start

Installation

pip install probabilistic-quantum-reasoner

For development with extra features:

pip install probabilistic-quantum-reasoner[dev,docs,extras]

Basic Usage

from probabilistic_quantum_reasoner import QuantumBayesianNetwork
from probabilistic_quantum_reasoner.backends import QiskitBackend

# Create a quantum Bayesian network
qbn = QuantumBayesianNetwork(backend=QiskitBackend())

# Add quantum and classical nodes
weather = qbn.add_quantum_node("weather", ["sunny", "rainy"])
mood = qbn.add_stochastic_node("mood", ["happy", "sad"])

# Create entangled relationship
qbn.add_edge(weather, mood)
qbn.entangle([weather, mood])

# Perform quantum inference
result = qbn.infer(evidence={"weather": "sunny"})
print(f"Mood probabilities: {result}")

# Quantum intervention (do-calculus)
intervention_result = qbn.intervene("weather", "rainy")
print(f"Mood under intervention: {intervention_result}")

🧬 Mathematical Foundation

The library implements quantum probabilistic reasoning using:

  • Tensor Product Spaces: Joint state representation as |ψ⟩ = Σᵢⱼ αᵢⱼ|iⱼ⟩
  • Amplitude Manipulation: Via Kraus operators and parameterized unitaries
  • Density Matrix Operations: Mixed state inference through partial tracing
  • Non-commutative Conditional Probability: P_Q(A|B) ≠ P_Q(B|A) in general

📖 Documentation

🧪 Examples

Quantum XOR Reasoning

# Create entangled XOR gate reasoning
qbn = QuantumBayesianNetwork()
a = qbn.add_quantum_node("A", [0, 1])
b = qbn.add_quantum_node("B", [0, 1])
xor = qbn.add_quantum_node("XOR", [0, 1])

qbn.add_quantum_xor_relationship(a, b, xor)
result = qbn.infer(evidence={"A": 1, "B": 0})

Weather-Mood Causal Graph

# Hybrid classical-quantum causal modeling
from probabilistic_quantum_reasoner.examples import WeatherMoodExample

example = WeatherMoodExample()
causal_effect = example.estimate_causal_effect("weather", "mood")
counterfactual = example.counterfactual_query("What if it was sunny?")

🛠️ Architecture

probabilistic_quantum_reasoner/
├── core/                    # Core network structures
│   ├── network.py          # QuantumBayesianNetwork
│   ├── nodes.py            # Quantum/Stochastic/Hybrid nodes
│   └── operators.py        # Quantum operators and gates
├── inference/              # Reasoning engines
│   ├── engine.py           # Main inference engine
│   ├── causal.py           # Causal reasoning
│   ├── belief_propagation.py
│   └── variational.py      # Variational quantum inference
├── backends/               # Backend implementations
│   ├── qiskit_backend.py
│   ├── pennylane_backend.py
│   └── simulator.py
└── examples/               # Example implementations

🔬 Research Applications

  • AGI Inference Scaffolds: Uncertainty-aware reasoning for autonomous systems
  • Quantum Explainable AI (Q-XAI): Interpretable quantum decision making
  • Counterfactual Analysis: "What-if" scenarios in quantum superposition
  • Epistemic Uncertainty Modeling: Non-classical uncertainty representation

🤝 Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

📚 Citation

If you use this library in your research, please cite:

@software{bajpai2025quantum,
  title={Probabilistic Quantum Reasoner: A Hybrid Quantum-Classical Reasoning Engine},
  author={Bajpai, Krishna},
  year={2025},
  url={https://github.com/krish567366/probabilistic-quantum-reasoner}
}

👨‍💻 Author

Krishna Bajpai

🙏 Acknowledgments

  • Quantum computing community for foundational algorithms
  • Classical probabilistic reasoning research
  • Open source quantum computing frameworks (Qiskit, PennyLane)

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

probabilistic_quantum_reasoner-0.1.0.tar.gz (59.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

probabilistic_quantum_reasoner-0.1.0-py3-none-any.whl (63.2 kB view details)

Uploaded Python 3

File details

Details for the file probabilistic_quantum_reasoner-0.1.0.tar.gz.

File metadata

File hashes

Hashes for probabilistic_quantum_reasoner-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a1868cc10b75ec91bfcb4c6890011891e71ce08aa762d0ed2f07075a958f76e9
MD5 53acd231de480d9237eba5ff5a592474
BLAKE2b-256 1a20b1af1f4a57b5d5f13fea3f6400afcdcacb50c923175eae476c9bb0d84bf7

See more details on using hashes here.

File details

Details for the file probabilistic_quantum_reasoner-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for probabilistic_quantum_reasoner-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c4211a84e07fec6837e30b15b0a1f4a83e1394058610cc41b991222fe481707
MD5 385a68bf198d9cb6f57a239b3686b34a
BLAKE2b-256 fc2eefc1e0b3263ed804a00bace44e9e1c533fed2c864677ae59041a983129eb

See more details on using hashes here.

Supported by

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