Giter VIP home page Giter VIP logo

jscoq's Introduction

Run the Coq Proof Assistant in your browser!

Build Status Gitter

jsCoq is an Online Integrated Development Environment for the Coq proof assistant and runs in your browser! We aim to enable new UI/interaction possibilities and to improve the accessibility of the Coq platform itself. Current stable version is jsCoq v8.10+0.10.0~beta supporting Coq 8.10, try it:

https://jscoq.github.io

JsCoq is written in ES2017, thus any recent standard-compliant browser should work. jsCoq also runs in my 8-year old Galaxy Nexus. Browser performance is quite variable these days, see the Troubleshooting section if you have problems.

Coq is compiled to JavaScript using the js_of_ocaml compiler. No servers or external programs are needed. We want to strongly thank the js_of_ocaml developers. Without their great and quick support jsCoq wouldn't have been possible.

Basic Usage

The main page showcases jsCoq by walking through a proof for the infinitude of primes using math-comp, due to Georges Gonthier. Once jsCoq finishes loading, you can step through the proof using the arrow buttons on the toolbar (top right), or using these keyboard shortcuts:

Shortcut Action
Alt-N or Alt-↓ Go to next
Alt-P or Alt-↑ Go to previous
Alt-Enter or Alt-→ Go to cursor

You can open a blank editor and experiment with your own Coq developments using the scratchpad. The same keyboard shortcuts apply here.

The scratchpad's contents are saved in your browser's local storage (IndexedDB, specifically), so they are not lost if you close the browser window or refresh the page. You can, in fact, store more than one document using the local open/save file dialogs:

Shortcut Action
Ctrl-S Save file (with the last name provided, or untitled.v)
Ctrl-Shift-S Save file as (prompts for file name)
Ctrl-O Open file (prompts for file name, supports tab completion)
Ctrl-Alt-O Open file from disk (using the browser's Open dialog)

On Mac, replace Ctrl with ⌘ (command) and Alt with ⌥ (option), as is traditional.

Development Version

Development for jsCoq 0.10 takes place in the v8.10 branch. A preview build of jsCoq 0.10 is usually available at:

https://x80.org/rhino-coq/v8.10/

jsCoq is easy to develop using the Chrome developer tools; the jsCoq object has a debug flag, and it is possible to compile Coq with debug information by setting the makefile variable JSCOQ_DEBUG=yes.

Previous Coq versions can be accessed at:

Publications

A paper describing the ideas behind jsCoq has been published in the proceeding of the UITP 2016 workshop. The paper is available from the open access EPTCS proceedings. The recommended citation is:

@Inproceedings{gallego:uitp2016,
  author    = {Gallego Arias, Emilio Jes\'us and Pin, Beno\^it and Jouvelot, Pierre},
  year      = {2017},
  title     = {{jsCoq}: Towards Hybrid Theorem Proving Interfaces},
  editor    = {Autexier, Serge and Quaresma, Pedro},
  booktitle = {{\rmfamily Proceedings of the 12th Workshop on} User Interfaces for Theorem Provers,
               {\rmfamily Coimbra, Portugal, 2nd July 2016}},
  series    = {Electronic Proceedings in Theoretical Computer Science},
  volume    = {239},
  publisher = {Open Publishing Association},
  pages     = {15-27},
  doi       = {10.4204/EPTCS.239.2},
  issn      = {2075-2180}
}

Some further ideas behind jsCoq are also discussed in SerAPI: Machine-Friendly, Data-Centric Serialization for COQ. Technical Report

Collacoq

A small pastebin-like server based on haste is available at https://x80.org/collacoq. Note that this service is totally experimental, data loss is guaranteed.

See also the branch at https://github.com/ejgallego/haste-server/tree/collacoq Help with Collacoq is very welcome!

Troubleshooting

Are you getting a StackOverflow exception? Unfortunately these are hard to fix; you may be stuck with them for a while.

  • Clearing the browser cache usually solves lots of issues.
  • Change browser, if using Firefox try Chrome, if using Chrome try Firerox.
  • Consider using --js-flags="--stack-size=65536" in Chrome if you get StackOverflows.
  • Use the --js-flags="--harmony-tailcalls" command line flag.
  • Enable the chrome://flags/#enable-javascript-harmony flag if you get StackOverflows.

API / How to embed in your own webpage

JsCoq provides a coqManager javascript object for embedding Coq in your particular application, blog, or webpage. The basic pattern to add jsCoq to webpage with Coq code is:

  <script src="$path/ui-js/jscoq-loader.js" type="text/javascript"></script>
  <script type="text/javascript">
    loadJsCoq($path).then( () => new CoqManager ($list_of_ids, {$options}) );
  </script>

where $path is the path the jsCoq distribution, $list_of_ids is the list of textareas that will form the Coq document. See below for available $options.

The jsCoq landing webpage is a good running example.

Options

JsCoq accepts the following options as an optional second parameter to the CoqManager constructor:

Key Type Default Description
base_path string './' Path where jsCoq is installed.
wrapper_id string 'ide-wrapper' Id of <div> element in which the jsCoq panel is to be created.
all_pkgs array of string (see below) List of available packages that will be listed in the packages panel.
init_pkgs array of string ['init'] Packages to load at startup.
prelude boolean true Load the Coq prelude (Coq.Init.Prelude) at startup. (If set, make sure that init_pkgs includes 'init'.)
implicit_libs boolean false Allow Requireing modules by short name only (e.g., Require Arith.).
theme string 'light' IDE theme to use; includes icon set and color scheme. Supported values are 'light' and 'dark'.
file_dialog boolean false Enables UI for loading and saving files (^O/^S, or ⌘O/⌘S on Mac).
editor object {} Additional options to be passed to CodeMirror.
coq object {} Additional Coq option values to be set at startup.

The list of available packages defaults to all Coq libraries and addons available with the current version of jsCoq. At the moment, it is:

['init', 'coq-base', 'coq-collections', 'coq-arith', 'coq-reals',  
 'math-comp', 'elpi', 'equations', 'ltac2',
 'coquelicot', 'flocq', 'lf', 'plf', 'cpdt', 'color']

The editor property may contain any option supported by CodeMirror (see here).

The coq property may hold a list of Coq properties mapped to their values, and is case sensitive (see here). For example:

{'Implicit Arguments': true, 'Default Timeout': 10}

Examples

The main page includes a proof of the infinitude of primes by G. Gonthier. We provide some more examples as a showcase of the tool:

Outdated examples [but still working]

CoqDoc

A coqdoc replacement that is better suited to produce jsCoq output while (mostly) remaining compatible is being developed at https://github.com/ejgallego/udoc

It works OK for converting coqdoc files, but it may produce some artifacts and have bugs.

Mailing List

You can subscribe to the jsCoq mailing list at:

https://x80.org/cgi-bin/mailman/listinfo/jscoq

The list archives should be also available through Gmane at group:

gmane.science.mathematics.logic.coq.jscoq

you can post to the list using nntp.

Contributing

This is certainly an alpha-status project, but any contribution or comment is really welcome! Please submit your pull request for review to the mailing list using git request-pull. You can also submit a github PR, but it is not guaranteed that we'll look into it.

Reporting Bugs

Feel free to use the issue tracker. Please include your browser/OS/user-agent and command line options.

CodeMirror

CodeMirror has played a crucial role in the project, we are very happy with it, thanks a lot!

Please consider supporting the development of CodeMirror with a donation.

What is broken

  • Loading ML modules is slow.
  • Loading .vo files is slow.
  • There surely are threading and performance problems.
  • vm_compute and native_compute are devired to regular compute.

Contact & Sponsorship

FEEVER Logo

jsCoq has been make possible thanks to funding by the FEEVER project.

Contact: Emilio J. Gallego Arias e+jscoq at x80.org.

jsCoq Users:

Incomplete list of places where jsCoq has been used:

jsCoq in the press

How to Install/Build

You can download ready-to-use builds from https://github.com/ejgallego/jscoq-builds/ ; find below the instructions to build JsCoq yourself, it is reasonably easy:

$ git submodule update --remote
$ ./etc/toolchain-setup.sh
$ make coq
$ make jscoq

For more detailed description and prerequisites, see docs/Build.md.

Addon Packages:

One of jsCoq's strengths is its support for bundling addon packages. In order to add your Coq package to jsCoq, you need to add a definition file in the coq-addons repository. We recommend you use one of the existing files as a model.

Also, you need to define a jsCoq package by editing the coq-jslib//dftlibs.ml file. Once that is done, calling make jscoq agian.

Serialization

JsCoq used to support serialization to Json or Sexps for Coq's internal data structures, but this effort has been split to an independent development. See https://github.com/ejgallego/coq-serapi for more information.

Documents

See the etc/notes/ directory for some random notes about the project.

jscoq's People

Contributors

corwin-of-amber avatar ejgallego avatar gasche avatar pinbe avatar satyendrabanjare avatar tchajed 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.