{"id":16871760,"url":"https://github.com/phase/dtt","last_synced_at":"2025-03-22T07:31:09.586Z","repository":{"id":50321911,"uuid":"256409900","full_name":"phase/dtt","owner":"phase","description":"dependent type theory experiment","archived":false,"fork":false,"pushed_at":"2024-03-01T03:02:44.000Z","size":18,"stargazers_count":25,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T09:21:26.373Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"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}},"created_at":"2020-04-17T05:30:37.000Z","updated_at":"2025-01-09T20:22:00.000Z","dependencies_parsed_at":"2024-10-28T12:47:13.960Z","dependency_job_id":null,"html_url":"https://github.com/phase/dtt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phase%2Fdtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phase%2Fdtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phase%2Fdtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phase%2Fdtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phase","download_url":"https://codeload.github.com/phase/dtt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244925072,"owners_count":20532873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-13T15:09:38.640Z","updated_at":"2025-03-22T07:31:08.241Z","avatar_url":"https://github.com/phase.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dtt experiments\n\nExperimenting with Dependent Type Theory in Rust. The goal here is to\nattempt to lower MLT Terms to an SSA IR.\n\nThe core is extremely simple and as such a number of things need to\nbe _encoded_.\n\n[Dependent Products](https://math.stackexchange.com/a/673003):\n\n```\nΣ : Π A : U (A → U) → U′\nΣ = λA : U . λB : A → U . Π C : U (Π x : A B(x) → C) → C\n\nsigma = \\A : U\n```\n\nHere are some examples:\n\n```\nN : Type 0\nZ : N\nS : forall _ : N -\u003e N\nthree = \\f : (forall _ : N -\u003e N) =\u003e \\x : N =\u003e (f (f (f x)))\ncheck (three S)\ncheck (three (three S))\neval ((three (three S)) Z)\n```\n\nrunning this code will produce:\n\n```\n(three S) : N -\u003e N\n(three (three S)) : N -\u003e N\n((three (three S)) Z)\n    = (S (S (S (S (S (S (S (S (S Z)))))))))\n    : N\n```\n\n## Irrelevance\n\nThought: If irrelevant terms are erased, we can extract functions that don't need dependent types for computation but\nstill benefit from type checking.\n\n```ocaml\nVec T .n\nval Vec : Π(x : Type 0) -\u003e (.Π(l: C) -\u003e Type 0)\n\nval append : Vec T .n -\u003e Vec T .m -\u003e Vec T .(n + m)\nappend: Π(T: Type0) -\u003e (\n          .Π(n: Nat) -\u003e (\n            .Π(m: Nat) -\u003e (\n              Π(_:Vec T .n) -\u003e (\n                Π(_:Vec T .m) -\u003e (\n                  Vec T .(+ n m)\n                )\n              )\n            )\n          )\n        )\n\nval erased_Vec : Π(x : Type 0) -\u003e Type 0\nval erased_append : Vec T -\u003e Vec T -\u003e Vec T\nerased_append : Π(T: Type0) -\u003e (\n                  Π(_:Vec T) -\u003e (\n                    Π(_:Vec T) -\u003e (\n                      Vec T\n                    )\n                  )\n                )\n```\n\n### Erasing Π Types\n\n```\nΠ(x : Type 0) -\u003e (.Π(l: C) -\u003e Type 0)\nΠ(x : Type 0) -\u003e Type 0\n\n.Π(x:X) -\u003e T ==\u003e .T, erroring if .T depends on x\n```\n\n### Erasing λ Expressions\n\n```\n.λ(x:X) =\u003e E ==\u003e .E, erroring if .E depends on x\n```\n\n### Erasing Applications\n\n```\n((Vec T) .n)\n(Vec T)\n\n.(a b) ==\u003e .a, erroring if .a requires a parameter\n```\n\n## References\n\n* [How to implement dependent type theory I](http://math.andrej.com/2012/11/08/how-to-implement-dependent-type-theory-i/)\n* [Practical Erasure in Dependently Typed Languages](https://eb.host.cs.st-andrews.ac.uk/drafts/dtp-erasure-draft.pdf)\n* [From System F to Typed Assembly Language](https://www.cs.princeton.edu/~dpw/papers/tal-toplas.pdf)\n* [Compiling with Dependent Types](https://www.williamjbowman.com/resources/wjb-dissertation.pdf)\n* [The Implicit Calculus of Constructions as a Programming Language with Dependent Types](http://www.lix.polytechnique.fr/Labo/Bruno.Bernardo/writings/barras-bernardo-icc-fossacs08.pdf)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphase%2Fdtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphase%2Fdtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphase%2Fdtt/lists"}