/* Authoring surface — DSL editor + live preview + parsed-entity sidebar + autocomplete */ const AuthoringSurface = () => { // We render a "frozen mid-keystroke" state — caret position fixed, autocomplete open. const codeLines = [ { n: 1, t: 'definition "derivative" {', tokens: [["k","definition"],[" ",""],["s",'"derivative"'],[" ",""],["p","{"]] }, { n: 2, t: ' """', tokens: [["w"," "],["s",'"""']] }, { n: 3, t: ' The instantaneous rate of change of a function at a point.', tokens: [["w"," "],["d","The instantaneous rate of change of a function at a point."]] }, { n: 4, t: ' """', tokens: [["w"," "],["s",'"""']] }, { n: 5, t: '', tokens: [] }, { n: 6, t: ' context: real_analysis, calculus', tokens: [["w"," "],["k","context"],["p",":"],[" "," "],["i","real_analysis"],["p",","],[" "," "],["i","calculus"]] }, { n: 7, t: ' given: function f: R -> R, point x in domain(f)', tokens: [["w"," "],["k","given"],["p",":"],["w"," "],["i","function"],[" "," "],["v","f"],["p",":"],[" "," "],["t","R"],[" "," "],["o","->"],[" "," "],["t","R"],["p",","],["w"," "],["i","point"],[" "," "],["v","x"],[" "," "],["k","in"],[" "," "],["i","domain"],["p","("],["v","f"],["p",")"]] }, { n: 8, t: ' notation: $f\'(x)$', tokens: [["w"," "],["k","notation"],["p",":"],[" "," "],["m","$f'(x)$"]] }, { n: 9, t: ' means: $\\lim_{h \\to 0} \\frac{f(x+h) - f(x)}{h}$', tokens: [["w"," "],["k","means"],["p",":"],["w"," "],["m","$\\lim_{h \\to 0} \\frac{f(x+h) - f(x)}{h}$"]] }, { n: 10, t: ' provided: this limit exists', tokens: [["w"," "],["k","provided"],["p",":"],[" "," "],["d","this limit exists"]] }, { n: 11, t: '', tokens: [] }, { n: 12, t: ' @aliases: "differential", "instantaneous rate of change"', tokens: [["w"," "],["a","@aliases"],["p",":"],["w"," "],["s",'"differential"'],["p",","],[" "," "],["s",'"instantaneous rate of change"']] }, { n: 13, t: ' @difficulty: 2', tokens: [["w"," "],["a","@difficulty"],["p",":"],[" "," "],["n","2"]] }, { n: 14, t: '}', tokens: [["p","}"]] }, { n: 15, t: '', tokens: [] }, { n: 16, t: 'theorem "chain_rule" {', tokens: [["k","theorem"],[" "," "],["s",'"chain_rule"'],[" "," "],["p","{"]] }, { n: 17, t: ' statement: $(f \\circ g)\'(x) = f\'(g(x)) \\cdot g\'(x)$', tokens: [["w"," "],["k","statement"],["p",":"],[" "," "],["m","$(f \\circ g)'(x) = f'(g(x)) \\cdot g'(x)$"]] }, { n: 18, t: ' context: real_analysis', tokens: [["w"," "],["k","context"],["p",":"],["w"," "],["i","real_analysis"]] }, { n: 19, t: ' given: differentiable f: R -> R,', tokens: [["w"," "],["k","given"],["p",":"],["w"," "],["i","differentiable"],[" "," "],["v","f"],["p",":"],[" "," "],["t","R"],[" "," "],["o","->"],[" "," "],["t","R"],["p",","]] }, { n: 20, t: ' differentiable g: R -> R', tokens: [["w"," "],["i","differentiable"],[" "," "],["v","g"],[" "," "],["p",":"],[" "," "],["t","R"],[" "," "],["o","->"],[" "," "],["t","R"]] }, { n: 21, t: '', tokens: [] }, { n: 22, t: ' proof: by "limit_of_compo█', isCaret: true, autocomplete: true, tokens: [["w"," "],["k","proof"],["p",":"],[" "," "],["k","by"],[" "," "],["s",'"'],["i","limit_of_compo"],["caret",""]] }, { n: 23, t: '}', tokens: [["p","}"]] }, ]; const tokenClass = { k: "tk-key", s: "tk-str", p: "tk-punc", d: "tk-doc", w: "tk-ws", i: "tk-ident", v: "tk-var", t: "tk-type", o: "tk-op", m: "tk-math", a: "tk-anno", n: "tk-num" }; const Tex = ({ tex, display }) => { const ref = React.useRef(null); React.useEffect(() => { if (window.katex && ref.current) { try { window.katex.render(tex, ref.current, { displayMode: !!display, throwOnError: false }); } catch(e){} } }, [tex, display]); return ; }; const autocompleteItems = [ { k:"limit_of_composition", kind:"lemma", desc:"If lim g exists at a and lim f exists at g(a), then lim (f∘g) = f(lim g).", match:true }, { k:"limit_of_composite_continuous", kind:"lemma", desc:"Special case under continuity.", match:false }, { k:"limit_of_compose_uniform", kind:"lemma", desc:"Composition under uniform convergence.", match:false }, { k:"limit_compose_metric", kind:"lemma", desc:"Generalization to metric spaces.", match:false }, ]; return (
{/* top chrome */}
Project calculus.kgraph / definitions / derivative.kg
Validate ✓ 0 errors · 1 warning

{/* left rail — file tree / entity outline */} {/* editor */}
DSL · derivative.kg UTF-8 LF SP·2
{codeLines.map((line) => (
{line.n.toString().padStart(2,"0")} {line.tokens.length === 0 ? <>  : line.tokens.map((tok, i) => { if (tok[0] === "caret") return ; if (tok[0] === "m") return ( $ $ ); return {tok[1]}; }) } {line.autocomplete && (
Cross-reference · lemma | theorem 4 matches
    {autocompleteItems.map((it, i) => (
  • {it.kind.slice(0,3).toUpperCase()} {it.match ? <>limit_of_composition : it.k} {it.desc}
  • ))}
↑↓ navigate ⏎ insert ⌘. open ref
)}
))}
{/* live preview */}
Rendered preview KaTeX live
Definition def.calc.derivative

Derivative

The instantaneous rate of change of a function at a point.


Context
real_analysis · calculus
Given
function , point
Notation
Means
Provided
this limit exists

Aliases differential · instantaneous rate of change
Difficulty
Theorem thm.calc.chain_rule Unresolved ref

Chain rule


Proof by "limit_of_compo" ▲ resolving
{/* right rail — parsed entity graph + status */}
); }; window.AuthoringSurface = AuthoringSurface;