https://github.com/innovativeinventor/hack-python-types
Abusing Python’s type-checker (mypy) to construct a propositional, constructive logic proof checker via the Curry-Howard correspondence and the BHK interpretation of intuitionistic logic. (see blog post)
https://github.com/innovativeinventor/hack-python-types
Last synced: 12 months ago
JSON representation
Abusing Python’s type-checker (mypy) to construct a propositional, constructive logic proof checker via the Curry-Howard correspondence and the BHK interpretation of intuitionistic logic. (see blog post)
- Host: GitHub
- URL: https://github.com/innovativeinventor/hack-python-types
- Owner: InnovativeInventor
- Created: 2021-12-30T20:48:22.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-30T20:53:19.000Z (over 4 years ago)
- Last Synced: 2025-02-26T14:45:24.293Z (over 1 year ago)
- Language: Python
- Homepage: https://max.fan/posts/hacking-python-types/
- Size: 1000 Bytes
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## hack-python-types
This repo contains the code and fully type-checkable proofs for various natural deduction inference rules in Python's type system.
It is intended to accompany [my blog post on the hacking Python's type system](https://max.fan/posts/hacking-python-types/).
You can see the corresponding proofs at [`/natural_deduction.py`](/natural_deduction.py).
To type-check the proofs yourself, run:
```
mypy .
```
See [https://max.fan/posts/hacking-python-types/](https://max.fan/posts/hacking-python-types/) for more.
## Contents
This repo proves the following natural deduction rules in Python's type system:
- modus ponens
- contrapositive
- modus tollens
- transitive implication (if A implies B and B implies C, then A implies C)
- conjunction introduction
- conjunction elimination
- disjunction introduction
Additionally, type definitions/stubs are given for:
- modus tollendo ponens (admitted as axiom -- not proven yet)
- constructive dilemma (admitted as axiom -- not proven yet)
Feedback is welcome.