{"id":21179029,"url":"https://github.com/spaceavocado/pyillogical","last_synced_at":"2026-02-18T19:32:09.865Z","repository":{"id":134971510,"uuid":"612021002","full_name":"spaceavocado/pyillogical","owner":"spaceavocado","description":"A micro conditional go engine used to parse the raw logical and comparison expressions, evaluate the expression in the given data context, and provide access to a text form of the given expressions.","archived":false,"fork":false,"pushed_at":"2025-02-24T05:37:39.000Z","size":156,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-24T22:01:52.598Z","etag":null,"topics":["expression","expression-evaluator","logical"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spaceavocado.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"contributing.md","funding":null,"license":"LICENSE.md","code_of_conduct":"code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-10T02:53:50.000Z","updated_at":"2025-02-24T05:37:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"e962d7fd-d4c4-4e0c-8169-f8ed3cbda3fe","html_url":"https://github.com/spaceavocado/pyillogical","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/spaceavocado/pyillogical","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaceavocado%2Fpyillogical","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaceavocado%2Fpyillogical/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaceavocado%2Fpyillogical/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaceavocado%2Fpyillogical/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spaceavocado","download_url":"https://codeload.github.com/spaceavocado/pyillogical/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaceavocado%2Fpyillogical/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29591929,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T18:54:29.675Z","status":"ssl_error","status_checked_at":"2026-02-18T18:50:50.517Z","response_time":162,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["expression","expression-evaluator","logical"],"created_at":"2024-11-20T17:28:01.844Z","updated_at":"2026-02-18T19:32:09.822Z","avatar_url":"https://github.com/spaceavocado.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# (py)illogical\n\nA micro conditional engine used to parse the logical and comparison expressions, evaluate an expression in data context, and provide access to a text form of the given expression.\n\n[![codecov](https://codecov.io/gh/spaceavocado/pyillogical/branch/master/graph/badge.svg?token=NC8CX62BMC)](https://codecov.io/gh/spaceavocado/pyillogical)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)​\n\n\u003e Revision: August 26, 2024.\n\nOther implementations:\n- [TS/JS](https://github.com/spaceavocado/illogical)\n- [GO](https://github.com/spaceavocado/goillogical)\n- [C#](https://github.com/spaceavocado/cillogical)\n- [Java](https://github.com/spaceavocado/jillogical)\n- [Odin](https://github.com/spaceavocado/oillogical)\n\n## About\n\nThis project has been developed to provide Python implementation of [spaceavocado/illogical](https://github.com/spaceavocado/illogical).\n\n\n## Getting Started\n\nYou can install the **(py)illogical** from [PyPI](https://pypi.org/project/illogical/):\n\n```sh\npython -m pip install illogical\n```\n\nThe reader is supported on Python 3.7 and above.\n\n**Table of Content**\n\n---\n\n- [(py)illogical](#pyillogical)\n  - [About](#about)\n  - [Getting Started](#getting-started)\n  - [Basic Usage](#basic-usage)\n    - [Evaluate](#evaluate)\n    - [Statement](#statement)\n    - [Parse](#parse)\n    - [Evaluable](#evaluable)\n      - [Simplify](#simplify)\n      - [Serialize](#serialize)\n  - [Working with Expressions](#working-with-expressions)\n    - [Evaluation Data Context](#evaluation-data-context)\n      - [Accessing Array Element:](#accessing-array-element)\n      - [Accessing Array Element via Reference:](#accessing-array-element-via-reference)\n      - [Nested Referencing](#nested-referencing)\n      - [Composite Reference Key](#composite-reference-key)\n      - [Data Type Casting](#data-type-casting)\n    - [Operand Types](#operand-types)\n      - [Value](#value)\n      - [Reference](#reference)\n      - [Collection](#collection)\n    - [Comparison Expressions](#comparison-expressions)\n      - [Equal](#equal)\n      - [Not Equal](#not-equal)\n      - [Greater Than](#greater-than)\n      - [Greater Than or Equal](#greater-than-or-equal)\n      - [Less Than](#less-than)\n      - [Less Than or Equal](#less-than-or-equal)\n      - [In](#in)\n      - [Not In](#not-in)\n      - [Prefix](#prefix)\n      - [Suffix](#suffix)\n      - [Overlap](#overlap)\n      - [None](#none)\n      - [Present](#present)\n    - [Logical Expressions](#logical-expressions)\n      - [And](#and)\n      - [Or](#or)\n      - [Nor](#nor)\n      - [Xor](#xor)\n      - [Not](#not)\n  - [Engine Options](#engine-options)\n    - [Reference Serialize Options](#reference-serialize-options)\n      - [From](#from)\n      - [To](#to)\n    - [Collection Serialize Options](#collection-serialize-options)\n      - [Escape Character](#escape-character)\n    - [Simplify Options](#simplify-options)\n      - [Ignored Paths](#ignored-paths)\n      - [Ignored Paths RegEx](#ignored-paths-regex)\n    - [Operator Mapping](#operator-mapping)\n  - [Contributing](#contributing)\n  - [License](#license)\n\n---\n\n\n## Basic Usage\n\n```py\nfrom illogical.illogical import Illogical\n\n# Create a new instance of the engine\nillogical = Illogical()\n\n# Evaluate an expression\nillogical.evaluate([\"==\", 1, 1], {})\n```\n\n\u003e For advanced usage, please [Engine Options](#engine-options).\n\n### Evaluate\n\nEvaluate comparison or logical expression:\n\n`illogical.evaluate(`[Comparison Expression](#comparison-expressions) or [Logical Expression](#logical-expressions), [Evaluation Data Context](#evaluation-data-context)`)` =\u003e `bool`\n\n**Example**\n\n```py\ncontext = {\n  \"name\": \"peter\",\n}\n\n# Comparison expression\nillogical.evaluate([\"==\", 5, 5], context)\nillogical.evaluate([\"==\", \"circle\", \"circle\"], context)\nillogical.evaluate([\"==\", True, True], context)\nillogical.evaluate([\"==\", \"$name\", \"peter\"], context)\nillogical.evaluate([\"NIL\", \"$RefA\"], context)\n\n# Logical expression\nillogical.evaluate([\"AND\", [\"==\", 5, 5], [\"==\", 10, 10]], context)\nillogical.evaluate([\"AND\", [\"==\", \"circle\", \"circle\"], [\"==\", 10, 10]], context)\nillogical.evaluate([\"OR\", [\"==\", \"$name\", \"peter\"], [\"==\", 5, 10]], context)\n```\n\n### Statement\n\nGet expression string representation:\n\n`illogical.statement(`[Comparison Expression](#comparison-expressions) or [Logical Expression](#logical-expressions)`)` =\u003e `str`\n\n**Example**\n\n```py\n# Comparison expression\n\nillogical.statement([\"==\", 5, 5])\n# (5 == 5)\n\nillogical.statement([\"==\", \"circle\", \"circle\"])\n# (\"circle\" == \"circle\")\n\nillogical.statement([\"==\", True, True])\n# (True == True)\n\nillogical.statement([\"==\", \"$name\", \"peter\"])\n# ({name} == \"peter\")\n\nillogical.statement([\"NIL\", \"$RefA\"])\n# ({RefA} \u003cis nil\u003e)\n\n# Logical expression\n\nillogical.statement([\"AND\", [\"==\", 5, 5], [\"==\", 10, 10]])\n# ((5 == 5) AND (10 == 10))\n\nillogical.statement([\"AND\", [\"==\", \"circle\", \"circle\"], [\"==\", 10, 10]])\n# ((\"circle\" == \"circle\") AND (10 == 10))\n\nillogical.statement([\"OR\", [\"==\", \"$name\", \"peter\"], [\"==\", 5, 10]])\n# (({name} == \"peter\") OR (5 == 10))\n```\n\n### Parse\n\nParse the expression into a **Evaluable** object, i.e. it returns the parsed self-evaluable condition expression.\n\n`illogical.parse(`[Comparison Expression](#comparison-expressions) or [Logical Expression](#logical-expressions)`)` =\u003e `Evaluable`\n\n### Evaluable\n\n- `evaluable.evaluate(context)` please see [Evaluation Data Context](#evaluation-data-context).\n- `evaluable.simplify(context)` please see [Simplify](#simplify).\n- `evaluable.serialize()` please see [Serialize](#serialize).\n- `str(evaluable) | evaluable.__str__()` please see [Statement](#statement).\n\n**Example**\n\n```py\nevaluable = illogical.parse([\"==\", \"$name\", \"peter\"])\n\nevaluable.evaluate({\"name\": \"peter\"})\n# True\n\nprint(evaluable)\n# ({name} == \"peter\")\n```\n\n#### Simplify\n\nSimplifies an expression with a given context. This is useful when you already have some of\nthe properties of context and wants to try to evaluate the expression.\n\n**Example**\n\n```py\nevaluable = illogical.parse([\"AND\", [\"==\", \"$a\", 10], [\"==\", \"$b\", 20]])\n\nevaluable.simplify({\"a\": 10})\n# ({b} == 20)\n\nevaluable.simplify({\"a\": 20})\n# False\n```\n\nValues not found in the context will cause the parent operand not to be evaluated and returned\nas part of the simplified expression.\n\nIn some situations we might want to evaluate the expression even if referred value is not\npresent. You can provide a list of keys that will be strictly evaluated even if they are not\npresent in the context.\n\n**Example**\n\n```py\nfrom illogical.illogical import Illogical\nfrom illogical.parser.parse import Options\n\nignored_paths = [\"ignored\"],\nignored_path_rx = [r\"^ignored\"],\n\nillogical = Illogical(Options(ignored_paths=ignored_paths, ignored_path_rx=ignored_path_rx))\n\nevaluable = illogical.parse([\"AND\", [\"==\", \"$a\", 10], [\"==\", \"$ignored\", 20]])\n\nevaluable.simplify({\"a\": 10})\n# False\n# $ignored\" will be evaluated to None.\n```\n\nAlternatively we might want to do the opposite and strictly evaluate the expression for all referred\nvalues not present in the context except for a specified list of optional keys.\n\n**Example**\n\n```py\nfrom illogical.illogical import Illogical\nfrom illogical.parser.parse import Options\n\nignored_paths = [\"b\"]\n\nillogical = Illogical(Options(ignored_paths=ignored_paths))\n\nevaluable = illogical.parse([\"OR\", [\"==\", \"$a\", 10], [\"==\", \"$b\", 20}, [\"==\", \"$c\", 20]])\n\nevaluable.simplify({\"c\": 10})\n# ({a} == 10)\n# except for \"$b\" everything not in context will be evaluated to None.\n```\n\n#### Serialize\n\nSerializes an expression into the raw expression form, reverse the parse operation.\n\n**Example**\n\n```py\nevaluable = illogical.parse([\"AND\", [\"==\", \"$a\", 10], [\"==\", 10, 20]])\n\nevaluable.serialize()\n# [\"AND\", [\"==\", \"$a\", 10], [\"==\", 10, 20]]\n```\n\n## Working with Expressions\n\n### Evaluation Data Context\n\nThe evaluation data context is used to provide the expression with variable references, i.e. this allows for the dynamic expressions. The data context is object with properties used as the references keys, and its values as reference values.\n\n\u003e Valid reference values: dist, str, int, float, list; set; tuple of (bool, string, int, float).\n\nTo reference the nested reference, please use \".\" delimiter, e.g.:\n`$address.city`\n\n#### Accessing Array Element:\n\n`$options[1]`\n\n#### Accessing Array Element via Reference:\n\n`$options[{index}]`\n\n- The **index** reference is resolved within the data context as an array index.\n\n#### Nested Referencing\n\n`$address.{segment}`\n\n- The **segment** reference is resolved within the data context as a property key.\n\n#### Composite Reference Key\n\n`$shape{shapeType}`\n\n- The **shapeType** reference is resolved within the data context, and inserted into the outer reference key.\n- E.g. **shapeType** is resolved as \"**B**\" and would compose the **$shapeB** outer reference.\n- This resolution could be n-nested.\n\n#### Data Type Casting\n\n`$payment.amount.(Type)`\n\nCast the given data context into the desired data type before being used as an operand in the evaluation.\n\n\u003e Note: If the conversion is invalid, then a warning message is being logged.\n\nSupported data type conversions:\n\n- .(String): cast a given reference to String.\n- .(Number): cast a given reference to Number.\n- .(Integer): cast a given reference to Integer.\n- .(Float): cast a given reference to Float.\n- .(Boolean): cast a given reference to Boolean.\n\n**Example**\n\n```py\n# Data context\ncontext = {\n  \"name\":    \"peter\",\n  \"country\": \"canada\",\n  \"age\":     21,\n  \"options\": [1, 2, 3],\n  \"address\": {\n    city:    \"Toronto\",\n    country: \"Canada\",\n  },\n  \"index\":     2,\n  \"segment\":   \"city\",\n  \"shapeA\":    \"box\",\n  \"shapeB\":    \"circle\",\n  \"shapeType\": \"B\",\n}\n\n# Evaluate an expression in the given data context\n\nillogical.evaluate([\"\u003e\", \"$age\", 20], context)\n# True\n\nillogical.evaluate([\"==\", \"$address.city\", \"Toronto\"], context)\n# True\n\n# Accessing Array Element\nillogical.evaluate([\"==\", \"$options[1]\", 2], context)\n# True\n\n# Accessing Array Element via Reference\nillogical.evaluate([\"==\", \"$options[{index}]\", 3], context)\n# True\n\n# Nested Referencing\nillogical.evaluate([\"==\", \"$address.{segment}\", \"Toronto\"], context)\n# True\n\n# Composite Reference Key\nillogical.evaluate([\"==\", \"$shape{shapeType}\", \"circle\"], context)\n# True\n\n# Data Type Casting\nillogical.evaluate([\"==\", \"$age.(String)\", \"21\"], context)\n# True\n```\n\n### Operand Types\n\nThe [Comparison Expression](#comparison-expression) expect operands to be one of the below:\n\n#### Value\n\nSimple value types: string, int, float, bool, None.\n\n**Example**\n\n```py\nval1 = 5\nvar2 = \"cirle\"\nvar3 = True\n\nillogical.parse([\"AND\", [\"==\", val1, var2], [\"==\", var3, var3]])\n```\n\n#### Reference\n\nThe reference operand value is resolved from the [Evaluation Data Context](#evaluation-data-context), where the the operands name is used as key in the context.\n\nThe reference operand must be prefixed with `$` symbol, e.g.: `$name`. This might be customized via [Reference Predicate Parser Option](#reference-predicate).\n\n**Example**\n\n| Expression                    | Data Context      |\n| ----------------------------- | ----------------- |\n| `[\"==\", \"$age\", 21]`          | `{age: 21}`       |\n| `[\"==\", \"circle\", \"$shape\"] ` | `{shape: \"circle\"}` |\n| `[\"==\", \"$visible\", True]`    | `{visible: True}` |\n\n#### Collection\n\nThe operand could be an array mixed from [Value](#value) and [Reference](#reference).\n\n**Example**\n\n| Expression                               | Data Context                        |\n| ---------------------------------------- | ----------------------------------- |\n| `[\"IN\", [1, 2], 1]`                      | `{}`                                |\n| `[\"IN\", \"circle\", [\"$shapeA\", \"$shapeB\"] ` | `{shapeA: \"circle\", shapeB: \"box\"}` |\n| `[\"IN\", [\"$number\", 5], 5]`                | `{number: 3}`                       |\n\n### Comparison Expressions\n\n#### Equal\n\nExpression format: `[\"==\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: string, int, float, bool, None.\n\n```json\n[\"==\", 5, 5]\n```\n\n```py\nillogical.evaluate([\"==\", 5, 5], context)\n# True\n```\n\n#### Not Equal\n\nExpression format: `[\"!=\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: string, int, float, bool, None.\n\n```json\n[\"!=\", \"circle\", \"square\"]\n```\n\n```py\nillogical.evaluate([\"!=\", \"circle\", \"square\"], context)\n# True\n```\n\n#### Greater Than\n\nExpression format: `[\"\u003e\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: int, float.\n\n```json\n[\"\u003e\", 10, 5]\n```\n\n```py\nillogical.evaluate([\"\u003e\", 10, 5], context)\n# True\n```\n\n#### Greater Than or Equal\n\nExpression format: `[\"\u003e=\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: int, float.\n\n```json\n[\"\u003e=\", 5, 5]\n```\n\n```py\nillogical.evaluate([\"\u003e=\", 5, 5], context)\n# True\n```\n\n#### Less Than\n\nExpression format: `[\"\u003c\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: int, float.\n\n```json\n[\"\u003c\", 5, 10]\n```\n\n```py\nillogical.evaluate([\"\u003c\", 5, 10], context)\n# True\n```\n\n#### Less Than or Equal\n\nExpression format: `[\"\u003c=\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: int, float.\n\n```json\n[\"\u003c=\", 5, 5]\n```\n\n```py\nillogical.evaluate([\"\u003c=\", 5, 5], context)\n# True\n```\n\n#### In\n\nExpression format: `[\"IN\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: string, int, float, bool, None and list; set; tuple of (string, int, float, bool, None).\n\n```json\n[\"IN\", 5, [1, 2, 3, 4, 5]]\n[\"IN\", [\"circle\", \"square\", \"triangle\"], \"square\"]\n```\n\n```py\nillogical.evaluate([\"IN\", 5, [1, 2, 3, 4, 5]], context)\n# True\n\nillogical.evaluate([\"IN\", [\"circle\", \"square\", \"triangle\"], \"square\"], context)\n# True\n```\n\n#### Not In\n\nExpression format: `[\"NOT IN\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: string, int, float, bool, None and list; set; tuple of (string, int, float, bool, None).\n\n```json\n[\"IN\", 10, [1, 2, 3, 4, 5]]\n[\"IN\", [\"circle\", \"square\", \"triangle\"], \"oval\"]\n```\n\n```py\nillogical.evaluate([\"NOT IN\", 10, [1, 2, 3, 4, 5]], context)\n# True\n\nillogical.evaluate([\"NOT IN\", [\"circle\", \"square\", \"triangle\"], \"oval\"], context)\n# True\n```\n\n#### Prefix\n\nExpression format: `[\"PREFIX\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: string.\n\n- Left operand is the PREFIX term.\n- Right operand is the tested word.\n\n```json\n[\"PREFIX\", \"hemi\", \"hemisphere\"]\n```\n\n```py\nillogical.evaluate([\"PREFIX\", \"hemi\", \"hemisphere\"], context)\n# True\n\nillogical.evaluate([\"PREFIX\", \"hemi\", \"sphere\"], context)\n# False\n```\n\n#### Suffix\n\nExpression format: `[\"SUFFIX\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: string.\n\n- Left operand is the tested word.\n- Right operand is the SUFFIX term.\n\n```json\n[\"SUFFIX\", \"establishment\", \"ment\"]\n```\n\n```py\nillogical.evaluate([\"SUFFIX\", \"establishment\", \"ment\"], context)\n# True\n\nillogical.evaluate([\"SUFFIX\", \"establish\", \"ment\"], context)\n# False\n```\n\n#### Overlap\n\nExpression format: `[\"OVERLAP\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: list; set; tuple of (string, int, float, bool, None).\n\n```json\n[\"OVERLAP\", [1, 2], [1, 2, 3, 4, 5]]\n[\"OVERLAP\", [\"circle\", \"square\", \"triangle\"], [\"square\"]]\n```\n\n```py\nillogical.evaluate([\"OVERLAP\", [1, 2, 6], [1, 2, 3, 4, 5]], context)\n# True\n\nillogical.evaluate([\"OVERLAP\", [\"circle\", \"square\", \"triangle\"], [\"square\", \"oval\"]], context)\n# True\n```\n\n#### None\n\nExpression format: `[\"NONE\", `[Reference Operand](#reference)`]`.\n\n```json\n[\"NONE\", \"$RefA\"]\n```\n\n```py\nillogical.evaluate([\"NONE\", \"RefA\"], {})\n# True\n\nillogical.evaluate([\"NONE\", \"RefA\"], {\"RefA\": 10})\n# False\n```\n\n#### Present\n\nEvaluates as FALSE when the operand is UNDEFINED or NULL.\n\nExpression format: `[\"PRESENT\", `[Reference Operand](#reference)`]`.\n\n```json\n[\"PRESENT\", \"$RefA\"]\n```\n\n```py\nillogical.evaluate([\"PRESENT\", \"RefA\"], {})\n# False\n\nillogical.evaluate([\"PRESENT\", \"RefA\"], {\"RefA\": 10})\n# True\n\nillogical.evaluate([\"PRESENT\", \"RefA\"], {\"RefA\": False})\n# True\n\nillogical.evaluate([\"PRESENT\", \"RefA\"], {\"RefA\": \"val\"})\n# True\n```\n\n### Logical Expressions\n\n#### And\n\nThe logical AND operator returns the bool value TRUE if both operands are TRUE and returns FALSE otherwise.\n\nExpression format: `[\"AND\", Left Operand 1, Right Operand 2, ... , Right Operand N]`.\n\n\u003e Valid operand types: [Comparison Expression](#comparison-expressions) or [Nested Logical Expression](#logical-expressions).\n\n```json\n[\"AND\", [\"==\", 5, 5], [\"==\", 10, 10]]\n```\n\n```py\nillogical.evaluate([\"AND\", [\"==\", 5, 5], [\"==\", 10, 10]], context)\n# True\n```\n\n#### Or\n\nThe logical OR operator returns the bool value TRUE if either or both operands is TRUE and returns FALSE otherwise.\n\nExpression format: `[\"OR\", Left Operand 1, Right Operand 2, ... , Right Operand N]`.\n\n\u003e Valid operand types: [Comparison Expression](#comparison-expressions) or [Nested Logical Expression](#logical-expressions).\n\n```json\n[\"OR\", [\"==\", 5, 5], [\"==\", 10, 5]]\n```\n\n```py\nillogical.evaluate([\"OR\", [\"==\", 5, 5], [\"==\", 10, 5]], context)\n# True\n```\n\n#### Nor\n\nThe logical NOR operator returns the bool value TRUE if both operands are FALSE and returns FALSE otherwise.\n\nExpression format: `[\"NOR\", Left Operand 1, Right Operand 2, ... , Right Operand N]`\n\n\u003e Valid operand types: [Comparison Expression](#comparison-expressions) or [Nested Logical Expression](#logical-expressions).\n\n```json\n[\"NOR\", [\"==\", 5, 1], [\"==\", 10, 5]]\n```\n\n```py\nillogical.evaluate([\"NOR\", [\"==\", 5, 1], [\"==\", 10, 5]], context)\n# True\n```\n\n#### Xor\n\nThe logical NOR operator returns the bool value TRUE if both operands are FALSE and returns FALSE otherwise.\n\nExpression format: `[\"XOR\", Left Operand 1, Right Operand 2, ... , Right Operand N]`\n\n\u003e Valid operand types: [Comparison Expression](#comparison-expressions) or [Nested Logical Expression](#logical-expressions).\n\n```json\n[\"XOR\", [\"==\", 5, 5], [\"==\", 10, 5]]\n```\n\n```py\nillogical.evaluate([\"XOR\", [\"==\", 5, 5], [\"==\", 10, 5]], context)\n# True\n```\n\n```json\n[\"XOR\", [\"==\", 5, 5], [\"==\", 10, 10]]\n```\n\n```py\nillogical.evaluate([\"XOR\", [\"==\", 5, 5], [\"==\", 10, 10]], context)\n# False\n```\n\n#### Not\n\nThe logical NOT operator returns the bool value TRUE if the operand is FALSE, TRUE otherwise.\n\nExpression format: `[\"NOT\", Operand]`\n\n\u003e Valid operand types: [Comparison Expression](#comparison-expressions) or [Nested Logical Expression](#logical-expressions).\n\n```json\n[\"NOT\", [\"==\", 5, 5]]\n```\n\n```py\nillogical.evaluate([\"NOT\", [\"==\", 5, 5]], context)\n# True\n```\n\n## Engine Options\n\n### Reference Serialize Options\n\n**Usage**\n\n```py\n\nfrom illogical.illogical import Illogical\nfrom illogical.parser.parse import Options\n\nillogical = Illogical(Options(reference_from=reference_from, reference_to=reference_to))\n```\n\n#### From\n\nA function used to determine if the operand is a reference type, otherwise evaluated as a static value.\n\n```py\nCallable[[str], str]\n```\n\n**Return value:**\n\n- `True` = reference type\n- `False` = value type\n\n**Default reference predicate:**\n\n\u003e The `$` symbol at the begging of the operand is used to predicate the reference type., E.g. `$State`, `$Country`.\n\n#### To\n\nA function used to transform the operand into the reference annotation stripped form. I.e. remove any annotation used to detect the reference type. E.g. \"$Reference\" =\u003e \"Reference\".\n\n```py\nCallable[[str], str]\n```\n\n\u003e **Default reference transform:**\n\u003e It removes the `$` symbol at the begging of the operand name.\n\n### Collection Serialize Options\n\n**Usage**\n\n```py\nfrom illogical.illogical import Illogical\nfrom illogical.parser.parse import Options\n\nescape_character = \"\\\\\"\n\nillogical = Illogical(Options(escape_character=escape_character))\n```\n\n#### Escape Character\n\nCharter used to escape fist value within a collection, if the value contains operator value.\n\n**Example**\n- `[\"==\", 1, 1]` # interpreted as EQ expression\n- `[\"\\==\", 1, 1]` # interpreted as a collection\n\n\u003e **Default escape character:**\n\u003e `\\`\n\n### Simplify Options\n\nOptions applied while an expression is being simplified.\n\n**Usage**\n\n```py\nfrom illogical.illogical import Illogical\nfrom illogical.parser.parse import Options\n\nignored_paths = [\"ignored\"]\nignored_path_rx = [r\"^prefix\"]\n\nillogical = Illogical(Options(ignored_paths=ignored_paths, ignored_path_rx=ignored_path_rx))\n```\n\n#### Ignored Paths\n\nReference paths which should be ignored while simplification is applied. Must be an exact match.\n\n#### Ignored Paths RegEx\n\nReference paths which should be ignored while simplification is applied. Matching regular expression patterns.\n\n### Operator Mapping\n\nMapping of the operators. The key is unique operator key, and the value is the key used to represent the given operator in the raw expression.\n\n**Usage**\n\n```py\nfrom illogical.illogical import Illogical\nfrom illogical.parser.parse import Options, DEFAULT_OPERATOR_MAPPING, EQ\n\noperator_mapping = DEFAULT_OPERATOR_MAPPING.copy()\noperator_mapping[EQ] = \"IS\"\n\nillogical = Illogical(Options(operator_mapping=operator_mapping))\n```\n\n**Default operator mapping:**\n\n```py\nDEFAULT_OPERATOR_MAPPING = {\n    # Logical\n    AND:     \"AND\",\n    OR:      \"OR\",\n    NOR:     \"NOR\",\n    XOR:     \"XOR\",\n    NOT:     \"NOT\",\n    # Comparison\n    EQ:      \"==\",\n    NE:      \"!=\",\n    GT:      \"\u003e\",\n    GE:      \"\u003e=\",\n    LT:      \"\u003c\",\n    LE:      \"\u003c=\",\n    NONE:     \"NONE\",\n    PRESENT: \"PRESENT\",\n    IN:      \"IN\",\n    NIN:     \"NOT IN\",\n    OVERLAP: \"OVERLAP\",\n    PREFIX:  \"PREFIX\",\n    SUFFIX:  \"SUFFIX\",\n}\n```\n\n---\n\n## Contributing\n\nSee [contributing.md](https://github.com/spaceavocado/pyillogical/blob/master/contributing.md).\n\n## License\n\nIllogical is released under the MIT license. See [license.md](https://github.com/spaceavocado/pyillogical/blob/master/LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspaceavocado%2Fpyillogical","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspaceavocado%2Fpyillogical","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspaceavocado%2Fpyillogical/lists"}