# 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](https://qiskit.org/) .
The specification and definition of the QRBS implemented here can be found in the following [publication](https://www.neasqc.eu/wp-content/uploads/2021/05/NEASQC_D6.2_QRBS-Models-Architecture-and-Formal-Specification-V1.5-Final.pdf) by V. Bonillo et al. and the wider NExt ApplicationS of Quantum Computing, or [NEASQC](https://www.neasqc.eu/about-the-project/) 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](https://github.com/kvcmarshall/qrbsgen/tree/main/examples).
## 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](https://github.com/aresio/simpful) fuzzy reasoning API.
Raw data
{
"_id": null,
"home_page": "https://github.com/kvcmarshall/qrbsgen",
"name": "qrbsgen",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "quantum computing,quantum rule based systems,rule based systems,expert systems,qiskit,python",
"author": "Kate Marshall",
"author_email": "kate.marshall@ibm.com",
"download_url": "",
"platform": null,
"description": "# Description\nA 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. \n\nMade possible with an integration to `Qiskit` SDK. \n\n## Prerequisites\n\nFamiliarity with `Qiskit` is useful - check it out [here](https://qiskit.org/) .\n\nThe specification and definition of the QRBS implemented here can be found in the following [publication](https://www.neasqc.eu/wp-content/uploads/2021/05/NEASQC_D6.2_QRBS-Models-Architecture-and-Formal-Specification-V1.5-Final.pdf) by V. Bonillo et al. and the wider NExt ApplicationS of Quantum Computing, or [NEASQC](https://www.neasqc.eu/about-the-project/) project. \n\n## Installation\n\n`pip install qrbsgen` \n\n## Usage \n\nSee the usage steps below to get started:\n\n```\nimport qrbsgen as q\n\n# Instantiate your QuantumRuleBasedSystem\nrule_system = q.QuantumRuleBasedSystem()\n\n# Define and add rules using appropriate syntax (see below)\nrule = \"IF ((A) AND ((B) OR (C))) THEN (R)\"\nrule_terms, qubits = rule_system.add_rules([rule])\n\n# Perform quantum circuit\nrule_system.evaluate_rules(rule_terms, qubits)\n```\nGiven the two-level system representing true or false outcomes, the probability of the above test will be a probabilistic result like so:\n\n```\n* Added rule IF ((A) AND ((B) OR (C))) THEN (R)\n* Probability of outcome: 0.378 \n```\n\n## Syntax \n\nCurrently, QRBS is limited to supporting inputs of two-level systems, as can be easily mapped to a two-level quantum system, or qubit.\n\nThis 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.\n\nPlease define rules and clauses as follows:\n\n- Start with an `\"IF\"` statement in capital letters.\n- 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)`.\n- Follow with a `\"THEN\"` statement in capital letters.\n- 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)`. \n\n```\n\"IF ((A IS true) AND ((B IS true) OR (C IS true))) THEN (R IS true)\"\n```\n\n## Examples\n\nExamples can be found [here](https://github.com/kvcmarshall/qrbsgen/tree/main/examples).\n\n## Information\nCreated by Kate Marshall of IBM. \nAlthough this is copyright of IBM, this is not an official or unofficial IBM product.\nPlease get in touch for any further information: kate.marshall@ibm.com.\n\nInspiration for this repo and rule parsing techniques came from the [Simpful](https://github.com/aresio/simpful) fuzzy reasoning API.\n\n\n",
"bugtrack_url": null,
"license": "LICENSE.txt",
"summary": "A simple Python library for encoding Quantum Rule Based Systems",
"version": "0.0.2",
"split_keywords": [
"quantum computing",
"quantum rule based systems",
"rule based systems",
"expert systems",
"qiskit",
"python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b0e9fa7ba7dbdae2b63500d2f92fb86e65de52bccd4213bdfd1e5829f26f9b1c",
"md5": "26f2e3653d2a7b90d6d1643f536c5cfb",
"sha256": "16ba005079cdd73b1ff8d2bad087d759f9ad949eba913f58154bfea3695bb67f"
},
"downloads": -1,
"filename": "qrbsgen-0.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "26f2e3653d2a7b90d6d1643f536c5cfb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 17352,
"upload_time": "2023-03-13T22:17:29",
"upload_time_iso_8601": "2023-03-13T22:17:29.515560Z",
"url": "https://files.pythonhosted.org/packages/b0/e9/fa7ba7dbdae2b63500d2f92fb86e65de52bccd4213bdfd1e5829f26f9b1c/qrbsgen-0.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-13 22:17:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "kvcmarshall",
"github_project": "qrbsgen",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "qrbsgen"
}