Operator-Generalization.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <html lang="en">
  2. <head>
  3. <title>Operator Generalization - avram - a virtual machine code interpreter</title>
  4. <meta http-equiv="Content-Type" content="text/html">
  5. <meta name="description" content="avram - a virtual machine code interpreter">
  6. <meta name="generator" content="makeinfo 4.13">
  7. <link title="Top" rel="start" href="index.html#Top">
  8. <link rel="up" href="Exception-Handling.html#Exception-Handling" title="Exception Handling">
  9. <link rel="prev" href="A-Hierarchy-of-Sets.html#A-Hierarchy-of-Sets" title="A Hierarchy of Sets">
  10. <link rel="next" href="Error-Messages.html#Error-Messages" title="Error Messages">
  11. <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
  12. <meta http-equiv="Content-Style-Type" content="text/css">
  13. <style type="text/css"><!--
  14. pre.display { font-family:inherit }
  15. pre.format { font-family:inherit }
  16. pre.smalldisplay { font-family:inherit; font-size:smaller }
  17. pre.smallformat { font-family:inherit; font-size:smaller }
  18. pre.smallexample { font-size:smaller }
  19. pre.smalllisp { font-size:smaller }
  20. span.sc { font-variant:small-caps }
  21. span.roman { font-family:serif; font-weight:normal; }
  22. span.sansserif { font-family:sans-serif; font-weight:normal; }
  23. --></style>
  24. </head>
  25. <body>
  26. <div class="node">
  27. <a name="Operator-Generalization"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="Error-Messages.html#Error-Messages">Error Messages</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="A-Hierarchy-of-Sets.html#A-Hierarchy-of-Sets">A Hierarchy of Sets</a>,
  31. Up:&nbsp;<a rel="up" accesskey="u" href="Exception-Handling.html#Exception-Handling">Exception Handling</a>
  32. <hr>
  33. </div>
  34. <h5 class="subsubsection">2.7.15.2 Operator Generalization</h5>
  35. <p>Each set in the hierarchy induces a structure preserving <code>cons</code>
  36. <a name="index-g_t_0040code_007bcons_007d-351"></a>operator, denoted <code>cons_</code><var>n</var> for the <var>n</var>th level
  37. set, and satisfying this equation.
  38. <dl>
  39. <dt><em>E10</em><dd><code>cons_</code><var>n</var><code>(</code><var>x</var><code>_</code><var>n</var><code>,</code><var>y</var><code>_</code><var>n</var><code>)</code> =
  40. <code>(cons(</code><var>x</var><code>,</code><var>y</var><code>))_</code><var>n</var>
  41. </dl>
  42. <p class="noindent">It will be convenient to generalize all of these <code>cons</code> operators to be
  43. defined on members of other sets than their own.
  44. <dl>
  45. <dt><em>E11</em><dd>For <var>m</var> greater than <var>n</var>,
  46. &nbsp;<!-- /@w --> &nbsp;<!-- /@w --> &nbsp;<!-- /@w --> <code>cons_</code><var>n</var><code>(</code><var>x</var><code>_</code><var>m</var><code>,</code><var>y</var><code>_</code><var>p</var><code>)</code> =
  47. <var>x</var><code>_</code><var>m</var>
  48. </dl>
  49. <p class="noindent">In this equation, <var>p</var> is unrestricted. The intuition is that
  50. if the left operand of a <code>cons</code> is the result of a computation that
  51. went wrong due to an exceptional condition (more exceptional than
  52. <var>n</var>, the level already in effect), then the exceptional
  53. result becomes the whole result.
  54. <p>It is tempting to hazard a slightly stronger statement, which is that
  55. this equation holds even if <var>y</var><code>_</code><var>p</var> is equal to some
  56. expression <var>f</var> <var>x</var> that is undefined according to the
  57. operator semantics. This stipulation would correspond to an
  58. implementation in which the right operand isn't evaluated after an error
  59. is detected in the left, but there are two problems with it.
  60. <ul>
  61. <li>This semantics might unreasonably complicate a concurrent
  62. implementation of the virtual machine. If evaluation leads to
  63. non-termination in some cases where the result is undefined (as it certainly
  64. would in any possible implementation consistent with cases where it's
  65. defined), then the mechanism that evaluates the right side of a pair
  66. must be interruptible in case an exception is detected in the left.
  67. <li>It is beyond the expressive power of the present mathematical
  68. framework to make such a statement, because it entails universal
  69. quantification over non-members of the constructed sets, which includes
  70. <a name="index-universal-quantification-352"></a>almost everything.
  71. </ul>
  72. <p class="noindent">Nevertheless, the implementation in <code>avram</code> is sequential and does
  73. indeed behave as proposed, with no practical difficulty. As for any
  74. deficiency in the theory, it could be banished by recasting the
  75. semantics in terms of a calculus of expressions with formal rules of
  76. manipulation. An operand to the <code>cons</code> operator would be identified
  77. not with a member of a semantic domain, but with the expression used to
  78. write it down, and then even &ldquo;undefinedness&rdquo; could be
  79. <a name="index-undefined-expressions-353"></a>defined. However, the present author's preference in computing as in
  80. <a name="index-author-354"></a>life is to let some things remain a mystery rather than to abandon the
  81. quest for meaning entirely.
  82. <p>A comparable condition applies in cases where the right side of a pair
  83. represents an exceptional result.
  84. <dl>
  85. <dt><em>E12</em><dd>For <var>m</var> greater than <var>n</var>,
  86. &nbsp;<!-- /@w --> &nbsp;<!-- /@w --> <code>cons_</code><var>n</var><code>(</code><var>x</var><code>_</code><var>n</var><code>,</code><var>y</var><code>_</code><var>m</var><code>)</code> =
  87. <var>y</var><code>_</code><var>m</var>
  88. </dl>
  89. <p>Whereas an infinitude of <code>cons</code> operators has been needed, it will
  90. <a name="index-g_t_0040code_007bcons_007d-355"></a>be possible to get by with only one invisible operator, as before, by
  91. generalizing it in the following way to operands on any level of the
  92. hierarchy.
  93. <dl>
  94. <dt><em>P43</em><dd><var>f</var><code>_</code><var>n</var> <var>x</var><code>_</code><var>n</var> = <code>(</code><var>f</var> <var>x</var><code>)_</code><var>n</var>
  95. <br><dt><em>P44</em><dd>For distinct <var>n</var> and <var>m</var>, &nbsp;<!-- /@w --><var>f</var><code>_</code><var>n</var> <var>x</var><code>_</code><var>m</var> = <var>x</var><code>_</code><var>m</var>
  96. </dl>
  97. <p class="noindent">That is, the result of evaluating two operands on the same level is the
  98. image relative to that level of the result of their respective images on
  99. the bottom level, but the result of evaluating two operands on different
  100. levels is the same as the right operand.
  101. </body></html>