fact string | type string | library string | imports list | filename string | symbolic_name string | docstring string |
|---|---|---|---|---|---|---|
AnimatedHtml : Component AnimatedHtmlProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "animatedHtml.js" open scoped ProofWidgets.Jsx in -- put your cursor on the below line to see an animated widget #html <AnimatedHtml frames={mkFrames fn} framesPerSecond?={some 60} /> | def | ProofWidgets | [] | ProofWidgets/Demos/Plot.lean | AnimatedHtml | null |
RBColour where | red | black | inductive | ProofWidgets | [] | ProofWidgets/Demos/RbTree.lean | RBColour | null |
RBTree (α : Type u) where | empty : RBTree α | node (color : RBColour) (l : RBTree α) (a : α) (r : RBTree α) : RBTree α namespace RBTree | inductive | ProofWidgets | [] | ProofWidgets/Demos/RbTree.lean | RBTree | null |
contains [Ord α] (a : α) : RBTree α → Bool | empty => false | node _ l b r => match compare a b with | .lt => l.contains a | .eq => true | .gt => r.contains a | def | ProofWidgets | [] | ProofWidgets/Demos/RbTree.lean | contains | null |
balance : RBColour → RBTree α → α → RBTree α → RBTree α | .black, (node .red (node .red a x b) y c), z, d | .black, (node .red a x (node .red b y c)), z, d | .black, a, x, (node .red (node .red b y c) z d) | .black, a, x, (node .red b y (node .red c z d)) => node .red (node .black a x b) y (node .black c z d) | color, ... | def | ProofWidgets | [] | ProofWidgets/Demos/RbTree.lean | balance | null |
insert [Ord α] (a : α) (s : RBTree α) : RBTree α := makeBlack (ins s) where ins : RBTree α → RBTree α | empty => node .red empty a empty | node c l b r => match compare a b with | .lt => balance c (ins l) b r | .eq => node c l b r | .gt => balance c l b (ins r) makeBlack : RBTree α → RBTree α | empty => empty | node _ ... | def | ProofWidgets | [] | ProofWidgets/Demos/RbTree.lean | insert | null |
empty ? (e : Expr) : Bool := e.app1? ``RBTree.empty matches some _ @[inline] def Lean.Expr.app5? (e : Expr) (fName : Name) : Option (Expr × Expr × Expr × Expr × Expr) := if e.isAppOfArity fName 5 then some ( e.appFn!.appFn!.appFn!.appFn!.appArg!, e.appFn!.appFn!.appFn!.appArg!, e.appFn!.appFn!.appArg!, e.appFn!.appArg!... | def | ProofWidgets | [] | ProofWidgets/Demos/RbTree.lean | empty | null |
node ? (e : Expr) : Option (Expr × Expr × Expr × Expr) := do let some (_, color, l, a, r) := e.app5? ``RBTree.node | none return (color, l, a, r) | def | ProofWidgets | [] | ProofWidgets/Demos/RbTree.lean | node | null |
evalColourUnsafe (e : Expr) : MetaM RBColour := Lean.Meta.evalExpr' RBColour ``RBColour e @[implemented_by evalColourUnsafe] | def | ProofWidgets | [] | ProofWidgets/Demos/RbTree.lean | evalColourUnsafe | null |
evalColour (e : Expr) : MetaM RBColour /-- Like `RBTreeColour`, but with `blue` standing in for unknown, symbolic `c : RBTreeColour`. -/ | opaque | ProofWidgets | [] | ProofWidgets/Demos/RbTree.lean | evalColour | null |
RBTreeVarsColour where | red | black | blue deriving FromJson, ToJson open Widget in /-- Like `RBTree` but with concrete node contents replaced by quoted, pretty-printed code, and an extra constructor for similarly pretty-printed symbolic subtrees. Tangent: what is the transformation of polynomial functors from the ori... | inductive | ProofWidgets | [] | ProofWidgets/Demos/RbTree.lean | RBTreeVarsColour | /-- Like `RBTreeColour`, but with `blue` standing in for unknown, symbolic `c : RBTreeColour`. -/ |
RBTreeVars where | empty : RBTreeVars | var : CodeWithInfos → RBTreeVars | node (color : RBTreeVarsColour) (l : RBTreeVars) (a : CodeWithInfos) (r : RBTreeVars) : RBTreeVars deriving Server.RpcEncodable /-! # `Expr` presenter to display red-black trees -/ | inductive | ProofWidgets | [] | ProofWidgets/Demos/RbTree.lean | RBTreeVars | /-- Like `RBTree` but with concrete node contents replaced by quoted, pretty-printed code,
and an extra constructor for similarly pretty-printed symbolic subtrees.
Tangent: what is the transformation of polynomial functors from the original type to
one with this kind of symbolic data? -/ |
RBDisplayProps where tree : RBTreeVars deriving Server.RpcEncodable open ProofWidgets @[widget_module] | structure | ProofWidgets | [] | ProofWidgets/Demos/RbTree.lean | RBDisplayProps | null |
RBDisplay : Component RBDisplayProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "rbTree.js" open scoped Jsx in | def | ProofWidgets | [] | ProofWidgets/Demos/RbTree.lean | RBDisplay | null |
drawTree ? (e : Expr) : MetaM (Option Html) := do if let some _ := node? e then return some <RBDisplay tree={← go e}/> else if empty? e then return some <RBDisplay tree={← go e}/> else return none where go (e : Expr) : MetaM RBTreeVars := do if let some (color, l, a, r) := node? e then let color ← try match ← evalColou... | def | ProofWidgets | [] | ProofWidgets/Demos/RbTree.lean | drawTree | null |
RBTree.presenter : ExprPresenter where userName := "Red-black tree" present e := do let some t ← drawTree? e | throwError "not a tree :(" return t /-! # Example -/ open RBTree RBColour in | def | ProofWidgets | [] | ProofWidgets/Demos/RbTree.lean | RBTree.presenter | null |
RubiksProps where seq : Array String := #[] deriving ToJson, FromJson, Inhabited @[widget_module] | structure | ProofWidgets | [] | ProofWidgets/Demos/Rubiks.lean | RubiksProps | null |
Rubiks : Component RubiksProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "rubiks.js" | def | ProofWidgets | [] | ProofWidgets/Demos/Rubiks.lean | Rubiks | null |
eg := #["L", "L", "D⁻¹", "U⁻¹", "L", "D", "D", "L", "U⁻¹", "R", "D", "F", "F", "D"] #html <Rubiks seq={eg} /> | def | ProofWidgets | [] | ProofWidgets/Demos/Rubiks.lean | eg | null |
SolveReturn where expr : Expr val? : Option String listRest : List Nat | structure | ProofWidgets | [] | ProofWidgets/Demos/SelectInsertConv.lean | SolveReturn | null |
solveLevel (expr : Expr) (path : List Nat) : MetaM SolveReturn := match expr with | Expr.app _ _ => do let mut descExp := expr let mut count := 0 let mut explicitList := [] -- we go through the application until we reach the end, counting how many explicit arguments -- it has and noting whether they are explicit or imp... | def | ProofWidgets | [] | ProofWidgets/Demos/SelectInsertConv.lean | solveLevel | null |
insertEnter (locations : Array Lean.SubExpr.GoalsLocation) (goalType : Expr) : MetaM String := do let some pos := locations[0]? | throwError "You must select something." let ⟨_, .target subexprPos⟩ := pos | throwError "You must select something in the goal." let mut list := (SubExpr.Pos.toArray subexprPos).toList let m... | def | ProofWidgets | [] | ProofWidgets/Demos/SelectInsertConv.lean | insertEnter | null |
findGoalForLocation (goals : Array Widget.InteractiveGoal) (loc : SubExpr.GoalsLocation) : Option Widget.InteractiveGoal := goals.find? (·.mvarId == loc.mvarId) | def | ProofWidgets | [] | ProofWidgets/Demos/SelectInsertConv.lean | findGoalForLocation | null |
ConvSelectionPanelProps extends PanelWidgetProps where /-- The range in the source document where the `conv` command will be inserted. -/ replaceRange : Lsp.Range deriving RpcEncodable open scoped Jsx in @[server_rpc_method] | structure | ProofWidgets | [] | ProofWidgets/Demos/SelectInsertConv.lean | ConvSelectionPanelProps | null |
ConvSelectionPanel.rpc (props : ConvSelectionPanelProps) : RequestM (RequestTask Html) := RequestM.asTask do let doc ← RequestM.readDoc let inner : Html ← (do if props.selectedLocations.isEmpty then return <span>Use shift-click to select one sub-expression in the goal that you want to zoom on.</span> let some selectedL... | def | ProofWidgets | [] | ProofWidgets/Demos/SelectInsertConv.lean | ConvSelectionPanel.rpc | /-- The range in the source document where the `conv` command will be inserted. -/ |
ConvSelectionPanel : Component ConvSelectionPanelProps := mk_rpc_widget% ConvSelectionPanel.rpc open scoped Json in elab stx:"conv?" : tactic => do let some replaceRange := (← getFileMap).lspRangeOfStx? stx | return Widget.savePanelWidgetInfo ConvSelectionPanel.javascriptHash (pure $ json% { replaceRange: $(replaceRang... | def | ProofWidgets | [] | ProofWidgets/Demos/SelectInsertConv.lean | ConvSelectionPanel | null |
test_sorry {α} : α | axiom | ProofWidgets | [] | ProofWidgets/Demos/SelectInsertConv.lean | test_sorry | null |
frame : Frame where xmin := 0 ymin := 0 xSize := 450 width := 450 height := 450 | def | ProofWidgets | [] | ProofWidgets/Demos/Svg.lean | frame | null |
github : Svg frame := { elements := #[ circle (200.0, 245.0) (.px 175) |>.setFill (1.0, 1.0, 1.0), path "M195,25C99.3,25,20,104.3,20,200C20,276,70.4,340.9,140.8,370.2C151.9,372.2,155.4,365.4,155.4,359.4C155.4,354,155.2,338.7,155.1,320C104.7,332.6,92.9,296.4,92.9,296.4C83.9,270.7,70.5,263.9,70.5,263.9C53.4,250.3,71.8,25... | def | ProofWidgets | [] | ProofWidgets/Demos/Svg.lean | github | null |
triangle01 : Svg frame := {elements := #[ path "M 100 100 L 300 100 L 200 300 z" |>.setFill ( 1.0 , 0. , 0.) |>.setStroke (136., 136., 136.) (.px 3) ]} #html triangle01.toHtml | def | ProofWidgets | [] | ProofWidgets/Demos/Svg.lean | triangle01 | null |
cubic01 : Svg frame := { elements := #[ polyline #[ (100.,200.), (100.,100.)] |>.setStroke (136., 136., 136.) (.px 2), polyline #[ (250.,100.), (250.,200.)] |>.setStroke (136., 136., 136.) (.px 2), polyline #[ (250.,200.), (250.,300.)] |>.setStroke (136., 136., 136.) (.px 2), polyline #[ (400.,300.), (400.,200.)] |>.se... | def | ProofWidgets | [] | ProofWidgets/Demos/Svg.lean | cubic01 | null |
svgprims : Svg frame := {elements := #[ rect (100.0, 100.0) (.abs 70.0) (.abs 70.0) |>.setStroke (255., 0., 0.) (.px 2) |>.setFill (0.5, 0.5, 0.5), ellipse (200.0, 200.0) (.abs 50.0) (.abs 30.0) |>.setStroke (0., 255., 0.) (.px 2) |>.setFill (0.3, 0.3, 1.0), line (300.0, 300.0) (350.0, 350.0) |>.setStroke (255., 255., ... | def | ProofWidgets | [] | ProofWidgets/Demos/Svg.lean | svgprims | null |
Set (α : Type u) := α → Prop namespace Set /-- Membership in a set -/ | def | ProofWidgets | [] | ProofWidgets/Demos/Venn.lean | Set | null |
Mem (s : Set α) (a : α) : Prop := s a | def | ProofWidgets | [] | ProofWidgets/Demos/Venn.lean | Mem | /-- Membership in a set -/ |
ext {a b : Set α} (h : ∀ (x : α), x ∈ a ↔ x ∈ b) : a = b := funext (fun x ↦ propext (h x)) | theorem | ProofWidgets | [] | ProofWidgets/Demos/Venn.lean | ext | /-- Membership in a set -/ |
Subset (s₁ s₂ : Set α) := ∀ ⦃a⦄, a ∈ s₁ → a ∈ s₂ /-- Porting note: we introduce `≤` before `⊆` to help the unifier when applying lattice theorems to subset hypotheses. -/ | def | ProofWidgets | [] | ProofWidgets/Demos/Venn.lean | Subset | /-- Membership in a set -/ |
isSubsetPred ? (e : Expr) : Option (Expr × Expr) := do let some (_, _, S, T) := e.app4? ``HasSubset.Subset | none return (S, T) /-- Expressions to display as labels in a diagram. -/ | def | ProofWidgets | [] | ProofWidgets/Demos/Venn.lean | isSubsetPred | /-- If `e == S ⊆ T` return `some (S, T)`, otherwise `none`. -/ |
ExprEmbeds := Array (String × Expr) open scoped Jsx in | abbrev | ProofWidgets | [] | ProofWidgets/Demos/Venn.lean | ExprEmbeds | /-- Expressions to display as labels in a diagram. -/ |
mkSetDiag (sub : String) (embeds : ExprEmbeds) : MetaM Html := do let embeds ← embeds.mapM fun (s, h) => return (s, <InteractiveCode fmt={← Widget.ppExprTagged h} />) return <PenroseDiagram embeds={embeds} dsl={include_str ".."/".."/"widget"/"penrose"/"setTheory.dsl"} sty={include_str ".."/".."/"widget"/"penrose"/"venn... | def | ProofWidgets | [] | ProofWidgets/Demos/Venn.lean | mkSetDiag | /-- Expressions to display as labels in a diagram. -/ |
isSetGoal ? (hyps : Array LocalDecl) : MetaM (Option Html) := do let mut sub := "AutoLabel All\n" let mut sets : Std.HashMap String Expr := ∅ for assm in hyps do let tp ← instantiateMVars assm.type if let some (S, T) := isSubsetPred? tp then let sS ← toString <$> Lean.Meta.ppExpr S let sT ← toString <$> Lean.Meta.ppExp... | def | ProofWidgets | [] | ProofWidgets/Demos/Venn.lean | isSetGoal | /-- Expressions to display as labels in a diagram. -/ |
findGoalForLocation (goals : Array Widget.InteractiveGoal) (loc : SubExpr.GoalsLocation) : Option Widget.InteractiveGoal := goals.find? (·.mvarId == loc.mvarId) open scoped Jsx in @[server_rpc_method] | def | ProofWidgets | [] | ProofWidgets/Demos/Venn.lean | findGoalForLocation | null |
VennDisplay.rpc (props : PanelWidgetProps) : RequestM (RequestTask Html) := RequestM.asTask do let inner : Html ← (do if props.selectedLocations.isEmpty then return <span>Use shift-click to select hypotheses to include in the diagram.</span> let some selectedLoc := props.selectedLocations[0]? | unreachable! let some g ... | def | ProofWidgets | [] | ProofWidgets/Demos/Venn.lean | VennDisplay.rpc | null |
VennDisplay : Component PanelWidgetProps := mk_rpc_widget% VennDisplay.rpc /-! # Example usage -/ | def | ProofWidgets | [] | ProofWidgets/Demos/Venn.lean | VennDisplay | null |
ProofWidgets.CheckHighlight (name : Lean.Name) (showAlt : Bool) : MetaM Unit := do let constVal ← getConstVal name Meta.forallTelescope constVal.type <| fun args outType => do let mut msg : MessageData := toString name if !constVal.levelParams.isEmpty then let univStr : String := ",".intercalate (constVal.levelParams.m... | def | ProofWidgets | [] | ProofWidgets/Extra/CheckHighlight.lean | ProofWidgets.CheckHighlight | /--
Print the signature of `name` as a widget message in the infoview
with dimmed implicit arguments (opacity 50%).
Arguments:
* `name`: fully qualified name of the constant to print the signature of
* `showAlt`: if `false`, implicit arguments are omitted
from the `alt` argument of `MessageData.ofWidget`
-/ |
ExprPresenter where /-- A user-friendly name for this presenter. For example, "LaTeX". -/ userName : String /-- Whether the output HTML has inline (think something which fits in the space normally occupied by an `Expr`, e.g. LaTeX) or block (think large diagram which needs dedicated space) layout. -/ layoutKind : Layou... | structure | ProofWidgets | [] | ProofWidgets/Presentation/Expr.lean | ExprPresenter | /-- An `Expr` presenter is similar to a delaborator but outputs HTML trees instead of syntax, and
the output HTML can contain elements which interact with the original `Expr` in some way. We call
interactive outputs with a reference to the original input *presentations*. -/ |
evalExprPresenter (env : Environment) (opts : Options) (constName : Name) : Except String ExprPresenter | opaque | ProofWidgets | [] | ProofWidgets/Presentation/Expr.lean | evalExprPresenter | null |
GetExprPresentationsParams where expr : WithRpcRef ExprWithCtx deriving RpcEncodable | structure | ProofWidgets | [] | ProofWidgets/Presentation/Expr.lean | GetExprPresentationsParams | null |
ExprPresentationData where name : Name userName : String html : Html deriving RpcEncodable | structure | ProofWidgets | [] | ProofWidgets/Presentation/Expr.lean | ExprPresentationData | null |
ExprPresentations where presentations : Array ExprPresentationData deriving RpcEncodable @[server_rpc_method] | structure | ProofWidgets | [] | ProofWidgets/Presentation/Expr.lean | ExprPresentations | null |
getExprPresentations : GetExprPresentationsParams → RequestM (RequestTask ExprPresentations) | ⟨ref⟩ => RequestM.asTask do let mut presentations : Array ExprPresentationData := #[] let expr := ref.val let env := expr.ci.env for nm in exprPresenters.ext.getState env do presentations ← addPresenterIfApplicable expr nm pr... | def | ProofWidgets | [] | ProofWidgets/Presentation/Expr.lean | getExprPresentations | null |
GetExprPresentationParams where expr : WithRpcRef ExprWithCtx /-- Name of the presenter to use. -/ name : Name deriving RpcEncodable | structure | ProofWidgets | [] | ProofWidgets/Presentation/Expr.lean | GetExprPresentationParams | null |
ExprPresentationProps where expr : WithRpcRef ExprWithCtx deriving RpcEncodable /-- This component shows a selection of all known and applicable `ProofWidgets.ExprPresenter`s which are used to render the expression when selected. The one with highest precedence (TODO) is shown by default. -/ @[widget_module] | structure | ProofWidgets | [] | ProofWidgets/Presentation/Expr.lean | ExprPresentationProps | /-- Name of the presenter to use. -/ |
ExprPresentation : Component ExprPresentationProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "exprPresentation.js" | def | ProofWidgets | [] | ProofWidgets/Presentation/Expr.lean | ExprPresentation | /-- This component shows a selection of all known and applicable `ProofWidgets.ExprPresenter`s which
are used to render the expression when selected. The one with highest precedence (TODO) is shown by
default. -/ |
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 currently selected... | structure | ProofWidgets | [] | ProofWidgets/Component/Panel/Basic.lean | PanelWidgetProps | null |
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 | [] | ProofWidgets/Component/Panel/Basic.lean | withPanelWidgets | /-- Display the selected panel widgets in the nested tactic script. For example,
assuming we have written a `GeometryDisplay` component,
```lean
by with_panel_widgets [GeometryDisplay]
simp
rfl
```
will show the geometry display alongside the usual tactic state throughout the proof.
-/ |
GoalTypePanel : Component PanelWidgetProps where javascript := include_str ".." / ".." / ".." / ".lake" / "build" / "js" / "goalTypePanel.js" | def | ProofWidgets | [] | ProofWidgets/Component/Panel/GoalTypePanel.lean | GoalTypePanel | /-- Display the goal type using known `Expr` presenters. -/ |
Lean.SubExpr.GoalsLocation.saveExprWithCtx (loc : GoalsLocation) : MetaM ExprWithCtx := let mvarId := loc.mvarId match loc.loc with | .hyp fv => mvarId.withContext <| ExprWithCtx.save (mkFVar fv) | .hypType fv pos => mvarId.withContext do let tp ← Meta.inferType (mkFVar fv) Meta.viewSubexpr (visit := fun _ => ExprWithC... | def | ProofWidgets | [] | ProofWidgets/Component/Panel/SelectionPanel.lean | Lean.SubExpr.GoalsLocation.saveExprWithCtx | /-- Save the expression corresponding to a goals location. -/ |
GoalsLocationsToExprsParams where locations : Array (WithRpcRef Elab.ContextInfo × SubExpr.GoalsLocation) deriving RpcEncodable | structure | ProofWidgets | [] | ProofWidgets/Component/Panel/SelectionPanel.lean | GoalsLocationsToExprsParams | null |
GoalsLocationsToExprsResponse where exprs : Array (WithRpcRef ExprWithCtx) deriving RpcEncodable /-- Compute expressions corresponding to the given `GoalsLocation`s. -/ @[server_rpc_method] | structure | ProofWidgets | [] | ProofWidgets/Component/Panel/SelectionPanel.lean | GoalsLocationsToExprsResponse | null |
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 } /-- Display a l... | def | ProofWidgets | [] | ProofWidgets/Component/Panel/SelectionPanel.lean | goalsLocationsToExprs | /-- Compute expressions corresponding to the given `GoalsLocation`s. -/ |
SelectionPanel : Component PanelWidgetProps where javascript := include_str ".." / ".." / ".." / ".lake" / "build" / "js" / "presentSelection.js" | def | ProofWidgets | [] | ProofWidgets/Component/Panel/SelectionPanel.lean | SelectionPanel | /-- 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. -/ |
mkEdge (st : String × String) : GraphDisplay.Edge := {source := st.1, target := st.2} -- Place your cursor here. #html <GraphDisplay vertices={#["a", "b", "c", "d", "e", "f"].map ({id := ·})} edges={#[("b","c"), ("d","e"), ("e","f"), ("f","d")].map mkEdge} /> /-! ### Custom layout Forces acting on the vertices can be c... | def | ProofWidgets | [] | ProofWidgets/Demos/Graph/Basic.lean | mkEdge | null |
complete (n : Nat) : Array GraphDisplay.Vertex × Array GraphDisplay.Edge := Id.run do let mut verts := #[] let mut edges := #[] for i in [:n] do verts := verts.push {id := toString i} for j in [:i] do edges := edges.push {source := toString i, target := toString j} edges := edges.push {source := toString j, target := t... | def | ProofWidgets | [] | ProofWidgets/Demos/Graph/Basic.lean | complete | null |
K₁₀ := complete 10 #html <GraphDisplay vertices={K₁₀.1} edges={K₁₀.2} -- Specify forces here. forces={#[ .link { distance? := some 150 } ]} /> /-! ### Vertex labels Arbitrary SVG elements can be used as vertex labels. -/ #html <GraphDisplay vertices={#[ { id := "a" -- Specify a label here. label := <circle r={5} fill="... | def | ProofWidgets | [] | ProofWidgets/Demos/Graph/Basic.lean | K₁₀ | null |
elabExprGraphCmd : CommandElab := fun | stx@`(#expr_graph $i:ident) => runTermElabM fun _ => do let env ← getEnv let c ← realizeGlobalConstNoOverloadWithInfo i let some c := env.find? c | throwError "internal error" let nodes : NameSet := c.getUsedConstantsAsSet let mut edges : Std.HashSet (String × String) := {} for a... | def | ProofWidgets | [] | ProofWidgets/Demos/Graph/ExprGraph.lean | elabExprGraphCmd | /-- Display the graph of all constants appearing in a given constant. -/ |
a : Nat := 0 | def | ProofWidgets | [] | ProofWidgets/Demos/Graph/ExprGraph.lean | a | null |
b : Nat := 1 | def | ProofWidgets | [] | ProofWidgets/Demos/Graph/ExprGraph.lean | b | null |
foo (c : Nat) : Nat × Int := (a + b * c, a / b) -- Put your cursor here. #expr_graph foo | def | ProofWidgets | [] | ProofWidgets/Demos/Graph/ExprGraph.lean | foo | null |
Graph (α β : Type u) [BEq α] [Hashable α] := Std.HashMap α (List (α × β)) variable {α β : Type u} [BEq α] [Hashable α] /-- Filter out vertices not reachable from a vertex in `vs`. -/ | abbrev | ProofWidgets | [] | ProofWidgets/Demos/Graph/MVarGraph.lean | Graph | /-- Adjacency list representation of a directed graph with labelled edges. -/ |
Graph.filterReachable (g : Graph α β) (vs : List α) : Graph α β := Id.run do let mut work := vs let mut reached := Std.HashSet.ofList vs -- FIXME: `do` notation freaks out if `a` and `β` live in different universes while h : !work.isEmpty do let v := work.head (by simpa using h) work := work.tail for (u, _) in g.get? v... | def | ProofWidgets | [] | ProofWidgets/Demos/Graph/MVarGraph.lean | Graph.filterReachable | /-- Filter out vertices not reachable from a vertex in `vs`. -/ |
_root_.Lean.MVarId.getName (m : MVarId) : MetaM Name := do let d ← m.getDecl if !d.userName.isAnonymous then return d.userName let .num _ n := m.name | return m.name return Name.anonymous.str "m" |>.num n /-- Return the graph of metavariables, where a `true` edge `m → n` exists iff `n` is assigned an expression that us... | def | ProofWidgets | [] | ProofWidgets/Demos/Graph/MVarGraph.lean | _root_.Lean.MVarId.getName | /-- Return the user name if it exists, otherwise the prettified underlying name. -/ |
buildMVarGraph : MetaM (Graph MVarId Bool) := do let mut g : Graph MVarId Bool := {} for (m, _) in (← getMCtx).decls do g := g.alter m (·.getD []) if let some e := (← getMCtx).eAssignment.find? m then for n in (e.collectMVars {}).result do g := g.alter n ((m, true) :: ·.getD []) if let some a := (← getMCtx).dAssignment... | def | ProofWidgets | [] | ProofWidgets/Demos/Graph/MVarGraph.lean | buildMVarGraph | /-- Return the graph of metavariables,
where a `true` edge `m → n` exists iff `n` is assigned an expression that uses `m`,
and a `false` edge `m → n` exists iff the type of `n` depends on `m`. -/ |
mkLabel (e : MVarId) (stroke := "var(--vscode-editor-foreground)") (fill := "var(--vscode-editor-background)") : MetaM (Nat × Nat × Html) := do let fmt := s!"?{← e.getName}" let fmtTp ← withOptions (·.setNat `pp.deepTerms.threshold 2) (toString <$> ppExpr (← e.getType')) let len := fmt.length + fmtTp.length + 3 let w :... | def | ProofWidgets | [] | ProofWidgets/Demos/Graph/MVarGraph.lean | mkLabel | null |
drawMVarGraph (goals : List MVarId) : MetaM Html := do let mvars ← buildMVarGraph let mg := goals.head! let g := mvars.filterReachable goals let mut vertices := #[] let mut edges := #[] let mut maxLabelRadius := 0.0 for (m, ns) in g do -- TODO: mark delayed assigned mvars in yet another colour? let vAssigned ← m.isAssi... | def | ProofWidgets | [] | ProofWidgets/Demos/Graph/MVarGraph.lean | drawMVarGraph | null |
MVarGraph.rpc (props : PanelWidgetProps) : RequestM (RequestTask Html) := RequestM.asTask do let inner : Html ← (do -- Are there any goals unsolved? If so, the first one is the current main goal. if props.goals.isEmpty then return <span>No goals.</span> let some g := props.goals[0]? | unreachable! -- Execute the next p... | def | ProofWidgets | [] | ProofWidgets/Demos/Graph/MVarGraph.lean | MVarGraph.rpc | null |
MVarGraph : Component ProofWidgets.PanelWidgetProps := mk_rpc_widget% MVarGraph.rpc show_panel_widgets [local MVarGraph] -- When printing an assigned metavariable `?m := v`, -- print out the metavariable name `?m` rather than `v`. set_option pp.instantiateMVars false -- Do the same for delayed assigned metavariables. s... | def | ProofWidgets | [] | ProofWidgets/Demos/Graph/MVarGraph.lean | MVarGraph | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.