statement stringlengths 1 1.08k | proof stringlengths 0 2.65k | type stringclasses 10
values | symbolic_name stringlengths 1 55 | library stringclasses 9
values | filename stringclasses 39
values | imports listlengths 0 4 | deps listlengths 0 8 | docstring stringlengths 0 1.82k | source_url stringclasses 1
value | commit stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|
AwaitRefreshParams where
state : WithRpcRef RefreshRef
/-- The index of the HTML tree that is currently on display. -/
oldIdx : Nat
deriving RpcEncodable | structure | ProofWidgets.RefreshComponent.AwaitRefreshParams | Component | ProofWidgets/Component/RefreshComponent.lean | [] | [] | The data used to call `awaitRefresh`, for updating the HTML display. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
awaitRefresh (ps : AwaitRefreshParams) : RequestM (RequestTask (Option VersionedHtml)) | do
let { curr, idx, next } ← ps.state.val.ref.get
if ps.oldIdx < idx then
-- We have a more recent state than the client. Send the current state immediately.
RequestM.asTask do
let html ← IO.forceThunk curr
return some { html, idx }
else
-- We have the same state as the client. Wait for an... | def | ProofWidgets.RefreshComponent.awaitRefresh | Component | ProofWidgets/Component/RefreshComponent.lean | [] | [
"IO.forceThunk"
] | If any updates are available (i.e., the server-side state is more recent than the client's),
immediately return the most recent version of the HTML tree.
Otherwise await the next update.
Returns `none` if the client's state is the last one that should be shown. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
Props where
/-- Initial state of the component. -/
state : WithRpcRef RefreshRef
/-- Will be cancelled whenever the widget is rendered with a new `state`, or unmounted,
or when the whole infoview is closed. -/
cancelTk : WithRpcRef IO.CancelToken
deriving RpcEncodable | structure | ProofWidgets.RefreshComponent.Props | Component | ProofWidgets/Component/RefreshComponent.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | ||
monitor (p : Props) : RequestM (RequestTask Unit) | RequestM.asTask do
repeat do
IO.sleep 1000
if ← (← read).cancelTk.wasCancelledByCancelRequest then
p.cancelTk.val.set
return | def | ProofWidgets.RefreshComponent.monitor | Component | ProofWidgets/Component/RefreshComponent.lean | [] | [] | HACK: We cancel background threads driving `RefreshComponent`s when they are no longer needed.
However, there is currently no good way to do this when the infoview closes,
as in that case React effect cleanup functions are never executed.
Instead, `RefreshComponent` calls this persistent monitor task during creation.
T... | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
RefreshComponent : Component Props | where
javascript := include_str ".." / ".." / "widget" / "js" / "RefreshComponent.js" | def | ProofWidgets.RefreshComponent | Component | ProofWidgets/Component/RefreshComponent.lean | [] | [] | Displays a HTML tree, refreshing the display when the tree is updated.
Use `mkRefreshComponentM` to conveniently spawn a dedicated thread
from which you can update the display.
The component resets its state when rendered with a new `props.state`.
Conversely, reusing `props.state` preserves the client-side state. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
RefreshToken where
state : IO.Ref RefreshState
/-- If set, the `RefreshComponent` is no longer displayed in the UI.
The `RefreshToken` should be discarded, and any associated thread should exit. -/
cancelTk : IO.CancelToken
/-- The promise that `RefreshState.next` waits for.
If we drop the `RefreshToken`, ... | structure | ProofWidgets.RefreshToken | Component | ProofWidgets/Component/RefreshComponent.lean | [] | [] | A `RefreshToken` allows you to manage a `RefreshComponent` instance.
Use `RefreshToken.update` to update the HTML currently on display.
Use `RefreshToken.cancelTk` to check if the instance has been discarded. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
RefreshToken.new (initial : Thunk Html) : BaseIO RefreshToken | do
let promise ← IO.Promise.new
let state := {
curr := initial
-- Client's initial version is `0`; this state is an update on that.
idx := 1
next := promise.result?
}
return {
state := ← IO.mkRef state
cancelTk := ← IO.CancelToken.new
promise := ← IO.mkRef promise
} | def | ProofWidgets.RefreshToken.new | Component | ProofWidgets/Component/RefreshComponent.lean | [] | [] | Create a `RefreshToken` with an initial HTML tree. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
RefreshToken.updateLazy (token : RefreshToken) (html : Thunk Html) : BaseIO Unit | do
let { state, promise, .. } := token
let newPromise ← IO.Promise.new
-- `state` is the ref that guards the critical region.
let st ← unsafe state.take
let oldPromise ← promise.swap newPromise
state.set {
curr := html
idx := st.idx + 1
next := newPromise.result?
}
oldPromise.resolve () | def | ProofWidgets.RefreshToken.updateLazy | Component | ProofWidgets/Component/RefreshComponent.lean | [] | [] | Update the current HTML tree to be `html`.
The `html` thunk is only forced when the client requests it;
if another update is made before that, it will never be forced.
This function is thread-safe: each update is made atomically. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
RefreshToken.update (token : RefreshToken) (html : Html) : BaseIO Unit | token.updateLazy (.pure html) | def | ProofWidgets.RefreshToken.update | Component | ProofWidgets/Component/RefreshComponent.lean | [] | [] | Update the current HTML tree to be `html`. See also `updateLazy`. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
mkRefreshComponent (initial : Html := .text "") : BaseIO (Html × RefreshToken) | do
let token ← RefreshToken.new initial
return (<RefreshComponent state={← WithRpcRef.mk ⟨token.state⟩}
cancelTk={← WithRpcRef.mk token.cancelTk} />, token) | def | ProofWidgets.mkRefreshComponent | Component | ProofWidgets/Component/RefreshComponent.lean | [] | [] | Create a `RefreshComponent` instance together with a token to manage it. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
mkRefreshComponentM (initial : Html) (k : RefreshToken → m Unit) : m Html | do
let (html, token) ← mkRefreshComponent initial
let mkAct : m (EIO Exception Unit) := saveCtxM do
withTheReader Core.Context ({· with cancelTk? := token.cancelTk}) <|
k token
discard <| BaseIO.asTask (prio := .dedicated) <|
(← mkAct).catchExceptions fun ex => do
if let .internal id _ := ex t... | def | ProofWidgets.mkRefreshComponentM | Component | ProofWidgets/Component/RefreshComponent.lean | [] | [] | Create a `RefreshComponent` together with a dedicated thread that drives it by running `k`.
The typeclass assumptions essentially require `m` to extend `CoreM`.
For early cooperative cancellation of `CoreM` computations,
we automatically pass `RefreshToken.cancelTk` to `Core.Context`. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
PanelWidgetProps : Type where
/-- Cursor position in the file at which the widget is being displayed. -/
pos : Lsp.Position
/-- The current tactic-mode goals. -/
goals : Array Widget.InteractiveGoal
/-- The current term-mode goal, if any. -/
termGoal? : Option Widget.InteractiveTermGoal
/-- Locations curr... | structure | ProofWidgets.PanelWidgetProps | Component.Panel | ProofWidgets/Component/Panel/Basic.lean | [] | [] | In the infoview, an **info block** is a top-level collapsible block corresponding to a given
location in a Lean file (e.g. with the header `▼ Basic.lean:12:34`).
A **panel widget** is a component which can appear as a panel inside an info block in the infoview.
For example, a tactic state display.
The type `PanelWidge... | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
withPanelWidgets : Tactic | | stx@`(tactic| with_panel_widgets [ $specs,* ] $seq) => do
specs.getElems.forM fun specStx => do
let spec ← Widget.elabWidgetInstanceSpec specStx
let wi ← Widget.evalWidgetInstance spec
Widget.savePanelWidgetInfo wi.javascriptHash wi.props stx
evalTacticSeq seq
| _ => throwUnsupportedSyntax | def | ProofWidgets.withPanelWidgets | Component.Panel | ProofWidgets/Component/Panel/Basic.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
GoalTypePanel : Component PanelWidgetProps | where
javascript := include_str ".." / ".." / ".." / "widget" / "js" / "goalTypePanel.js" | def | ProofWidgets.GoalTypePanel | Component.Panel | ProofWidgets/Component/Panel/GoalTypePanel.lean | [] | [] | Display the goal type using known `Expr` presenters. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
Lean.SubExpr.GoalsLocation.saveExprWithCtx (loc : GoalsLocation) : MetaM ExprWithCtx | let mvarId := loc.mvarId
mvarId.withContext do
match loc.loc with
| .hyp fvarId => ExprWithCtx.save (.fvar fvarId)
| .hypType fvarId pos =>
Meta.viewSubexpr (fun _ => ExprWithCtx.save) pos (← instantiateMVars (← fvarId.getType))
| .hypValue fvarId pos =>
let some val ← fvarId.getValue? | t... | def | Lean.SubExpr.GoalsLocation.saveExprWithCtx | Component.Panel | ProofWidgets/Component/Panel/SelectionPanel.lean | [] | [] | Save the expression corresponding to a goals location. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
GoalsLocationsToExprsParams where
locations : Array (WithRpcRef Elab.ContextInfo × SubExpr.GoalsLocation)
deriving RpcEncodable | structure | ProofWidgets.GoalsLocationsToExprsParams | Component.Panel | ProofWidgets/Component/Panel/SelectionPanel.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | ||
GoalsLocationsToExprsResponse where
exprs : Array (WithRpcRef ExprWithCtx)
deriving RpcEncodable | structure | ProofWidgets.GoalsLocationsToExprsResponse | Component.Panel | ProofWidgets/Component/Panel/SelectionPanel.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | ||
goalsLocationsToExprs (args : GoalsLocationsToExprsParams) :
RequestM (RequestTask GoalsLocationsToExprsResponse) | RequestM.asTask do
let mut exprs := #[]
for ⟨ref, loc⟩ in args.locations do
let ci := ref.val
exprs := exprs.push (← WithRpcRef.mk (← ci.runMetaM {} loc.saveExprWithCtx))
return { exprs } | def | ProofWidgets.goalsLocationsToExprs | Component.Panel | ProofWidgets/Component/Panel/SelectionPanel.lean | [] | [] | Compute expressions corresponding to the given `GoalsLocation`s. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
SelectionPanel : Component PanelWidgetProps | where
javascript := include_str ".." / ".." / ".." / "widget" / "js" / "presentSelection.js" | def | ProofWidgets.SelectionPanel | Component.Panel | ProofWidgets/Component/Panel/SelectionPanel.lean | [] | [] | Display a list of all expressions selected in the goal state, with a choice of which `Expr`
presenter should be used to display each of those expressions.
Expressions can be selected using shift-click. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
Html where
/-- An `element "tag" attrs children` represents `<tag {...attrs}>{...children}</tag>`. -/
| element : String → Array (String × Json) → Array Html → Html
/-- Raw HTML text. -/
| text : String → Html
/-- A `component h e props children` represents `<Foo {...props}>{...children}</Foo>`,
where `Foo ... | inductive | ProofWidgets.Html | Data | ProofWidgets/Data/Html.lean | [] | [] | A HTML tree which may contain widget components. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Html.ofComponent [RpcEncodable Props]
(c : Component Props) (props : Props) (children : Array Html) : Html | .component (hash c.javascript) c.export (rpcEncode props) children | def | ProofWidgets.Html.ofComponent | Data | ProofWidgets/Data/Html.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
LayoutKind where
| block
| inline | inductive | ProofWidgets.LayoutKind | Data | ProofWidgets/Data/Html.lean | [] | [] | See [MDN docs](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flow_Layout/Block_and_Inline_Layout_in_Normal_Flow). | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
jsxTextForbidden : String | "{<>}$" | def | ProofWidgets.Jsx.jsxTextForbidden | Data | ProofWidgets/Data/Html.lean | [] | [] | Characters not allowed inside JSX plain text. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
jsxText : Parser | withAntiquot (mkAntiquot "jsxText" `ProofWidgets.Jsx.jsxText) {
fn := fun c s =>
let startPos := s.pos
let s := takeWhile1Fn (fun c => !jsxTextForbidden.contains c) "expected JSX text" c s
mkNodeToken `ProofWidgets.Jsx.jsxText startPos true c s } | def | ProofWidgets.Jsx.jsxText | Data | ProofWidgets/Data/Html.lean | [] | [
"fn"
] | A plain text literal for JSX (notation for `Html.text`). | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
getJsxText : TSyntax ``jsxText → String | | stx => stx.raw[0].getAtomVal | def | ProofWidgets.Jsx.getJsxText | Data | ProofWidgets/Data/Html.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
jsxText.formatter : Formatter | Formatter.visitAtom ``jsxText | def | ProofWidgets.Jsx.jsxText.formatter | Data | ProofWidgets/Data/Html.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
jsxText.parenthesizer : Parenthesizer | Parenthesizer.visitToken | def | ProofWidgets.Jsx.jsxText.parenthesizer | Data | ProofWidgets/Data/Html.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
transformTag (tk : Syntax) (n m : Ident) (vs : Array (TSyntax `proofWidgetsJsxAttr))
(cs : Array (TSyntax `proofWidgetsJsxChild)) : MacroM Term | do
let nId := n.getId.eraseMacroScopes
let mId := m.getId.eraseMacroScopes
if nId != mId then
Macro.throwErrorAt m s!"expected </{nId}>"
let trailingWs (stx : Syntax) :=
if let .original _ _ trailing _ := stx.getTailInfo then
trailing.toString
else ""
-- Whitespace appearing before the cur... | def | ProofWidgets.Jsx.transformTag | Data | ProofWidgets/Data/Html.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
delabHtmlText : DelabM (TSyntax ``jsxText) | do
let_expr Html.text e := ← getExpr | failure
let .lit (.strVal s) := e | failure
if s.any (fun (c : Char) => jsxTextForbidden.contains c) then
failure
annotateTermLikeInfo <| mkNode ``jsxText #[mkAtom s] | def | ProofWidgets.Jsx.delabHtmlText | Data | ProofWidgets/Data/Html.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
delabHtmlElement' : DelabM (TSyntax `proofWidgetsJsxElement) | do
let_expr Html.element tag _attrs _children := ← getExpr | failure
let .lit (.strVal s) := tag | failure
let tag ← withNaryArg 0 <| annotateTermLikeInfo <| mkIdent <| .mkSimple s
let attrs ← withNaryArg 1 <|
try
delabArrayLiteral <| withAnnotateTermLikeInfo do
let_expr Prod.mk _ _ a _ := ←... | def | ProofWidgets.Jsx.delabHtmlElement' | Data | ProofWidgets/Data/Html.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
delabHtmlOfComponent' : DelabM (TSyntax `proofWidgetsJsxElement) | do
let_expr Html.ofComponent _Props _inst _c _props _children := ← getExpr | failure
let c ← withNaryArg 2 delab
unless c.raw.isIdent do failure
let tag : Ident := ⟨c.raw⟩
-- TODO: handle `Props` that do not delaborate to `{ }`, such as `Prod`, by parsing the `Expr`
-- instead.
let attrDelab ← withNaryAr... | def | ProofWidgets.Jsx.delabHtmlOfComponent' | Data | ProofWidgets/Data/Html.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
delabJsxChildren : DelabM (Array (TSyntax `proofWidgetsJsxChild)) | do
try
delabArrayLiteral (withAnnotateTermLikeInfo do
try
match_expr ← getExpr with
| Html.text _ =>
let html ← delabHtmlText
return ← `(proofWidgetsJsxChild| $html:jsxText)
| Html.element _ _ _ =>
let html ← delabHtmlElement'
return ← `(proofW... | def | ProofWidgets.Jsx.delabJsxChildren | Data | ProofWidgets/Data/Html.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
delabHtmlElement : Delab | do
let t ← delabHtmlElement'
`(term| $t:proofWidgetsJsxElement) | def | ProofWidgets.Jsx.delabHtmlElement | Data | ProofWidgets/Data/Html.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
delabHtmlOfComponent : Delab | do
let t ← delabHtmlOfComponent'
`(term| $t:proofWidgetsJsxElement) | def | ProofWidgets.Jsx.delabHtmlOfComponent | Data | ProofWidgets/Data/Html.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
_root_.Int.toFloat (i : Int) : Float | if i >= 0 then
i.toNat.toFloat
else
-((-i).toNat.toFloat) | def | Int.toFloat | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Frame where
(xmin ymin : Float)
(xSize : Float)
(width height : Nat)
deriving ToJson, FromJson | structure | ProofWidgets.Svg.Frame | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | ||
Frame.ySize (frame : Frame) : Float | frame.height.toFloat * (frame.xSize / frame.width.toFloat) | def | ProofWidgets.Svg.Frame.ySize | Data | ProofWidgets/Data/Svg.lean | [] | [
"frame"
] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Frame.xmax (frame : Frame) : Float | frame.xmin + frame.xSize | def | ProofWidgets.Svg.Frame.xmax | Data | ProofWidgets/Data/Svg.lean | [] | [
"frame"
] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Frame.ymax (frame : Frame) : Float | frame.ymin + frame.ySize | def | ProofWidgets.Svg.Frame.ymax | Data | ProofWidgets/Data/Svg.lean | [] | [
"frame"
] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Frame.pixelSize (frame : Frame) : Float | frame.xSize / frame.width.toFloat | def | ProofWidgets.Svg.Frame.pixelSize | Data | ProofWidgets/Data/Svg.lean | [] | [
"frame"
] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Color where
(r := 0.0)
(g := 0.0)
(b := 0.0)
deriving ToJson, FromJson | structure | ProofWidgets.Svg.Color | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | ||
Color.toStringRGB (c : Color) : String | s!"rgb({255*c.r}, {255*c.g}, {255*c.b})" | def | ProofWidgets.Svg.Color.toStringRGB | Data | ProofWidgets/Data/Svg.lean | [] | [] | Returns string "rgb(r, g, b)" with `r,g,b ∈ [0,...,256)` | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
Point (f : Frame) where
| px (i j : Int)
| abs (x y : Float)
deriving Inhabited, ToJson, FromJson | inductive | ProofWidgets.Svg.Point | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | ||
Point.toPixels {f : Frame} (p : Point f) : Int × Int | match p with
| .px x y => (x,y)
| .abs x y =>
let Δx := f.pixelSize
let i := ((x - f.xmin) / Δx).floor.toInt
let j := ((f.ymax - y) / Δx).floor.toInt
(i, j) | def | ProofWidgets.Svg.Point.toPixels | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Point.toAbsolute {f : Frame} (p : Point f) : Float × Float | match p with
| .abs x y => (x,y)
| .px i j =>
let Δx := f.pixelSize
let x := f.xmin + (i.toFloat + 0.5) * Δx
let y := f.ymax - (j.toFloat + 0.5) * Δx
(x,y) | def | ProofWidgets.Svg.Point.toAbsolute | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Size (f : Frame) where
| px (size : Nat) : Size f
| abs (size : Float) : Size f
deriving ToJson, FromJson | inductive | ProofWidgets.Svg.Size | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | ||
Size.toPixels {f : Frame} (s : Size f) : Nat | match s with
| .px x => x
| .abs x => (x / f.pixelSize).ceil.toUInt64.toNat | def | ProofWidgets.Svg.Size.toPixels | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Shape (f : Frame) where
| line (src trg : Point f)
| circle (center : Point f) (radius : Size f)
| polyline (points : Array (Point f)) -- (type : PolylineType)
| polygon (points : Array (Point f))
| path (d : String)
| ellipse (center : Point f) (rx ry : Size f)
| rect (corner : Point f) (... | inductive | ProofWidgets.Svg.Shape | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | ||
Shape.toHtmlData {f : Frame} : Shape f → String × Array (String × Json) | | .line src trg =>
let (x1,y1) := src.toPixels
let (x2,y2) := trg.toPixels
("line", #[("x1", x1), ("y1", y1), ("x2", x2), ("y2", y2)])
| .circle center radius =>
let (cx,cy) := center.toPixels
let r := radius.toPixels
("circle", #[("cx", cx), ("cy", cy), ("r", r)])
| .polyline points =>
... | def | ProofWidgets.Svg.Shape.toHtmlData | Data | ProofWidgets/Data/Svg.lean | [] | [
"init"
] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Element (f : Frame) where
shape : Shape f
strokeColor | (none : Option Color)
strokeWidth := (none : Option (Size f))
fillColor := (none : Option Color)
id := (none : Option String)
data := (none : Option Json)
deriving ToJson, FromJson | structure | ProofWidgets.Svg.Element | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Element.setStroke {f} (elem : Element f) (color : Color) (width : Size f) | { elem with strokeColor := some color, strokeWidth := some width } | def | ProofWidgets.Svg.Element.setStroke | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Element.setFill {f} (elem : Element f) (color : Color) | { elem with fillColor := some color } | def | ProofWidgets.Svg.Element.setFill | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Element.setId {f} (elem : Element f) (id : String) | { elem with id := some id } | def | ProofWidgets.Svg.Element.setId | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Element.setData {α : Type} {f} (elem : Element f) (a : α) [ToJson α] | { elem with data := some (toJson a) } | def | ProofWidgets.Svg.Element.setData | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Element.toHtml {f : Frame} (e : Element f) : Html | Id.run do
let mut (tag, args) := e.shape.toHtmlData
let mut children := #[]
if let .text _ content _ := e.shape then
children := #[.text content] -- adding children <text>
if let .some color := e.strokeColor then
args := args.push ("stroke", color.toStringRGB)
if let .some width := e.strokeWidth t... | def | ProofWidgets.Svg.Element.toHtml | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
line {f} (p q : Point f) : Element f | { shape := .line p q } | def | ProofWidgets.Svg.line | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
circle {f} (c : Point f) (r : Size f) : Element f | { shape := .circle c r } | def | ProofWidgets.Svg.circle | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
polyline {f} (pts : Array (Point f)) : Element f | { shape := .polyline pts } | def | ProofWidgets.Svg.polyline | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
polygon {f} (pts : Array (Point f)) : Element f | { shape := .polygon pts } | def | ProofWidgets.Svg.polygon | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
path {f} (d : String) : Element f | { shape := .path d } | def | ProofWidgets.Svg.path | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
ellipse {f} (center : Point f) (rx ry : Size f) : Element f | { shape := .ellipse center rx ry } | def | ProofWidgets.Svg.ellipse | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
rect {f} (corner : Point f) (width height : Size f) : Element f | { shape := .rect corner width height } | def | ProofWidgets.Svg.rect | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
text {f} (pos : Point f) (content : String) (size : Size f) : Element f | { shape := .text pos content size } | def | ProofWidgets.Svg.text | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
mkIdToIdx {f} (elements : Array (Svg.Element f)) : Std.HashMap String (Fin elements.size) | let idToIdx := elements
|>.mapFinIdx (λ idx el h => (⟨idx, h⟩, el)) -- zip with `Fin` index
|>.filterMap (λ (idx,el) => el.id.map (λ id => (id, idx))) -- keep only elements with specified id
|>.toList
|> Std.HashMap.ofList
idToIdx | def | ProofWidgets.mkIdToIdx | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Svg (f : Svg.Frame) where
elements : Array (Svg.Element f)
idToIdx | mkIdToIdx elements | structure | ProofWidgets.Svg | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
toHtml {f : Frame} (svg : Svg f) : Html | <svg xmlns="http://www.w3.org/2000/svg" version="1.1"
width={f.width} height={f.height}>
{... svg.elements.map (·.toHtml)}
</svg> | def | ProofWidgets.Svg.toHtml | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
idToDataList {f} (svg : Svg f) : List (String × Json) | svg.elements.foldr (init := []) (λ e l =>
match e.id, e.data with
| some id, some data => (id,data)::l
| _, _ => l) | def | ProofWidgets.Svg.idToDataList | Data | ProofWidgets/Data/Svg.lean | [] | [
"init"
] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
idToData {f} (svg : Svg f) : Std.HashMap String Json | HashMap.ofList svg.idToDataList | def | ProofWidgets.Svg.idToData | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
getData {f} (svg : Svg f) (id : String) : Option Json | match svg[id] with
| none => none
| some elem => elem.data | def | ProofWidgets.Svg.getData | Data | ProofWidgets/Data/Svg.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
List.product : List α → List β → List (α × β) | | [], _ => []
| a::as, bs => bs.map ((a, ·)) ++ as.product bs | def | List.product | Demos | ProofWidgets/Demos/Dynkin.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
Matrix (n m α : Type) | n → m → α | def | Matrix | Demos | ProofWidgets/Demos/Dynkin.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
nat_index (i j : Nat) : Int | if h : i < n ∧ j < n then A ⟨i, h.1⟩ ⟨j, h.2⟩ else 999 | def | Matrix.nat_index | Demos | ProofWidgets/Demos/Dynkin.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
get_node_pos_E : Nat → Nat × Nat | | 0 => ⟨0, 0⟩
| 1 => ⟨2, 1⟩
| (i+1) => ⟨i, 0⟩ | def | Matrix.get_node_pos_E | Demos | ProofWidgets/Demos/Dynkin.lean | [] | [] | TODO Delete me once `get_node_pos` smart enough to infer layout from values in `A`. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
get_node_pos (n : Nat) : Nat → Nat × Nat | if n < 6 then ((·, 0)) else get_node_pos_E | def | Matrix.get_node_pos | Demos | ProofWidgets/Demos/Dynkin.lean | [] | [] | TODO Use `A` to infer sensible layout. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
get_node_cx (n i : Nat) : Int | 20 + (get_node_pos n i).1 * 40 | def | Matrix.get_node_cx | Demos | ProofWidgets/Demos/Dynkin.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
get_node_cy (n i : Nat) : Int | 20 + (get_node_pos n i).2 * 40 | def | Matrix.get_node_cy | Demos | ProofWidgets/Demos/Dynkin.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
get_node_html (n i : Nat) : Html | <circle
cx={toString <| get_node_cx n i}
cy={toString <| get_node_cy n i}
r="10"
fill="white"
stroke="black" /> | def | Matrix.get_node_html | Demos | ProofWidgets/Demos/Dynkin.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
get_edge_html : Nat × Nat → List Html | | (i, j) => if A.nat_index i j = 0 then [] else
[<line
x1={toString <| get_node_cx n i}
y1={toString <| get_node_cy n i}
x2={toString <| get_node_cx n j}
y2={toString <| get_node_cy n j}
fill="black"
stroke="black" />] | def | Matrix.get_edge_html | Demos | ProofWidgets/Demos/Dynkin.lean | [] | [] | TODO
* Error if `j ≤ i`
* Error if `(A i j, A j i) ∉ [((0 : Int), (0 : Int)), (-1, -1), (-1, -2), (-2, -1), (-1, -3), (-3, -1)]`
* Render `(A i j) * (A j i)` edges
* Render arrow on double or triple edge with direction decided by `A i j < A j i` | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
get_nodes_html (n : Nat) : List Html | (List.range n).map (get_node_html n) | def | Matrix.get_nodes_html | Demos | ProofWidgets/Demos/Dynkin.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
get_edges_html : List Html | Id.run do
let mut out := []
for j in [:n] do
for i in [:j] do
out := A.get_edge_html (i, j) ++ out
return out | def | Matrix.get_edges_html | Demos | ProofWidgets/Demos/Dynkin.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
toHtml (M : Matrix (Fin n) (Fin n) Int) : Html | <div style={json% { height: "100px", width: "300px", background: "grey" }}>
{Html.element "svg" #[] (M.get_edges_html ++ Matrix.get_nodes_html n).toArray}
</div> | def | Matrix.toHtml | Demos | ProofWidgets/Demos/Dynkin.lean | [] | [
"Matrix",
"Matrix.get_nodes_html"
] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
cartanMatrix.E₈ : Matrix (Fin 8) (Fin 8) Int | fun i j =>
[[ 2, 0, -1, 0, 0, 0, 0, 0],
[ 0, 2, 0, -1, 0, 0, 0, 0],
[-1, 0, 2, -1, 0, 0, 0, 0],
[ 0, -1, -1, 2, -1, 0, 0, 0],
[ 0, 0, 0, -1, 2, -1, 0, 0],
[ 0, 0, 0, 0, -1, 2, -1, 0],
[ 0, 0, 0, 0, 0, -1, 2, -1],
[ 0, 0, 0, 0, 0, 0, -1, 2... | def | cartanMatrix.E₈ | Demos | ProofWidgets/Demos/Dynkin.lean | [] | [
"Matrix"
] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
IncidenceGeometry where
Point : Type u₁
Line : Type u₂
Circle : Type u₃
between : Point → Point → Point → Prop -- implies colinearity
onLine : Point → Line → Prop
onCircle : Point → Circle → Prop
inCircle : Point → Circle → Prop
centerCircle : Point → Circle → Prop
circlesInter : Circle → Circle → Pr... | class | IncidenceGeometry | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | ||
isBetweenPred? (e : Expr) : Option (Expr × Expr × Expr) | do
let some (_, a, b, c) := e.app4? ``between | none
return (a, b, c) | def | isBetweenPred? | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [] | If `e == between a b c` return `some (a, b, c)`, otherwise `none`. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
isOnLinePred? (e : Expr) : Option (Expr × Expr) | do
let some (_, a, L) := e.app3? ``onLine | none
return (a, L) | def | isOnLinePred? | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [] | If `e == onLine a L` return `some (a, L)`, otherwise `none`. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
isOnCirclePred? (e : Expr) : Option (Expr × Expr) | do
let some (_, a, C) := e.app3? ``onCircle | none
return (a, C) | def | isOnCirclePred? | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [] | If `e == onCircle a C` return `some (a, C)`, otherwise `none`. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
isInCirclePred? (e : Expr) : Option (Expr × Expr) | do
let some (_, a, C) := e.app3? ``inCircle | none
return (a, C) | def | isInCirclePred? | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [] | If `e == inCircle a C` return `some (a, C)`, otherwise `none`. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
isCenterCirclePred? (e : Expr) : Option (Expr × Expr) | do
let some (_, a, C) := e.app3? ``centerCircle | none
return (a, C) | def | isCenterCirclePred? | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [] | If `e == centerCircle a C` return `some (a, C)`, otherwise `none`. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
isCirclesInterPred? (e : Expr) : Option (Expr × Expr) | do
let some (_, a, C) := e.app3? ``circlesInter | none
return (a, C) | def | isCirclesInterPred? | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [] | If `e == circlesInter a C` return `some (a, C)`, otherwise `none`. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
isPoint? (e : Expr) : Bool | e.isAppOf ``Point | def | isPoint? | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
isLine? (e : Expr) : Bool | e.isAppOf ``Line | def | isLine? | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
addHypotheses (hyps : Array LocalDecl) : DiagramBuilderM Unit | do
for h in hyps do
let tp ← instantiateMVars h.type
if isPoint? tp then
discard $ addExpr "Point" h.toExpr
if isLine? tp then
discard $ addExpr "Line" h.toExpr
if let some (a, b, c) := isBetweenPred? tp then
let sa ← addExpr "Point" a
let sb ← addExpr "Point" b
let sc ← ... | def | addHypotheses | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [
"isBetweenPred?",
"isCenterCirclePred?",
"isCirclesInterPred?",
"isInCirclePred?",
"isLine?",
"isOnCirclePred?",
"isOnLinePred?",
"isPoint?"
] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
EuclideanDisplay.dsl | include_str ".."/".."/"widget"/"penrose"/"euclidean.dsl" | def | EuclideanDisplay.dsl | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
EuclideanDisplay.sty | include_str ".."/".."/"widget"/"penrose"/"euclidean.sty" | def | EuclideanDisplay.sty | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
EuclideanDisplay.rpc (props : PanelWidgetProps) : RequestM (RequestTask Html) | RequestM.asTask do
let inner : Html ← (do
-- Are there any goals unsolved? If so, pick the first one.
if props.goals.isEmpty then
return <span>No goals.</span>
let some g := props.goals[0]? | unreachable!
-- Execute the next part using the metavariable context and local context of t... | def | EuclideanDisplay.rpc | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [
"addHypotheses"
] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
EuclideanDisplay : Component PanelWidgetProps | mk_rpc_widget% EuclideanDisplay.rpc | def | EuclideanDisplay | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [
"EuclideanDisplay.rpc"
] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
constructLines (hyps : Array LocalDecl) (docMeta : Server.DocumentMeta) (cursorPos : Lsp.Position)
: DiagramBuilderM Unit | do
-- Identify objects and hypotheses from which constructions can be made.
let mut points : Array LocalDecl := {}
let mut circleInters : Array (LocalDecl × LocalDecl × LocalDecl) := {}
for h in hyps do
let tp ← instantiateMVars h.type
if isPoint? tp then
points := points.push h
if let some (.... | def | constructLines | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [
"isCirclesInterPred?",
"isPoint?"
] | Add every possible line between any two points in `hyps`
to the diagram.
Lines are labelled with links to insert them into the proof script. | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
EuclideanConstructions.rpc (props : PanelWidgetProps) : RequestM (RequestTask Html) | RequestM.asTask do
let doc ← RequestM.readDoc
let inner : Html ← (do
-- Are there any goals unsolved? If so, pick the first one.
if props.goals.isEmpty then
return <span>No goals.</span>
let some g := props.goals[0]? | unreachable!
-- Execute the next part using the metavariable... | def | EuclideanConstructions.rpc | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [
"EuclideanDisplay.dsl",
"EuclideanDisplay.sty",
"addHypotheses",
"constructLines"
] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
EuclideanConstructions : Component PanelWidgetProps | mk_rpc_widget% EuclideanConstructions.rpc | def | EuclideanConstructions | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [
"EuclideanConstructions.rpc"
] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b | |
test_sorry {α} : α
show_panel_widgets [local EuclideanConstructions] | axiom | test_sorry | Demos | ProofWidgets/Demos/Euclidean.lean | [] | [
"EuclideanConstructions"
] | https://github.com/leanprover-community/ProofWidgets4 | 85bb7e7637e84a7d9803be7d954579fdae42c64b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.