Git Product home page Git Product logo

jvm.agda's Introduction

Intrinsically-Typed Compilation with Nameless Labeles

Or "One PRSA To Bind Them All"

To avoid compilation errors it is desired to verify that a compiler is type correct---i.e., given well-typed source code, it always outputs well-typed target code. We present an approach to verify type correctness of a compiler intrinsically by implementing it as a function in the dependently-typed programming language Agda.

A key challenge in implementing a compiler intrinsically is the representation of labels in bytecode. Because label names are global, bytecode typing appears inherently a non-compositional, whole-program property. The individual operations of the compiler do not preserve this property.

We address this problem using a new nameless and typed global label binding. Our key idea is to use linearity to ensure that all labels are bound exactly once. We develop a linear, dependently-typed, shallowly embedded language in Agda, based on separation logic. And implement intrinsically-typed operations on bytecode, culminating in an intrinsically-typed compiler for a language with structured control-flow.

Browsing the code

In the distributed source we included a html version of the code that hyperlinks definitions in doc/. The index is Everything.html.

Type-checking the code

This repository relies heavily on Agda's instance search to get overloaded syntax for the separation logic connectives and primitives. Unfortunately stable Agda contains a performance bug related to these. The repository thus requires fixes that are only in Agda master (to be released in 2.6.2).

To install, follow the instructions from the official documentation here. The lastest commit that we tested was 552987aa0119.

Don't forget to (setq agda-mode-path ..) to the output agda-mode --locate if you are using emacs and have a fixed agda-mode path set. Instructions on the emacs-mode can be found here.

A good place to start exploring the codebase is Everything.agda, which links to all the moving parts and relates them to the paper. The usual way to type-check Agda code is to load it in emacs, and load the file with C-c C-l. On the commandline, the code can be checked with make.

Compiling the examples

Lacking a frontend, we include two example programs embedded in Agda. These programs can be compiled with make examples. The binaries that output print the resulting bytecode will be output in ./_build/bin. The compilation makes use of the haskell tool stack, which needs to be installed prior.

jvm.agda's People

Contributors

ajrouvoet avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.