{"id":17319608,"url":"https://github.com/ziman/ttstar","last_synced_at":"2026-01-06T22:19:25.134Z","repository":{"id":32149045,"uuid":"35721993","full_name":"ziman/ttstar","owner":"ziman","description":"Dependently typed core calculus with erasure","archived":false,"fork":false,"pushed_at":"2021-08-31T19:09:48.000Z","size":3411,"stargazers_count":18,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-01T08:15:04.372Z","etag":null,"topics":["dependent-types","erasure","functional-programming","type-system","typechecker"],"latest_commit_sha":null,"homepage":"","language":"Idris","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ziman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-16T11:58:56.000Z","updated_at":"2023-11-16T07:06:33.000Z","dependencies_parsed_at":"2022-09-11T17:24:13.497Z","dependency_job_id":null,"html_url":"https://github.com/ziman/ttstar","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziman%2Fttstar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziman%2Fttstar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziman%2Fttstar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziman%2Fttstar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ziman","download_url":"https://codeload.github.com/ziman/ttstar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245772597,"owners_count":20669717,"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":["dependent-types","erasure","functional-programming","type-system","typechecker"],"created_at":"2024-10-15T13:26:02.858Z","updated_at":"2026-01-06T22:19:25.108Z","avatar_url":"https://github.com/ziman.png","language":"Idris","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TTstar\n\nDependently typed core calculus with erasure inference.\n\n## Examples from the dissertation\n\n* Palindrome ([source](https://github.com/ziman/ttstar/blob/master/examples/palindrome.tt),\n  [erased](https://github.com/ziman/ttstar/blob/master/examples/outputs/palindrome/erased.tt))\n* Binary adder ([source](https://github.com/ziman/ttstar/blob/master/examples/bin.tt),\n  [erased](https://github.com/ziman/ttstar/blob/master/examples/outputs/bin/erased.tt))\n* RLE ([source](https://github.com/ziman/ttstar/blob/master/examples/rle.tt),\n  [erased](https://github.com/ziman/ttstar/blob/master/examples/outputs/rle/erased.tt))\n* Scope-indexed lambda calculus ([source](https://github.com/ziman/ttstar/blob/master/examples/tt.tt),\n  [erased](https://github.com/ziman/ttstar/blob/master/examples/outputs/tt/erased.tt))\n* [Other example programs](https://github.com/ziman/ttstar/tree/master/examples)\n  and [their outputs](https://github.com/ziman/ttstar/tree/master/examples/outputs)\n\n## Features\n\n### Erasure\n\n* erasure inference (fills in erasure annotations)\n* separate erasure checker (verifies consistency of inferred annotations)\n* erasure from higher-order functions\n* complete removal of unused arguments (rather than passing in `NULL`)\n* erasure polymorphism for functions\n* four constraint solvers\n    * simple and straightforward O(n²) solver\n    * graph-based constraint solver\n    * indexing solver (fastest, default)\n    * LMS solver\n        * \"last man standing\"\n        * Adapted from \"Chaff: Engineering an efficient SAT solver\"\n          by Moskewicz et al., 2001.\n        * theoretically faster than the indexer, my implementation is slower\n* a tentative implementation of irrelevance ([example](https://github.com/ziman/ttstar/blob/master/examples/irrelevance.tt))\n\n### Language\n\n* full dependent pattern matching clauses\n* pattern matching local `let` definitions are useful for emulating\n    * `case` expressions\n    * `with` clauses\n    * mutual recursion\n* rudimentary term/type inference via first order unification\n\n### Practicalities\n\n* type errors come with backtraces\n* rudimentary FFI via `foreign` postulates\n* a simplified intermediate representation for backends (`IR`)\n    * translation from `TT` to `IR` compiles patterns into case trees\n* native code generators\n    * a codegen from `TT`: via Scheme (Chicken Scheme or Racket)\n        * uses the `matchable` extension\n    * a codegen from `IR`: produces standard Scheme\n        * mostly R5RS-compliant\n            * except that some programs redefine the same name repeatedly in `let*`\n        * when interpreted with `csi`, the `IR`-generated code runs much (~3x) faster than the `TT`-generated code\n        * only about 10% faster than `TT`-generated code when compiled using `csc`\n    * a codegen via [Malfunction](https://github.com/stedolan/malfunction), using `IR`\n        * produces fast native code\n\n## Other stuff\n\n* dependent erasure (if `x == 3` then `erased` else `not_erased`)\n* unused functions are removed entirely\n* `Refl` is always erased\n* `Maybe` sometimes becomes Boolean after erasure\n\n## Does not feature\n\n* totality checking\n* mutual recursion\n\t* a restricted form is easy to achieve using local let bindings\n\t* sufficient in all cases I've come across\n* much syntax sugar\n\n\u003c!--\nBesides what the original paper had, we have:\n* [M] support of inductive families and full dependent pattern matching\n    * M-L avoids this entirely\n* [MP] erasure polymorphism for let-bound names (includes top-level)\n    * but not lambda-bound names\n* checkable result of erasure\n* an erasure calculus\n* equivalence of pattern clauses vs. case trees\n* pruning case trees\n* local pattern-matching clauses in let\n    * actually, let is fully equivalent to top-level\n    * only one definition per let at the moment; absolutely not necessary, I just can't be bothered to invent good syntax for it\n* separate typechecker that checks the result of inference\n\nSymbols:\n* [P] = improvement over previous paper, [M] = improvement over Mishra-Linger\n\n\n### TODO\n* good error reporting\n* first-order evars for unlimited-rank polymorphism\n* mutual recursion\n    * this is fairly easy but it requires clumsy propagation of constraints\n    * (iterate checking of Defs until the set of constraints does not change)\n    * leave out of paper\n    * if let f, g in X, then while checking body of f, we have empty set of constraints for g\n    * therefore the reference to g in the body of f puts wrong constraints in\n    * also implementable by non-mutual recursion with an extra tag argument\n\n#### Short-term TODO\n* fix mutual recursion in the implementation\n    * then fix typing rules in the paper\n* continue with the proofs in the paper\n* This rule is disgustingly complicated but it just says \"take all\nknown equalities and rewrite everything\".\n* Resolve telescopicness of lets. Let is not telescopic because it's\nmutually recursive. Fix that.\n* Probably nothing is telescopic in the Greek.\n\n### Secondary features\n* backtrace in typechecker\n* erasure explorer (defunct)\n* including very dependent functions\n* erasure of whole functions (dead function removal)\n* recursion\n* every binder is a `Def`\n* `Refl` is erased\n--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziman%2Fttstar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fziman%2Fttstar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziman%2Fttstar/lists"}