{"id":13749293,"url":"https://github.com/andrew-johnson-4/PunCalculus","last_synced_at":"2025-05-09T12:32:26.992Z","repository":{"id":195415583,"uuid":"692862888","full_name":"andrew-johnson-4/PunCalculus","owner":"andrew-johnson-4","description":"A variant of Typed Lambda Calculus with generalized variable punning (ad-hoc polymorphism)","archived":false,"fork":false,"pushed_at":"2023-12-31T18:00:42.000Z","size":115,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-22T22:32:45.861Z","etag":null,"topics":["computer-science","language","programming-language"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrew-johnson-4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"andrew-johnson-4","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-09-17T20:05:17.000Z","updated_at":"2024-01-23T23:16:55.000Z","dependencies_parsed_at":"2023-09-28T18:40:15.570Z","dependency_job_id":"4740eb62-97fb-443a-9b41-8261ee5f8fa7","html_url":"https://github.com/andrew-johnson-4/PunCalculus","commit_stats":null,"previous_names":["andrew-johnson-4/puncalculus"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrew-johnson-4%2FPunCalculus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrew-johnson-4%2FPunCalculus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrew-johnson-4%2FPunCalculus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrew-johnson-4%2FPunCalculus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrew-johnson-4","download_url":"https://codeload.github.com/andrew-johnson-4/PunCalculus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224863108,"owners_count":17382279,"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":["computer-science","language","programming-language"],"created_at":"2024-08-03T07:00:58.663Z","updated_at":"2024-11-16T00:30:25.111Z","avatar_url":"https://github.com/andrew-johnson-4.png","language":"Rust","funding_links":["https://github.com/sponsors/andrew-johnson-4"],"categories":["Lambda Calculus"],"sub_categories":["Libraries"],"readme":"# [Pun Calculus](https://github.com/andrew-johnson-4/PunCalculus/wiki)\nA variant of Typed Lambda Calculus with generalized variable punning (ad-hoc polymorphism). This methodology may be useful for adapting other type theories into concurrent domains.\n\n## Contribution\n\nAd-Hoc Polymorphism is introduced to the Simply Typed Lambda Calculus by pluralizing lambda abstractions.\nTerms such as `λx:X. y` are represented instead as `λ⟨x:X. y⟩`.\nPlural abstractions are represented with more braces: `λ⟨a:A. b⟩⟨x:X. y⟩`.\nThe type system is also extended slightly to support plural types: `A + B`.\n\n## Types\n\n$$abstraction \\quad \\frac{\\Gamma \\vdash a:A \\quad \\Gamma \\vdash b:B \\quad \\Gamma \\vdash x:X \\quad \\Gamma \\vdash y:Y \\quad λ⟨a.b⟩⟨x.y⟩}{\\Gamma \\vdash λ⟨a.b⟩⟨x.y⟩:(A \\to B) + (X \\to Y)}$$\n\n$$application \\quad \\frac{\\Gamma \\vdash f:(A \\to B) + (C \\to D) + (X \\to Y) \\quad \\Gamma \\vdash x:A + X \\quad f(x)}{\\Gamma \\vdash f(x):B + Y}$$\n\n## Evaluation\n\nRules for evaluation are mostly the same as lambda calculus with the exception of plural arrows that may *carry* multiple values at a time. This feature leads to the possibility of plural values which may diverge in new ways.\n\nExample split (singular value yields plural):\n```punc\nλ⟨a:Int.True⟩⟨x:Int.x⟩ 3\n---------------------------------\n⟨True⟩⟨3⟩\n```\n\nExample merge (plural value yields singular):\n```punc\nλ⟨a:Bool.2⟩⟨x:Int.2⟩ (⟨False⟩⟨5⟩)\n---------------------------------\n⟨2⟩\n```\n\nExample carry (plural value yields plural):\n```punc\nλ⟨a:Bool.not a⟩⟨x:Int.- x 2⟩ (⟨False⟩⟨5⟩)\n---------------------------------\n⟨True⟩⟨3⟩\n```\n\n## Optional Constraints\n\nIt may often be desirable to entirely prevent plural values.\nThis would require the type system to show that no splits will happen, which are always the root cause of plural values.\nNotice that plural types always have plural values.\n\n$$ban \\ plurals \\quad \\frac{\\Gamma \\vdash f:(A \\to B)+(A \\to C) \\quad \\Gamma \\vdash x:A \\quad \\Gamma \\vdash f(x)}{\\Gamma \\vdash \\bot}$$\n\nBanning plurals still permits ad-hoc polymorphism in the *either-or* cases.\n\n## Notes\n\n\"Plural Types\" are similar to product types plus the implicit subtyping relations that `A + B ⇒ A` and `A + B ⇒ B`.\nTypes are either singular or plural, never both.\nIf you want to turn `A + B` into a singular type, then you could write it as its corresponding product: `(A,B)`.\n\n## Direct Citations\n\n[A very brisk introduction to Type Theory](https://ncatlab.org/nlab/show/type+theory)\n\n## Similar Work\n\n[The Kernel of Ad Hoc Polymorphism](https://dspace.mit.edu/bitstream/handle/1721.1/106072/965197677-MIT.pdf)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrew-johnson-4%2FPunCalculus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrew-johnson-4%2FPunCalculus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrew-johnson-4%2FPunCalculus/lists"}