{ "info": { "author": "Thiago P. Bueno", "author_email": "thiago.pbueno@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: Education", "Intended Audience :: Science/Research", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering :: Artificial Intelligence", "Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "pyddlib\n=======\n\npyddlib is a Python3 library for manipulating decision diagrams (DD).\n\nIt is intended to follow (as much as possible) the notation and overall\nconstruction proposed in the following papers:\n\n[1] Bryant, Randal E. **Graph-based algorithms for boolean function\nmanipulation**. Computers, IEEE Transactions on 100, no. 8 (1986):\n677-691.\n\n[2] Brace, Karl S., Richard L. Rudell, and Randal E. Bryant. **Efficient\nimplementation of a BDD package**. In Proceedings of the 27th ACM/IEEE\ndesign automation conference, pp. 40-45. ACM, 1991.\n\n[3] Bahar, R. Iris, Erica A. Frohm, Charles M. Gaona, Gary D. Hachtel,\nEnrico Macii, Abelardo Pardo, and Fabio Somenzi. **Algebraic decision\ndiagrams and their applications**. Formal methods in system design 10,\nno. 2-3 (1997): 171-206.\n\nInstall\n-------\n\nIt is required to have Python3 installed.\n\n::\n\n $ pip3 install pyddlib\n\n\nUsage\n-----\n\nBinary Decision Diagrams (BDDs)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou create BDDs from constants and variables by composing boolean\nfunctions with logical operations AND (&), OR (\\|), XOR (^) and NOT (-).\n\n.. code:: python\n\n from pyddlib.bdd import BDD\n\n one = BDD.one()\n zero = BDD.zero()\n print(\"== True ==\")\n print(one)\n print(\"== False ==\")\n print(zero)\n\n x1 = BDD.variable(1)\n x2 = BDD.variable(2)\n x3 = BDD.variable(3)\n print(\"=== x1 ===\")\n print(x1)\n\n print(\"=== NOT x1 ===\")\n print(~x1)\n\n print(\"=== x1 AND x2 ===\")\n print(x1 & x2)\n\n print(\"=== x1 OR x2 ===\")\n print(x1 | x2)\n\n print(\"=== x1 XOR x2 ===\")\n print(x1 ^ x2)\n\n bdd1 = ~x1 | (x2 ^ ~x3)\n if (bdd1 & one) == bdd1:\n print('True is the neutral element for AND operation!')\n\n bdd2 = ~(~x2) ^ (~(x1 | x3))\n if (bdd2 | zero) == bdd2:\n print('False is the neutral element for OR operation!')\n\n bdd3 = x1 & ~x1\n if bdd3.is_zero():\n print('You can check contradiction with is_zero() funtion!')\n\n bdd4 = x1 | ~x1\n if bdd4.is_one():\n print('You can check tautology with is_one() function!')\n\n bdd5 = ~(x1 | ~(x2 & ~x3))\n if (bdd5 ^ bdd5).is_zero():\n print('You can check equivalence with XOR!')\n\n if (x1 & x2) == (x2 & x1):\n print('Commutative law works for boolean functions!')\n\n if x1 & (x2 & x3) == (x1 & x2) & x3:\n print('Associative law works for boolean functions!')\n\n if (x1 & (x2 | x3)) == ((x1 & x2) | (x1 & x3)):\n print('Distributivity law works: AND distributes over OR!')\n\n if (x1 | (x2 & x3)) == ((x1 | x2) & (x1 | x3)):\n print('Distributivity law works: OR distributes over AND!')\n\n bdd6 = ~(x1 & ~(~x2 | x3))\n valuation1 = { 1: True, 2: True, 3: False }\n\n if bdd6.restrict(valuation1).is_zero():\n print('You can evaluate the function with restrict!')\n\n valuation2 = { 1: True }\n if bdd6.restrict(valuation2) == (~x2 | x3):\n print('You can also partially evaluate the function with restrict!')\n\n\nAlgebraic Decision Diagrams (ADDs)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou create ADDs from constants and variables by composing arithmetic operations functions +, -, *, /.\n\n.. code:: python\n\n from pyddlib.add import ADD\n\n c0 = ADD.constant(0.0)\n c1 = ADD.constant(1.0)\n c2 = ADD.constant(2.0)\n print(\"=== c1 ===\")\n print(c1)\n print(\"=== c2 ===\")\n print(c2)\n\n x1 = ADD.variable(1)\n x2 = ADD.variable(2)\n x3 = ADD.variable(3)\n print(\"=== x1 ===\")\n print(x1)\n\n print(\"=== NOT x1 ===\")\n print(~x1)\n\n print(\"=== x1 * x2 * c1 ===\")\n print(x1 * x2 * c2)\n\n print(\"=== (x1 + x2) * c2 ===\")\n print((x1 + x2) * c2)\n\n print(\"=== x1 - x2 ===\")\n print(x1 - x2)\n\n add1 = ~x1 + (x2 * ~x3)\n if (add1 * c1) == add1:\n print('ADD.constant(1.0) is the neutral element for multiplication!')\n\n add2 = ~(~x2) * (~(x1 + x3))\n if (add2 + c0) == add2:\n print('ADD.constant(0.0) is the neutral element for addition!')\n\n add3 = x1 * ~x1\n if add3 == c0:\n print('You can check contradiction by comparing with ADD.constant(0.0) !')\n\n add4 = x1 + ~x1\n if add4 == c1:\n print('You can check tautology by comparing with ADD.constant(1.0) !')\n\n if (x1 * x2) == (x2 * x1) and (x1 + x2) == (x2 + x1):\n print('Commutative law works for multiplication and addition!')\n\n if x1 * (x2 * x3) == (x1 * x2) * x3 and x1 + (x2 + x3) == (x1 + x2) + x3:\n print('Associative law works for multiplication and addition!')\n\n if (x1 * (x2 + x3)) == ((x1 * x2) + (x1 * x3)):\n print('Distributivity law works: multiplication distributes over addition!')\n\n add5 = x1 * x2 + x3 * c2\n valuation = { 1: True, 2: False, 3: True }\n\n if add5.restrict(valuation).value == 2.0:\n print('You can evaluate the function with restrict!')\n\n valuation2 = { 1: True }\n if add5.restrict(valuation2) == (x2 + x3 * c2):\n print('You can also partially evaluate the function with restrict!')\n\n\nLICENSE\n-------\n\nCopyright (c) 2017 Thiago Pereira Bueno All Rights Reserved.\n\npyddlib is free software: you can redistribute it and/or modify it under\nthe terms of the GNU Lesser General Public License as published by the\nFree Software Foundation, either version 3 of the License, or (at your\noption) any later version.\n\npyddlib is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public\nLicense for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with pyddlib. If not, see http://www.gnu.org/licenses/", "description_content_type": null, "docs_url": "https://pythonhosted.org/pyddlib/", "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/thiagopbueno/pyddlib", "keywords": "decision diagrams,BDD,ADD,symbolic,boolean,data structure", "license": "GNU General Public License v3.0", "maintainer": null, "maintainer_email": null, "name": "pyddlib", "package_url": "https://pypi.org/project/pyddlib/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pyddlib/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/thiagopbueno/pyddlib" }, "release_url": "https://pypi.org/project/pyddlib/0.2.1/", "requires_dist": null, "requires_python": null, "summary": "pyddlib is a Python3 library for manipulating decision diagrams (DD).", "version": "0.2.1" }, "last_serial": 2710411, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "e9cb21e89a7adf09695ce427a7a7ac70", "sha256": "4f170f26936844511f432af6e332324235b7dff3ec879f682e1310c93b5bb6d1" }, "downloads": -1, "filename": "pyddlib-0.1.0.tar.gz", "has_sig": false, "md5_digest": "e9cb21e89a7adf09695ce427a7a7ac70", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7929, "upload_time": "2017-03-09T16:42:35", "url": "https://files.pythonhosted.org/packages/9b/be/925cf70c0d935676b24bb4786562dd89bf0bf0f6f1d05d97b90a804002e1/pyddlib-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "cbb09963e293b44643d796f5238ef52e", "sha256": "7188f2d4b41364ca8d37989e8c396f43cb347300338db5dad934386977f624c1" }, "downloads": -1, "filename": "pyddlib-0.2.0.tar.gz", "has_sig": false, "md5_digest": "cbb09963e293b44643d796f5238ef52e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12876, "upload_time": "2017-03-16T14:14:20", "url": "https://files.pythonhosted.org/packages/a9/bd/202775dabcdfd21dbeeafe33eb8e3a14555a9683c1480dd804ca5a89c0f0/pyddlib-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "c9f68099923ceecf825f6ffdb7db7f27", "sha256": "5a29bc61d7c07a66dfbe025a3d7d8b10fbf0da4ce044b472dc817cd6a9ec2ef0" }, "downloads": -1, "filename": "pyddlib-0.2.1.tar.gz", "has_sig": false, "md5_digest": "c9f68099923ceecf825f6ffdb7db7f27", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12893, "upload_time": "2017-03-16T15:30:38", "url": "https://files.pythonhosted.org/packages/65/8b/fcba14d9c8afc133350e3da819996407ffa895452039489ba73147788ddb/pyddlib-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c9f68099923ceecf825f6ffdb7db7f27", "sha256": "5a29bc61d7c07a66dfbe025a3d7d8b10fbf0da4ce044b472dc817cd6a9ec2ef0" }, "downloads": -1, "filename": "pyddlib-0.2.1.tar.gz", "has_sig": false, "md5_digest": "c9f68099923ceecf825f6ffdb7db7f27", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12893, "upload_time": "2017-03-16T15:30:38", "url": "https://files.pythonhosted.org/packages/65/8b/fcba14d9c8afc133350e3da819996407ffa895452039489ba73147788ddb/pyddlib-0.2.1.tar.gz" } ] }