Skip to content

Instantly share code, notes, and snippets.

@corwin-of-amber
Created January 29, 2021 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corwin-of-amber/49abf4b49f257e29279a2b156bda73f5 to your computer and use it in GitHub Desktop.
Save corwin-of-amber/49abf4b49f257e29279a2b156bda73f5 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<script src="./node_modules/jscoq/ui-js/jscoq-loader.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
class Observer {
constructor() {
this.when_ready = new Promise(resolve => this._ready = resolve);
}
coqReady() { this._ready(); }
coqGoalInfo(sid, goals) {
var bar = `\n${"-".repeat(60)}\n`
console.log(bar, goals, bar);
$('body').append(this.pprint.goals2DOM(goals));
}
}
var coq, pm, o = new Observer;
(async () => {
await JsCoq.load();
coq = new CoqWorker();
pm = new PackageManager(document.createElement('div'), /* need a div, sry */
{'node_modules/jscoq/coq-pkgs/': ['coq']}, {}, coq);
coq.options.debug = true;
coq.options.warn = false; // will silence warnings about unhandled messages
coq.observers.push(o);
// Load packages
await coq.when_created;
await pm.populate();
await pm.loadDeps(['coq']);
// Initialize document
coq.init({}, {lib_init: [["Coq", "Init", "Prelude"]], lib_path: pm.getLoadPath()})
await o.when_ready;
// Pretty-printer to format messages and goals
o.pprint = new FormatPrettyPrint();
// Do some proofs
coq.add(1, 2, "Goal 3 = 3.");
await coq.execPromise(2);
coq.goals(2);
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment