Code Monkey home page Code Monkey logo

dtt's Introduction

dtt experiments

Experimenting with Dependent Type Theory in Rust. The goal here is to attempt to lower MLT Terms to an SSA IR.

The core is extremely simple and as such a number of things need to be encoded.

Dependent Products:

Σ : Π A : U (A → U) → U′
Σ = λA : U . λB : A → U . Π C : U (Π x : A B(x) → C) → C

sigma = \A : U

Here are some examples:

N : Type 0
Z : N
S : forall _ : N -> N
three = \f : (forall _ : N -> N) => \x : N => (f (f (f x)))
check (three S)
check (three (three S))
eval ((three (three S)) Z)

running this code will produce:

(three S) : N -> N
(three (three S)) : N -> N
((three (three S)) Z)
    = (S (S (S (S (S (S (S (S (S Z)))))))))
    : N

Irrelevance

Thought: If irrelevant terms are erased, we can extract functions that don't need dependent types for computation but still benefit from type checking.

Vec T .n
val Vec : Π(x : Type 0) -> (.Π(l: C) -> Type 0)

val append : Vec T .n -> Vec T .m -> Vec T .(n + m)
append: Π(T: Type0) -> (
          .Π(n: Nat) -> (
            .Π(m: Nat) -> (
              Π(_:Vec T .n) -> (
                Π(_:Vec T .m) -> (
                  Vec T .(+ n m)
                )
              )
            )
          )
        )

val erased_Vec : Π(x : Type 0) -> Type 0
val erased_append : Vec T -> Vec T -> Vec T
erased_append : Π(T: Type0) -> (
                  Π(_:Vec T) -> (
                    Π(_:Vec T) -> (
                      Vec T
                    )
                  )
                )

Erasing Π Types

Π(x : Type 0) -> (.Π(l: C) -> Type 0)
Π(x : Type 0) -> Type 0

.Π(x:X) -> T ==> .T, erroring if .T depends on x

Erasing λ Expressions

.λ(x:X) => E ==> .E, erroring if .E depends on x

Erasing Applications

((Vec T) .n)
(Vec T)

.(a b) ==> .a, erroring if .a requires a parameter

References

dtt's People

Contributors

phase avatar

Stargazers

Jason avatar  avatar Xiyu Zhai avatar Jason Manuel avatar Tim Kersey avatar Brendan Zabarauskas avatar Luis avatar Thomas Murphy avatar William avatar RJ Larson avatar SeungheonOh avatar Andrejs Agejevs avatar  Jaewon Seo avatar 김회준 avatar  avatar Sidharth Kulkarni avatar Yegor Wienski avatar  avatar Ilmari Vacklin avatar ebigram avatar Andrew N avatar Nikita avatar Alex Arslan avatar

Watchers

James Cloos avatar  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.