You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
4.2 KiB

2 months ago
  1. <!doctype html>
  2. <title>CodeMirror: sTeX mode</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link rel="stylesheet" href="../../lib/codemirror.css">
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="stex.js"></script>
  8. <style>.CodeMirror {background: #f8f8f8;}</style>
  9. <div id=nav>
  10. <a href="https://codemirror.net/5"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
  11. <ul>
  12. <li><a href="../../index.html">Home</a>
  13. <li><a href="../../doc/manual.html">Manual</a>
  14. <li><a href="https://github.com/codemirror/codemirror5">Code</a>
  15. </ul>
  16. <ul>
  17. <li><a href="../index.html">Language modes</a>
  18. <li><a class=active href="#">sTeX</a>
  19. </ul>
  20. </div>
  21. <article>
  22. <h2>sTeX mode</h2>
  23. <form><textarea id="code" name="code">
  24. \begin{module}[id=bbt-size]
  25. \importmodule[balanced-binary-trees]{balanced-binary-trees}
  26. \importmodule[\KWARCslides{dmath/en/cardinality}]{cardinality}
  27. \begin{frame}
  28. \frametitle{Size Lemma for Balanced Trees}
  29. \begin{itemize}
  30. \item
  31. \begin{assertion}[id=size-lemma,type=lemma]
  32. Let $G=\tup{V,E}$ be a \termref[cd=binary-trees]{balanced binary tree}
  33. of \termref[cd=graph-depth,name=vertex-depth]{depth}$n>i$, then the set
  34. $\defeq{\livar{V}i}{\setst{\inset{v}{V}}{\gdepth{v} = i}}$ of
  35. \termref[cd=graphs-intro,name=node]{nodes} at
  36. \termref[cd=graph-depth,name=vertex-depth]{depth} $i$ has
  37. \termref[cd=cardinality,name=cardinality]{cardinality} $\power2i$.
  38. \end{assertion}
  39. \item
  40. \begin{sproof}[id=size-lemma-pf,proofend=,for=size-lemma]{via induction over the depth $i$.}
  41. \begin{spfcases}{We have to consider two cases}
  42. \begin{spfcase}{$i=0$}
  43. \begin{spfstep}[display=flow]
  44. then $\livar{V}i=\set{\livar{v}r}$, where $\livar{v}r$ is the root, so
  45. $\eq{\card{\livar{V}0},\card{\set{\livar{v}r}},1,\power20}$.
  46. \end{spfstep}
  47. \end{spfcase}
  48. \begin{spfcase}{$i>0$}
  49. \begin{spfstep}[display=flow]
  50. then $\livar{V}{i-1}$ contains $\power2{i-1}$ vertexes
  51. \begin{justification}[method=byIH](IH)\end{justification}
  52. \end{spfstep}
  53. \begin{spfstep}
  54. By the \begin{justification}[method=byDef]definition of a binary
  55. tree\end{justification}, each $\inset{v}{\livar{V}{i-1}}$ is a leaf or has
  56. two children that are at depth $i$.
  57. \end{spfstep}
  58. \begin{spfstep}
  59. As $G$ is \termref[cd=balanced-binary-trees,name=balanced-binary-tree]{balanced} and $\gdepth{G}=n>i$, $\livar{V}{i-1}$ cannot contain
  60. leaves.
  61. \end{spfstep}
  62. \begin{spfstep}[type=conclusion]
  63. Thus $\eq{\card{\livar{V}i},{\atimes[cdot]{2,\card{\livar{V}{i-1}}}},{\atimes[cdot]{2,\power2{i-1}}},\power2i}$.
  64. \end{spfstep}
  65. \end{spfcase}
  66. \end{spfcases}
  67. \end{sproof}
  68. \item
  69. \begin{assertion}[id=fbbt,type=corollary]
  70. A fully balanced tree of depth $d$ has $\power2{d+1}-1$ nodes.
  71. \end{assertion}
  72. \item
  73. \begin{sproof}[for=fbbt,id=fbbt-pf]{}
  74. \begin{spfstep}
  75. Let $\defeq{G}{\tup{V,E}}$ be a fully balanced tree
  76. \end{spfstep}
  77. \begin{spfstep}
  78. Then $\card{V}=\Sumfromto{i}1d{\power2i}= \power2{d+1}-1$.
  79. \end{spfstep}
  80. \end{sproof}
  81. \end{itemize}
  82. \end{frame}
  83. \begin{note}
  84. \begin{omtext}[type=conclusion,for=binary-tree]
  85. This shows that balanced binary trees grow in breadth very quickly, a consequence of
  86. this is that they are very shallow (and this compute very fast), which is the essence of
  87. the next result.
  88. \end{omtext}
  89. \end{note}
  90. \end{module}
  91. %%% Local Variables:
  92. %%% mode: LaTeX
  93. %%% TeX-master: "all"
  94. %%% End: \end{document}
  95. </textarea></form>
  96. <script>
  97. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
  98. </script>
  99. <p>sTeX mode supports this option:</p>
  100. <d1>
  101. <dt><code>inMathMode: boolean</code></dt>
  102. <dd>Whether to start parsing in math mode (default: <code>false</code>).</dd>
  103. </d1>
  104. <p><strong>MIME types defined:</strong> <code>text/x-stex</code>.</p>
  105. <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#stex_*">normal</a>, <a href="../../test/index.html#verbose,stex_*">verbose</a>.</p>
  106. </article>