Skip to content
Snippets Groups Projects
index.html 8.33 KiB
Newer Older
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta name="description" content="An Online IDE for the Coq Theorem Prover" />
Shachar Itzhaky's avatar
Shachar Itzhaky committed
    <link rel="icon" href="ui-images/favicon.ico">
    <link rel="stylesheet" type="text/css" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
    <style>
      kbd { background: #0003; color: #333; font-size: 80%; }
      table.doc-actions th, table.doc-actions td {
        padding: .2em .5em;
        vertical-align: top;
        border: 1px solid #999;
      }
      table.doc-actions td {
        padding-bottom: .25em;
      }
      h4 {
        background: #f6f9f9;
        padding: 3px;
        color: #089;
        margin-top: 1em;
      }
      h5 {
        margin-top: 12px;
        margin-bottom: 7px;
        font-size: 110%;
        font-style: italic;
        color: #089;
      }
      span.jscoq-name {
        color: #363;
      }
      #team {
        margin-top: 2em;
        border: 1px solid #eee;
        padding: 5px;
      }
    </style>
    <title>jsCoq – Use Coq in Your Browser</title>
<body class="jscoq-main">
  <div id="ide-wrapper" class="toggled">
  <div id="code-wrapper">
  <div id="document">
  <div>
    <h3>Welcome to the <span class="jscoq-name">jsCoq</span> Interactive Online System!</h3>
      Welcome to the <span class="jscoq-name">jsCoq</span> technology demo!
      <span class="jscoq-name">jsCoq</span> is an interactive,
      web-based environment for the Coq Theorem prover, and is a collaborative
      development effort. See the <a href="#team">list of contributors</a>
      below.
      <span class="jscoq-name">jsCoq</span> is open source. If you find any problem or want to make
      any contribution, you are extremely welcome! We await your
      feedback at <a href="https://github.com/ejgallego/jscoq">GitHub</a>
      and <a href="https://gitter.im/jscoq/Lobby">Gitter</a>.
    <h4>Instructions:</h4>
    <p>
      The following document contains embedded Coq code.
      All the code is editable and can be run directly on the page.
      Once <span class="jscoq-name">jsCoq</span> finishes loading, you are
      free to experiment by stepping through the proof and viewing intermediate
      proof states on the right panel.
    </p>
    <h5>Actions:</h5>
    <table class="doc-actions">
      <tr><th>Button</th><th>Key binding</th><th>Action</th></tr>
      <tr>
        <td><img src="ui-images/down.png" height="15px"><img src="ui-images/up.png" height="15px"></td>
        <td>
          <kbd>Alt</kbd>+<kbd></kbd>/<kbd></kbd> or<br/>
          <kbd>Alt</kbd>+<kbd>N</kbd>/<kbd>P</kbd>
        </td>
        <td>Move through the proof.</td>
      </tr>
      <tr>
        <td><img src="ui-images/to-cursor.png" height="20px"></td>
        <td>
          <kbd>Alt</kbd>+<kbd>Enter</kbd> or<br/> <kbd>Alt</kbd>+<kbd></kbd>
        </td>
        <td>Run (or go back) to the current point.</td>
      </tr>
      <tr>
        <td><img src="ui-images/power-button-512-black.png" height="20px"></td>
        <td><kbd>F8</kbd></td>
        <td>Toggles the goal panel.</td>
      </tr>
    </table>
    <h5>Saving your own proof scripts:</h5>
      The <a href="examples/scratchpad.html">scratchpad</a> offers simple, local
      storage functionality.
      Please go to <a href="https://x80.org/collacoq/">CollaCoq</a> if
      you want to share your developments with other users.
    <h4>A First Example: The Infinitude of Primes</h4>
      We don't provide a Coq tutorial (yet), but as a showcase, we
      display a proof of the infinitude of primes in Coq.  The proof relies
      in the Mathematical Components library by the
      <a href="http://ssr.msr-inria.inria.fr/">MSR/Inria</a> team led
      by Georges Gonthier, so our first step will be to load it and
      set a few Coq options:
    </p>
  </div>
  <div>
    <textarea id="addnC" >
From Coq Require Import ssreflect ssrfun ssrbool.
From mathcomp Require Import eqtype ssrnat div prime. </textarea>
    <h5>Ready to do Proofs!</h5>
      Once the basic environment has been set up, we can proceed to
      the proof:
    </p>
  </div> <!-- panel-heading -->
  <div>
    <textarea id="prime_above1" >
(* A nice proof of the infinitude of primes, by Georges Gonthier *)
Lemma prime_above m : {p | m < p & prime p}.
Proof. </textarea>
    <p>
Shachar Itzhaky's avatar
Shachar Itzhaky committed
      The lemma states that for any number <code>m</code>,
      there is a prime number larger than <code>m</code>.

      Coq is a <em>constructive system</em>, which among other things
      implies that to show the existence of an object, we need to
      actually provide an algorithm that will construct it.

      In this case, we need to find a prime number <code>p</code>
Shachar Itzhaky's avatar
Shachar Itzhaky committed
      that is greater than <code>m</code>.
      What would be a suitable <code>p</code>?
Shachar Itzhaky's avatar
Shachar Itzhaky committed
      Choosing <code>p</code> to be the first prime divisor of <code>m! + 1</code>
      works.
      As we will shortly see, properties of divisibility will imply that
      <code>p</code> must be greater than <code>m</code>.
    </p>
    <textarea id="prime_above2" >
have /pdivP[p pr_p p_dv_m1]: 1 < m`! + 1
  by rewrite addn1 ltnS fact_gt0.</textarea>
    <p>
      Our first step is thus to use the library-provided lemma
      <code>pdivP</code>, which states that every number is divided by a
      prime. Thus, we obtain a number <code>p</code> and the corresponding
      hypotheses <code>pr_p : prime p</code> and <code>p_dv_m1</code>,
      "p divides m! + 1".
      The ssreflect tactic <code>have</code> provides a convenient way to
      instantiate this lemma and discard the side proof obligation
      <code>1 &lt; m! + 1</code>.
    </p>
    <textarea id="prime_above3" >
exists p => //; rewrite ltnNge; apply: contraL p_dv_m1 => p_le_m.</textarea>
    <p>
      It remains to prove that <code>p</code> is greater than <code>m</code>.
      contraposition with the divisibility hypothesis, which gives us
      the goal "if <code>p ≤ m</code> then <code>p</code> is not a prime divisor of 
      <code>m! + 1</code>".
    </p>
    <textarea id="prime_above4" >
by rewrite dvdn_addr ?dvdn_fact ?prime_gt0 // gtnNdvd ?prime_gt1.
    <p>
      The goal follows from basic properties of divisibility, plus
      from the fact that if <code>p ≤ m</code>, then <code>p</code> divides
      <code>m!</code>, so that for <code>p</code> to divide
      <code>m! + 1</code> it must also divide 1,
      in contradiction to <code>p</code> being prime.
    </p>
    <hr/>
    <span class="jscoq-name">jsCoq</span> provides many other packages,
    including Coq's standard library and the
    <a href="https://math-comp.github.io"></a>mathematical components</a>
    library.
    Feel free to experiment, and bear with the beta status of this demo.
  </p>
  </div> <!-- /#panel body -->
  <div id="team">
    <a name="team"></a>
      <p><i>The dev team</i></p>
    <ul>
      <li>
        <a href="https://www.irif.fr/~gallego/">Emilio Jesús Gallego Arias</a>
        (<a href="https://www.inria.fr">Inria</a>,
         <a href="https://u-paris.fr">Université de Paris</a>,
         <a href="https://www.irif.fr">IRIF</a>)
      </li>
      <li>
        <a href="https://www.cs.technion.ac.il/~shachari/">Shachar Itzhaky</a>
        (<a href="https://cs.technion.ac.il">Technion</a>)
      </li>
    </ul>
    <p><i>Contributors</i></p>
    <ul>
      <li>
        Benoît Pin
        (<a href="https://www.cri.ensmp.fr/">CRI</a>,
         <a href="http://www.mines-paristech.eu">MINES ParisTech</a>)
      </li>
    </ul>
  </div>
  </div> <!-- /#document -->
  </div> <!-- /#code-wrapper -->
  </div> <!-- /#ide-wrapper -->

  <script src="ui-js/jscoq-loader.js" type="text/javascript"></script>
  <script type="text/javascript">
    var jscoq_ids  = ['addnC', 'prime_above1', 'prime_above2', 'prime_above3', 'prime_above4' ];
    var jscoq_opts = {
        focus: false,
        base_path: './',
        editor: { mode: { 'company-coq': true }, keyMap: 'default' },
        init_pkgs: ['init'],
        all_pkgs:  ['coq', 'mathcomp', 'equations', 'elpi', 'quickchick', 'lf', 'plf']
    };

    /* Global reference */
    JsCoq.start(jscoq_ids, jscoq_opts).then(res => coq = res);
  </script>
</body>