GithubHelp home page GithubHelp logo

5ht / formality Goto Github PK

View Code? Open in Web Editor NEW

This project forked from higherorderco/kind1

0.0 2.0 0.0 8.84 MB

An efficient proof language

Home Page: https://docs.formality-lang.org

License: MIT License

JavaScript 0.24% TypeScript 99.50% Nix 0.26%

formality's Introduction

An efficient proof-gramming language. It aims to be:

  • Fast: no garbage-collection, optimal beta-reduction and a massively parallel GPU compiler make it fast.

  • Safe: a type system capable of proving mathematical theorems about its own programs make it secure.

  • Portable: the full language is implemented in a 400-LOC runtime, making it easily available everywhere.

Check the official documentation, browse our base-libraries and come hang out with us on Telegram.

Examples

  • Adding all numbers of a list:

    sum(xs : List(Number)) : Number
      case xs
      | nil  => 0
      | cons => xs.head .+. sum(xs.tail)
  • A proof that negating a bool twice returns the same bool:

    not_not_is_same(b : Bool) : not(not(b)) == b
      case b
      | true  => refl(__)
      | false => refl(__)
      : not(not(b)) == b
  • Extracting the first element of a list statically checked to be non-empty:

    safe_head(A; xs: List(A), e: length(_ xs) != 0n) : A
      case xs
      + e : length(_ xs) != 0n
      | nil  => absurd(e(refl(__)), _) -- provably unreachable!
      | cons => xs.head

Usage

Multiple implementations (Haskell, Rust, Go, etc.) will be available in a future. Right now, you can already use the JavaScript one (requires Node v0.12).

Install it via npm with:

$ npm i -g formality-lang

Or via nix, using node2nix, we can also install Formality using the Nix package manager:

$ git clone [email protected]:moonad/Formality.git
$ cd Formality
$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable
$ nix-env -f '<unstable>' -iA nodePackages.node2nix
$ node2nix -d -i package.json --nodejs-12
$ nix-env -i -f override.nix

It can be used from the terminal with the fm command, or as a library with require("formality-lang").


Interaction-Net compilation

Formality is fully compiled to a 400-LOC Interaction-Net Runtime.

formality's People

Contributors

5ht avatar bamorim avatar courajs avatar erhannis avatar evaporei avatar g-guimaraes avatar gabriel-barrett avatar jimmyhmiller avatar johnchandlerburnham avatar lqd avatar maisamilena avatar michaelforney avatar shaunazzopardi avatar victortaelin avatar

Watchers

 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.