Raw-Material.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <html lang="en">
  2. <head>
  3. <title>Raw Material - 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="Virtual-Machine-Specification.html#Virtual-Machine-Specification" title="Virtual Machine Specification">
  9. <link rel="prev" href="Virtual-Machine-Specification.html#Virtual-Machine-Specification" title="Virtual Machine Specification">
  10. <link rel="next" href="Concrete-Syntax.html#Concrete-Syntax" title="Concrete Syntax">
  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="Raw-Material"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="Concrete-Syntax.html#Concrete-Syntax">Concrete Syntax</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="Virtual-Machine-Specification.html#Virtual-Machine-Specification">Virtual Machine Specification</a>,
  31. Up:&nbsp;<a rel="up" accesskey="u" href="Virtual-Machine-Specification.html#Virtual-Machine-Specification">Virtual Machine Specification</a>
  32. <hr>
  33. </div>
  34. <h3 class="section">2.1 Raw Material</h3>
  35. <p>The purpose of this section is to instill some basic concepts about the
  36. way information is stored or communicated by the virtual machine, which
  37. may be necessary for an understanding of subsequent sections.
  38. <p>The virtual machine represents both programs and data as members of a
  39. semantic domain that is straightforward to describe. Lisp users and
  40. functional programmers may recognize familiar concepts of atoms and
  41. <a name="index-lists-141"></a>lists in this description. However, these terms are avoided for the
  42. moment, in order to keep this presentation self contained and to prevent
  43. knowledgeable readers from inferring any unintended meanings.
  44. <p>As a rule, it is preferable to avoid overspecifying any theoretical
  45. artifact. In this spirit, the set of entities with which the virtual
  46. machine is concerned can be defined purely in terms of the properties we
  47. need it to have.
  48. <dl>
  49. <dt><em>A distinguished element</em><dd>A particular element of the set is designated, arbitrarily or otherwise,
  50. as a distinguished element. Given any element of the set, it is
  51. always possible to decide whether or not it is the distinguished
  52. element. The set is non-empty and such an element exists.
  53. <br><dt><em>A binary operator</em><dd>A map from pairs of elements of the set to elements of the set exists
  54. and meets these conditions.
  55. <ul>
  56. <li>It associates a <em>unique</em> element of the set with any given
  57. ordered pair of elements from the set.
  58. <li>It does not associate the distinguished element with any pair of elements.
  59. </ul>
  60. </dl>
  61. <p>For the sake of concreteness, an additional constraint is needed:
  62. <em>the set has no proper subset satisfying the above conditions</em>. Any
  63. number of constructions remain within these criteria, but there is no
  64. need to restrict them further, because they are all equivalent for our
  65. purposes.
  66. <p>To see that these properties provide all the structure we need for
  67. general purpose computation, we may suppose some given set <code>S</code> and
  68. an operator <code>cons</code> having them are fixed, and infer the following
  69. points.
  70. <ul>
  71. <li><code>S</code> contains at least one element, the distinguished
  72. element. Call it <code>nil</code>.
  73. <a name="index-g_t_0040code_007bnil_007d-142"></a><li>The pair <code>(nil,nil)</code> is a pair of
  74. elements of <code>S</code>, so there must be an element of <code>S</code> that
  75. <code>cons</code> associates with it. We can denote this element
  76. <code>cons(nil,nil)</code>.
  77. <a name="index-g_t_0040code_007bcons_007d-143"></a><li>As no pair of elements is associated with the
  78. distinguished element, <code>cons(nil,nil)</code> must differ from <code>nil</code>, so
  79. <code>S</code> contains at least two distinct elements.
  80. <li>The pair <code>(nil,cons(nil,nil))</code> therefore differs from <code>(nil,nil)</code>,
  81. but because it is yet another pair of elements from <code>S</code>, there
  82. must be an element associated with it by the operator. We can denote
  83. this element as <code>cons(nil,cons(nil,nil))</code>.
  84. <li>Inasmuch as the operator
  85. associates every pair of elements with a <em>unique</em> element,
  86. <code>cons(nil,cons(nil,nil))</code> must differ from the element associated
  87. with any other pair of elements, so it must differ from
  88. <code>cons(nil,nil)</code>, and we conclude that <code>nil</code>,
  89. <code>cons(nil,nil)</code> and <code>cons(nil,cons(nil,nil))</code> constitute three
  90. distinct elements of the set <code>S</code>.
  91. <li>By defining <code>cons(cons(nil,nil),nil)</code>
  92. and <code>cons(cons(nil,nil),cons(nil,nil))</code> analogously and following a
  93. similar line of reasoning, one may establish the existence of two more
  94. distinct elements of <code>S</code>.
  95. </ul>
  96. <p>It is not difficult to see that an argument in more general terms could
  97. show that the inclusion of infinitely many elements in <code>S</code> is
  98. mandated by the properties of the <code>cons</code> operator. Furthermore,
  99. every element of <code>S</code> other than <code>nil</code> owes its inclusion to
  100. being associated with some other pair of elements by <code>cons</code>,
  101. because if it were not, its exclusion would permit a proper subset of
  102. <code>S</code> to meet all of the above conditions. We can conclude that
  103. <code>S</code> contains exactly <code>nil</code> and the countable infinitude of
  104. elements of the form <code>cons(x,y)</code>, where <code>x</code> and <code>y</code> are
  105. either <code>nil</code> or something of the form <code>cons(...)</code> themselves.
  106. <p>Some specific examples of sets and operators that have the required
  107. properties are as follows.
  108. <ul>
  109. <li>the set of natural numbers, with <code>0</code> as the distinguished element,
  110. and the <code>cons</code> operator defined by <code>cons(</code><var>x</var><code>,</code><var>y</var><code>) =
  111. ((</code><var>x</var><code>+</code><var>y</var><code>)(</code><var>x</var><code>+</code><var>y</var><code>+1))/2 + </code><var>y</var><code> + 1</code>
  112. <li>a set of balanced strings of parentheses, with <code>()</code> as the
  113. distinguished element, and <code>cons</code> defined as string concatenation
  114. followed by enclosure in parentheses
  115. <li>a set of ordered binary trees, with the empty tree as the distinguished
  116. element, and the <code>cons</code> operator as that which takes an ordered
  117. pair of trees to the tree having them as its descendents
  118. <li>a set containing only its own Cartesian product and an arbitrary
  119. but fixed element <code>nil</code>, with <code>cons</code> being the identity
  120. function
  121. </ul>
  122. <p>Each of these models may suggest a different implementation, some of which
  123. are more practical than others. The remainder of this document is
  124. phrased somewhat imprecisely in terms of a combination of the latter
  125. two. The nature of the set in question is not considered further, and
  126. elements of the set are described as &ldquo;trees&rdquo; or &ldquo;lists&rdquo;. The
  127. <a name="index-trees-144"></a><a name="index-lists-145"></a>distinguished element is denoted by <code>nil</code> and the operator by
  128. <code>cons</code>. Where no ambiguity results, <code>cons(x,y)</code> may be written
  129. simply as <code>(x,y)</code>. These terms should not be seen as constraints
  130. on the implementation.
  131. </body></html>