{"id":19637206,"url":"https://github.com/seeker04/stlc-agda-elab","last_synced_at":"2026-02-14T02:38:49.670Z","repository":{"id":206580129,"uuid":"670370879","full_name":"Seeker04/stlc-agda-elab","owner":"Seeker04","description":"Agda formalisation of an elaborator for a simply typed language","archived":false,"fork":false,"pushed_at":"2024-06-26T17:39:41.000Z","size":5226,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-09T17:03:37.382Z","etag":null,"topics":["agda","elaboration","formalization","lambda-calculus"],"latest_commit_sha":null,"homepage":"","language":"Agda","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/Seeker04.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-24T22:55:33.000Z","updated_at":"2024-11-09T12:03:58.000Z","dependencies_parsed_at":"2023-11-15T23:25:28.060Z","dependency_job_id":"6192827c-4285-4870-86f2-ba228ab8b0b1","html_url":"https://github.com/Seeker04/stlc-agda-elab","commit_stats":null,"previous_names":["seeker04/stlc-agda-elab"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seeker04%2Fstlc-agda-elab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seeker04%2Fstlc-agda-elab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seeker04%2Fstlc-agda-elab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seeker04%2Fstlc-agda-elab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Seeker04","download_url":"https://codeload.github.com/Seeker04/stlc-agda-elab/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240941503,"owners_count":19882062,"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":["agda","elaboration","formalization","lambda-calculus"],"created_at":"2024-11-11T12:33:39.345Z","updated_at":"2025-10-03T21:03:14.508Z","avatar_url":"https://github.com/Seeker04.png","language":"Agda","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Agda formalisation of an elaborator for a language based on simply typed lambda calculus\n\n## Abstract\n\nProgramming languages are the backbone of software development. Defining them with mathematical rigorousness in a formal framework can help us better understand and reason about them. One way of explaining languages is through the process of elaboration. It refines the concept of the language from broader ideas such as strings and lexical tokens to more concrete and strict ones like syntax trees and well-typed terms.\n\nThis thesis aims to walk the reader through each step of such an elaboration. Our method is an extension to an existing formalisation of a simple language. We go from source code by lexical analysis to a list of tokens, then by parsing to an abstract syntax tree, which is followed by scope checking leading to an abstract binding tree. Finally, we present a bidirectional type checking algorithm which turns the binding tree to a well-typed term of our language. We apply a correct by construction approach by 1.) formalising all levels and the algorithms between them in type theory using Agda, 2.) constructing terms with an algebraic description, which cannot be badly typed by definition.\n\nOur language is based on simply typed lambda calculus with the function space having finite types: booleans, nullary/binary products and sums; inductive types: naturals, lists, trees (and their iterators); coinductive types: streams and simple state machines; a few additional operators.\n\nWe discuss both the benefits and difficulties of the presented solution. The study is concluded by ideas on how our framework can be extended or improved.\n\n**Keywords:** lambda-calculus, Agda, formalisation, elaboration, parsing, typechecking\n\n## About\n\nThis project started as an extension to an existing formalisation. The quotiented well-typed description that you can see in [STLC.agda](src/STLC.agda) was written by Ambrus Kaposi [here](https://bitbucket.org/akaposi/typesystems/src/master/).\n\nIf you wish to see the commits of the elaborator from before going independent, you can find them [in this fork](https://bitbucket.org/zahoranb/typesystems/commits/).\n\nYou can read my MSc thesis in [STLC-elaboration-in-Agda.pdf](thesis/STLC-elaboration-in-Agda.pdf), view the presentation in [slides.pdf](slides/slides.pdf) and browse the source code in [src](src).\n\n## Installation\n\nThis project requires [Agda version 2.6.2.2](https://wiki.portal.chalmers.se/agda/Main/Download).\n\nHere is a method to install:\n```bash\n# from https://www.haskell.org/ghcup/\ncurl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh\ncabal update\ncabal install alex happy\ncabal install Agda-2.6.2.2\n```\n\nThe following libraries are also required:\n\n* [agda-stdlib-1.7.1](https://github.com/agda/agda-stdlib/releases)\n* [agdarsec-0.5.0](https://github.com/gallais/agdarsec/releases)\n\n1. Make sure to download the correct versions, i.e., `1.7.1` and `0.5.0`, respectively\n\n2. Follow the steps of the [stdlib install guide](https://github.com/agda/agda-stdlib/blob/master/notes/installation-guide.md)\n\n3. Also, add the agdarsec path next to the stdlib one in your `$HOME/.agda/libraries`:\n```\n\u003cdownload-location\u003e/agda-stdlib-1.7.1/standard-library.agda-lib\n\u003cdownload-location\u003e/agdarsec-0.5.0/agdarsec.agda-lib\n```\n\nNow you should be able to typecheck the project.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseeker04%2Fstlc-agda-elab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseeker04%2Fstlc-agda-elab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseeker04%2Fstlc-agda-elab/lists"}