{ "info": { "author": "Risto Stevcev", "author_email": "risto1@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: End Users/Desktop", "Intended Audience :: Science/Research", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.3", "Programming Language :: Python :: 2.4", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.0", "Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering :: Mathematics" ], "description": "# Church Encodings in Python\n\nThis exercise was to demonstrate and play around with church encodings in a more involved way, and as a way for me to gain experience with python and it's type system.\n\n**Church encodings** were developed by the late and famous Alonzo Church. Church is probably most well known for inventing **lambda calculus**, a formal branch of mathematics that introduces the notion of **lambas**, or *anonymous functions*. You may have used them before when programming.\n\n**Church encodings** are a very interesting development arising from **lambda calculus**. Church found out that every concept in programming languages can be represented using *functions*! everything from boolean logic, conditional statements, numbers (natural, integer, real, complex, imaginary), and even loops (infinite loops also)!\n\nThe most interesting thing about this is that numbers aren't anything special in math, they're just convenient placeholders. Math is really just logic in it's purest form.\n\nSo far I've translated church booleans, church boolean operators, church conditionals, church comparison operators, church numerals (natural numbers), church arithmetic operators (for natural numbers), church lists, church integers, loops with the z-combinator, and church arithmetic operators (for integers) less the exponential and factorial operators. \n\n**View the package on [PyPI](http://pypi.python.org/pypi/church_encoding/)**\n\n\n## Z Combinator\n\nThe Z combinator is used in place of the Y combinator in normal form progrmaming languages that don't implement lazy evaluation or call by name. See the [fixed-point combinator](https://en.wikipedia.org/wiki/Fixed-point_combinator) wiki for more details.\n\n\n## Conditionals\n\nThe translation for some of the lambda functions involved using regular if/then statements instead of the **ifelse** lamdba function. I suspect that this might again be a limitation like the Z combinator, where the evaluation order plays a role in being able to use lambdas in the truest sense. There may be a workaround I'll find to get it to work some day.\n\n\n## Installation\n\n* Install using pip. \n ``pip install --user church_encoding`` \n\n* Import the church module. \n ``python`` \n ``>>> import church_encoding.church as church`` \n\n* Play around with the functions. \n ``>>> dir(church)`` \n ``>>> (church.unchurch_bool) ((church.AND) (church.true) (church.false))`` \n ``False`` \n\n\nHere is a full list of the commands: \n\nBoolean true/false: ``true``, ``false``, ``unchurch_bool`` \n\nBoolean operators: ``AND``, ``NOT``, ``OR``, ``XOR`` \n\nZ-combinator: ``Z`` \n\nConditional: ``ifelse`` \n\nNatural numbers: ``zero``, ``one``, ``two``, ``three``, ``num``, ``unchurch_num`` \n\nIntegers: ``convertNZ``, ``unchurch_int`` \n\nComparison operators (natural numbers): ``eq``, ``geq``, ``gt``, ``leq``, ``lt`` \n\nArithmetic operators (natural numbers): ``pred``, ``succ``, ``add``, ``sub``, ``mult``, ``div``, ``divnZ``, ``exp``, ``fac``, ``is_zero`` \n\nArithmetic operators (integers): ``addZ``, ``subZ``, ``multZ``, ``divZ``, ``neg``, ``onezero`` \n\nLists: ``car``, ``cdr``, ``cons`` \n\n\nFor usage examples, see the [test suite](https://github.com/Risto-Stevcev/python-church-encodings/blob/master/church_encoding/test/church_test.py)\n\n\n## Credits\n\nI'd like to give credit where it's due:\n\n* [James Tauber's Blog](http://jtauber.com/blog/2008/11/26/church_encoding_in_python/) for starting me off in the right direction. \n\n* The [chuch encoding](https://en.wikipedia.org/wiki/Church_encoding) wikipedia page for being so incredibly detailed and informative. \n\nAnd finally, Church himself, for being such a badass! \n\n![Alonzo Church](https://upload.wikimedia.org/wikipedia/en/a/a6/Alonzo_Church.jpg) \nAlonzo Church", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/Risto-Stevcev/python-church-encodings", "keywords": "church encoding encodings", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "church_encoding", "package_url": "https://pypi.org/project/church_encoding/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/church_encoding/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/Risto-Stevcev/python-church-encodings" }, "release_url": "https://pypi.org/project/church_encoding/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "Church encodings written in Python", "version": "0.1.1" }, "last_serial": 1072335, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "d31204e924f9daf9f3192b5546d7b322", "sha256": "a63b40a8f8783e8b30b06a140873f90db6cfae1bfdf88e2f26223ab43e76f0fd" }, "downloads": -1, "filename": "church_encoding-0.1.tar.gz", "has_sig": false, "md5_digest": "d31204e924f9daf9f3192b5546d7b322", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6345, "upload_time": "2014-04-26T07:30:27", "url": "https://files.pythonhosted.org/packages/2e/d6/3c0a954fbf9b4cd9dad0b62baed7f7015d79056f13db80e3bd24d36c985a/church_encoding-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "ae6fae0dd6b5aa2d4ccf7d3dfd23cb16", "sha256": "68e952db61a21eb68981f05a0ec8ebf1fb446858358976e0b11c906ea3ab6501" }, "downloads": -1, "filename": "church_encoding-0.1.1.tar.gz", "has_sig": false, "md5_digest": "ae6fae0dd6b5aa2d4ccf7d3dfd23cb16", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6332, "upload_time": "2014-04-26T07:40:31", "url": "https://files.pythonhosted.org/packages/b0/ec/28b43669713e35240a412d2d486f658c96e117db7ec8c75c04ca03f5af8f/church_encoding-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ae6fae0dd6b5aa2d4ccf7d3dfd23cb16", "sha256": "68e952db61a21eb68981f05a0ec8ebf1fb446858358976e0b11c906ea3ab6501" }, "downloads": -1, "filename": "church_encoding-0.1.1.tar.gz", "has_sig": false, "md5_digest": "ae6fae0dd6b5aa2d4ccf7d3dfd23cb16", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6332, "upload_time": "2014-04-26T07:40:31", "url": "https://files.pythonhosted.org/packages/b0/ec/28b43669713e35240a412d2d486f658c96e117db7ec8c75c04ca03f5af8f/church_encoding-0.1.1.tar.gz" } ] }