Proof Assistant Projects
Collection
Digesting proof assistant libraries for AI ingestion. • 84 items • Updated • 3
fact string | type string | library string | imports list | filename string | symbolic_name string | docstring string |
|---|---|---|---|---|---|---|
widgetDir : FilePath := "widget" nonrec def Lake.Package.widgetDir (pkg : Package) : FilePath := pkg.dir / widgetDir | def | root | [
"import Lake"
] | lakefile.lean | widgetDir | null |
Lake.Package.runNpmCommand (pkg : Package) (args : Array String) : LogIO Unit := -- Running `cmd := "npm.cmd"` directly fails on Windows sometimes -- (https://github.com/leanprover-community/ProofWidgets4/issues/97) -- so run in PowerShell instead (`cmd.exe` also doesn't work.) if Platform.isWindows then proc { cmd := ... | def | root | [
"import Lake"
] | lakefile.lean | Lake.Package.runNpmCommand | null |
widgetJsAllTarget (pkg : Package) (isDev : Bool) : FetchM (Job Unit) := do let srcs ← widgetJsSrcs.fetch let rollupConfig ← widgetRollupConfig.fetch let tsconfig ← widgetTsconfig.fetch let widgetPackageLock ← widgetPackageLock.fetch /- `widgetJsAll` is built via `needs`, and Lake's default build order is `needs -> clou... | def | root | [
"import Lake"
] | lakefile.lean | widgetJsAllTarget | /-- Target to build all widget modules from `widgetJsSrcs`. -/ |
RequestId := Nat | abbrev | ProofWidgets | [] | ProofWidgets/Cancellable.lean | RequestId | null |
CancellableTask where task : Task (Except RequestError (LazyEncodable Json)) /- Note: we cannot just `IO.cancel task` because it is a result of `map`. See https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Should.20cancelling.20a.20purely.20mapped.20task.20cancel.20the.20original.3F -/ cancel : IO Unit ... | structure | ProofWidgets | [] | ProofWidgets/Cancellable.lean | CancellableTask | null |
mkCancellable [RpcEncodable β] (handler : α → RequestM (RequestTask β)) : α → RequestM (RequestTask RequestId) := fun a => do RequestM.asTask do let t ← handler a let t' := t.mapCheap (·.map rpcEncode) runningRequests.modifyGet fun (id, m) => (id, (id+1, m.insert id ⟨t'.task, t.cancel⟩)) /-- Cancel the request with ID ... | def | ProofWidgets | [] | ProofWidgets/Cancellable.lean | mkCancellable | /-- Transforms a request handler returning `β`
into one that returns immediately with a `RequestId`.
The ID uniquely identifies the running request:
its results can be retrieved using `checkRequest`,
and it can be cancelled using `cancelRequest`. -/ |
cancelRequest (rid : RequestId) : RequestM (RequestTask String) := do RequestM.asTask do let t? ← runningRequests.modifyGet fun (id, m) => (m[rid]?, (id, m.erase rid)) if let some t := t? then t.cancel return "ok" /-- The status of a running cancellable request. -/ | def | ProofWidgets | [] | ProofWidgets/Cancellable.lean | cancelRequest | /-- Cancel the request with ID `rid`.
Does nothing if `rid` is invalid. -/ |
CheckRequestResponse | running | done (result : LazyEncodable Json) deriving RpcEncodable /-- Check whether a request has finished computing, and return the response if so. The request is removed from `runningRequests` the first time it is checked and found to have finished. Throws an error if the `rid` is invalid, or ... | inductive | ProofWidgets | [] | ProofWidgets/Cancellable.lean | CheckRequestResponse | /-- The status of a running cancellable request. -/ |
checkRequest (rid : RequestId) : RequestM (RequestTask CheckRequestResponse) := do RequestM.asTask do let (_, m) ← runningRequests.get match m[rid]? with | none => throw $ RequestError.invalidParams s!"Request '{rid}' has already finished, or the ID is invalid." | some t => if !(← IO.hasFinished t.task) then return .ru... | def | ProofWidgets | [] | ProofWidgets/Cancellable.lean | checkRequest | /-- Check whether a request has finished computing,
and return the response if so.
The request is removed from `runningRequests` the first time it is checked
and found to have finished.
Throws an error if the `rid` is invalid,
or if the request itself threw an error. -/ |
cancellableSuffix : Name := `_cancellable /-- Like `server_rpc_method`, but requests for this method can be cancelled. The method should check for that using `IO.checkCanceled`. Cancellable methods are invoked differently from JavaScript: see `callCancellable` in `cancellable.ts`. -/ initialize registerBuiltinAttribute... | def | ProofWidgets | [] | ProofWidgets/Cancellable.lean | cancellableSuffix | null |
LazyEncodable α := StateM RpcObjectStore α -- back from exile | abbrev | ProofWidgets | [] | ProofWidgets/Compat.lean | LazyEncodable | null |
ExprWithCtx where ci : Elab.ContextInfo lctx : LocalContext linsts : LocalInstances expr : Expr deriving TypeName | structure | ProofWidgets | [] | ProofWidgets/Compat.lean | ExprWithCtx | null |
ExprWithCtx.runMetaM (e : ExprWithCtx) (x : Expr → MetaM α) : IO α := e.ci.runMetaM {} $ Meta.withLCtx e.lctx e.linsts (x e.expr) | def | ProofWidgets | [] | ProofWidgets/Compat.lean | ExprWithCtx.runMetaM | null |
ExprWithCtx.save (e : Expr) : MetaM ExprWithCtx := return { ci := { ← CommandContextInfo.save with } lctx := ← getLCtx linsts := ← Meta.getLocalInstances expr := e } | def | ProofWidgets | [] | ProofWidgets/Compat.lean | ExprWithCtx.save | null |
joinArrays {m} [Monad m] [MonadRef m] [MonadQuotation m] (arr : Array Term) : m Term := do if h : 0 < arr.size then arr.foldlM (fun x xs => `($x ++ $xs)) arr[0] (start := 1) else `(#[]) /-- Collapse adjacent `inl (_ : α)`s into a `β` using `f`. For example, `#[.inl a₁, .inl a₂, .inr b, .inl a₃] ↦ #[← f #[a₁, a₂], b, ← ... | def | ProofWidgets | [] | ProofWidgets/Util.lean | joinArrays | /-- Sends `#[a, b, c]` to `` `(term| $a ++ $b ++ $c)``-/ |
foldInlsM {m} [Monad m] (arr : Array (α ⊕ β)) (f : Array α → m β) : m (Array β) := do let mut ret : Array β := #[] let mut pending_inls : Array α := #[] for c in arr do match c with | .inl ci => pending_inls := pending_inls.push ci | .inr cis => if pending_inls.size ≠ 0 then ret := ret.push <| ← f pending_inls pending_... | def | ProofWidgets | [] | ProofWidgets/Util.lean | foldInlsM | /-- Collapse adjacent `inl (_ : α)`s into a `β` using `f`.
For example, `#[.inl a₁, .inl a₂, .inr b, .inl a₃] ↦ #[← f #[a₁, a₂], b, ← f #[a₃]]`. -/ |
delabListLiteral {α} (elem : DelabM α) : DelabM (Array α) := go #[] where go (acc : Array α) : DelabM (Array α) := do match_expr ← getExpr with | List.nil _ => return acc | List.cons _ _ _ => let hd ← withNaryArg 1 elem withNaryArg 2 $ go (acc.push hd) | _ => failure /-- Delaborate the elements of an array literal sepa... | def | ProofWidgets | [] | ProofWidgets/Util.lean | delabListLiteral | /-- Delaborate the elements of a list literal separately, calling `elem` on each. -/ |
delabArrayLiteral {α} (elem : DelabM α) : DelabM (Array α) := do match_expr ← getExpr with | List.toArray _ _ => withNaryArg 1 <| delabListLiteral elem | _ => failure /-- A copy of `Delaborator.annotateTermInfo` for other syntactic categories. -/ | def | ProofWidgets | [] | ProofWidgets/Util.lean | delabArrayLiteral | /-- Delaborate the elements of an array literal separately, calling `elem` on each. -/ |
annotateTermLikeInfo (stx : TSyntax n) : DelabM (TSyntax n) := do let stx ← annotateCurPos ⟨stx⟩ addTermInfo (← getPos) stx (← getExpr) pure ⟨stx⟩ /-- A copy of `Delaborator.withAnnotateTermInfo` for other syntactic categories. -/ | def | ProofWidgets | [] | ProofWidgets/Util.lean | annotateTermLikeInfo | /-- A copy of `Delaborator.annotateTermInfo` for other syntactic categories. -/ |
withAnnotateTermLikeInfo (d : DelabM (TSyntax n)) : DelabM (TSyntax n) := do let stx ← d annotateTermLikeInfo stx | def | ProofWidgets | [] | ProofWidgets/Util.lean | withAnnotateTermLikeInfo | /-- A copy of `Delaborator.withAnnotateTermInfo` for other syntactic categories. -/ |
CustomProps where val : Nat str : String deriving Server.RpcEncodable | structure | test | [
"import ProofWidgets.Data.Html"
] | test/delab.lean | CustomProps | /-- info: <div {...attrs}>{...children}</div> : ProofWidgets.Html -/ |
CustomComponent : ProofWidgets.Component CustomProps where javascript := "" -- TODO: spacing between attributes /-- info: <div><CustomComponent val={2}str={"3"}>Content</CustomComponent></div> : ProofWidgets.Html -/ #guard_msgs in #check <div><CustomComponent val={2} str="3">Content</CustomComponent></div> | def | test | [
"import ProofWidgets.Data.Html"
] | test/delab.lean | CustomComponent | /-- info: <div {...attrs}>{...children}</div> : ProofWidgets.Html -/ |
ProdComponent : ProofWidgets.Component (Nat × Nat) where javascript := "" /-- info: <div><ProdComponent {...(1, 2)}/></div> : ProofWidgets.Html -/ #guard_msgs in #check <div><ProdComponent fst={1} snd={2} /></div> /-- info: <div><ProdComponent {...(1, 2)}/></div> : ProofWidgets.Html -/ #guard_msgs in #check <div><ProdC... | def | test | [
"import ProofWidgets.Data.Html"
] | test/delab.lean | ProdComponent | /-- info: <div><CustomComponent val={2}str={"3"}>Content</CustomComponent></div> : ProofWidgets.Html -/ |
Component (Props : Type) extends Widget.Module where /-- Which export of the module to use as the component function. -/ «export» : String := "default" | structure | ProofWidgets | [] | ProofWidgets/Component/Basic.lean | Component | null |
InteractiveCodeProps where fmt : Widget.CodeWithInfos deriving Server.RpcEncodable /-- Present pretty-printed code as interactive text. The most common use case is to instantiate this component from a `Lean.Expr`. To do so, you must eagerly pretty-print the `Expr` using `Widget.ppExprTagged`. See also `InteractiveExpr`... | structure | ProofWidgets | [] | ProofWidgets/Component/Basic.lean | InteractiveCodeProps | /-- Which export of the module to use as the component function. -/ |
InteractiveCode : Component InteractiveCodeProps where javascript := " import { InteractiveCode } from '@leanprover/infoview' import * as React from 'react' export default function(props) { return React.createElement(InteractiveCode, props) }" | def | ProofWidgets | [] | ProofWidgets/Component/Basic.lean | InteractiveCode | /-- Present pretty-printed code as interactive text.
The most common use case is to instantiate this component from a `Lean.Expr`. To do so, you must
eagerly pretty-print the `Expr` using `Widget.ppExprTagged`. See also `InteractiveExpr`. -/ |
InteractiveExprProps where expr : Server.WithRpcRef ExprWithCtx deriving Server.RpcEncodable @[server_rpc_method] | structure | ProofWidgets | [] | ProofWidgets/Component/Basic.lean | InteractiveExprProps | null |
ppExprTagged : InteractiveExprProps → Server.RequestM (Server.RequestTask Widget.CodeWithInfos) | ⟨ref⟩ => Server.RequestM.asTask <| ref.val.runMetaM Widget.ppExprTagged /-- Lazily pretty-print and present a `Lean.Expr` as interactive text. This component is preferrable over `InteractiveCode` when the `Expr` will not n... | def | ProofWidgets | [] | ProofWidgets/Component/Basic.lean | ppExprTagged | null |
InteractiveExpr : Component InteractiveExprProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "interactiveExpr.js" | def | ProofWidgets | [] | ProofWidgets/Component/Basic.lean | InteractiveExpr | null |
InteractiveMessageProps where msg : Server.WithRpcRef MessageData deriving Server.RpcEncodable /-- Present a structured Lean message. -/ @[widget_module] | structure | ProofWidgets | [] | ProofWidgets/Component/Basic.lean | InteractiveMessageProps | null |
InteractiveMessage : Component InteractiveMessageProps where javascript := " import { InteractiveMessageData } from '@leanprover/infoview' import * as React from 'react' export default function(props) { return React.createElement(InteractiveMessageData, props) } " | def | ProofWidgets | [] | ProofWidgets/Component/Basic.lean | InteractiveMessage | /-- Present a structured Lean message. -/ |
MarkdownDisplay.Props where contents : String deriving ToJson, FromJson /-- Render a given string as Markdown. LaTeX is supported with MathJax: use `$...$` for inline math, and `$$...$$` for displayed math. Example usage: ```lean <MarkdownDisplay contents={"$a + b = c$"} /> ``` -/ @[widget_module] | structure | ProofWidgets | [] | ProofWidgets/Component/Basic.lean | MarkdownDisplay.Props | /-- Present a structured Lean message. -/ |
MarkdownDisplay : Component MarkdownDisplay.Props where javascript := " import { Markdown } from '@leanprover/infoview' import * as React from 'react' export default (props) => React.createElement(Markdown, props) " | def | ProofWidgets | [] | ProofWidgets/Component/Basic.lean | MarkdownDisplay | /-- Render a given string as Markdown.
LaTeX is supported with MathJax:
use `$...$` for inline math,
and `$$...$$` for displayed math.
Example usage:
```lean
<MarkdownDisplay contents={"$a + b = c$"} />
``` -/ |
Lean.MessageData.ofComponent [Server.RpcEncodable Props] (c : ProofWidgets.Component Props) (p : Props) (alt : String) : CoreM MessageData := do let wi ← Widget.WidgetInstance.ofHash c.javascriptHash (Server.RpcEncodable.rpcEncode p) return .ofWidget wi alt | def | ProofWidgets | [] | ProofWidgets/Component/Basic.lean | Lean.MessageData.ofComponent | /-- Construct a structured message from a ProofWidgets component.
For the meaning of `alt`, see `MessageData.ofWidget`. -/ |
FilterDetailsProps where /-- Contents of the `<summary>`. -/ summary : Html /-- What is shown in the filtered state. -/ filtered : Html /-- What is shown in the non-filtered state. -/ all : Html /-- Whether to start in the filtered state. -/ initiallyFiltered : Bool := true deriving Server.RpcEncodable /-- The `FilterD... | structure | ProofWidgets | [] | ProofWidgets/Component/FilterDetails.lean | FilterDetailsProps | /-- Props for the `FilterDetails` component. -/ |
FilterDetails : Component FilterDetailsProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "filterDetails.js" | def | ProofWidgets | [] | ProofWidgets/Component/FilterDetails.lean | FilterDetails | /-- The `FilterDetails` component is like a `<details>` HTML element,
but also has a filter button
that allows you to switch between filtered and unfiltered states. -/ |
mkCircle (attrs : Array (String × Json) := #[]) : Html := <circle r={5} fill="var(--vscode-editor-background)" stroke="var(--vscode-editor-foreground)" strokeWidth={.num 1.5} {...attrs} /> /-- A shape containing the vertex label. Used to position incident edge endpoints. The shape is assumed to be centred on the vertex... | def | ProofWidgets | [] | ProofWidgets/Component/GraphDisplay.lean | mkCircle | /-- A themed `<circle>` SVG element, with optional extra attributes. -/ |
BoundingShape where /-- A circle of fixed radius. -/ | circle (radius : Float) : BoundingShape /-- A rectangle of fixed dimensions. -/ | rect (width height : Float) : BoundingShape deriving Inhabited, FromJson, ToJson | inductive | ProofWidgets | [] | ProofWidgets/Component/GraphDisplay.lean | BoundingShape | /-- A shape containing the vertex label.
Used to position incident edge endpoints.
The shape is assumed to be centred on the vertex position. -/ |
Vertex where /-- Identifier for this vertex. Must be unique. -/ id : String /-- The label is drawn at the vertex position. This must be an SVG element. Use `<foreignObject>` to draw non-SVG elements. -/ label : Html := mkCircle boundingShape : BoundingShape := .circle 5 /-- Details are shown below the graph display aft... | structure | ProofWidgets | [] | ProofWidgets/Component/GraphDisplay.lean | Vertex | /-- A rectangle of fixed dimensions. -/ |
Edge where /-- Source vertex. Must match the `id` of one of the vertices. -/ source : String /-- Target vertex. Must match the `id` of one of the vertices. -/ target : String /-- Extra attributes to set on the SVG `<line>` element representing this edge. See also `Props.defaultEdgeAttrs`. -/ attrs : Array (String × Jso... | structure | ProofWidgets | [] | ProofWidgets/Component/GraphDisplay.lean | Edge | /-- Details are shown below the graph display
after the vertex label has been clicked.
See also `Props.showDetails`. -/ |
ForceCenterParams where x? : Option Float := none y? : Option Float := none strength? : Option Float := none deriving Inhabited, FromJson, ToJson | structure | ProofWidgets | [] | ProofWidgets/Component/GraphDisplay.lean | ForceCenterParams | /-- Details are shown below the graph display
after the edge has been clicked.
See also `Props.showDetails`. -/ |
ForceCollideParams where radius? : Option Float := none strength? : Option Float := none iterations? : Option Nat := none deriving Inhabited, FromJson, ToJson | structure | ProofWidgets | [] | ProofWidgets/Component/GraphDisplay.lean | ForceCollideParams | /-- Details are shown below the graph display
after the edge has been clicked.
See also `Props.showDetails`. -/ |
ForceLinkParams where distance? : Option Float := none strength? : Option Float := none iterations? : Option Nat := none deriving Inhabited, FromJson, ToJson | structure | ProofWidgets | [] | ProofWidgets/Component/GraphDisplay.lean | ForceLinkParams | null |
ForceManyBodyParams where strength? : Option Float := none theta? : Option Float := none distanceMin? : Option Float := none distanceMax? : Option Float := none deriving Inhabited, FromJson, ToJson | structure | ProofWidgets | [] | ProofWidgets/Component/GraphDisplay.lean | ForceManyBodyParams | null |
ForceXParams where x? : Option Float := none strength? : Option Float := none deriving Inhabited, FromJson, ToJson | structure | ProofWidgets | [] | ProofWidgets/Component/GraphDisplay.lean | ForceXParams | null |
ForceYParams where y? : Option Float := none strength? : Option Float := none deriving Inhabited, FromJson, ToJson | structure | ProofWidgets | [] | ProofWidgets/Component/GraphDisplay.lean | ForceYParams | null |
ForceRadialParams where radius : Float x? : Option Float := none y? : Option Float := none strength? : Option Float := none deriving Inhabited, FromJson, ToJson /-- Settings for the simulation of forces on vertices. See https://d3js.org/d3-force. -/ | structure | ProofWidgets | [] | ProofWidgets/Component/GraphDisplay.lean | ForceRadialParams | null |
ForceParams where | center : ForceCenterParams → ForceParams | collide : ForceCollideParams → ForceParams | link : ForceLinkParams → ForceParams | manyBody : ForceManyBodyParams → ForceParams | x : ForceXParams → ForceParams | y : ForceYParams → ForceParams | radial : ForceRadialParams → ForceParams deriving Inhabited,... | inductive | ProofWidgets | [] | ProofWidgets/Component/GraphDisplay.lean | ForceParams | /-- Settings for the simulation of forces on vertices.
See https://d3js.org/d3-force. -/ |
Props where vertices : Array Vertex /-- At most one edge may exist between any two vertices. Self-loops are allowed, but (TODO) are currently not rendered well. -/ edges : Array Edge /-- Attributes to set by default on `<line>` elements representing edges. -/ defaultEdgeAttrs : Array (String × Json) := #[ ("fill", "var... | structure | ProofWidgets | [] | ProofWidgets/Component/GraphDisplay.lean | Props | /-- Settings for the simulation of forces on vertices.
See https://d3js.org/d3-force. -/ |
GraphDisplay : Component GraphDisplay.Props where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "d3Graph.js" | def | ProofWidgets | [] | ProofWidgets/Component/GraphDisplay.lean | GraphDisplay | /-- Display a graph with an interactive force simulation. -/ |
HtmlDisplayProps where html : Html deriving RpcEncodable @[widget_module] | structure | ProofWidgets | [] | ProofWidgets/Component/HtmlDisplay.lean | HtmlDisplayProps | null |
HtmlDisplay : Component HtmlDisplayProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "htmlDisplay.js" @[widget_module] | def | ProofWidgets | [] | ProofWidgets/Component/HtmlDisplay.lean | HtmlDisplay | null |
HtmlDisplayPanel : Component HtmlDisplayProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "htmlDisplayPanel.js" open Lean Server Elab Command /-- Any term `t : α` with a `HtmlEval α` instance can be evaluated in a `#html t` command. This is analogous to how `Lean.MetaEval` supports `#eval`.... | def | ProofWidgets | [] | ProofWidgets/Component/HtmlDisplay.lean | HtmlDisplayPanel | null |
HtmlEval (α : Type u) where eval : α → CommandElabM Html | class | ProofWidgets | [] | ProofWidgets/Component/HtmlDisplay.lean | HtmlEval | /-- Any term `t : α` with a `HtmlEval α` instance
can be evaluated in a `#html t` command.
This is analogous to how `Lean.MetaEval` supports `#eval`. -/ |
evalCommandMHtmlUnsafe (stx : Term) : TermElabM (CommandElabM Html) := do let tp := mkApp (mkConst ``CommandElabM) (mkConst ``Html) Term.evalTerm _ tp stx @[implemented_by evalCommandMHtmlUnsafe] | def | ProofWidgets | [] | ProofWidgets/Component/HtmlDisplay.lean | evalCommandMHtmlUnsafe | null |
evalCommandMHtml : Term → TermElabM (CommandElabM Html) /-- Display a value of type `Html` in the infoview. The input can be a pure value or a computation in any Lean metaprogramming monad (e.g. `CommandElabM Html`). -/ syntax (name := htmlCmd) "#html " term : command @[command_elab htmlCmd] | opaque | ProofWidgets | [] | ProofWidgets/Component/HtmlDisplay.lean | evalCommandMHtml | null |
elabHtmlCmd : CommandElab := fun | stx@`(#html $t:term) => do let htX ← liftTermElabM <| evalCommandMHtml <| ← ``(HtmlEval.eval $t) let ht ← htX liftCoreM <| Widget.savePanelWidgetInfo (hash HtmlDisplayPanel.javascript) (return json% { html: $(← rpcEncode ht) }) stx | stx => throwError "Unexpected syntax {stx}." | def | ProofWidgets | [] | ProofWidgets/Component/HtmlDisplay.lean | elabHtmlCmd | /-- Display a value of type `Html` in the infoview.
The input can be a pure value
or a computation in any Lean metaprogramming monad
(e.g. `CommandElabM Html`). -/ |
Lean.MessageData.ofHtml (h : ProofWidgets.Html) (alt : String) : CoreM MessageData := MessageData.ofComponent ProofWidgets.HtmlDisplay ⟨h⟩ alt | def | ProofWidgets | [] | ProofWidgets/Component/HtmlDisplay.lean | Lean.MessageData.ofHtml | /-- Construct a structured message from ProofWidgets HTML.
For the meaning of `alt`, see `MessageData.ofWidget`. -/ |
_root_.Float.toInt (x : Float) : Int := if x >= 0 then x.toUInt64.toNat else -((-x).toUInt64.toNat) namespace Svg | def | ProofWidgets | [] | ProofWidgets/Component/InteractiveSvg.lean | _root_.Float.toInt | null |
ActionKind where | timeout | mousedown | mouseup | mousemove -- [note] mouse moves only happen when mouse button is down. deriving ToJson, FromJson, DecidableEq | inductive | ProofWidgets | [] | ProofWidgets/Component/InteractiveSvg.lean | ActionKind | null |
Action where kind : ActionKind id : Option String data : Option Json deriving ToJson, FromJson /-- The input type `State` is any state the user wants to use and update SvgState in addition automatically handles tracking of time, selection and custom data -/ | structure | ProofWidgets | [] | ProofWidgets/Component/InteractiveSvg.lean | Action | null |
SvgState (State : Type) where state : State time : Float /-- time in milliseconds -/ selected : Option String mousePos : Option (Int × Int) idToData : List (String × Json) deriving ToJson, FromJson, Server.RpcEncodable | structure | ProofWidgets | [] | ProofWidgets/Component/InteractiveSvg.lean | SvgState | /-- The input type `State` is any state the user wants to use and update
SvgState in addition automatically handles tracking of time, selection and custom data -/ |
UpdateParams (State : Type) where elapsed : Float actions : Array Action state : SvgState State mousePos : Option (Float × Float) -- TODO: change to Option (Int × Int) or do we want to support subpixel precision? deriving ToJson, FromJson | structure | ProofWidgets | [] | ProofWidgets/Component/InteractiveSvg.lean | UpdateParams | /-- time in milliseconds -/ |
UpdateResult (State : Type) where html : Html state : SvgState State /-- Approximate number of milliseconds to wait before calling again. -/ callbackTime : Option Float := some 33 deriving Server.RpcEncodable -- maybe add title, refresh rate, initial time?, custom selection rendering | structure | ProofWidgets | [] | ProofWidgets/Component/InteractiveSvg.lean | UpdateResult | /-- time in milliseconds -/ |
InteractiveSvg (State : Type) where init : State frame : Svg.Frame update (time_ms Δt_ms : Float) (action : Action) (mouseStart mouseEnd : Option (Svg.Point frame)) (selectedId : Option String) (getSelectedData : (α : Type) → [FromJson α] → Option α) : State → State render (time_ms : Float) (mouseStart mouseEnd : Optio... | structure | ProofWidgets | [] | ProofWidgets/Component/InteractiveSvg.lean | InteractiveSvg | /-- Approximate number of milliseconds to wait before calling again. -/ |
InteractiveSvg.serverRpcMethod {State : Type} (isvg : InteractiveSvg State) (params : UpdateParams State) : RequestM (RequestTask (UpdateResult State)) := do -- Ideally, each action should have time and mouse position attached -- right now we just assume that all actions are uqually spaced within the frame let Δt := (p... | def | ProofWidgets | [] | ProofWidgets/Component/InteractiveSvg.lean | InteractiveSvg.serverRpcMethod | null |
Lean.Lsp.Position.advance (p : Position) (s : Substring.Raw) : Position := let (nLinesAfter, lastLineUtf16Sz) := s.foldl (init := (0, 0)) fun (n, l) c => if c == '\n' then (n + 1, 0) else (n, l + c.utf16Size.toNat) { line := p.line + nLinesAfter character := (if nLinesAfter == 0 then p.character else 0) + lastLineUtf16... | def | ProofWidgets | [] | ProofWidgets/Component/MakeEditLink.lean | Lean.Lsp.Position.advance | /-- Assuming that `s` is the content of a file starting at position `p`,
advance `p` to the end of `s`. -/ |
MakeEditLinkProps where /-- The edit to perform on the file. -/ edit : Lsp.TextDocumentEdit /-- Which textual range to select after the edit. The range is interpreted in the file that `edit` applies to. If present and `start == end`, the cursor is moved to `start` and nothing is selected. If not present, the selection ... | structure | ProofWidgets | [] | ProofWidgets/Component/MakeEditLink.lean | MakeEditLinkProps | /-- Assuming that `s` is the content of a file starting at position `p`,
advance `p` to the end of `s`. -/ |
MakeEditLinkProps.ofReplaceRange' (doc : Server.DocumentMeta) (range : Lsp.Range) (newText : String) (newSelection? : Option Lsp.Range := none) : MakeEditLinkProps := let edit := { textDocument := { uri := doc.uri, version? := doc.version } edits := #[{ range, newText }] } if newSelection?.isSome then { edit, newSelect... | def | ProofWidgets | [] | ProofWidgets/Component/MakeEditLink.lean | MakeEditLinkProps.ofReplaceRange' | /-- Replace `range` with `newText`.
If `newSelection?` is absent, place the cursor at the end of the new text.
If `newSelection?` is present, make the specified selection instead.
See also `MakeEditLinkProps.ofReplaceRange`.
-/ |
MakeEditLinkProps.ofReplaceRange (doc : Server.DocumentMeta) (range : Lsp.Range) (newText : String) (newSelection? : Option (String.Pos.Raw × String.Pos.Raw) := none) : MakeEditLinkProps := ofReplaceRange' doc range newText (newSelection?.map fun (s, e) => let ps := range.start.advance (newText.toRawSubstring.extract 0... | def | ProofWidgets | [] | ProofWidgets/Component/MakeEditLink.lean | MakeEditLinkProps.ofReplaceRange | /-- Replace `range` with `newText`.
If `newSelection?` is absent, place the cursor at the end of the new text.
If `newSelection?` is present, select the range it specifies within `newText`.
See also `MakeEditLinkProps.ofReplaceRange'`. -/ |
MakeEditLink : Component MakeEditLinkProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "makeEditLink.js" | def | ProofWidgets | [] | ProofWidgets/Component/MakeEditLink.lean | MakeEditLink | /-- A link that, when clicked, makes the specified edit
and potentially moves the cursor
or makes a selection. -/ |
ofRpcMethodTemplate := include_str ".." / ".." / ".lake" / "build" / "js" / "ofRpcMethod.js" /-- The elaborator `mk_rpc_widget%` allows writing certain widgets in Lean instead of JavaScript. Specifically, it translates an RPC method of type `MyProps → RequestM (RequestTask Html)` into a widget component of type `Compon... | def | ProofWidgets | [] | ProofWidgets/Component/OfRpcMethod.lean | ofRpcMethodTemplate | null |
MyProps where ... deriving RpcEncodable @[server_rpc_method] | structure | ProofWidgets | [] | ProofWidgets/Component/OfRpcMethod.lean | MyProps | null |
MyComponent.rpc (ps : MyProps) : RequestM (RequestTask Html) := ... @[widget_module] | def | ProofWidgets | [] | ProofWidgets/Component/OfRpcMethod.lean | MyComponent.rpc | null |
MyComponent : Component MyProps := mk_rpc_widget% MyComponent.rpc ``` This is convenient because we can program the logic that computes an output HTML tree given input props in Lean directly. ⚠️ However, note that there are several limitations on what such component can do compared to ones written natively in TypeScrip... | def | ProofWidgets | [] | ProofWidgets/Component/OfRpcMethod.lean | MyComponent | null |
MyComponent.rpc (ps : MyProps) : RequestM (RequestTask Html) := RequestM.asTask do return Html.ofComponent MyComponent ps #[] ``` -/ elab "mk_rpc_widget%" fn:term : term <= expectedType => do let α ← mkFreshExprMVar (some (.sort levelOne)) (userName := `α) let compT ← mkAppM ``Component #[α] if !(← isDefEq expectedType... | def | ProofWidgets | [] | ProofWidgets/Component/OfRpcMethod.lean | MyComponent.rpc | null |
DiagramProps where embeds : Array (String × Html) dsl : String sty : String sub : String /-- Maximum number of optimization steps to take before showing the diagram. Optimization may converge earlier, before taking this many steps. -/ maxOptSteps : Nat := 500 deriving Inhabited, RpcEncodable /-- Displays the given diag... | structure | ProofWidgets | [] | ProofWidgets/Component/PenroseDiagram.lean | DiagramProps | null |
Diagram : Component DiagramProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "penroseDisplay.js" /-! # `DiagramBuilderM` -/ | def | ProofWidgets | [] | ProofWidgets/Component/PenroseDiagram.lean | Diagram | null |
DiagramState where /-- The Penrose substance program. Note that `embeds` are added lazily at the end. -/ sub : String := "" /-- Components to display as labels in the diagram, stored in the map as name ↦ (type, html). -/ embeds : Std.HashMap String (String × Html) := ∅ /-- A monad to easily build Penrose diagrams in. -... | structure | ProofWidgets | [] | ProofWidgets/Component/PenroseDiagram.lean | DiagramState | null |
DiagramBuilderM := StateT DiagramState MetaM namespace DiagramBuilderM open scoped Jsx in /-- Assemble the diagram using the provided domain and style programs. `none` is returned iff nothing was added to the diagram. -/ | abbrev | ProofWidgets | [] | ProofWidgets/Component/PenroseDiagram.lean | DiagramBuilderM | /-- A monad to easily build Penrose diagrams in. -/ |
buildDiagram (dsl sty : String) (maxOptSteps : Nat := 500) : DiagramBuilderM (Option Html) := do let st ← get if st.sub == "" && st.embeds.isEmpty then return none let mut sub := "AutoLabel All\n" let mut embedHtmls := #[] for (n, (tp, h)) in st.embeds.toArray do sub := sub ++ s!"{tp} {n}\n" embedHtmls := embedHtmls.pu... | def | ProofWidgets | [] | ProofWidgets/Component/PenroseDiagram.lean | buildDiagram | /-- Assemble the diagram using the provided domain and style programs.
`none` is returned iff nothing was added to the diagram. -/ |
addEmbed (nm : String) (tp : String) (h : Html) : DiagramBuilderM Unit := do modify fun st => { st with embeds := st.embeds.insert nm (tp, h) } open scoped Jsx in /-- Add an object of Penrose type `tp`, corresponding to (and labelled by) the expression `e`, to the substance program. Return its Penrose name. -/ | def | ProofWidgets | [] | ProofWidgets/Component/PenroseDiagram.lean | addEmbed | /-- Add an object `nm` of Penrose type `tp`,
labelled by `h`, to the substance program. -/ |
addExpr (tp : String) (e : Expr) : DiagramBuilderM String := do let nm ← toString <$> Lean.Meta.ppExpr e let h := <InteractiveCode fmt={← Widget.ppExprTagged e} /> addEmbed nm tp h return nm /-- Add an instruction `i` to the substance program. -/ | def | ProofWidgets | [] | ProofWidgets/Component/PenroseDiagram.lean | addExpr | /-- Add an object of Penrose type `tp`,
corresponding to (and labelled by) the expression `e`,
to the substance program.
Return its Penrose name. -/ |
addInstruction (i : String) : DiagramBuilderM Unit := do modify fun st => { st with sub := st.sub ++ s!"{i}\n" } | def | ProofWidgets | [] | ProofWidgets/Component/PenroseDiagram.lean | addInstruction | /-- Add an instruction `i` to the substance program. -/ |
run (x : DiagramBuilderM α) : MetaM α := x.run' {} | def | ProofWidgets | [] | ProofWidgets/Component/PenroseDiagram.lean | run | /-- Add an instruction `i` to the substance program. -/ |
PenroseDiagramProps := Penrose.DiagramProps /-- Abbreviation for backwards-compatibility. -/ | abbrev | ProofWidgets | [] | ProofWidgets/Component/PenroseDiagram.lean | PenroseDiagramProps | /-- Abbreviation for backwards-compatibility. -/ |
PenroseDiagram := Penrose.Diagram | abbrev | ProofWidgets | [] | ProofWidgets/Component/PenroseDiagram.lean | PenroseDiagram | /-- Abbreviation for backwards-compatibility. -/ |
Recharts : Widget.Module where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "recharts.js" | def | ProofWidgets | [] | ProofWidgets/Component/Recharts.lean | Recharts | null |
LineChartLayout where | horizontal | vertical deriving FromJson, ToJson | inductive | ProofWidgets | [] | ProofWidgets/Component/Recharts.lean | LineChartLayout | null |
LineChartSyncMethod where | index | value deriving FromJson, ToJson | inductive | ProofWidgets | [] | ProofWidgets/Component/Recharts.lean | LineChartSyncMethod | null |
LineChartMargin where top : Nat := 5 right : Nat := 5 bottom : Nat := 5 left : Nat := 5 deriving FromJson, ToJson | structure | ProofWidgets | [] | ProofWidgets/Component/Recharts.lean | LineChartMargin | null |
LineChartProps where layout : LineChartLayout := .horizontal syncId? : Option String := none syncMethod? : Option LineChartSyncMethod := some .index width : Nat height : Nat data : Array Json margin : LineChartMargin := {} deriving FromJson, ToJson /-- See https://recharts.org/en-US/api/LineChart. -/ | structure | ProofWidgets | [] | ProofWidgets/Component/Recharts.lean | LineChartProps | null |
LineChart : Component LineChartProps where javascript := Recharts.javascript «export» := "LineChart" | def | ProofWidgets | [] | ProofWidgets/Component/Recharts.lean | LineChart | /-- See https://recharts.org/en-US/api/LineChart. -/ |
AxisType where /-- Treat values as numbers: spacing on axis by numeric difference. -/ | number /-- Treat values as categorical: equal spacing between values. -/ | category deriving FromJson, ToJson | inductive | ProofWidgets | [] | ProofWidgets/Component/Recharts.lean | AxisType | /-- See https://recharts.org/en-US/api/LineChart. -/ |
AxisProps where dataKey? : Option Json := none domain? : Option (Array Json) := none allowDataOverflow : Bool := false /-- How values along this axis should be interpreted. The Recharts default is `category`. -/ type : AxisType := .number -- TODO: There are many more props deriving FromJson, ToJson /-- See https://rech... | structure | ProofWidgets | [] | ProofWidgets/Component/Recharts.lean | AxisProps | /-- Treat values as categorical: equal spacing between values. -/ |
XAxis : Component AxisProps where javascript := Recharts.javascript «export» := "XAxis" /-- See https://recharts.org/en-US/api/YAxis. -/ | def | ProofWidgets | [] | ProofWidgets/Component/Recharts.lean | XAxis | /-- See https://recharts.org/en-US/api/XAxis. -/ |
YAxis : Component AxisProps where javascript := Recharts.javascript «export» := "YAxis" | def | ProofWidgets | [] | ProofWidgets/Component/Recharts.lean | YAxis | /-- See https://recharts.org/en-US/api/YAxis. -/ |
LineType where | basis | basisClosed | basisOpen | linear | linearClosed | natural | monotoneX | monotoneY | monotone | step | stepBefore | stepAfter deriving FromJson, ToJson | inductive | ProofWidgets | [] | ProofWidgets/Component/Recharts.lean | LineType | /-- See https://recharts.org/en-US/api/YAxis. -/ |
LineProps where type : LineType := .linear dataKey : Json stroke : String dot? : Option Bool := none -- TODO: There are many more props deriving FromJson, ToJson /-- See https://recharts.org/en-US/api/Line. -/ | structure | ProofWidgets | [] | ProofWidgets/Component/Recharts.lean | LineProps | /-- See https://recharts.org/en-US/api/YAxis. -/ |
Line : Component LineProps where javascript := Recharts.javascript «export» := "Line" | def | ProofWidgets | [] | ProofWidgets/Component/Recharts.lean | Line | /-- See https://recharts.org/en-US/api/Line. -/ |
Structured dataset from ProofWidgets4 — Interactive proof widgets.
276 declarations extracted from Lean 4 source files.
| Column | Type | Description |
|---|---|---|
| fact | string | Declaration body |
| type | string | theorem, def, lemma, etc. |
| library | string | Source module |
| imports | list | Required imports |
| filename | string | Source file path |
| symbolic_name | string | Identifier |
| docstring | string | Documentation (if present) |