A simple Python library for encoding Quantum Rule Based Systems
Project description
Description
A Python library for encoding Quantum Rule Based Systems (QRBS). Calculate the probabilities associated with forward chaining rule bases using quantum gates and circuits. qrbsgen
supports rule bases involving AND
, OR
, and NOT
operators.
Made possible with an integration to Qiskit
SDK.
Prerequisites
Familiarity with Qiskit
is useful - check it out here .
The specification and definition of the QRBS implemented here can be found in the following publication by V. Bonillo et al. and the wider NExt ApplicationS of Quantum Computing, or NEASQC project.
Installation
pip install qrbsgen
Usage
See the usage steps below to get started:
import qrbsgen as q
# Instantiate your QuantumRuleBasedSystem
rule_system = q.QuantumRuleBasedSystem()
# Define and add rules using appropriate syntax (see below)
rule = "IF ((A) AND ((B) OR (C))) THEN (R)"
rule_terms, qubits = rule_system.add_rules([rule])
# Perform quantum circuit
rule_system.evaluate_rules(rule_terms, qubits)
Given the two-level system representing true or false outcomes, the probability of the above test will be a probabilistic result like so:
* Added rule IF ((A) AND ((B) OR (C))) THEN (R)
* Probability of outcome: 0.378
Syntax
Currently, QRBS is limited to supporting inputs of two-level systems, as can be easily mapped to a two-level quantum system, or qubit.
This means clauses, or variables, must be defined as true
or false
, one
or zero
. You can also define variables as A
and NOT A
for simplicity.
Please define rules and clauses as follows:
- Start with an
"IF"
statement in capital letters. - Follow with the rule antecedent and antecedent clauses, where
"IS"
is typed in capital letters where relevant e.g.:A IS one
,A IS true
,(A is true)
,A
or(A)
. - Follow with a
"THEN"
statement in capital letters. - Finish with the rule consequet, where
"IS"
is typed in capital letters where relevant e.g.:B IS one
,B IS true
,(B is true)
,B
or(B)
.
"IF ((A IS true) AND ((B IS true) OR (C IS true))) THEN (R IS true)"
Examples
Examples can be found here.
Information
Created by Kate Marshall of IBM.
Although this is copyright of IBM, this is not an official or unofficial IBM product.
Please get in touch for any further information: kate.marshall@ibm.com.
Inspiration for this repo and rule parsing techniques came from the Simpful fuzzy reasoning API.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file qrbsgen-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: qrbsgen-0.0.2-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16ba005079cdd73b1ff8d2bad087d759f9ad949eba913f58154bfea3695bb67f |
|
MD5 | 26f2e3653d2a7b90d6d1643f536c5cfb |
|
BLAKE2b-256 | b0e9fa7ba7dbdae2b63500d2f92fb86e65de52bccd4213bdfd1e5829f26f9b1c |