Author full Lean 4 algebraic types (inductive, structure, abbrev, class) with type parameters and deriving clauses.
In: uses · Out: decl
lean_def
Lean 4
Pure Lean 4 functions (def, partial def, noncomputable def, instance, opaque) with optional @[simp] & termination_by. Directly callable from both Lean theorems AND App Computed/Predicate/Action expressions!
In: uses · Out: decl, val
lean_theorem
Lean 4
Standalone or app-coupled Lean 4 proofs (theorem, lemma, example, axiom) in tactic or term mode. Double-click or click ƒ to open the Visual Tactic Proof Builder.
Typed reactive state field (Nat, Int, String, Bool) with initState.
In: mutate · Out: val
collection
ViewModel
Typed record list (List Row) with schema columns, initial rows, and .length/.count/.sum/.avg/.any/.all/.minOf/.maxOf/push/pop/take/drop/reverse/clear ops.
In: mutate · Out: items
computed
ViewModel
Pure derived property (def ViewModel.<name>) evaluated from state, other computeds, and canvas lean_def functions. Double-click for Visual Logic Editor.
In: in · Out: val
predicate
ViewModel
Boolean guard / condition (Bool) used for button disabling, conditional gates, and filters. Double-click for Visual Logic Editor.
In: in · Out: bool
action
ViewModel
Pure state reducer branch (inductive Action + def update) with guarded assignments and direct lean_def calls. Double-click for Visual Logic Editor.
In: trigger, guard · Out: effect
state_machine
ViewModel
Verified Finite State Machine (FSM) with named states, initialState, terminalStates, and guarded transitions (from, event, to, guardExpr).
In: trigger · Out: state, step, done
validator
ViewModel
Multi-rule validation pipeline evaluating ordered boolean rules (rules[]) into aggregate validity (valid), error count (errorCount), and first failure message (firstError).
In: in · Out: valid, errorCount, firstError
invariant
Formal Proof
Safety invariant (def Invariant) proved over initState and every reachable transition. Double-click for Visual Logic Editor.
In: check
proof_rule
Formal Proof
User-defined formal theorem (HoareTriple, ViewConstraint, or ReachableGoal) compiled directly to Lean 4 theorem rule_*.
In: check, action
effect
ViewModel
Declarative side-effect descriptor (log, toast, http, storage, navigate) separated cleanly from pure reducer logic.
In: trigger
subprogram
Modular
Encapsulated nested MVU sub-graph with its own state, actions, views, and drill-down breadcrumbs. Double-click to enter.
Typed external or local data connector across 9 providers: Online (hacker_news live HN Firebase API, rest, graphql, websocket), Firebase Realtime (firebase_rtdb, firestore with live REST or local multi-tab BroadcastChannel sync + declarative security rules), MS Access / Relational DB (ms_access, sql_db with Autonumber PK, Foreign Keys, inline Auto-Form with FK lookup dropdowns), and Local Files (local_file CSV/TSV/JSON/NDJSON browser upload & export). Verified by DATA001–DATA004 and Lean 4 data_sources_valid + foreign_keys_valid.
MS Access / SQL / Firestore declarative query pipeline supporting INNER/LEFT JOIN across sibling tables, reactive WHERE expressions, substring searchField, ORDER BY, LIMIT, and numeric sum/count aggregates. Verified by DATA005 and Lean 4 data_queries_valid.
In: source, joinWith, filterVal · Out: rows, count, sum
Named visual style token (tokenName, bgHex, fgHex, borderHex, fontSizePx, radiusPx, paddingPx) formally checked for WCAG AA contrast (≥ 4.5:1 or custom minContrastX10).
Out: style
resource
Design / i18n
Typed Resource Dictionary (tokens[] with Light value + optional darkValue for colors, radii, fonts, lengths) AND multi-locale i18n bundle (locales[], entries[]) usable via {res:key} in Control Templates and Views. Verified for 100% locale coverage.
Out: res
control_template
Design
Avalonia/WPF-style reusable control blueprint defining typed props[] ({tpl:propName}), visual parts[] (border, stack, row, text, badge, icon, progress, button, divider, content_presenter), {res:token} resource bindings, and stateTriggers[] (:hover, :active, :disabled, :checked). Verified by TPL001–TPL003 and Lean 4 control_templates_valid.
In: res · Out: template
templated_control
View
Instantiates a wired control_template with propValues, optional res dictionary override, data & disabled bindings, onClick action/FSM dispatch, and child View projection into the template's ContentPresenter slot. Verified by TPL004.
Embeds a live interactive App View preview directly on the 2D graph canvas (supports active module or cross-module targetModuleId with module_ref resolution, live action dispatch, and synchronized runtime state). See Chapter 10.
In: state_in, style_in
template_preview
Preview
Embeds a live interactive Control Template preview directly on the 2D graph canvas for any built-in or custom control_template, with Light/Dark and Resource Dictionary token preview. See Chapter 10.
In: template_in, style_in
module_ref
Scale
Typed cross-module import referencing an exported State/Computed/Predicate from another module in the Solution.
Out: val
group
Organization
Resizable, collapsible visual frame grouping related nodes; dragging the header moves all enclosed nodes together.
—
reroute
Routing
Compact waypoint dot spliced onto any wire (Shift+Click on wire) to keep dense graphs cleanly routed.
In: in · Out: out
portal_out
Routing
Wireless sender broadcasting a signal on a named channel (#channel) to eliminate long crossing wires.
In: in
portal_in
Routing
Wireless receiver subscribing to #channel (click ⇄ chip on node to jump straight to its peer).
Two-pane horizontal or vertical resizable split layout (orientation, ratioPercent).
In: parent, style · Out: children
drawer
Slide-out drawer panel (left, right, bottom) toggled reactively via boolean open binding.
In: parent, open, style · Out: children
chart
Pure inline SVG data visualization (bar, line, donut, sparkline) bound to any collection, datasource, or data_query (items, labelField, valueField, accentHex, heightPx). Verified by VIEW007.
In: parent, items, style
stepper
Multi-step progress wizard (steps[], horizontal/vertical) driven reactively by step : Nat. Verified by VIEW008.
Visual Lean 4 Tactic Proof Mode (lean_theorem): Double-click any lean_theorem node (or click ƒ) to visually chain Lean 4 tactics (intro, simp, rw, cases, induction, split, apply, exact, have, omega, decide, rfl, constructor, linarith, aesop, custom) with live Lean 4 theorem code preview and bidirectional sync (tacticsToLogicGraph ↔ logicGraphToTactics).
Unified Main-Canvas Visual Editing for Control Templates (❖) & Built-In / Custom Templates#
LeanUI Studio uses the exact same full-featured main Graph Canvas for BOTH control_template blueprints AND all Built-In Verified / Custom Component Templates — giving both scopes 100% parity with main editing while specializing the Palette, Breadcrumb Bar, Inspector, Live Preview, Verification, and Lean 4 Proving:
Open it by double-clicking any control_template node on the Canvas, clicking the ❖ chip on a control_template or templated_control card header, clicking ❖ Open Visual Template Designer in the Inspector, clicking ❖ in the ✓ Proofs panel, or via ❖ Edit Node Graph in the Templates dialog.
100% Main-Canvas Parity: Powered by the bidirectional SpecGraph compiler (controlTemplateToSpecGraph ↔ specGraphToControlTemplate) and 5 first-class category: 'template' node kinds (tpl_prop, tpl_resource, tpl_part, tpl_trigger, tpl_root). Every main editor tool works seamlessly inside a ControlTemplate: infinite pan/zoom, minimizable Minimap, Libavoid/ELK obstacle-avoiding Ortho/Curve/Line wire routing, reroute waypoints, wireless portal_out/portal_in portals (transparently resolved during compilation!), group frames, marquee multi-selection, Undo/Redo, Copy/Cut/Paste/Duplicate, Align/Distribute, Bypass & Heal (⌥⌫), all 5 Auto-Layouts, Palette drag-and-drop with ghost preview & magnetic auto-connect, and Causal Wire Trace.
Full 36-Control Nesting Inside Templates: Wire tpl_root.children → ANY ViewNode.parent (and nest ContentPresenter inside any container via parent : VNode) to compose arbitrary multi-level UI hierarchies (grid, split_view, scroll, card, accordion, tabs, conditional, stat, chart, slider, rating, toggle, button, code_block, tree_view, etc.) inside any ControlTemplate, with {tpl:...} / {res:...} interpolation & direct tpl_prop / tpl_resource port wiring verified in both @leanui/verifier and Lean 4 control_templates_valid!
Scope-Aware Node Palette: Promotes the highlighted Control Template Nodes (Active Scope) section while keeping all 36 View controls at full contrast and auto-wiring newly added controls into the selected container or tpl_root.children.
Specialized Inspector & Configurable Root Containers: Configure the Template Root's container element & layout (Border, StackPanel, RowPanel, Grid with columns, ScrollView with bounded max height, elevated Card, chrome-free Panel, or semantic <button>), wire {res:...} / {tpl:...} directly into tpl_root's bg/fg/border ports, edit live sampleValue, pick bound ResourceBundle tokens with color swatches, use native color pickers, and click One-Click Canvas Wiring chips (→ text:{tpl:...}, → bg:{res:...}, → fg:{res:...}).
Live WYSIWYG Preview Dock: Interactive State Simulator (Normal / :hover / :active / :disabled / :checked), Light/Dark Resource Dictionary toggle, Locale (EN / DE), ContentPresenter Slot Sample, click-any-part to select its tpl_part node on the Main Canvas, and drag tpl_part nodes vertically to reorder.
Real-Time Verification & Lean 4 Proving: Instant TPL001–TPL003 diagnostics pinned to offending tpl_part/tpl_resource/tpl_root nodes plus one-click λ Prove verifying theorem control_templates_valid : ControlTemplatesValid controlTemplates := by decide in both Lake & browser WASM!
Click ◈ Edit Visually on any Built-In Verified Template (e.g. Bounded Counter Block, Lean 4 Function + Proof Pair, Resource + Templated Control Kit, etc.) or My Custom Template to open its full node-and-wire graph on the main Studio Canvas with a specialized editing banner featuring inline Name, Category, and Description inputs, direct λ Prove, ✓ Save Template, ⧉ Save Copy, ↺ Reset Default, and ✕ Exit.
Seamless Nested Drill-Down: While editing a Built-In Verified Template such as Resource + Templated Control Kit, double-clicking its InfoTileTemplate node drills right into Scope 1 (⌂ Built-In Template › ❖ ControlTemplate), and clicking ✓ Apply & Back writes your updated parts/props/triggers straight back into the Built-In Template!
Save any canvas selection (or full graph) into My Custom Templates, update from canvas (↻ From Canvas), or fork any built-in template (⧉ Fork).
Multi-Selection: Hold Shift or Cmd/Ctrl while clicking nodes, press Cmd/Ctrl+A to select all, or switch to Select mode in the bottom Canvas HUD to drag a marquee box.
Selection Action Bar: Selecting 1+ nodes displays a floating bar with Dup (⌘D), Group (⌘G), ↗ Sub (extract selection into a nested Sub-Program), ⊡ Fit (Auto-Size Selected), ↔ W / ↕ H / ⤢ Size (Match Width / Height / Both), Align (Left / Center / Right / Top / Middle / Bottom), Distribute (Horizontal / Vertical), and Delete.
Sub-Program Drill-Down: Double-click any subprogram node (or click ↗) to enter its inner graph; use the breadcrumb bar (⌂ Parent › Sub-Program) to navigate back up at any depth.
Reusable Templates: Click Templates in the topbar or Palette to insert pre-wired multi-node patterns (e.g., Bounded Counter, Searchable List, Validated Input, Modal Confirmation) directly onto the canvas.
Every resizable node kind — including Live App View Previews (app_preview), Template Previews (template_preview), Group frames (group), and all standard View, ViewModel, Data, Design, and Lean 4 nodes — supports industry-standard interactive resizing and automatic content-aware sizing:
8-Handle Interactive Resizer: Hover or select any node or Group frame to reveal 4 edge rails (N, E, S, W) and 4 corner handles (NW, NE, SE, SW) with live 60fps wire re-routing and minimap updates:
Shift + Drag: Toggle Aspect Ratio Lock dynamically mid-drag.
Alt / Option + Drag: Resize symmetrically from the node's center.
Cmd / Ctrl + Drag: Temporarily bypass grid and magnetic guide snapping for free pixel precision.
Escape during drag: Cancel and smoothly restore the original dimensions and position.
Double-click any resize handle: Instant Fit-to-Content (E/W fits width, N/S fits height, corners fit both dimensions — measuring live rendered UI content for preview nodes).
Magnetic Smart Guides & Live Dimension HUD: While dragging any handle, LeanUI renders live cyan neighbor edge/center alignment guides, magenta equal-dimension match brackets (=W / =H), and a floating W × H Dimension HUD pill showing active modifier badges (🔒 Ratio, ⊕ Center, =W, =H, Free).
Universal "Size & Layout" Inspector Card: Available on every resizable node with:
Exact W × H Inputs, Aspect Ratio Lock (🔒), Size Lock (🔐) (protects nodes from accidental drags or bulk auto-resize), ⊡ Fit Content, ↺ Reset, and collapsible Min / Max Constraints.
Auto-Size All Nodes & Multi-Select Matching:
Click ⊡ Size in the bottom Canvas HUD (or use the right-click Auto-Size Graph menu / ⌘K Command Palette) to auto-size all unlocked nodes with Compact, Comfortable, or Expanded density, automatically resolving sibling overlaps and re-wrapping Group frames.
Toggle Auto-Size on Layout (context menu or ⌘K) to automatically size all nodes right before running any of the 5 size-aware Auto-Layout algorithms (layered, hierarchical, tree, grid, grouped).
Select 2+ nodes to Match Width (↔ W), Match Height (↕ H), or Match Size (⤢ Size) from the floating Selection Bar, Inspector, context menu, or ⌘K Command Palette.
All sizing operations (auto_size_all, auto_size_selected, reset_sizes, match_width, match_height, match_size, auto_fit_groups, apply_preview_preset, and apply_layout(autoSizeNodes: true)) are also exposed to AI agents via @leanui/mcp-server.
Live Annotated 8-Handle Node Resizing & Embedded Live App Preview Card (with Resize Handles, Smart Guides & Auto-Size Callouts)
Export Diagrams as SVG, High-DPI PNG & Multi-Page PDF#
Open Export ▾ → 🖼 Export Diagram (SVG / PNG / PDF)…, click ⤓ Export in the bottom Canvas HUD, right-click the canvas, or press ⌘K and search Export Visual Diagram.
Export any Studio stage mode (Graph, Timeline Storyboard, App Flow, CAD Explode, 3D Orbit, Multi-View, Solution Stages, Prototype Flow) in Clean (initState), Current Live State (including runtime values, selection & causal wiring trace), or Timeline History!
Choose SVG (crisp self-contained vector + Copy SVG), PNG (1× / 2× Retina / 3× Print + Copy PNG), or PDF (Auto-Fit, A4 Landscape, 16:9 Slide, Multi-Page Timeline History Book, or Complete Architecture Deck combining all modes in one PDF!), with optional Auto-Annotate Help Callouts (① ② ③…).
Drag nodes freely into negative left/top and arbitrarily large positive coordinates with zero clipping of nodes or SVG wires.
Synchronized dot grid pans and scales cleanly with zoom (12%–200%), anchored around a subtle (0, 0) origin crosshair and live world cursor readout (X, Y) in the top Canvas HUD.
Ergonomic Panning: Pan from empty space, hold Space + Drag or Middle-Click Drag from anywhere (even over nodes or in Select mode), or drag any node/palette item/wire near a viewport border to trigger smooth Edge Auto-Panning.
Press F to fit selected nodes (or the whole graph) into view, or 0 to reset to (0, 0) at 100%.
Palette & Solution Explorer Drag-and-Drop with Live Preview:
Drag any of the 39 Node Palette items onto the canvas to see a live zoom-scaled Node Card Ghost (complete with typed ports and action status pill). Clicking a palette item still adds it immediately for single-pointer accessibility.
Drag any Module row from the Solution Explorer onto the canvas to drop a pre-linked module_ref node referencing that module's primary export.
Hold Alt while dragging to suppress wire-splitting and magnetic auto-connect for pure free placement, or press Esc to cancel.
Dropping Into Wires (Split & Tap) + Existing-Node Insertion:
Drop a pass-through node (computed, predicate, card, container, conditional, accordion, reroute, etc.) onto any compatible wire to ✂ Split it (A → New → B), with live emerald split highlight and dashed preview wires before release.
Drop a sink node (invariant, proof_rule, text, alert, effect, etc.) onto a compatible wire to ⑂ Tap / Branch the upstream signal while keeping the original wire intact.
Drag any existing single node on the canvas directly onto a wire to splice or tap it with the exact same live preview!
Magnetic Auto-Connect:
When dropping a node near compatible existing nodes, LeanUI highlights target ports and draws live dashed ⚡ Auto-Connect preview wires (fromPort→toPort), wiring automatically on release (respecting single-input ports and natural left-to-right flow).
Either click source port → target port OR press-and-drag directly from a port! Dragging magnetically snaps to compatible ports (or drops onto any compatible node body to auto-pick its best port), and releasing in empty space opens the Smart Add & Auto-Wire picker.
Double-click (or Shift+Click) any wire to splice a reroute waypoint; deleting a reroute automatically heals the wire (upstream → downstream).
Right-click any wire for the Wire Context Menu: Insert Reroute Waypoint, ⇄ Split into Wireless Portals, Insert Compatible Node, or Delete Wire.
Press Alt + Backspace (or right-click node → Bypass & Heal Wires) to remove a middle node while automatically reconnecting compatible upstream and downstream wires.
Auto-Grouped (grouped) — Automatically clusters nodes by domain into visual group zones.
View Tree (tree) — Hierarchical layout emphasizing parent → child UI tree structure.
Compact Grid (grid) — Dense uniform grid for scanning large graphs quickly.
Obstacle-Avoiding Wire Routing Engine (3 Modes): Click Curve / Ortho / Line in the bottom Canvas HUD to cycle between:
Orthogonal (Ortho): Libavoid/ELK-inspired sparse orthogonal visibility grid + direction-aware constrained A* (penalizing bends, reverse stubs, and corridor congestion), Left-Edge parallel segment nudging to fan overlapping tracks out cleanly inside corridors, rounded corner fillets, and miniature semicircular crossing bridge hops where horizontal wires jump over vertical wires.
Bezier Curves (Curve): Classic smooth cubic S-curve when line-of-sight is unobstructed, automatically transitioning to a corridor-constrained cubic fillet spline when intermediate nodes or back-edges intervene so wires never pass underneath node cards.
Straight / Polyline (Line): Direct line when completely clear, or a pull-string line-of-sight visibility polyline wrapping cleanly around obstacle corners with preserved port exit/entry stubs.
On-Wire Labels & Exact Hit-Testing: Inline fromPort→toPort trace pills and delete badges are anchored directly onto the routed wire's longest unobstructed segment (with label-to-label collision nudging), and drag-and-drop wire splitting/tapping hit-tests against the exact routed polyline.
Causal Wiring Cone (Trace): Toggle Trace in the bottom Canvas HUD to illuminate every upstream input (↑) and downstream consumer (↓) of the selected node(s) with inline fromPort→toPort labels.
Large-Graph Performance: Graphs with >35 nodes automatically enable frustum culling, 3-tier Zoom LOD (Full / Mid / Macro), and a hardware-accelerated 2D Minimap (Map toggle; click or drag to pan).