A small, nutty dependently typed language.

Overview

pistachio


I want to learn about how theorem provers and dependently typed languages are implemented. This is a little repo for experimentation.

Things I want to learn about

  • Why normalization by evaluation?

    It seems the reason for this is efficiency, from (Christiansen, Checking Dependent Types with Normalization by Evaluation):

    One way to find the normal form of an expression would be to repeatedly traverse it, performing all possible β-reductions. However, this is extremely inefficient—first, a redex must be located, and then a new expression constructed by applying the β rule. Then, the context around the former redex must be reconstructed to point at the newly-constructed expression. Doing this for each and every redex is not particularly efficient, and the resulting code is typically not pleasant to read.

  • Does exposing interfaces to the elaborator enable typed metaprogramming?

  • What are the standard compilation techniques for a dependently typed language? Do they differ from normal functional techniques?

  • How do you compile elaborator strategies? Can you stage the interpreter?

  • How does a module system interact with elaboration?

  • How do computational effects interact with elaboration, and proofs?

  • From peridot, what does a dependently typed object language gain us?

    peridot is based on two-level type theory - something which I ultimately think I'll have to consider. The meta-language of peridot is a specially designed logic language for working with terms of the object-language. Crucially (and something I've recently realized), if the object language is dependently typed, we gain the ability to make statements about types and term equality! That means we can reason about the semantic correctness of optimizers written in the meta-language which take term to term (the meta-language is resolved completely at compile time).

    Ultimately, peridot has uncovered this very deep and useful idea using dependent types. From my perspective, I need to investigate the meta-language - determine if it is sufficient to express the types of transformations I wish to express.

    Another paper worth exploring here: Meta-F*: Proof Automation with SMT, Tactics, and Metaprograms

Why is this?

When it comes to dependent types, my main question is about runtime performance. Do dependent types provide a substrate for communicating with the compiler in a direct way? More generally, is it possible to construct a language system where metaprograms (optimizers, program transformers, etc) are also specified and checked?

If yes, it's possible that a language system like this could provide a useful basis for modern techniques in numerical method:s (like machine learning). There are plenty of new language papers on automatic differentation, including implementations via delimited continuations, and source-to-source program transformations, etc. Instead of building a transformation like this into the compiler, what's the right language platform to allow a library of metaprograms to implement fully specified AD.

Probabilistic programming is another area which motivates me. Large scale (repeated) inference often requires re-evaluating functions with small modifications to inputs. Static techniques have been developed for this use case -- and expressed by program transformers. What sort of language allows me to write these transformers in user-space?

The main downside of dependent types seems to be ergonomics: the implementation is complicated. Proving things is complicated. Exposing metaprogramming to programmers via elaboration extension also appears to be a complicated thing.

Prior art?

There's tons of related ideas here. Probably F* is the language which is "closest" to what I want. However, I don't understand how F* is implemented! At least for me, if I can't see how to implement it -- I don't understand it. So I want a small language which supports some of the features of F*:

  1. Functional and strict.
  2. Functional, but in place
  3. Metaprograms, via elaborator reflection.
  4. Effectful.

Ergonomics aside -- we can focus on (1, 3, 4) as "semantic" features of the language. (2) is how you make a language like this go fast. JIT compiling (3) is how you make metaprograms go fast.

The other system which is directly related to my ideas is peridot. The author of this language wants the user to be able to write the compiler in user-space! This is very close to what I want to achieve. Similar to F*, I don't understand peridot! Hence the experiments.

You might also like...
The Devils' Programming Language (Quantum Programming Language)

devilslang has roots in Scheme and ML-flavored languages: it's the culmination of everything I expect from a programming language, including the desire to keep everything as minimalistic and concise as possible. At its core, devilslang is lambda-calculus with pattern-matching, structural types, fiber-based concurrency, and syntactic extension.

:crab: Small exercises to get you used to reading and writing Rust code!
:crab: Small exercises to get you used to reading and writing Rust code!

rustlings 🦀 ❤️ Greetings and welcome to rustlings. This project contains small exercises to get you used to reading and writing Rust code. This inclu

Fegeya Elitebuild, small, powerful build system. Written in Rust.
Fegeya Elitebuild, small, powerful build system. Written in Rust.

Fegeya Elitebuild Small, powerful, work-in-progress build system. Written in Rust. Features: No functions (all are built-ins) All variables are global

This project contains small exercises to get you used to reading and writing Rust code
This project contains small exercises to get you used to reading and writing Rust code

rustlings 🦀 ❤️ Greetings and welcome to rustlings. This project contains small exercises to get you used to reading and writing Rust code. This inclu

Small programs written in Rust. Warm up for the upcoming Selenium Manager

Rust Examples This repository contains several example programs written in Rust. Selenium Manager These examples are used as warm up for the upcoming

A small utility for modifying ELF shared library loading order.

elfpromote A small utility for modifying ELF shared library loading order. Usage $ cargo install elfpromote $ ldd blueboat_server linux-vdso.s

A small in-memory key value database for rust

SmollDB Small in-memory key value database for rust This is a small in-memory key-value database, which can be easly backed up in a file or stream and

`memory_pages` is a small library provinig a cross-platform API to request pages from kernel with certain premisions

memory_pages: High level API for low level memory management While using low-level memory management in a project can provide substantial benefits, it

RcLite: small, fast, and memory-friendly reference counting for Rust

RcLite: small, fast, and memory-friendly reference counting RcLite is a lightweight reference-counting solution for Rust that serves as an alternative

Owner
McCoy R. Becker
Bayesian brain-in-a-jar.
McCoy R. Becker
A statically-typed, interpreted programming language, with generics and type inference

Glide A programming language. Currently, this includes: Static typing Generics, with monomorphization Type inference on function calls func identity<T

Patrick Gu 1 Apr 10, 2022
The compiler for Gera, a statically typed and garbage collected programming language.

Gera The compiler for Gera, a satically typed and garbage collected programming language. Currently WIP (Work in progress). Progress This is a rough o

null 4 Oct 26, 2023
Make your IDs strongly typed!!

About TypedId introduces a single type, aptly named TypedId. This is a generic wrapper any type, often types that you would use as an identifier. Howe

Tyler Bloom 8 Sep 2, 2022
A typed map which can make sure item exist.

Certain Map A typed map which can make sure item exist. What Problem Does It Solve In Rust, we often use Service abstraction for modular structure des

ihc童鞋@提不起劲 27 Jun 26, 2023
Small ray tracer demo of the F# to Rust language transpiler in Fable 4.x

Small ray tracer demo of the F# to Rust language transpiler in Fable 4.x

null 45 Nov 16, 2022
Small, clean, easy to use programming language

Thistle A modern, simplistic multi-paradigm language supporting object-oriented features Hello World! import IO object Main def main(): unit

null 7 Apr 13, 2022
A repository for showcasing my knowledge of the Rust programming language, and continuing to learn the language.

Learning Rust I started learning the Rust programming language before using GitHub, but increased its usage afterwards. I have found it to be a fast a

Sean P. Myrick V19.1.7.2 2 Nov 8, 2022
Nyah is a programming language runtime built for high performance and comes with a scripting language.

?? Nyah ( Unfinished ) Nyah is a programming language runtime built for high performance and comes with a scripting language. ??️ Status Nyah is not c

Stacker 3 Mar 6, 2022
Mewl, program in cats' language; A just-for-fun language

Mewl The programming language of cats' with the taste of lisp ?? What,Why? Well, 2 years ago in 2020, I created a esoteric programming language called

Palash Bauri 14 Oct 23, 2022
lelang programming language is a toy language based on LLVM.

lelang leang是一门使用Rust编写,基于LLVM(inkwell llvm safe binding library)实现的编程语言,起初作为课程实验项目,现在为个人长期维护项目。 Target Features 支持8至64位的整形类型和32/64位浮点 基本的函数定义,调用,声明外部

Aya0wind 5 Sep 4, 2022