{"id":13993018,"url":"https://github.com/leanprover-community/ProofWidgets4","last_synced_at":"2025-07-22T16:33:27.144Z","repository":{"id":63303503,"uuid":"566256168","full_name":"leanprover-community/ProofWidgets4","owner":"leanprover-community","description":"Helper toolkit for creating your own Lean 4 UserWidgets","archived":false,"fork":false,"pushed_at":"2024-11-27T10:59:20.000Z","size":1077,"stargazers_count":116,"open_issues_count":14,"forks_count":27,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-11-28T23:31:36.195Z","etag":null,"topics":["lean","lean4","visualization"],"latest_commit_sha":null,"homepage":"","language":"Lean","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leanprover-community.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-15T09:42:25.000Z","updated_at":"2024-11-26T12:27:28.000Z","dependencies_parsed_at":"2023-02-17T22:01:06.011Z","dependency_job_id":"e5c21c72-623d-4f10-b1a6-2e4620fb600d","html_url":"https://github.com/leanprover-community/ProofWidgets4","commit_stats":null,"previous_names":["leanprover-community/proofwidgets4"],"tags_count":71,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover-community%2FProofWidgets4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover-community%2FProofWidgets4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover-community%2FProofWidgets4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover-community%2FProofWidgets4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leanprover-community","download_url":"https://codeload.github.com/leanprover-community/ProofWidgets4/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227143282,"owners_count":17737134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lean","lean4","visualization"],"created_at":"2024-08-09T14:02:12.318Z","updated_at":"2025-07-22T16:33:27.131Z","avatar_url":"https://github.com/leanprover-community.png","language":"Lean","funding_links":[],"categories":["Lean","Packages (Meta)"],"sub_categories":[],"readme":"# ProofWidgets\n\nProofWidgets is a library of user interface components for [Lean 4](https://leanprover.github.io/). It\nsupports:\n- symbolic visualizations of mathematical objects and data structures\n- data visualization\n- interfaces for tactics and tactic modes\n- alternative and domain-specific goal state displays\n- user interfaces for entering expressions and editing proofs\n\nAuthors: Wojciech Nawrocki, E.W.Ayers with contributions from Tomáš Skřivan\n\n### How does ProofWidgets relate to user widgets?\n\nProofWidgets relies on the [user widgets](https://leanprover.github.io/lean4/doc/examples/widgets.lean.html)\nmechanism built into Lean. User widgets provide the minimum of functionality needed to enable\ncustom user interfaces. ProofWidgets builds on top of this with a higher-level component library,\nsyntax sugar, and user-friendly abstractions. Stable parts of ProofWidgets may eventually be\nbackported into Lean core, but ProofWidgets overall will remain a separate library\nfor the foreseeable future.\n\n## Usage\n\n### Viewing the demos\n\nThe easiest way to get started is to clone a **release tag** of ProofWidgets and run\n`lake build :release`, as follows:\n\n```bash\n# You should replace v0.0.3 with the latest version published under Releases\ngit clone https://github.com/leanprover-community/ProofWidgets4 --branch v0.0.3\ncd ProofWidgets4/\nlake build :release\n```\n\nAfter doing this you will hopefully be able to view the demos in `ProofWidgets/Demos/`. Top tip: use\nthe pushpin icon (![pin](https://raw.githubusercontent.com/microsoft/vscode-codicons/31b33da05aab662f1973ba5667dad672c8e20fbc/src/icons/pin.svg))\nto keep a widget in view. You can then live code your widgets.\n\n### Using ProofWidgets as a dependency\n\nPut this in your `lakefile.lean`, making sure to reference a **release tag**\nrather than the `main` branch:\n\n```lean\n-- You should replace v0.0.3 with the latest version published under Releases\nrequire proofwidgets from git \"https://github.com/leanprover-community/ProofWidgets4\"@\"v0.0.3\"\n```\n\n[Developing ProofWidgets](#developing-proofwidgets) involves building TypeScript code with NPM.\nWhen depending on `ProofWidgets` but not writing any custom TypeScript yourself,\nyou likely want to spare yourself and your users from having to install and run NPM.\nProofWidgets is configured to use Lake's [cloud releases](https://github.com/leanprover/lake/#cloud-releases) feature\nwhich will automatically fetch pre-built JavaScript files *as long as* you require a release tag\nrather than the `main` branch.\nIn this mode, you and your users should not need to have NPM installed.\nHowever, fetching cloud release may sometimes fail,\nin which case ProofWidgets may still revert to a full build.\nYou can force ProofWidgets to fail with a custom error in this case by importing it like so:\n\n```lean\n-- You should replace v0.0.3 with the latest version published under Releases\nrequire proofwidgets with NameMap.empty.insert `errorOnBuild \"\u003cmy message\u003e\" from git \"https://github.com/leanprover-community/ProofWidgets4\"@\"v0.0.3\"\n```\n\n⚠️ [EXPERIMENTAL] To use ProofWidgets4 JS components in widgets defined in other Lean packages,\nyou can import [@leanprover-community/proofwidgets4](https://www.npmjs.com/package/@leanprover-community/proofwidgets4) from NPM.\n\n## Features\n\n![Red-black tree](doc/infoview-rbtree.png)\n\n### JSX-like syntax\n\n```lean\nimport ProofWidgets.Component.HtmlDisplay\nopen scoped ProofWidgets.Jsx\n\n-- click on the line below to see it in your infoview!\n#html \u003cb\u003eYou can use HTML in Lean {.text s!\"{1 + 3}\"}!\u003c/b\u003e\n```\n\nSee the `Jsx.lean` and `ExprPresentation.lean` demos.\n\n### Support for libraries\n\nWe have good support for building diagrams with [Penrose](https://penrose.cs.cmu.edu/), and expose\nsome [Recharts](https://recharts.org/en-US/) components for plotting functions and other kinds of\ndata. See the `Venn.lean` and `Plot.lean` demos.\n\nFor more purpose-specific integrations of libraries see the `Rubiks.lean` and `RbTree.lean` demos.\n\n### Custom `Expr` displays\n\nJust like delaborators and unexpanders allow you to customize how expressions are displayed as text,\nProofWidgets allows \"delaborating\" into (potentially interactive) HTML. See the\n`ExprPresentation.lean` demo.\n\n### Multi-stage interactions\n\nProof widgets can be used to create proving loops involving user interactions and running tactics\nin the background. See the `LazyComputation.lean` demo, and the `Conv.lean` demo for an example of\nediting the proof script.\n\n### Animated HTML\n\nAs a hidden feature, you can also make animated widgets using the `AnimatedHtml` component. This\nworks particularly well with libraries that ease between different plots, for example Recharts.\nYou can see an example of how to do this in the `Plot.lean` demo.\n\n## Developing ProofWidgets\n\n**Contributions are welcome!** Check out issues tagged with \"good first issue\".\n\nThe package consists of widget user interface modules written in TypeScript (under `widget/`),\nand Lean modules (under `ProofWidgets/`).\nTo build ProofWidgets from source,\nyou must have NPM (the [Node.js](https://nodejs.org/en) package manager) installed.\nDuring a build, we first compile the TypeScript widget code using NPM,\nand afterwards build all Lean modules.\nLean modules may use TypeScript compilation outputs.\nThe Lakefile handles all of this, so executing `lake build` should suffice to build the entire package.\nIn order to build only the TypeScript, run `lake build widgetJsAll`.\nWidgets can also be built in development mode using `lake build widgetJsAllDev`.\nThis makes them easier to inspect in developer tools.\n\n💡 The NPM part of the build process may sometimes fail with missing packages.\nIf this happens, run `npm clean-install` in the `widget/` directory and then try `lake build` again.\n\nWe use the `include_str` term elaborator\nto splice the minified JavaScript\nproduced during the first part of the build (by `tsc` and Rollup)\ninto ProofWidgets Lean modules.\nThe minifed JS is stored in `.lake/build/js/`.\nModifying any TypeScript source will trigger a rebuild,\nand should correctly propagate the new minified code\nto where it used in Lean.\n\n⚠️ Note however that due to Lake issue [#86](https://github.com/leanprover/lake/issues/86),\n*all* the widget sources are rebuilt whenever any single one changes,\nwhich might take a while.\n\n## Cite\n\nWe have written [a paper describing the design of ProofWidgets4](https://drops.dagstuhl.de/opus/volltexte/2023/18399/).\n\nIf this work helps you in your own research, you can cite it as follows:\n```bibtex\n@InProceedings{nawrocki_et_al:LIPIcs.ITP.2023.24,\n  author =\t{Nawrocki, Wojciech and Ayers, Edward W. and Ebner, Gabriel},\n  title =\t{{An Extensible User Interface for Lean 4}},\n  booktitle =\t{14th International Conference on Interactive Theorem Proving (ITP 2023)},\n  pages =\t{24:1--24:20},\n  series =\t{Leibniz International Proceedings in Informatics (LIPIcs)},\n  ISBN =\t{978-3-95977-284-6},\n  ISSN =\t{1868-8969},\n  year =\t{2023},\n  volume =\t{268},\n  editor =\t{Naumowicz, Adam and Thiemann, Ren\\'{e}},\n  publisher =\t{Schloss Dagstuhl -- Leibniz-Zentrum f{\\\"u}r Informatik},\n  address =\t{Dagstuhl, Germany},\n  URL =\t\t{https://drops.dagstuhl.de/opus/volltexte/2023/18399},\n  URN =\t\t{urn:nbn:de:0030-drops-183991},\n  doi =\t\t{10.4230/LIPIcs.ITP.2023.24},\n  annote =\t{Keywords: user interfaces, human-computer interaction, Lean}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleanprover-community%2FProofWidgets4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleanprover-community%2FProofWidgets4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleanprover-community%2FProofWidgets4/lists"}