<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9161886791806233869</id><updated>2012-01-14T14:35:54.802-08:00</updated><category term='Haskell'/><category term='xml'/><category term='Go'/><category term='RDF'/><category term='IEEE754'/><category term='html'/><category term='Curry'/><category term='Scripts'/><category term='Tetration'/><category term='Logic'/><category term='Math'/><category term='Water'/><category term='JSON'/><category term='Lisp'/><category term='EXI'/><category term='Models'/><category term='OpenGL'/><category term='Web'/><category term='OpenMP'/><category term='Binary'/><category term='GUI'/><title type='text'>What A Stray Mind Coughed Up</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>18</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-2672493646054807025</id><published>2012-01-14T14:14:00.000-08:00</published><updated>2012-01-14T14:35:54.809-08:00</updated><title type='text'>On 'int128_t'</title><content type='html'>Every programming language has built-in integer types, both signed (representing mathematical integers) and unsigned (representing mathematical nonnegative integers). C compilers usually give these types fancy names like &lt;tt&gt;'unsigned long long'&lt;/tt&gt;, and have a nasty habit of changing the sizes (and meanings) of these types on different platforms. The C type &lt;tt&gt;'short'&lt;/tt&gt; is usually 16 bits, &lt;tt&gt;'int'&lt;/tt&gt; either 16 or 32 bits, and &lt;tt&gt;'long'&lt;/tt&gt; either 32 or 64 bits, depending on platform. This eventually led to the &lt;tt&gt;'stdint.h'&lt;/tt&gt; header in C99, which provides exact-size types which can be used accross platforms. These are named &lt;tt&gt;'int32_t'&lt;/tt&gt;, &lt;tt&gt;'int64_t'&lt;/tt&gt;, &lt;tt&gt;'uint32_t'&lt;/tt&gt;, &lt;tt&gt;'uint64_t'&lt;/tt&gt;, and so on.&lt;br /&gt;&lt;br /&gt;With stuff getting bigger, it's natural to ask the question: "Why 64?" and the answer is generally because the highest integer type most hardware can deal with is 64 bits. Can we go higher? Of course! but how? In this article, I will show you how to define &lt;tt&gt;'int128_t'&lt;/tt&gt; and &lt;tt&gt;'uint128_t'&lt;/tt&gt; in C without any compiler hacks. They can be used as parameter types and return types from functions, and they don't require any special memory management or allocation, because they're not pointer types.&lt;br /&gt;&lt;br /&gt;First, you might say we could just make an array type:&lt;br /&gt;&lt;pre&gt; typedef int32_t int128_as_int32x4_t[4];&lt;br /&gt; typedef int64_t int128_as_int64x2_t[2];&lt;/pre&gt;but which one to we pick? What we really need is a union of each of these, so we can decide later which array type to use. However, neither arrays nor unions can be used as return values from functions, only struct's can be used as return values. So in order to have a type that can be used as a return value we need to make a struct of a union of array types, as follows:&lt;br /&gt;&lt;pre&gt;typedef struct int128_s {&lt;br /&gt;    union int128_u {&lt;br /&gt;        int8_t  as_int8[16];&lt;br /&gt;        int16_t as_int16[8];&lt;br /&gt;        int32_t as_int32[4];&lt;br /&gt;        int64_t as_int64[2];&lt;br /&gt;    } value;&lt;br /&gt;} int128_t;&lt;/pre&gt;and wrap this type in a typedef. But how do we use these new integers? First of all we need some way of constructing &lt;tt&gt;'int128_t'&lt;/tt&gt;s, and in the spirit of &lt;tt&gt;'stdint.h'&lt;/tt&gt; we can make a &lt;tt&gt;'INT128_C()'&lt;/tt&gt; macro which expands to a constructed object of type &lt;tt&gt;'int128_t'&lt;/tt&gt;. We'll need a few functions for this:&lt;br /&gt;&lt;pre&gt;int128_t int128_from_int(int from);&lt;br /&gt;int128_t int128_from_str(char *from);&lt;br /&gt;int int_from_int128(int128_t from);&lt;br /&gt;int str_from_int128(char *to, int to_size, int128_t from);&lt;/pre&gt;and we can use the second one to define the macro as:&lt;br /&gt;&lt;pre&gt;#define INT128_C(x) int128_from_str(#x)&lt;/pre&gt;because &lt;tt&gt;'(#x)'&lt;/tt&gt; indicates to the preprocessor to turn x into a string before compile-time, which is then passed to &lt;tt&gt;int128_from_str&lt;/tt&gt; which then returns an object of type &lt;tt&gt;'int128_t'&lt;/tt&gt;. For compilers that do not support compile-time constant expressions involving function calls, we can also define simpler macros as follows:&lt;br /&gt;&lt;pre&gt;#ifdef BIG_ENDIAN&lt;br /&gt;#define INT128_C64(a,b)\&lt;br /&gt;    (int128_t){.value = {.as_int64 = {a, b}}}&lt;br /&gt;#define INT128_C32(a,b,c,d)\&lt;br /&gt;    (int128_t){.value = {.as_int32 = {a, b, c, d}}}&lt;br /&gt;#else&lt;br /&gt;#define INT128_C64(a,b)\&lt;br /&gt;    (int128_t){.value = {.as_int64 = {b, a}}}&lt;br /&gt;#define INT128_C32(a,b,c,d)\&lt;br /&gt;    (int128_t){.value = {.as_int32 = {d, c, b, a}}}&lt;br /&gt;#endif&lt;/pre&gt;Note that because we use designators (value and as_int##) this part requires a C99 compiler&lt;br /&gt;&lt;h4&gt;Conclusion&lt;/h4&gt;In order to use this integer type, we also need dozens of other functions, such as add, mul, sub, div, mod, and, or, xor, lsh, rsh, pow, etc., just to match the functionality usually associated with C integer types, and from there the possibilities are endless. A future article could revisit these functions. For now, though, I just wanted to bring focus to this integer type, especially considering how many common-place datatypes fit into an &lt;tt&gt;'int128_t'&lt;/tt&gt; such as UUID's and IPv6 addresses. We may need this sooner than we think.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-2672493646054807025?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/2672493646054807025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2012/01/on-int128t.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/2672493646054807025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/2672493646054807025'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2012/01/on-int128t.html' title='On &lt;tt&gt;&apos;int128_t&apos;&lt;/tt&gt;'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-2919665286551516497</id><published>2011-01-28T14:38:00.000-08:00</published><updated>2011-01-28T18:59:56.097-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IEEE754'/><category scheme='http://www.blogger.com/atom/ns#' term='Tetration'/><title type='text'>Tetrational-point</title><content type='html'>&lt;p&gt; As you might have guessed, most of my posts are a synthesis of two or more ideas. This time, they are IEEE-754 floating point formats and composite arithmetic formats. To provide some overview, IEEE-754 has been the official standard for representing numbers in computers for over 25 years, and is widely deployed in practically every computer architecture. Composite arithmetic on the other hand is a new approach which uses a combination of integer, rational, &lt;a href="http://en.wikipedia.org/wiki/Scientific_notation"&gt;scientific&lt;/a&gt;, and &lt;a href="http://en.wikipedia.org/wiki/Tetration"&gt;tetrational&lt;/a&gt; representation in unison to achieve greater accuracy, precision, &lt;i&gt;and&lt;/i&gt; dynamic range. &lt;/p&gt;&lt;p&gt; References for composite arithmetic include: "Beyond Floating Point" (by C.W.Clenshaw and F.W.J.Olver) which focuses on extending floating point with tetration alone, "Composite Arithmetic, a Proposal for a New Standard" and "Composite Arithmetic, A Storage Form" (both by W. Neville Holmes) which both focus on combining all four approaches, "Design of a Composite Arithmetic Unit for Rational Numbers" (by Tomasz Pinkiewicz, W. Neville Holmes, and Tariq Jamil) which focuses on the implementation of these in hardware, "Design of a 32-bit Arithmetic Unit based on Composite Arithmetic and its Implementation on a Field Programmable Gate Array." (by Tomasz Hubert Pinkiewicz) which focuses on the same, and "Lecture notes on: Computer Arithmetic: Principles, Architectures, and VLSI Design" (by Reto Zimmermann) which seems to be an overview of the subject targeted at students.&lt;/p&gt;&lt;p&gt; The most recent edition of IEEE-754 introduced a 16-bit floating point format, called '&lt;a href="http://en.wikipedia.org/wiki/Half_precision_floating-point_format"&gt;binary16&lt;/a&gt;' for short. Since this is the smallest standard floating point format, we will use it as an example of how IEEE-754 represents numbers. To begin we will see how it represents 1.5:&lt;/p&gt;&lt;table border="1" style="text-align: center;"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;&lt;/th&gt; &lt;th&gt;s&lt;/th&gt; &lt;th colspan="5"&gt;exponent&lt;/th&gt; &lt;th colspan="10"&gt;significand&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;th&gt;bin&lt;/th&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;hex&lt;/th&gt; &lt;td colspan="4"&gt;3&lt;/td&gt; &lt;td colspan="4"&gt;E&lt;/td&gt; &lt;td colspan="4"&gt;0&lt;/td&gt; &lt;td colspan="4"&gt;0&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;value&lt;/th&gt; &lt;td colspan="16"&gt;= 1.5&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;p&gt; and this is how the standard binary16 format represents infinity:&lt;/p&gt;&lt;table border="1" style="text-align: center;"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;&lt;/th&gt; &lt;th&gt;s&lt;/th&gt; &lt;th colspan="5"&gt;exponent&lt;/th&gt; &lt;th colspan="10"&gt;significand&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;th&gt;bin&lt;/th&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;hex&lt;/th&gt; &lt;td colspan="4"&gt;7&lt;/td&gt; &lt;td colspan="4"&gt;C&lt;/td&gt; &lt;td colspan="4"&gt;0&lt;/td&gt; &lt;td colspan="4"&gt;0&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;value&lt;/th&gt; &lt;td colspan="16"&gt;= Infinity&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;p&gt; As you can see, binary16 uses a 5-bit exponent and a 10-bit significand. One important class of representations which do not represent numbers is known collectively as Not-A-Number (NaN) representations. These are when the exponent is all 1's, regardless of the sign. Infinity is a particular example of this, since the exponent is all 1's and the significand is all 0's. If the significand is nonzero, then the remaining representations fall into two categories: signaling NaNs (sNaN) and quiet NaNs (qNaN). A signaling NaN is traditionally represented with a 0 in the &lt;a href="http://en.wikipedia.org/wiki/Most_significant_bit"&gt;MSB&lt;/a&gt; of the significand, and some other bit nonzero. A quiet NaN is traditionally represented with a 1 in the MSB of the significand, with anything in the other bits. Since sNaNs can cause errors and trap handlers to invoke, it is a bad idea to use them to represent numbers, since many architectures will automatically convert sNaNs to qNaNs. So, we will leave sNaNs alone, and replace qNaNs with a tetrational number representation format.&lt;/p&gt;&lt;p&gt; This tetrational format will use the two MSBs to represent quietness (q) and height (h) respectively. The tetrand will become the exponent at the top of the exponential tower. So a height of 0 will indicate a value of 2^2^2^2^2^(0.tetrand), and a height of 1 will indicate a value of 2^2^2^2^2^2^(0.tetrand). In general, the value associated with the tetrational format is:&lt;/p&gt;&lt;div style="text-align: center;"&gt; (-1)&lt;sup&gt;&lt;var&gt;s&lt;/var&gt;&lt;/sup&gt;&lt;b&gt;exp&lt;/b&gt;&lt;sub&gt;2&lt;/sub&gt;&lt;sup&gt;h+5&lt;/sup&gt;(0.tetrand) -- HTML&lt;/div&gt;&lt;div style="text-align: center;"&gt; &lt;math xmlns="http://www.w3.org/1998/Math/MathML"&gt; &lt;mrow&gt; &lt;msup&gt; &lt;mfenced&gt;&lt;mn&gt;-1&lt;/mn&gt;&lt;/mfenced&gt; &lt;mi&gt;s&lt;/mi&gt; &lt;/msup&gt; &lt;msubsup&gt; &lt;mi&gt;exp&lt;/mi&gt; &lt;mn&gt;2&lt;/mn&gt; &lt;mrow&gt; &lt;mi&gt;h&lt;/mi&gt; &lt;mo&gt;+&lt;/mo&gt; &lt;mn&gt;5&lt;/mn&gt; &lt;/mrow&gt; &lt;/msubsup&gt; &lt;mfenced&gt; &lt;mn&gt;0.tetrand&lt;/mn&gt; &lt;/mfenced&gt; &lt;/mrow&gt; &lt;/math&gt; -- MathML&lt;/div&gt;&lt;p&gt; We will start at 65536, which is just greater than the largest value represented by binary16 (65504). Extending this to larger formats (like binary32) should probably start here as well, because the next height is too much larger than the largest number represented by binary32. Starting from 65536, we can represent it as follows:&lt;/p&gt;&lt;table border="1" style="text-align: center;"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;binary16:&lt;/th&gt; &lt;th&gt;s&lt;/th&gt; &lt;th colspan="5"&gt;exponent&lt;/th&gt; &lt;th colspan="10"&gt;significand&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;tetra16:&lt;/th&gt; &lt;th&gt;s&lt;/th&gt; &lt;th colspan="5"&gt;exponent&lt;/th&gt; &lt;th&gt;q&lt;/th&gt; &lt;th&gt;h&lt;/th&gt; &lt;th colspan="10"&gt;tetrand&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;th&gt;bin&lt;/th&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;hex&lt;/th&gt; &lt;td colspan="4"&gt;7&lt;/td&gt; &lt;td colspan="4"&gt;E&lt;/td&gt; &lt;td colspan="4"&gt;0&lt;/td&gt; &lt;td colspan="4"&gt;0&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;value&lt;/th&gt; &lt;td colspan="16"&gt;&amp;#x2248; 65536&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;p&gt; We get this value because 2^2^2^2^2^(0.0) = 2^2^2^2^1 = 2^2^2^2 = 2^2^4 = 2^16 = 65536. The next greater representation is&lt;/p&gt;&lt;table border="1" style="text-align: center;"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;binary16:&lt;/th&gt; &lt;th&gt;s&lt;/th&gt; &lt;th colspan="5"&gt;exponent&lt;/th&gt; &lt;th colspan="10"&gt;significand&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;tetra16:&lt;/th&gt; &lt;th&gt;s&lt;/th&gt; &lt;th colspan="5"&gt;exponent&lt;/th&gt; &lt;th&gt;q&lt;/th&gt; &lt;th&gt;h&lt;/th&gt; &lt;th colspan="10"&gt;tetrand&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;th&gt;bin&lt;/th&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;hex&lt;/th&gt; &lt;td colspan="4"&gt;7&lt;/td&gt; &lt;td colspan="4"&gt;E&lt;/td&gt; &lt;td colspan="4"&gt;0&lt;/td&gt; &lt;td colspan="4"&gt;1&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;value&lt;/th&gt; &lt;td colspan="16"&gt;&amp;#x2248; 71036&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;p&gt; and perhaps another interesting representation is that of googolplex:&lt;/p&gt;&lt;table border="1" style="text-align: center;"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;binary16:&lt;/th&gt; &lt;th&gt;s&lt;/th&gt; &lt;th colspan="5"&gt;exponent&lt;/th&gt; &lt;th colspan="10"&gt;significand&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;tetra16:&lt;/th&gt; &lt;th&gt;s&lt;/th&gt; &lt;th colspan="5"&gt;exponent&lt;/th&gt; &lt;th&gt;q&lt;/th&gt; &lt;th&gt;h&lt;/th&gt; &lt;th colspan="10"&gt;tetrand&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;th&gt;bin&lt;/th&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;hex&lt;/th&gt; &lt;td colspan="4"&gt;7&lt;/td&gt; &lt;td colspan="4"&gt;F&lt;/td&gt; &lt;td colspan="4"&gt;B&lt;/td&gt; &lt;td colspan="4"&gt;2&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;value&lt;/th&gt; &lt;td colspan="16"&gt;&amp;#x2248; googolplex = 10^(10^100)&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;p&gt; Note that we only used a single bit for the height of the exponential tower, but we could have used more. I think that 2 bits should be used for height in binary32, and 3 bits should be used for height in binary64 and binary128. All floating point formats would encode the height and tetrand in the extra bits of a qNaN so as to avoid conflicts with hardware arithmetic.&lt;/p&gt;&lt;p&gt; Here is an overview of the extensions to the binary16 format:&lt;/p&gt;&lt;pre style="background-color: #222; font-size: 10px;"&gt;#x0000 = +0&lt;br /&gt;#x0001 = 5.960464477539063e-8&lt;br /&gt;       ... (standard binary16 floating-point) ...&lt;br /&gt;#x7BFF = 65504.&lt;br /&gt;#x7C00 = +Infinity&lt;br /&gt;#x7C01 = +sNaN&lt;br /&gt;       ... (standard binary16 signaling NaN) ...&lt;br /&gt;#x7DFF = +sNaN&lt;br /&gt;#x7E00 = 65536 = 2^2^2^2^2^(0)&lt;br /&gt;#x7E01 = 71036.&lt;br /&gt;       ... (new tetrational-point) ...&lt;br /&gt;#x7E?? = 2^2^2^2^2^(0.??_16)&lt;br /&gt;       ...&lt;br /&gt;#x7EFE = 8.9423389054e+15721&lt;br /&gt;#x7EFF = 6.2622606021e+17594&lt;br /&gt;#x7F00 = 2^65536 = 2^2^2^2^2^2^(0) = 2^2^2^2^2&lt;br /&gt;#x7F01 = 6.8504792165e+21383&lt;br /&gt;       ... (new tetrational-point) ...&lt;br /&gt;#x7F?? = 2^2^2^2^2^2^(0.??_16)&lt;br /&gt;       ...&lt;br /&gt;#x7FFE = 10^(2.69191e+15721) which is &amp;lt; 2^(2^65536)&lt;br /&gt;#x7FFF = +qNaN (unique)&lt;br /&gt;#x8000 = -0&lt;br /&gt;#x8001 = -5.960464477539063e-8&lt;br /&gt;       ... (standard binary16 floating-point) ...&lt;br /&gt;#xFBFF = -65504.&lt;br /&gt;#xFC00 = -Infinity&lt;br /&gt;#xFC01 = -sNaN&lt;br /&gt;       ... (standard binary16 signaling NaN) ...&lt;br /&gt;#xFDFF = -sNaN&lt;br /&gt;#xFE00 = -65536&lt;br /&gt;#xFE01 = -71036.&lt;br /&gt;       ... (new tetrational-point) ...&lt;br /&gt;#xFE?? = -2^2^2^2^2^(0.??_16)&lt;br /&gt;       ...&lt;br /&gt;#xFEFE = -8.9423389054e+15721&lt;br /&gt;#xFEFF = -6.2622606021e+17594&lt;br /&gt;#xFF00 = -2^65536&lt;br /&gt;#xFF01 = -6.8504792165e+21383&lt;br /&gt;       ... (new tetrational-point) ...&lt;br /&gt;#xFF?? = -2^2^2^2^2^2^(0.??_16)&lt;br /&gt;       ...&lt;br /&gt;#xFFFE = -10^(2.69191e+15721) which is &amp;gt; -2^(2^65536)&lt;br /&gt;#xFFFF = -qNaN (unique)&lt;/pre&gt;&lt;p&gt; In conclusion, we have shown exactly how to increase the dynamic range (quite dramatically) of standard IEEE-754 floating point formats by using a tetrational representation encoded in the unused bits of quiet NaNs. This provides a backwards-compatible hardware-accelerated tetrational floating point format which will encode approximate overflows as precisely as possible. So instead of overflows, you get a number! This makes it possible to be more informative when it comes to mathematical functions such as exp, log, or 1/x. With a bigger dynamic range, many of the outputs of these functions will no longer be indeterminate, but instead, finite. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-2919665286551516497?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/2919665286551516497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2011/01/tetrational-point.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/2919665286551516497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/2919665286551516497'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2011/01/tetrational-point.html' title='Tetrational-point'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-7777574067071015056</id><published>2011-01-03T17:59:00.000-08:00</published><updated>2011-01-03T19:09:26.339-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OpenMP'/><category scheme='http://www.blogger.com/atom/ns#' term='Go'/><title type='text'>GoLang Proposals</title><content type='html'>&lt;p&gt;Go is a very new programming language, barely a year old. Since its initial release, it has become an instant success, almost overnight. Google designed Go primarily for high-level systems programming. Since then, Google has replaced a few of its internal servers with custom Go servers. I believe this success is driven by the simplicity of Go, and its special features which focus on concurrency.&lt;/p&gt;&lt;p&gt;Compared to C, it has many more features so I consider its features a strict superset of C's features. Compared to C++ however, Go is very different, possibly described by a classic Venn-diagram in which Go's features and C++'s features intersect, but both have features the other doesn't. For example, method overloading can be accomplished in both languages, but in different ways.One feature that C++ has enjoyed is that of templates, which do not exist in Go. This requires that algorithms that can work on multiple datatypes be written out each time, which negatively affects readability and maintainability. While adding full-fledged C++ templates to Go is certainly possible, I believe we need to look at other languages for guidance.&lt;/p&gt;&lt;p&gt;Java started out as a simple language. Java's success is due in part to this simplicity, however, language designers at Sun (now Oracle) decided very late in the process (2004, a full 9 years after its introduction in 1995) to add generics to the language. In addition, they chose to use C++ syntax, which has conflicts with the shift operator (&gt;&gt;). In my opinion, avoiding the introduction of generics has divided the community, effected incompatibilities, and complicated the standard library with multiple versions of the same function.&lt;/p&gt;&lt;p&gt;Depending on your definition of generics, they may have different kinds of parameters. The most intellectually challenging are Agda generics, which imply that generics are just functions which return types, and any function may take types as a parameter. C++ templates are similar to this kind of generics, but make a distinction between usual functions and functions returning types. Since this is a minority when it comes to generics implementations, we will not consider this kind of generics in the remainder of this article.&lt;/p&gt;&lt;p&gt;The most prevalent form of generics are found in Java and Haskell, which only allow types as parameters. From this point of view, the only generic type found in Go today is the map type, so it will be the primary example used. &lt;/p&gt;&lt;hr/&gt;&lt;h4 style="font-weight:bold;color:#AD9"&gt;Proposal #1: Add first-class types&lt;/h4&gt;&lt;p&gt;This is doomed for failure, because it requires Agda-like (or C++/RTTI) semantics, but it is worth discussing. It is the proposal which requires the least syntactic changes, even if it might be the most intellectually demanding on semantics and runtime. If Go did have first-class types, then we could define the Map type as follows:&lt;/p&gt;&lt;pre&gt;func Map(KeyT .(type), T .(type)) .(type) {&lt;br /&gt;  type mapT []struct{&lt;br /&gt;    hash int&lt;br /&gt;    key KeyT&lt;br /&gt;    value T&lt;br /&gt;  }&lt;br /&gt;  return mapT&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;Using this proposal, we can simulate &lt;tt&gt;map[KeyT]T&lt;/tt&gt; with &lt;tt&gt;Map(KeyT, T)&lt;/tt&gt;. As you can see, type parameters are indicated with the &lt;tt&gt;".(type)"&lt;/tt&gt; token as is found in Go type-switch statements. One advantage of this system would be that it could be used to define &lt;tt&gt;Array(n, T)&lt;/tt&gt; and &lt;tt&gt;Matrix(m, n, T)&lt;/tt&gt; which would be impossible to define using more restrictive generics. Other functions that could defined using this proposal are &lt;tt&gt;new&lt;/tt&gt; and &lt;tt&gt;make&lt;/tt&gt;, which take a type as their first parameter. Here is a summary of the related changes to the Go specification:&lt;/p&gt;&lt;pre&gt;&lt;b&gt;Result&lt;/b&gt;        |= ".(type)"&lt;br /&gt;&lt;b&gt;ParameterDecl&lt;/b&gt; |= TypeName ".(type)"&lt;br /&gt;&lt;b&gt;Expression&lt;/b&gt;    |= TypeName&lt;/pre&gt;&lt;p&gt;In addition to these syntactic changes, a few paragraphs of rules and discussion maybe required.&lt;/p&gt;&lt;hr/&gt;&lt;h4 style="font-weight:bold;color:#AD9"&gt;Proposal #2: Add &lt;tt&gt;'generic'&lt;/tt&gt; (or &lt;tt&gt;'_Generic'&lt;/tt&gt;) keyword&lt;/h4&gt;&lt;p&gt;This is the crux of this blog article. Since first-class types require that types and objects be intermixed, it requires that every parameter be suffixed with &lt;tt&gt;.(type)&lt;/tt&gt;, but with the generic keyword, we can enforce that every parameter be a type parameter (Java/Haskell-style generics). This makes declarations much easier to read, and has provides a much more structured style.&lt;/p&gt;&lt;pre&gt;generic Map[KeyT]T []struct{&lt;br /&gt;    hash int&lt;br /&gt;    key KeyT&lt;br /&gt;    value T&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;Using this proposal, we can simulate &lt;tt&gt;map[KeyT]T&lt;/tt&gt; with &lt;tt&gt;Map[KeyT]T&lt;/tt&gt;. As you can see, this is very close to the standard built-in map type, with the obvious case difference. Here is an overview of the associated changes to the Go specification:&lt;/p&gt;&lt;pre&gt;&lt;b&gt;TypeLit&lt;/b&gt;       |= GenericType&lt;br /&gt;&lt;b&gt;TopLevelDecl&lt;/b&gt;  |= GenericDecl&lt;br /&gt;GenericType    = "generic"            GSignature Type&lt;br /&gt;GenericDecl    = "generic" identifier GSignature Type&lt;br /&gt;GSignature     = GParameters identifier&lt;br /&gt;GParameters    = "[" [ GParameterList [ "," ] ] "]"&lt;br /&gt;GParameterList = GParameterDecl { "," GParameterDecl }&lt;br /&gt;GParameterDecl = identifier&lt;/pre&gt;&lt;p&gt;Having considered adding generic syntax to &lt;tt&gt;LiteralType&lt;/tt&gt;, I don't think it would work well with literal syntax or semantics. What would such a literal mean? Would it simply be syntactic sugar for the base-type of the generic type with all the free variables filled in? If all that would be gained is syntax sugar, then I don't see the value of adding it to literal syntax.&lt;/p&gt;&lt;p&gt;This generics model also allows more than one parameter inside the brackets, but it also requires at least one parameter after the brackets, which is also very similar to how generic types work in Haskell, since the prevalence of monads has made the last parameter more important than the others. This generics model is also much closer to Go's existing map type, the only problem now is that the first letter is uppercase "M" whereas the built-in map type has a lowercase "m". This leads us to our next section, which discusses another proposal.&lt;/p&gt;&lt;hr/&gt;&lt;h4 style="font-weight:bold;color:#AD9"&gt;Proposal #3: Add &lt;tt&gt;'attrib'&lt;/tt&gt; (or &lt;tt&gt;'_Attrib'&lt;/tt&gt;) keyword&lt;/h4&gt;&lt;p&gt;This proposal combines two issues into a single solution. The first issue is nonessential attributes (such as alignment, packing, etc.) for which GCC uses the &lt;tt&gt;__attribute__((id))&lt;/tt&gt; syntax. The second issue is the public/private convention in Go which may be an issue in the future if it is used to implement existing APIs such as POSIX, which require lowercase external symbols. The solution I propose to both of these issues are a new syntax: &lt;tt&gt;_Attrib(id)&lt;/tt&gt;, which allows simple annotation of declarations in such a way as to override normal Go semantics. Consider two such attributes: public and private, which would allow us to define the built-in map type as follows:&lt;/p&gt;&lt;pre&gt;generic attrib(public) map[KeyT]T []struct{&lt;br /&gt;    hash int&lt;br /&gt;    key KeyT&lt;br /&gt;    value T&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;Using this proposal, there would be no difference between this defined type and the built-in map type. This would allow very small Go compilers which need only handle arrays and slices, and leave the map type, and possibly other built-in functions such as &lt;tt&gt;cap&lt;/tt&gt; and &lt;tt&gt;len&lt;/tt&gt; to a library implementation.&lt;/p&gt;&lt;p&gt;The syntax was designed to force the &lt;tt&gt;attrib&lt;/tt&gt; specifier immediately before the identifier, to make it clear which identifier it is referring to. The changes to the &lt;tt&gt;MethodDecl&lt;/tt&gt; production are questionable, and require more consideration and discussion. I have also considered moving &lt;tt&gt;AttribSpec&lt;/tt&gt; to before the keywords which would simplify the grammar significantly. This is the summary of all the required extensions to the Go specification.&lt;/p&gt;&lt;pre&gt;&lt;b&gt;ConstSpec&lt;/b&gt;    |= AttribSpec IdentifierList &lt;br /&gt;                [ [ Type ] "=" ExpressionList ]&lt;br /&gt;&lt;b&gt;TypeSpec&lt;/b&gt;     |= AttribSpec identifier Type&lt;br /&gt;&lt;b&gt;VarSpec&lt;/b&gt;      |= AttribSpec IdentifierList &lt;br /&gt;                ( Type [ "=" ExpressionList ] &lt;br /&gt;                | "=" ExpressionList )&lt;br /&gt;&lt;b&gt;MethodDecl&lt;/b&gt;   |= "func" Receiver AttribSpec &lt;br /&gt;                MethodName Signature [ Body ]&lt;br /&gt;&lt;b&gt;FunctionDecl&lt;/b&gt; |= "func" AttribSpec identifier &lt;br /&gt;                Signature [ Body ]&lt;br /&gt;GenericDecl  |= "generic" AttribSpec identifier &lt;br /&gt;                GSignature Type&lt;br /&gt;AttribSpec    = "attrib" "(" identifier &lt;br /&gt;                [ "(" ExpressionList ")" ] ")"&lt;/pre&gt;&lt;hr/&gt;&lt;h4 style="font-weight:bold;color:#AD9"&gt;Proposal #4: Add &lt;tt&gt;'pragma'&lt;/tt&gt; (or &lt;tt&gt;'_Pragma'&lt;/tt&gt;) keyword&lt;/h4&gt;&lt;p&gt;Another method used for nonessential attributes are top-level pragmas. Using pragmas, you can specify information to be used on a per-file or per-package basis. This could be a useful and simple extension to the language that could bring existing GCC syntax to Go compilers. Here is an example of using pragmas in a Go source file:&lt;/p&gt;&lt;pre&gt;pragma("GCC poison strdup")&lt;br /&gt;pragma("DSGO prefix pthread_")&lt;/pre&gt;&lt;p&gt;Other possibilities for pragmas are to use Go with OpenMP, even though it might sound funny at first, because most of the features of OpenMP are already in Go! However, we should never underestimate what people will do with compilers, given the chance. Here is a summary of the associated extensions to the Go specification:&lt;/p&gt;&lt;pre&gt;&lt;b&gt;TopLevelDecl&lt;/b&gt; |= PragmaDecl&lt;br /&gt;PragmaDecl    = "pragma" "(" string_lit ")"&lt;/pre&gt;&lt;hr/&gt;&lt;h4 style="color:#AD9"&gt;Conclusion&lt;/h4&gt;&lt;p&gt;We have reviewed four possible extensions to the Go programming language, which may not seem in the spirit of Go right now, but over time may become necessary. If Go is to be used for serious projects, developers may come to expect these features, rather than hope for them. As we have learned from Java, if we wait for too long to introduce new features to Go, it may polarize the community, which would be an undesirable outcome for everyone.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-7777574067071015056?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/7777574067071015056/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2011/01/golang-proposals.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/7777574067071015056'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/7777574067071015056'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2011/01/golang-proposals.html' title='GoLang Proposals'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-7389777720971919222</id><published>2009-08-16T06:56:00.000-07:00</published><updated>2009-08-16T06:58:15.703-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Math'/><category scheme='http://www.blogger.com/atom/ns#' term='Logic'/><category scheme='http://www.blogger.com/atom/ns#' term='GUI'/><title type='text'>Fuzzy Scrollbars</title><content type='html'>&lt;p&gt;After several weeks away from this blog, I would like to start up again with the exciting field of fuzzy logic. Most introductions to fuzzy logic talk about how everything is different, and overview the three major types: G&amp;ouml;del, product, and Lukasiewicz, but I'm going to take a different approach. I'm going to stick with &lt;a href="http://en.wikipedia.org/wiki/T-norm#Prominent_examples"&gt;product fuzzy logic&lt;/a&gt; for the remainder of this post.&lt;/p&gt;&lt;h4&gt;Product Fuzzy Logic&lt;/h4&gt;&lt;p&gt;It is important to discuss domains when regarding operations, and fuzzy logic is somewhat consistent in its use of the domain [0, 1], which includes 0, 1 and all the real numbers in between. Let's call this the &lt;code&gt;Clamp&lt;/code&gt; datatype. There are obvious mappings to and from &lt;code&gt;Clamp&lt;/code&gt; and &lt;code&gt;Bool&lt;/code&gt;: 0 maps to &lt;code&gt;False&lt;/code&gt;, 1 maps to &lt;code&gt;True&lt;/code&gt;, and the in betweens can be handled on a case-by-case basis (possibly to throw and error or something).&lt;/p&gt;&lt;p&gt;The operations on the &lt;code&gt;Clamp&lt;/code&gt; datatype would be both arithmetic and logic operations, which would include addition, subtraction, multiplication, division, conjunction (and), and disjuction (or). How would these be defined in product fuzzy logic? According to the product T-norm (the fancy name for how "and" is defined), the logic operations would be defined as&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;not&lt;/b&gt;(x) = 1 - x&lt;/li&gt;&lt;li&gt;&lt;b&gt;and&lt;/b&gt;(x, y) = xy&lt;/li&gt;&lt;li&gt;&lt;b&gt;or&lt;/b&gt;(x, y) = x + y - xy&lt;/li&gt;&lt;li&gt;&lt;b&gt;implies&lt;/b&gt;(x, y) = 1 - x(1 - y)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;One interesting thing about product fuzzy logic is that there are multiple ways of defining &lt;b&gt;equiv&lt;/b&gt;, depending on what properties you are looking for. One possibility is that &lt;b&gt;equiv&lt;/b&gt;(x, y) = &lt;b&gt;and&lt;/b&gt;(&lt;b&gt;implies&lt;/b&gt;(x, y), &lt;b&gt;implies&lt;/b&gt;(y, x)), which would mean that it would have to be defined as &lt;b&gt;equiv&lt;/b&gt;(x, y) = (1 - x - y + 3xy - yx&lt;sup&gt;2&lt;/sup&gt; - xy&lt;sup&gt;2&lt;/sup&gt; + x&lt;sup&gt;2&lt;/sup&gt;y&lt;sup&gt;2&lt;/sup&gt;). This is quite a mess, and the same effect (in terms of mapping to &lt;code&gt;Bool&lt;/code&gt;) can be accomplished by the definition &lt;b&gt;equiv&lt;/b&gt;(x, y) = (1 - x - y + 2xy).&lt;/p&gt;&lt;p&gt;Other considerations for operations on the &lt;code&gt;Clamp&lt;/code&gt; datatype are that when performing arithmetic operations, the output of the normal operation must be minimized or maximized to fall within the range [0, 1]. This may have the unfortunate side effect of many run-time errors, or unexpected mathematical outputs. If all conversions to and from the &lt;code&gt;Clamp&lt;/code&gt; datatype are excplicit, then this is not a problem.&lt;/p&gt;&lt;h4&gt;Scrollbars&lt;/h4&gt;&lt;p&gt;Just as the &lt;code&gt;String&lt;/code&gt; is the basis for the text field widget, the &lt;code&gt;Clamp&lt;/code&gt; datatype can be thought of as the basis for the scrollbar widget. Scrollbars are usually tied to a viewport, which can contain an image, a document, or a webpage. Usually the viewport has all the information that the scrollbar needs to do its job. It has height and width information of the entire image, and the height and width information of the part that is showing. Using this information, the only additional information that needs to be stored in the scrollbar is the percentage of how far down on the scrollbar you are, which is equivalent to what the &lt;code&gt;Clamp&lt;/code&gt; datatype provides.&lt;/p&gt;&lt;h4&gt;Colors&lt;/h4&gt;&lt;p&gt;Why is it that such a fundamental datatype like &lt;code&gt;Clamp&lt;/code&gt; is not found in more programming languages? Usually it is defined as equivalent to &lt;code&gt;Float&lt;/code&gt; or &lt;code&gt;Double&lt;/code&gt;, and intended to be used with values between 0.0 and 1.0, but no strict validation or bounds checking are done to ensure that this is so. One example where this kind of usage is found is in OpenGL, which we will talk about next.In OpenGL, one of the datatypes that is pervasive throughout the API is the  &lt;code&gt;GLclamp&lt;/code&gt; datatype. This is also a value between 0 and 1, and also where I got the name from. With this datatype, OpenGL defines some texture and image datatypes as structure with members of this type, for example a color in OpenGL is a structure with 3 &lt;code&gt;GLclamp&lt;/code&gt;s.&lt;/p&gt;&lt;p&gt;With so many applications, the &lt;code&gt;Clamp&lt;/code&gt; datatype is a prime example of a design goal that I've been trying to find a name for. When abstractions are too low-level, then you may have few abstractions (like bit and byte), but using these abstractions is a nightmare (just look at assembly code). When abstractions are too high-level, then you may be able to use them easily (like drag-and-drop database form designers), but the number of abstractions makes a steep learning curve, and a high pressure on the discovery of abstractions other people have made (for example: some game libraries have 3 types of fog, and dozens of types of meshes, depending on whether you want to add skeletons or water ripples, etc.). The design goal I'm trying to acheive is a balance of these two extremes that balances low-level abstraction and high-level abstraction in such a way that there are &lt;i&gt;few&lt;/i&gt; abstractions, and using them is &lt;i&gt;easy&lt;/i&gt;. I think &lt;code&gt;Clamp&lt;/code&gt; datatype meets both of these requirements.&lt;/p&gt;&lt;p&gt;From fuzzy logic to colors to scollbars, &lt;code&gt;Clamp&lt;/code&gt; seems to form the basis of an unrecognized basis for computation that may be useful in the future.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-7389777720971919222?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/7389777720971919222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2009/08/fuzzy-scrollbars.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/7389777720971919222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/7389777720971919222'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2009/08/fuzzy-scrollbars.html' title='Fuzzy Scrollbars'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-7200809858878304727</id><published>2009-06-15T14:13:00.000-07:00</published><updated>2009-06-15T14:15:21.957-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OpenGL'/><title type='text'>Embedded OpenGL</title><content type='html'>&lt;p&gt;OpenGL is a graphics library that has provided a foundation for many other high-level graphics libraries built on top of it. Because it is so versitle and low-level, it has been proven to stand the test of time, and has evolved to handle the changing demands that library authors have been placed on it. As demands have changed, new functions are added, and one trend between all versions of OpenGL is that more specific functions are being replaced by more general functions. For example, the functions &lt;code&gt;glColorPointer&lt;/code&gt;, &lt;code&gt;glNormalPointer&lt;/code&gt;, and &lt;code&gt;glTexCoordPointer&lt;/code&gt; have been augmented with &lt;code&gt;glVertexAttribPointer&lt;/code&gt;, which can be used to replace all of the previous functions. This has led to a completely different view of OpenGL that has led to the development of smaller profile of OpenGL functions called the Embedded Specification, or OpenGL-ES for short. One side effect of this is that the more abstract functions are increasingly similar to an object-oriented library, which means there are fewer and fewer functions that do not fit into an object model of OpenGL. If we partition the functions found in OpenGL-ES 2.0 into an object-oriented hierarchy, then we arrive at the following classes:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;Blend&lt;/b&gt; &lt;/li&gt;&lt;li&gt;&lt;b&gt;Buffer&lt;/b&gt; -- pixel buffers, vertex buffers, and index buffers&lt;/li&gt;&lt;li&gt;&lt;b&gt;Capability&lt;/b&gt; -- abstract class with glEnable and glDisable&lt;/li&gt;&lt;li&gt;&lt;b&gt;Clear&lt;/b&gt; -- clearing the background to a solid color&lt;/li&gt;&lt;li&gt;&lt;b&gt;Color&lt;/b&gt; &lt;/li&gt;&lt;li&gt;&lt;b&gt;CullFace&lt;/b&gt; -- consists of glCullFace and glFrontFace&lt;/li&gt;&lt;li&gt;&lt;b&gt;Depth&lt;/b&gt; &lt;/li&gt;&lt;li&gt;&lt;b&gt;FrameBuffer&lt;/b&gt; &lt;/li&gt;&lt;li&gt;&lt;b&gt;Get&lt;/b&gt; -- reading global state with functions like glGetString etc.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Mipmap&lt;/b&gt; -- utilities for the Texture class&lt;/li&gt;&lt;li&gt;&lt;b&gt;Program&lt;/b&gt; &lt;/li&gt;&lt;li&gt;&lt;b&gt;RenderBuffer&lt;/b&gt; &lt;/li&gt;&lt;li&gt;&lt;b&gt;Shader&lt;/b&gt; -- vertex and fragment shaders&lt;/li&gt;&lt;li&gt;&lt;b&gt;Stencil&lt;/b&gt; &lt;/li&gt;&lt;li&gt;&lt;b&gt;Texture&lt;/b&gt; &lt;/li&gt;&lt;li&gt;&lt;b&gt;Uniform&lt;/b&gt; -- uniform variables&lt;/li&gt;&lt;li&gt;&lt;b&gt;VertexAttrib&lt;/b&gt; -- vertex attributes&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;after removing these functions from the OpenGL-ES 2.0 API, we are left with the miscellaneous functions:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;glDrawArrays(mode, first, count)&lt;/li&gt;&lt;li&gt;glDrawElements(mode, count, type, indices)&lt;/li&gt;&lt;li&gt;glFinish()&lt;/li&gt;&lt;li&gt;glFlush()&lt;/li&gt;&lt;li&gt;glLineWidth(width)&lt;/li&gt;&lt;li&gt;glPolygonOffset(factor, units)&lt;/li&gt;&lt;li&gt;glSampleCoverage(value, invert)&lt;/li&gt;&lt;li&gt;glPixelStorei(name, param)&lt;/li&gt;&lt;li&gt;glReadPixels(x, y, width, height, format, type, pixels)&lt;/li&gt;&lt;li&gt;glScissor(x, y, width, height)&lt;/li&gt;&lt;li&gt;glViewport(x, y, width, height)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;This says a lot about OpenGL-ES, especially the fact that &lt;code&gt;glDrawPixels&lt;/code&gt; has been removed. This means the only way to copy pixels into an OpenGL-ES context is to apply a texture with the pixel data to a rectangle. However, OpenGL-ES forbids &lt;code&gt;GL_QUADS&lt;/code&gt;, so you have to use &lt;code&gt;GL_TRIANGLE_FAN&lt;/code&gt; to accomplish the same result. &lt;code&gt;glReadPixels&lt;/code&gt;, &lt;code&gt;glScissor&lt;/code&gt;, and &lt;code&gt;glViewport&lt;/code&gt; can be related in that they all accept a rectangle as an argument.&lt;/p&gt;&lt;p&gt;Although OpenGL-ES allows one to do everything that can be done in OpenGL 2.0, there is more of a suggestion to use more general interfaces, like shaders and buffer objects, since all of the fixed functionality has been removed. This means that it is possible to reimplement all of OpenGL in OpenGL-ES. However, since ES is still rather new, there have not been any such implementations of fixed functionality in terms of shaders or the like. There are some tutorials that show how to duplicate such simple functionality as colors in terms of shaders, but a complete reimplementation is still nowhere to be found.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-7200809858878304727?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/7200809858878304727/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2009/06/embedded-opengl.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/7200809858878304727'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/7200809858878304727'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2009/06/embedded-opengl.html' title='Embedded OpenGL'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-5154771864921392916</id><published>2009-06-08T18:23:00.001-07:00</published><updated>2011-01-28T18:48:49.419-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Math'/><category scheme='http://www.blogger.com/atom/ns#' term='RDF'/><category scheme='http://www.blogger.com/atom/ns#' term='Haskell'/><title type='text'>Semantic MathML</title><content type='html'>&lt;p&gt;I don't know &lt;a href="http://semanticweb.org/wiki/Semantic_MathML"&gt;what they were thinking&lt;/a&gt;, but there is a much better way to encode &lt;a href="http://www.w3.org/TR/MathML2/"&gt;MathML&lt;/a&gt; in RDF. One can be tempted to assign an RDF property to every element in MathML, but that wouldn't be the &lt;a href="http://www.openmath.org/"&gt;OpenMath&lt;/a&gt; way. Since MathML3 is getting more and more dependent on OpenMath, it seems appropriate to encode as much as possible using this combined system. MathML3 is split up into several sections: Presentation, Pragmatic Content, and &lt;i&gt;Strict Content&lt;/i&gt;. The last one requires only 10 XML Elements to be understood by MathML3 processors, namely: &lt;code&gt;m:apply&lt;/code&gt;, &lt;code&gt;m:bind&lt;/code&gt;, &lt;code&gt;m:bvar&lt;/code&gt;, &lt;code&gt;m:csymbol&lt;/code&gt;, &lt;code&gt;m:ci&lt;/code&gt;, &lt;code&gt;m:cn&lt;/code&gt;, &lt;code&gt;m:cs&lt;/code&gt;, &lt;code&gt;m:share&lt;/code&gt;, &lt;code&gt;m:semantics&lt;/code&gt;, &lt;code&gt;m:cerror&lt;/code&gt;, and &lt;code&gt;m:cbytes&lt;/code&gt;. This provides for a great economy of thought, and a chance to easily define a total mapping from MathML to RDF. MathML3 already defines a mapping from MathML2 to Strict Content MathML3, so this is the only set of Elements we need to consider. These are the prefixes we will use:&lt;/p&gt;&lt;pre&gt;@prefix ari: &amp;lt;http://www.openmath.org/cd/arith1#&amp;gt; .&lt;br /&gt;@prefix fns: &amp;lt;http://www.openmath.org/cd/fns1#&amp;gt; .&lt;br /&gt;@prefix sts: &amp;lt;http://www.openmath.org/cd/sts#&amp;gt; .&lt;br /&gt;@prefix sm: &amp;lt;http://example.com/SemanticMath/&amp;gt; .&lt;br /&gt;@prefix m: &amp;lt;http://www.w3.org/1998/Math/MathML&amp;gt; .&lt;/pre&gt;&lt;p&gt;These are the &lt;code&gt;rdfs:Class&lt;/code&gt;'s we will define:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;sm:Content&lt;/code&gt; (all MathML Content)&lt;/li&gt;&lt;li&gt;&lt;code&gt;sm:Number&lt;/code&gt; (for &amp;lt;cn/&amp;gt;, subclass of &lt;code&gt;sts:NumericalValue&lt;/code&gt;)&lt;/li&gt;&lt;li&gt;&lt;code&gt;sm:String&lt;/code&gt; (for &amp;lt;cs/&amp;gt;, subclass of &lt;code&gt;xs:string&lt;/code&gt;)&lt;/li&gt;&lt;/ul&gt;and these are the &lt;code&gt;rdf:Property&lt;/code&gt;'s we will define:&lt;ul&gt;&lt;li&gt;&lt;code&gt;sm:apply&lt;/code&gt; :: Property * sm:Content&lt;/li&gt;&lt;li&gt;&lt;code&gt;sm:applyTo&lt;/code&gt; :: Property * (List sm:Content)&lt;/li&gt;&lt;li&gt;&lt;code&gt;sm:bind&lt;/code&gt; :: Property * (List sm:Content)&lt;/li&gt;&lt;li&gt;&lt;code&gt;sm:bindOp&lt;/code&gt; :: Property * sm:Content&lt;/li&gt;&lt;li&gt;&lt;code&gt;sm:bindIn&lt;/code&gt; :: Property * sm:Content&lt;/li&gt;&lt;li&gt;&lt;code&gt;sm:error&lt;/code&gt; :: Property sm:Error sm:Content&lt;/li&gt;&lt;li&gt;&lt;code&gt;sm:errorWas&lt;/code&gt; :: Property sm:Error (List sm:Content)&lt;/li&gt;&lt;/ul&gt;Strict Content MathML3 can be translated with the following algorithm:&lt;ul&gt;&lt;li&gt;&lt;code&gt;&amp;lt;m:cn&amp;gt; NUM &amp;lt;/m:cn&amp;gt;&lt;/code&gt;&lt;/li&gt;&lt;code&gt;"NUM"^^sm:Number&lt;li&gt;&lt;code&gt;&amp;lt;m:cs&amp;gt; TEXT &amp;lt;/m:cs&amp;gt;&lt;/code&gt;&lt;/li&gt;&lt;code&gt;" TEXT "^^sm:String&lt;/code&gt;&lt;li&gt;&lt;code&gt;&amp;lt;m:ci&amp;gt; Name &amp;lt;/m:ci&amp;gt;&lt;/code&gt;&lt;/li&gt;Use blank node identifier (like _:Name)&lt;li&gt;&lt;code&gt;&amp;lt;m:csymbol&amp;gt; Symbol &amp;lt;/m:csymbol&amp;gt;&lt;/code&gt;&lt;/li&gt;Use URIs (http://www.openmath.org/cd/arith1#plus for &amp;lt;m:csymbol cd="arith1"&amp;gt;plus&amp;lt;/m:csymbol&amp;gt;, or the value of the &lt;code&gt;definitionURL&lt;/code&gt; for MathML2)&lt;li&gt;&lt;code&gt;&amp;lt;m:share/&amp;gt;&lt;/code&gt;&lt;/li&gt;Use URIs&lt;li&gt;&lt;code&gt;&amp;lt;m:cbytes&amp;gt; DATA &amp;lt;/m:cbytes&amp;gt;&lt;/code&gt;&lt;/li&gt;&lt;code&gt;" DATA "^^xs:base64Binary&lt;/code&gt;&lt;li&gt;&lt;code&gt;&amp;lt;m:cerror&amp;gt; Symbol Content* &amp;lt;/m:cerror&amp;gt;&lt;/code&gt;&lt;/li&gt;&lt;pre&gt;[] rdf:type sm:Error ;&lt;br /&gt;   sm:error Symbol ;&lt;br /&gt;   sm:errorWas LIST(Content) .&lt;/pre&gt;&lt;li&gt;&lt;code&gt;&amp;lt;m:apply&amp;gt; Symbol Content* &amp;lt;/m:apply&amp;gt;&lt;/code&gt;&lt;/li&gt;&lt;pre&gt;[] sm:apply Symbol ;&lt;br /&gt;   sm:applyTo LIST(Content) .&lt;/pre&gt;&lt;li&gt;&lt;code&gt;&amp;lt;m:bind&amp;gt; Symbol Vars* Content* &amp;lt;/m:bind&amp;gt;&lt;/code&gt;&lt;/li&gt;&lt;pre&gt;[] sm:bindOp Symbol ;&lt;br /&gt;   sm:bind LIST(Vars) ;&lt;br /&gt;        sm:bindIn LIST(Content) .&lt;/pre&gt;&lt;/code&gt;&lt;/ul&gt;&lt;p&gt;This allows all of Strict Content MathML to be encoded in a set of RDF triples. In order to have the full semantics of MathML and OpenMath there would have to be an OM-interpretation, OM-entailment, and so on, just as there is with every other application of RDF. Although I have not worked out the details of this, an OM-interpretation of an RDF graph that contains these properties would have to treat &lt;code&gt;sts:mapsTo&lt;/code&gt; special, and maybe map it to an appropriate &lt;code&gt;rdfs:Class&lt;/code&gt;. As an example of how this might be used, this is how the &lt;a href="http://www.haskell.org/"&gt;Haskell&lt;/a&gt; code (&lt;code&gt;\x -&gt; x + 2&lt;/code&gt;) would be translated into RDF using the properties listed above as follows:&lt;/p&gt;&lt;pre&gt;_:f sm:bindOp fns:lambda ;&lt;br /&gt;    sm:bind LIST(_:x) ;&lt;br /&gt;    sm:bindIn LIST(&lt;br /&gt;    [ sm:apply ari:plus ; &lt;br /&gt;      sm:applyTo LIST(_:x "2"^^sm:Number) ]).&lt;/pre&gt;&lt;p&gt;Now that RDF has lambdas, the possibilities are endless!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-5154771864921392916?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/5154771864921392916/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2009/06/semantic-mathml.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/5154771864921392916'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/5154771864921392916'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2009/06/semantic-mathml.html' title='Semantic MathML'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-677137618927688185</id><published>2009-06-07T13:48:00.000-07:00</published><updated>2009-06-07T13:52:52.682-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='Models'/><category scheme='http://www.blogger.com/atom/ns#' term='Haskell'/><title type='text'>Subtly Different Linked Lists</title><content type='html'>&lt;p&gt;If you don't know what a linked list is, then you probably shouldn't be reading this. However, the idea is very simple: a linked list is a list constructed from smaller lists of length two. So a list of length 3 would be constructed as (&lt;i&gt;A&lt;/i&gt;, &lt;i&gt;B&lt;/i&gt;, &lt;i&gt;C&lt;/i&gt;) = (&lt;i&gt;A&lt;/i&gt;, (&lt;i&gt;B&lt;/i&gt;, (&lt;i&gt;C&lt;/i&gt;, Nothing))), where Nothing would indicate that we have reached the end of the list. Most programming languages have some kind of linked list datatype. C++ has the &lt;code&gt;list&amp;lt;&lt;i&gt;T&lt;/i&gt;&amp;gt;&lt;/code&gt; type in STL, Lisp has the &lt;code&gt;'list&lt;/code&gt; type, Haskell has the &lt;code&gt;[&lt;i&gt;T&lt;/i&gt;]&lt;/code&gt; type, and RDF has the &lt;code&gt;rdf:List&lt;/code&gt; type. We will not consider sequences here, so C types will be left for a future article.&lt;/p&gt;&lt;p&gt;Without any type restrictions, such a pair need not be required to make a list. For example, we could make the structure ((&lt;i&gt;A&lt;/i&gt;, &lt;i&gt;B&lt;/i&gt;), &lt;i&gt;C&lt;/i&gt;), but we could not interpret it as a list. This is exactly how the Common Lisp &lt;code&gt;cl:cons&lt;/code&gt; constructor works. The &lt;a href="http://www.lispworks.com/documentation/HyperSpec/Front/index.htm"&gt;Common Lisp HyperSpec&lt;/a&gt; calls anything constructed with &lt;code&gt;cl:cons&lt;/code&gt; a list. The special case where the second element of &lt;code&gt;cl:cons&lt;/code&gt; is either another &lt;code&gt;cl:cons&lt;/code&gt; or a &lt;code&gt;cl:nil&lt;/code&gt; is called a &lt;b&gt;proper list&lt;/b&gt;. This restriction makes a subtype which can always be interpreted as a list. This subtype corresponds to the lists found in scripting languages such as Perl, Python, and Ruby. RDF lists can also be described as proper lists, since an RDFS-interpretation requires that the range of &lt;code&gt;rdf:rest&lt;/code&gt; is &lt;code&gt;rdf:List&lt;/code&gt;, so any attempt to make an improper list with &lt;code&gt;rdf:rest&lt;/code&gt; will result in an inconsistent RDF graph.&lt;/p&gt;&lt;p&gt;With the restriction that the second part of a pair is a list, we obtain so-called &lt;b&gt;heterogeneous lists&lt;/b&gt;, because the members of the list (encoded as the first part of each pair) can be of any type. If we also enforce the restriction that each member of the list is of the same type, then we obtain what is called &lt;b&gt;homogeneous lists&lt;/b&gt; for obvious reasons. This subtype is what is found in more strict languages, such as &lt;code&gt;list&amp;lt;&lt;i&gt;T&lt;/i&gt;&amp;gt;&lt;/code&gt; in C++ and &lt;code&gt;[&lt;i&gt;T&lt;/i&gt;]&lt;/code&gt; in Haskell. This is an overview of the different kinds of lists we have talked about:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Improper list (a, (b, c))&lt;/li&gt;&lt;li&gt;Proper list (a, (b, (c, ())))&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Heterogeneous list [1, "message"]&lt;/li&gt;&lt;li&gt;Homogeneous list [1, 2, 3]&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;p&gt;While we have talked about lists before, restricting RDF's heterogeneous lists to obtain homogeneous lists. However, in this article we are going to consider generalizing RDF's proper lists to obtain improper lists as well. In order to do this, we will make a distinction between &lt;code&gt;cl:Cons&lt;/code&gt; the Class and &lt;code&gt;cl:cons&lt;/code&gt; the constructor. First we need &lt;code&gt;rdf:List rdf:subClassOf cl:Cons&lt;/code&gt; so that they can work together, and then &lt;code&gt;cl:Cons&lt;/code&gt; will represent both improper lists and proper lists, and &lt;code&gt;rdf:List&lt;/code&gt; will represent proper lists only. To represent an improper list, would would have to be an instance of &lt;code&gt;cl:Cons&lt;/code&gt; but not &lt;code&gt;rdf:List&lt;/code&gt;. For a heterogeneous list, one would have to be missing the &lt;code&gt;ex:listType&lt;/code&gt; property, and for a homogeneous list, one would require the presence of the &lt;code&gt;ex:listType&lt;/code&gt; property. This covers all the different list types discussed above.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-677137618927688185?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/677137618927688185/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2009/06/subtly-different-linked-lists.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/677137618927688185'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/677137618927688185'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2009/06/subtly-different-linked-lists.html' title='Subtly Different Linked Lists'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-3481452233639159611</id><published>2009-06-06T18:01:00.000-07:00</published><updated>2009-06-06T18:13:28.784-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripts'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><title type='text'>HTML Script Datatypes</title><content type='html'>&lt;p&gt;While wandering through the W3C specification for &lt;code&gt;&lt;a href="http://www.w3.org/TR/rdf-text/"&gt;rdf:text&lt;/a&gt;&lt;/code&gt;, I realized a similar notation could be used for script objects, but there were too many pieces missing from the standards to connect everything together. So I will try to connect these ideas as best I can. &lt;a href="http://www.w3.org/TR/html401/"&gt;HTML 4.01&lt;/a&gt; defines multiple datatypes, some of which are redefined by &lt;a href="http://www.w3.org/Style/CSS/"&gt;CSS&lt;/a&gt;, such as Color and Length. The one that cought my attention was &lt;a href="http://www.w3.org/TR/html4/types.html#type-script"&gt;Script&lt;/a&gt;, which could be used to represent scripts written in different languages.&lt;/p&gt;&lt;p&gt;UNIX has long since had this datatype built in to almost every Shell interpreter. The so-called &lt;a href="http://en.wikipedia.org/wiki/Shebang_(Unix)"&gt;Hash-Bang&lt;/a&gt; system allows you to have programs written in any language that do not need to be compiled, but are passed to the appropriate program for interpretation. While RDF has two types that are very similar, it doesn't have a type for scripts or functions. Using a mixture of JavaScript and HTML datatypes, we can express a function definition in RDF as follows:&lt;/p&gt;&lt;pre&gt; @prefix hdt: &amp;lt;http://www.w3.org/TR/html4/types.html&amp;gt; .&lt;br /&gt; @prefix js: &amp;lt;urn:ecmascript:&amp;gt; .&lt;br /&gt;&lt;br /&gt; _:f rdf:type js:Function .&lt;br /&gt; _:f js:Call """&lt;br /&gt; function () {&lt;br /&gt;   this.done = true;&lt;br /&gt; } @&lt;a href="http://www.ietf.org/rfc/rfc4329.txt"&gt;application/ecmascript&lt;/a&gt;"""^^&lt;a href="http://www.w3.org/TR/html4/types.html#type-script"&gt;hdt:Script&lt;/a&gt; .&lt;/pre&gt;&lt;p&gt;Here you can see the &lt;code&gt;@&lt;/code&gt; notation is used to separate the script data from the media type, just as it is in the &lt;code&gt;rdf:text&lt;/code&gt; datatype. This would allow a mixture of data (RDF graphs) and code (JS scripts), which are the beginnings of a full-fledged programming language.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-3481452233639159611?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/3481452233639159611/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2009/06/html-script-datatypes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/3481452233639159611'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/3481452233639159611'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2009/06/html-script-datatypes.html' title='HTML Script Datatypes'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-3896209759507893841</id><published>2009-06-03T11:45:00.000-07:00</published><updated>2009-06-03T11:47:43.323-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='Models'/><title type='text'>XML Infoset Models</title><content type='html'>&lt;p&gt;The XML Information Set (Infoset) defines a number of classes that can be used to model XML documents, and to some extent, this is exactly the model used in other W3C specifications. However, some specifications use less or more than this set of classes, and it is insightful to compare them in order to find common subsets, and exhaustive supersets. In the comparison below "Info" means XML Infoset and "Path" means the XPath/XQuery Data Model. Also, the abbreviations (Y = yes/required, N = no/unspecified, O = optional) are used. &lt;/p&gt;&lt;table border="0" cellspacing="5" cellpadding="0"&gt;&lt;thead&gt;&lt;th style="text-align: left;"&gt;Class Name  &lt;/th&gt;&lt;th&gt;&lt;a href="http://www.w3.org/TR/REC-xml/"&gt;XML&lt;/a&gt;&lt;/th&gt;&lt;th&gt;&lt;a href="http://www.w3.org/TR/REC-DOM-Level-1/"&gt;DOM&lt;/a&gt;&lt;/th&gt;&lt;th&gt;&lt;a href="http://www.w3.org/TR/exi/"&gt;EXI&lt;/a&gt;&lt;/th&gt;&lt;th&gt;&lt;a href="http://www.w3.org/TR/xml-infoset/"&gt;Info&lt;/a&gt;&lt;/th&gt;&lt;th&gt;&lt;a href="http://www.w3.org/TR/xpath-datamodel/"&gt;Path&lt;/a&gt;&lt;/th&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;Attribute&lt;/b&gt;&lt;/td&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XML--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--DOM--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--EXI--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--IS--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XQ--&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;CDATASection  &lt;/td&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XML--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--DOM--&gt;&lt;td&gt;N&lt;/td&gt;&lt;!--EXI--&gt;&lt;td&gt;N&lt;/td&gt;&lt;!--IS--&gt;&lt;td&gt;N&lt;/td&gt;&lt;!--XQ--&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;CharacterData  &lt;/td&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XML--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--DOM--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--EXI--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--IS--&gt;&lt;td&gt;N&lt;/td&gt;&lt;!--XQ--&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Comment  &lt;/td&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XML--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--DOM--&gt;&lt;td&gt;O&lt;/td&gt;&lt;!--EXI--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--IS--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XQ--&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;Document&lt;/b&gt;&lt;/td&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XML--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--DOM--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--EXI--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--IS--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XQ--&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DocumentFragment  &lt;/td&gt;&lt;td&gt;N&lt;/td&gt;&lt;!--XML--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--DOM--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--EXI--&gt;&lt;td&gt;N&lt;/td&gt;&lt;!--IS--&gt;&lt;td&gt;N&lt;/td&gt;&lt;!--XQ--&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DocumentType  &lt;/td&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XML--&gt;&lt;td&gt;O&lt;/td&gt;&lt;!--DOM--&gt;&lt;td&gt;O&lt;/td&gt;&lt;!--EXI--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--IS--&gt;&lt;td&gt;N&lt;/td&gt;&lt;!--XQ--&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;Element&lt;/b&gt;&lt;/td&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XML--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--DOM--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--EXI--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--IS--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XQ--&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Entity  &lt;/td&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XML--&gt;&lt;td&gt;O&lt;/td&gt;&lt;!--DOM--&gt;&lt;td&gt;O&lt;/td&gt;&lt;!--EXI--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--IS--&gt;&lt;td&gt;N&lt;/td&gt;&lt;!--XQ--&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;EntityReference  &lt;/td&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XML--&gt;&lt;td&gt;O&lt;/td&gt;&lt;!--DOM--&gt;&lt;td&gt;O&lt;/td&gt;&lt;!--EXI--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--IS--&gt;&lt;td&gt;N&lt;/td&gt;&lt;!--XQ--&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;Namespace&lt;/b&gt;&lt;/td&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XML--&gt;&lt;td&gt;O&lt;/td&gt;&lt;!--DOM--&gt;&lt;td&gt;O&lt;/td&gt;&lt;!--EXI--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--IS--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XQ--&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Notation  &lt;/td&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XML--&gt;&lt;td&gt;O&lt;/td&gt;&lt;!--DOM--&gt;&lt;td&gt;N&lt;/td&gt;&lt;!--EXI--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--IS--&gt;&lt;td&gt;N&lt;/td&gt;&lt;!--XQ--&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ProcessingInstruction  &lt;/td&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XML--&gt;&lt;td&gt;O&lt;/td&gt;&lt;!--DOM--&gt;&lt;td&gt;O&lt;/td&gt;&lt;!--EXI--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--IS--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XQ--&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;Text&lt;/b&gt;&lt;/td&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XML--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--DOM--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--EXI--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--IS--&gt;&lt;td&gt;Y&lt;/td&gt;&lt;!--XQ--&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;Technically, XML Infoset does not include a CharacterData class, but includes a Character class that can be made into a list, which would be isomorphic to the CharacterData class. DOM only requires the optional classes if hasFeature("XML", "1.0") is implemented, so for all XML DOM implementations, these are not optional. Also, EXI requires the Namespace class, even though preserving the namespace prefix strings is optional. XPath has the smallest model, which only supports 7 of the above classes. &lt;/p&gt;&lt;p&gt;It is also interesting to note that Comments, Namespaces and ProcessingInstructions are not forbidden by any of the standards considered above. Also, as you can see, the only classes &lt;i&gt;required&lt;/i&gt; by all W3C models are: Attributes, Elements, Documents, Namespaces and Text. Why all the bloat?&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-3896209759507893841?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/3896209759507893841/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2009/06/xml-infoset-models.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/3896209759507893841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/3896209759507893841'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2009/06/xml-infoset-models.html' title='XML Infoset Models'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-5536706805604186208</id><published>2009-05-30T22:50:00.000-07:00</published><updated>2009-05-30T22:53:42.019-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Math'/><category scheme='http://www.blogger.com/atom/ns#' term='JSON'/><category scheme='http://www.blogger.com/atom/ns#' term='Curry'/><category scheme='http://www.blogger.com/atom/ns#' term='Tetration'/><title type='text'>Set Exponentiation</title><content type='html'>&lt;p&gt;Exponentiation is the operation of multiplying the same element by itself a given number of times. Defined by the relation &lt;var&gt;y&lt;/var&gt;&lt;sup&gt;&lt;var&gt;x&lt;/var&gt;&lt;/sup&gt; = &lt;var&gt;y&lt;/var&gt;&amp;sdot;&lt;var&gt;y&lt;/var&gt;&lt;sup&gt;&lt;var&gt;x&lt;/var&gt; &amp;minus; 1&lt;/sup&gt;, it can be evaluated by multiplication until &lt;var&gt;y&lt;/var&gt;&lt;sup&gt;1&lt;/sup&gt; is encountered, which is just &lt;var&gt;y&lt;/var&gt;. It can then be extended to rational numbers by solving an equation, then to the real numbers by the limit of a sequence, then to complex numbers by Euler's formula. Complex exponentiation is one of the most pervasive operations in all of mathematics. It can express all trigonometric functions such as sin, cos, tan, sec, csc, cot, and so on. It can express powers, polynomials, power series, Fourier series (with the help of addition), and much more. Simply put, it's everywhere.&lt;/p&gt;&lt;p&gt;Exponentiation can even be extended to matrices with the help of the equation &lt;var&gt;Y&lt;/var&gt;&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&lt;/sup&gt; = exp(log(&lt;var&gt;Y&lt;/var&gt;)&lt;var&gt;X&lt;/var&gt;) for square matrices, where exp and log are defined in terms of the usual power series. Exponentiation can also be extended to sets by noticing that the cardinalities of the domain |&lt;var&gt;X&lt;/var&gt;| and codomain |&lt;var&gt;Y&lt;/var&gt;| of a function, give |&lt;var&gt;Y&lt;/var&gt;|&lt;sup&gt;|&lt;var&gt;X&lt;/var&gt;|&lt;/sup&gt; = |&lt;var&gt;Y&lt;/var&gt;&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&lt;/sup&gt;| when exponentiated. This is the idea behind the notation of a power set (denoted 2&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&lt;/sup&gt;), which can be thought of as the set of all functions from &lt;var&gt;X&lt;/var&gt; to a boolean (which represents whether or not it is contained). This is illustrated by the following maps in &lt;a href="http://json.org/"&gt;JSON syntax&lt;/a&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;{"a": 0, "b": 0, "c": 0}&lt;/li&gt;&lt;li&gt;{"a": 0, "b": 0, "c": 1}&lt;/li&gt;&lt;li&gt;{"a": 0, "b": 1, "c": 0}&lt;/li&gt;&lt;li&gt;{"a": 0, "b": 1, "c": 1}&lt;/li&gt;&lt;li&gt;{"a": 1, "b": 0, "c": 0}&lt;/li&gt;&lt;li&gt;{"a": 1, "b": 0, "c": 1}&lt;/li&gt;&lt;li&gt;{"a": 1, "b": 1, "c": 0}&lt;/li&gt;&lt;li&gt;{"a": 1, "b": 1, "c": 1}&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Clearly, the number of such functions is 8, the cardinality of the domain is 3, and the cardinality of the codomain is 2, and we all know 2&lt;sup&gt;3&lt;/sup&gt; is 8. Following this to its logical conclusion, we arrive at a justification for &lt;a href="http://en.wikipedia.org/wiki/Currying"&gt;currying&lt;/a&gt;. Currying is the concept that a function of two variables that returns a value is the isomorphic to a function of one variable that returns a function of one variable that returns a value. In set-theory notation this would be &lt;var&gt;Z&lt;/var&gt;&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&amp;times&lt;var&gt;Y&lt;/var&gt;&lt;/sup&gt; = (&lt;var&gt;Z&lt;/var&gt;&lt;sup&gt;&lt;var&gt;Y&lt;/var&gt;&lt;/sup&gt;)&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&lt;/sup&gt;, and in Haskell notation this would be &lt;var&gt;X&lt;/var&gt; -&gt; &lt;var&gt;Y&lt;/var&gt; -&gt; &lt;var&gt;Z&lt;/var&gt;. So just as complex exponentiation is everywhere in Mathematics, so too is set exponentiation everywhere in most computer programming languages, whether or not they recognize the concept of currying. With this in mind, if the theory of algebraic datatypes includes type exponentiation, then pretty much all functions are accounted for. This is the approach that the &lt;a href="http://portal.acm.org/citation.cfm?id=61690"&gt;Z notation&lt;/a&gt; specification language, because it defines functions as equivalent to their relations. In other words &lt;var&gt;f&lt;/var&gt;(&lt;var&gt;x&lt;/var&gt;) = &lt;var&gt;y&lt;/var&gt; iff (&lt;var&gt;x&lt;/var&gt;, &lt;var&gt;y&lt;/var&gt;) is a member of &lt;var&gt;f&lt;/var&gt;. To illustrate how set exponentiation characterizes many concepts in programming languages, here is a list of common structures:&lt;/p&gt;&lt;ul&gt; &lt;li&gt;2&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&lt;/sup&gt; - &lt;b&gt;Predicates&lt;/b&gt; - functions that return a boolean.&lt;/li&gt; &lt;li&gt;&lt;var&gt;X&lt;/var&gt;&lt;sup&gt;2&lt;/sup&gt; - &lt;b&gt;If/Then/Else&lt;/b&gt; - functions from booleans to a value.&lt;/li&gt; &lt;li&gt;&lt;var&gt;X&lt;/var&gt;&lt;sup&gt;&lt;var&gt;n&lt;/var&gt;&lt;/sup&gt; - &lt;b&gt;Switch/Case&lt;/b&gt; - functions from an enumeration to a value.&lt;/li&gt; &lt;li&gt;&lt;var&gt;Y&lt;/var&gt;&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&lt;/sup&gt; - &lt;b&gt;Unary Functions&lt;/b&gt; - functions from any value to any value.&lt;/li&gt; &lt;li&gt;&lt;var&gt;X&lt;/var&gt;&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&lt;/sup&gt; - &lt;b&gt;Unary Operations&lt;/b&gt; - functions from a value to a value.&lt;/li&gt; &lt;li&gt;&lt;var&gt;X&lt;/var&gt;&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/sup&gt; - &lt;b&gt;Binary Operations&lt;/b&gt; - functions from two values.&lt;/li&gt; &lt;li&gt;&lt;var&gt;X&lt;/var&gt;&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&lt;sup&gt;&lt;var&gt;n&lt;/var&gt;&lt;/sup&gt;&lt;/sup&gt; - &lt;b&gt;&lt;i&gt;n&lt;/i&gt;-ary Operations&lt;/b&gt; - functions from many values.&lt;/li&gt; &lt;li&gt;2&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/sup&gt; - &lt;b&gt;Binary Relations&lt;/b&gt; - also called multi-functions. &lt;li&gt;2&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&lt;sup&gt;&lt;var&gt;n&lt;/var&gt;&lt;/sup&gt;&lt;/sup&gt; - &lt;b&gt;&lt;i&gt;n&lt;/i&gt;-ary Relations&lt;/b&gt; - also called multi-functions.&lt;/ul&gt;&lt;p&gt;This is quite a vast array of functions, which cover most basic structured programming concepts like if/then/else and switch/case. But there is one more: &lt;var&gt;X&lt;/var&gt;&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&lt;/sup&gt;&lt;/sup&gt;. What does this stand for? Well, conceptually, it takes a Unary Operation over &lt;var&gt;X&lt;/var&gt;, and gives a value from &lt;var&gt;X&lt;/var&gt;. This is exactly what happens when you evaluate a function at a value, which means the "evaluate at 0" function is in &lt;var&gt;X&lt;/var&gt;&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&lt;sup&gt;&lt;var&gt;X&lt;/var&gt;&lt;/sup&gt;&lt;/sup&gt;. What's more, is that this is the beginnings of a set-theoretic &lt;a href="http://tetration.itgo.com"&gt;Tetration&lt;/a&gt; (my other website), which I could talk about for hours, but I will save it for another time.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-5536706805604186208?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/5536706805604186208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2009/05/set-exponentiation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/5536706805604186208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/5536706805604186208'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2009/05/set-exponentiation.html' title='Set Exponentiation'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-3786344262414373241</id><published>2009-05-30T11:20:00.000-07:00</published><updated>2009-06-03T11:45:34.558-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><title type='text'>Nonstandard Namespaces</title><content type='html'>&lt;p&gt;XML namespaces are inherently vendor-neutral, and as such, anyone can define one, even me. So in order to help standardize XML dialects that do not define a namespace, I have put together a list of document types that really should have a namespace, but have not taken the time to define one.&lt;/p&gt;&lt;dl&gt;&lt;dt&gt;&lt;code&gt;r6rs&lt;/code&gt; (Scheme R6RS)&lt;/dt&gt;&lt;dd&gt;http://www.r6rs.org/final/html/r6rs/r6rs.html&lt;/dd&gt;&lt;dt&gt;&lt;code&gt;r5rs&lt;/code&gt; (Scheme R5RS)&lt;/dt&gt;&lt;dd&gt;http://www.schemers.org/Documents/Standards/R5RS/&lt;/dd&gt;&lt;dt&gt;&lt;code&gt;cl&lt;/code&gt; (Common Lisp)&lt;/dt&gt;&lt;dd&gt;http://www.lispworks.com/documentation/HyperSpec/&lt;/dd&gt;&lt;dt&gt;&lt;code&gt;cs&lt;/code&gt; (&lt;a href="http://crystal.svn.sourceforge.net/viewvc/crystal/CS/trunk/scripts/xml/cs_world.xsd"&gt;CS&lt;/a&gt;, &lt;a href="http://www.crystalspace3d.org/main/CEL_XML_syntax_guide"&gt;CEL&lt;/a&gt;)&lt;/dt&gt;&lt;dd&gt;http://www.crystalspace3d.org/2000/cs_world&lt;/dd&gt;&lt;dt&gt;&lt;code&gt;x3d&lt;/code&gt; (X3D, VRML)&lt;/dt&gt;&lt;dd&gt;http://www.web3d.org/specifications/x3d-namespace&lt;/dd&gt;&lt;dt&gt;&lt;code&gt;pl&lt;/code&gt; (Apple PList)&lt;/dt&gt;&lt;dd&gt;http://www.apple.com/DTDs/PropertyList-1.0.dtd&lt;/dd&gt;&lt;/dl&gt;&lt;p&gt;There really isn't much to say about these. Some of them are based on resources which describe the XML dialects, whereas others (like x3d-namespace) are a version-neutral namespace (while some X3D implementors have used x3d-3.0.xsd or x3d-3.2.xsd, for which files actually exist). If anyone thinks some of these are poor choices, then let me know, and I'll change it.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-3786344262414373241?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/3786344262414373241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2009/05/nonstandard-namespaces.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/3786344262414373241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/3786344262414373241'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2009/05/nonstandard-namespaces.html' title='Nonstandard Namespaces'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-3335518340521703570</id><published>2009-05-30T10:36:00.000-07:00</published><updated>2009-05-30T10:40:09.922-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='Lisp'/><title type='text'>Webizing Common Lisp</title><content type='html'>&lt;p&gt;Lisp is a very old language, but it is by no means old in the derogatory sense. Being the oldest language (except Fortran) has given it time to mature and grow into a language capable of amazing things. It has been said many places that Lisp and XML are similar in that they are both data (and if you include XAML and XSLT, code too). I would argue, though, that &lt;a href="http://www.lispworks.com/documentation/HyperSpec/Front/index.htm"&gt;Common Lisp&lt;/a&gt; has vastly more features. However, to make a true comparison, we have to &lt;a href="http://www.w3.org/DesignIssues/Webize.html"&gt;webize&lt;/a&gt; Lisp. At the very least, this requires a URI for every symbol. We can start by giving a namespace to all symbols in the &lt;a href="http://www.lispworks.com/documentation/HyperSpec/Body/01_i.htm"&gt;COMMON-LISP&lt;/a&gt; package.&lt;/p&gt;&lt;pre&gt;http://www.lispworks.com/documentation/HyperSpec/&lt;/pre&gt;&lt;p&gt;For convinience, we will use the &lt;code&gt;cl&lt;/code&gt; prefix for this namespace. We can now start relating Web standards and Lisp, or even writing ontologies using Lisp functions.&lt;/p&gt;&lt;p&gt;Lets compare lists, which are a fundamental part of Lisp. In Lisp, a cons &lt;code&gt;(x . y)&lt;/code&gt; would correspond to the RDF graph given by &lt;code&gt;[ a rdf:List ; rdf:first _:x ; rdf:rest _:y ]&lt;/code&gt; and &lt;code&gt;cl:nil&lt;/code&gt; would correspond to &lt;code&gt;rdf:nil&lt;/code&gt;. We can do this with almost all Lisp syntax, except perhaps for the syntax based on the hash (#) symbol. For example, &lt;code&gt;#c(3 4)&lt;/code&gt; would correspond to the MathML &lt;code&gt;&amp;lt;cn type="complex-cartesian"&amp;gt;3&amp;lt;sep/&amp;gt;4&amp;lt;/cn&amp;gt;&lt;/code&gt;, so the mapping can get complicated.&lt;/p&gt;&lt;p&gt;Considering such a mapping between Lisp and XML has many advantages. One thing they both have in common is the idea of homogenous data, however, when viewed as two separate syntaxes, they are incompatible, because XML would be a string in Lisp, and Lisp would be a string in XML, losing all structure. When considering such a mapping, it may seem equally advantageous to express XML in Lisp, and conversely, Lisp in XML. If only it were a &lt;a href="http://en.wikipedia.org/wiki/Bijection"&gt;bijection&lt;/a&gt;...&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-3335518340521703570?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/3335518340521703570/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2009/05/webizing-common-lisp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/3335518340521703570'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/3335518340521703570'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2009/05/webizing-common-lisp.html' title='Webizing Common Lisp'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-2382656372950372568</id><published>2009-05-22T18:06:00.000-07:00</published><updated>2009-05-23T09:18:23.730-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web'/><category scheme='http://www.blogger.com/atom/ns#' term='Models'/><title type='text'>The Web Metamodel</title><content type='html'>&lt;p&gt;The Object Management Group (OMG) likes to consider classes in a 4-level model, in which there is data, metadata (models), metametadata (metamodels), etc. This is way too confusing, so it is fortunate that &lt;a href="http://www.w3.org/"&gt;W3C&lt;/a&gt;'s standard only take up roughly 3-levels (much like &lt;a href="http://www.lispworks.com/documentation/HyperSpec/Front/index.htm"&gt;Lisp&lt;/a&gt;). The Resource Description Framework (RDF) defines 3 metaclasses that do not fit nicely into OMG's architecture, so they span several modeling levels. This can be seen in the image below, where containment indicates a &lt;a href="http://www.w3.org/TR/rdf-schema/#ch_subclassof"&gt;&lt;code&gt;rdf:subClassOf&lt;/code&gt;&lt;/a&gt; relationship, and the arrows indicate a &lt;a href="http://www.w3.org/TR/rdf-schema/#ch_type"&gt;&lt;code&gt;rdf:type&lt;/code&gt;&lt;/a&gt; relationship.&lt;/p&gt;&lt;img src="http://3.bp.blogspot.com/_UuUsxlSrZxM/ShdSdnOD5EI/AAAAAAAAAAM/D1NpSx6gTNo/s320/web_metamodel.png" border="0" alt="" /&gt;&lt;p&gt;Although there was no indication in the standards that &lt;a href="http://www.w3.org/TR/2004/REC-owl-guide-20040210/#owl_Class"&gt;&lt;code&gt;owl:Class&lt;/code&gt;&lt;/a&gt; is an instance of &lt;a href="http://www.w3.org/TR/rdf-schema/#ch_class"&gt;&lt;code&gt;rdfs:Class&lt;/code&gt;&lt;/a&gt;, it is a logical consequence, because &lt;code&gt;owl:Class&lt;/code&gt; is a subclass of &lt;code&gt;rdfs:Class&lt;/code&gt;, and &lt;code&gt;rdfs:Class&lt;/code&gt; is an instance of itself. However, the same could be said of &lt;code&gt;rdfs:Datatype&lt;/code&gt;, for which there is an explicit mention that &lt;code&gt;rdfs:Datatype&lt;/code&gt; is both a subclass &lt;em&gt;and&lt;/em&gt; an instance of &lt;code&gt;rdfs:Class&lt;/code&gt;. There was also &lt;a href="http://www.w3.org/2001/sw/WebOnt/webont-issues.html#I5.22-owl:Class-still-needed"&gt;an issue about this&lt;/a&gt;, which decided the reason for &lt;code&gt;owl:Class&lt;/code&gt; was to be distinct from &lt;code&gt;rdfs:Datatype&lt;/code&gt;, not because of some cyclic dependancy stuff. So to keep the model simple, and to minimize cycles, we can ignore the fact that &lt;code&gt;rdfs:Datatype&lt;/code&gt; is an instance of &lt;code&gt;rdfs:Class&lt;/code&gt;, because this is implied by the fact that &lt;code&gt;rdfs:Class&lt;/code&gt; is an instance of itself.&lt;/p&gt;&lt;p&gt;To overview some of the triples in this model, the standards say&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;rdfs:Class rdf:type rdfs:Class .&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;owl:Class rdf:subClassOf rdfs:Class .&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;rdfs:Datatype rdf:subClassOf rdfs:Class . &lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;rdfs:Class rdf:subClassOf rdfs:Resource .&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;rdfs:Resource rdf:type rdfs:Class .&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Notably, we have ignored the &lt;code&gt;rdf:Property&lt;/code&gt; class, which is part of the model level, not the metamodel level. So the image above is an accurate depiction of the Web metamodel, which consists of only four metaclasses: &lt;a href="http://www.w3.org/TR/rdf-schema/#ch_resource"&gt;&lt;code&gt;rdfs:Resource&lt;/code&gt;&lt;/a&gt;, &lt;a href=""&gt;&lt;code&gt;rdfs:Datatype&lt;/code&gt;&lt;/a&gt;, &lt;a href="http://www.w3.org/TR/rdf-schema/#ch_class"&gt;&lt;code&gt;rdfs:Class&lt;/code&gt;&lt;/a&gt;, and &lt;a href="http://www.w3.org/TR/2004/REC-owl-guide-20040210/#owl_Class"&gt;&lt;code&gt;owl:Class&lt;/code&gt;&lt;/a&gt;. Aside from &lt;a href="http://www.w3.org/TR/2004/REC-owl-ref-20040210/#EnumeratedDatatype"&gt;&lt;code&gt;owl:DataRange&lt;/code&gt;&lt;/a&gt;, this is a fairly complete picture of the Web metamodel. For beginners, the distinctions between these five metaclasses are essential before more indepth discussions take place. If one has any confusion about these distinctions, then nothing else about OWL will make any sense.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-2382656372950372568?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/2382656372950372568/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2009/05/web-metamodel.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/2382656372950372568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/2382656372950372568'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2009/05/web-metamodel.html' title='The Web Metamodel'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_UuUsxlSrZxM/ShdSdnOD5EI/AAAAAAAAAAM/D1NpSx6gTNo/s72-c/web_metamodel.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-7309666033732281296</id><published>2009-05-18T22:10:00.000-07:00</published><updated>2009-05-18T22:23:28.499-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web'/><category scheme='http://www.blogger.com/atom/ns#' term='Models'/><category scheme='http://www.blogger.com/atom/ns#' term='Haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='Binary'/><title type='text'>Semantic Binary Data</title><content type='html'>&lt;p&gt;There seems to be quite a few quite a few things missing from &lt;a href="http://www.w3.org/XML/Schema"&gt;XML Schema&lt;/a&gt;, &lt;a href="http://www.w3.org/TR/rdf-schema/"&gt;RDF&lt;/a&gt; and &lt;a href="http://www.w3.org/2007/OWL/wiki/OWL_Working_Group"&gt;OWL&lt;/a&gt;, for example, a single unified type for binary octet-streams. The distinction between the two types used for binary octet-streams has caused more than a few issues during the implementation of these technologies. One indication is that OWL 2.0 is much more complex than the OWL 1.0, and another indication is &lt;a href="http://www.w3.org/TR/2009/WD-owl2-syntax-20090421/#Binary_Data"&gt;a note in OWL 2&lt;/a&gt; which talks about the consequences of the distinction between &lt;a href="http://www.w3.org/TR/xmlschema-2/#base64Binary"&gt;&lt;code&gt;xs:base64Binary&lt;/code&gt;&lt;/a&gt; and &lt;a href="http://www.w3.org/TR/xmlschema-2/#hexBinary"&gt;&lt;code&gt;xs:hexBinary&lt;/code&gt;&lt;/a&gt;.  Both of these types are defined to have identical value spaces, but different lexical spaces. Their mutual value space is defined as all finite-length sequences of octets (numbers between 0 and 255).&lt;/p&gt;&lt;p&gt;If the Web metasystem is to understand anything, it must be able to understand octet-streams, since everything else is described in terms of these. Text can be viewed as an octet-stream. Pictures, movies, and music files can all be described as octet-streams, so unless XML, RDF and OWL allow clear expression of the concept of binary data, the application of these technologies will always be limited to vauge and abstract knowledge. There are many ways that a unified binary type could be brought to the XML world. One would be to make a &lt;a href="http://www.w3.org/TR/2004/REC-owl-ref-20040210/#unionOf-def"&gt;&lt;code&gt;owl:unionOf&lt;/code&gt;&lt;/a&gt; type that combined the two. Or another option would be to define an &lt;a href="http://www.w3.org/TR/rdf-schema/#ch_list"&gt;&lt;code&gt;rdf:List&lt;/code&gt;&lt;/a&gt; type, and restrict the types of the members of the list to octets. Since the first option is trivial, and does not provide much structural knowledge about octet-streams, we will not consider it. The second approach does add structural knowledge, and so would be more appropriate for allowing the Web to understand more about octet-streams.&lt;/p&gt;&lt;p&gt;Neither RDF nor OWL allow restricting lists to be of a certain type, so in order to make a class of lists of octets, we must first have the ability to make lists of a type. To this end, we define a new &lt;a href="http://www.w3.org/TR/rdf-schema/#ch_property"&gt;&lt;code&gt;rdf:Property&lt;/code&gt;&lt;/a&gt; called &lt;code&gt;&lt;b&gt;ex:listType&lt;/b&gt;&lt;/code&gt;. How would this property be used? To understand this, we must first understand how RDF handles higher-order types. For example, Properties in RDF can be thought of as higher-order types with two parameters. Using a &lt;a href="http://www.haskell.org/onlinereport/"&gt;Haskell&lt;/a&gt;-like syntax, this would mean (&lt;code&gt;x :: Property a b&lt;/code&gt;) would correspond to the triples&lt;/p&gt;&lt;pre&gt;_:x rdf:type rdf:Property .&lt;br /&gt;_:x rdfs:domain _:a .&lt;br /&gt;_:x rdfs:range _:b .&lt;/pre&gt;&lt;p&gt;which means the appropriate way to encode list types in RDF, such as (&lt;code&gt;x :: List a&lt;/code&gt;), would be with the triples&lt;/p&gt;&lt;pre&gt;_:x rdf:type rdf:List .&lt;br /&gt;_:x &lt;b&gt;ex:listType&lt;/b&gt; _:a .&lt;/pre&gt;&lt;p&gt;With this new construct, a unified &lt;code&gt;&lt;b&gt;ex:binary&lt;/b&gt;&lt;/code&gt; type could easily be defined as (&lt;code&gt;List xs:unsignedByte&lt;/code&gt;). Or in simpler terms, the triple (&lt;code&gt;_:x rdf:type &lt;b&gt;ex:binary&lt;/b&gt;&lt;/code&gt;) would be equivalent to the triples&lt;/p&gt;&lt;pre&gt;_:x rdf:type rdf:List .&lt;br /&gt;_:x &lt;b&gt;ex:listType&lt;/b&gt; xs:unsignedByte .&lt;/pre&gt;&lt;p&gt;This would allow OWL ontologies about file formats, stream protocols, multimedia files, and much more. Using these two higher-order types as examples, it seems all higher-order types can be patterned after these two. Also, since it is abstract enough to represent these higher-order types, it seems that Web technologies are on the right track. RDF and OWL seem to be the most abstract way of expressing modeling ideas, even more abstract than systems like &lt;a href="http://www.omg.org/gettingstarted/corbafaq.htm"&gt;CORBA&lt;/a&gt;, &lt;a href="http://www.w3.org/TR/WebIDL/"&gt;IDL&lt;/a&gt; and &lt;a href="http://www.uml.org/"&gt;UML&lt;/a&gt;. The fact that they allow expressing higher-order types such as those found in Haskell is promising. Perhaps the goal of model compilation (the &lt;a href="http://www.omg.org/"&gt;OMG&lt;/a&gt; kind), is much closer than we think. However, the &lt;a href="http://www.uml-forum.com/FAQ.htm#What_are_the_outstanding_issues"&gt;bloat of UML&lt;/a&gt; does more to complicate model translation than to simplify it.&lt;/p&gt;&lt;p&gt;Perhaps the simplicity of RDF is all we need.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-7309666033732281296?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/7309666033732281296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2009/05/semantic-binary-data.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/7309666033732281296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/7309666033732281296'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2009/05/semantic-binary-data.html' title='Semantic Binary Data'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-5166126114841580268</id><published>2009-05-11T19:41:00.000-07:00</published><updated>2009-05-11T21:44:22.065-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Water'/><title type='text'>Water Shortages</title><content type='html'>&lt;p&gt;We have water everywhere. Water flows off mountains, collects in lakes, and comprises 70% of the Earth's surface. It is hard to imagine our world without water. So when the idea of it running out is mentioned, it seems so &lt;a href="http://www.amazon.com/More-Water-Tub-Tedd-Arnold/dp/0803715811"&gt;funny&lt;/a&gt; that we pay little attention. If we listen, then we find the signs of its disappearance are also everywhere.&lt;/p&gt;&lt;img src="http://www.newser.com/image/46956-6-20071117035154.image"/&gt;&lt;p&gt;Places all across the globe are experiencing short-term water shortages (For example, &lt;a href="http://www.ktak.gov.my/template03.asp?newsID=349&amp;tt=news#"&gt;Putrajaya, Malaysia&lt;/a&gt;; &lt;a href="http://water.columbia.edu/?id=reports&amp;navid=cyprus"&gt;Hechi, Guangxi, China&lt;/a&gt;; &lt;a href="http://polizeros.com/2007/10/27/town-in-san-diego-has-no-water-left/"&gt;San Diego, California, US&lt;/a&gt;; &lt;a href="http://www.wsaz.com/news/headlines/44502932.html"&gt;Roane County, West Virginia, US&lt;/a&gt;; &lt;a href="http://www.examiner.com/a-1444911~Montgomery_residents_cope_with_water_shortage.html"&gt;Montgomery County, Maryland, US&lt;/a&gt;; &lt;a href="http://www.treehugger.com/files/2007/12/durham_north_ca_1.php"&gt;Durham, North Carolina, US&lt;/a&gt;). Nations such as &lt;a href="http://www.npr.org/templates/story/story.php?storyId=11134967"&gt;Australia&lt;/a&gt; and &lt;a href="http://www.nytimes.com/2008/06/03/world/europe/03dry.html"&gt;Spain&lt;/a&gt; are already noticing significant long-term water shortages, who say&lt;/p&gt;&lt;blockquote&gt;The battles of yesterday were fought over land, they warn. Those of the present center on oil. But those of the future -- a future made hotter and drier by climate change in much of the world -- seem likely to focus on water, they say.&lt;/blockquote&gt;&lt;p&gt;Two great examples of works that discuss a future without water are &lt;a href="http://www.dedaldeoro.cl/ed37-agua.htm"&gt;this Spanish poem&lt;/a&gt; (also in &lt;a href="http://translate.google.com/translate?prev=hp&amp;hl=en&amp;js=n&amp;u=http%3A%2F%2Fwww.dedaldeoro.cl%2Fed37-agua.htm&amp;sl=es&amp;tl=en"&gt;English&lt;/a&gt; and &lt;a href="http://www.youtube.com/watch?v=6QGxsd6EVvw"&gt;video&lt;/a&gt;), and the legacy of &lt;a href="http://johntitor.strategicbrains.com/"&gt;John Titor&lt;/a&gt;. While John Titor has made several predictions that turned out to be false (for example, he said &lt;a href="http://en.wikipedia.org/wiki/Y2K"&gt;Y2K&lt;/a&gt; would be devastating), he also predicted that water would become more scarce. This seems to be exactly what we are starting to see in many cities today.&lt;/p&gt;&lt;img src="http://www.newser.com/image/46951-6-20071117035037.image"/&gt;&lt;p&gt;Although a total water shortage is still a very far away, water contamination may be a problem sooner. It is already starting to kill off many spicies to the brink of extinction (for example &lt;a href="http://www.lifeonterra.com/results.php?tag=marine"&gt;Fish&lt;/a&gt; and &lt;a href="http://www.lifeonterra.com/episode.php?id=175"&gt;Frogs&lt;/a&gt;). Modern apathy may compel one to dismiss these, since they're just frogs, but ask yourself: What can we learn from frogs? Frogs (and most amphibians) are both land and water-based creatures, so they represent the future health of both fish and mammals. Since humans are mammals, that means we're next! If that wasn't enough, you might also be interested to know that the science of cryogenics (freezing people and bringing them back to life) rests on the study of tree frogs. Any selfish ego-centric person would love to get frozen when they're 80, and wake up in a hundred years when there's a cure waiting just for them. So regardless of your disposition, selfish or selfless, clean water is important.&lt;/p&gt;&lt;p&gt;We find that there is a growing awareness that water will not be as plentiful as it is now. Lessons given by John Titor and Tree Frogs both indicate we should reevaluate our water situation soon. Avoiding to do so would mean its scarcity would surpass that of both land and oil. Just as oil has been called &lt;a href="http://en.wikipedia.org/wiki/Petroleum"&gt;Black Gold&lt;/a&gt; it may be inevitable that in our near future, all power struggles will be for &lt;a href="http://waterliquidgold.com/"&gt;Liquid Gold&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Images Copyright (c) 2007 Associated Press.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-5166126114841580268?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/5166126114841580268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2009/05/water-shortages.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/5166126114841580268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/5166126114841580268'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2009/05/water-shortages.html' title='Water Shortages'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-1244226709820769020</id><published>2009-05-09T15:36:00.000-07:00</published><updated>2009-05-09T16:03:02.783-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web'/><category scheme='http://www.blogger.com/atom/ns#' term='Models'/><title type='text'>The Web Metasystem</title><content type='html'>&lt;p&gt;A recent &lt;a href="http://www.youtube.com/watch?v=yDYCf4ONh5M"&gt;TEDtalk given by Kevin Kelly&lt;/a&gt; came to my attention recently, which has a lot to do with the Web. In it, he gives a very interesting view of the Web, making the analogy that the number of transistors supporting it is about the same number of &lt;a href="http://en.wikipedia.org/wiki/Neuron"&gt;neurons&lt;/a&gt; in the human brain. Kevin Kelly says:&lt;/p&gt;&lt;blockquote&gt;&lt;pre&gt;There is only One machine.&lt;br /&gt;The web is its &lt;a href="http://en.wikipedia.org/wiki/Operating_system"&gt;OS&lt;/a&gt;.&lt;br /&gt;All screens look into the One.&lt;br /&gt;No &lt;a href="http://en.wikipedia.org/wiki/Bit"&gt;bits&lt;/a&gt; will live outside the web.&lt;br /&gt;To share is to gain.&lt;br /&gt;Let the One read it.&lt;br /&gt;The One is us.&lt;/pre&gt;&lt;/blockquote&gt;&lt;p&gt;The most interesting part is when he talks about the complexity of the Web over time. If transistors are akin to neurons, then that means in 10 years the Web will be 2 brains, and in 20 years, the Web will be 4 brains, and so on. The &lt;a href="http://en.wikipedia.org/wiki/Human_brain"&gt;human brain&lt;/a&gt; contains about 100 billion neurons, which are much more complex than a transistor in nature. I think that it would take on the order of 10 transistors to approximate a single neuron, making his estimates inaccurate.&lt;/p&gt;&lt;p&gt;In the long run, such an analogy could be viewed in the context of &lt;a href="http://pespmc1.vub.ac.be/MSTT.html"&gt;metasystem transition theory&lt;/a&gt;, in which evolution is not continuous as it is in Darwinian evolution, but happens in discrete steps marked by a &lt;a href="http://pespmc1.vub.ac.be/MST.html"&gt;metasystem transition&lt;/a&gt;. In this model, regardless of how many transistors there are in the Web at any one point in time, the evolutionary step in which the Web becomes a brain is when a control system emerges. Since the Web was designed by us, and continues to be re-structured by us. There is an obvious answer to what the control system behind the Web is. Everyone. The Web is us.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-1244226709820769020?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/1244226709820769020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2009/05/models-web-metasystem.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/1244226709820769020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/1244226709820769020'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2009/05/models-web-metasystem.html' title='The Web Metasystem'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-5831203156344949323</id><published>2009-05-01T14:45:00.000-07:00</published><updated>2009-05-09T15:59:48.990-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='EXI'/><category scheme='http://www.blogger.com/atom/ns#' term='Haskell'/><title type='text'>Haskell - Encodings</title><content type='html'>&lt;p&gt;The ASCII character set has withstood the test of time. However, as the use of computers and the internet becomes global, it is only natural that people speak in their native language. To this end, the &lt;a href="http://www.unicode.org/"&gt;Unicode character set&lt;/a&gt; was developed to meet this need. Since Unicode uses much more than 255 code points to represent these characters, there are many ways of mapping the much larger space of 4-bytes into a sequence of one or more bytes. The two most popular schemes for doing this are UTFs (UTF-8 and UTF-16), and Guóbiāo (GB2312 and GB18030). In particular, UTF-8 is a very organized and methodical scheme, which makes it well suited for purposes other than text encoding.&lt;/p&gt;&lt;p&gt;XML has become terrifyingly popular in acedemic and commercial circles, and while the overhead that it incurs is usually negligible, there are some who want to use an XML model while keeping a small memory footprint. For this, the &lt;a href="http://www.w3.org/"&gt;W3C&lt;/a&gt; has designed a binary XML format called EXI for the transmission of XML documents in binary form. Parts of this standard are not very nice (which is out of the scope of this post), whereas some parts are quite ingenious, like the integer and date-time formats.&lt;/p&gt;&lt;p&gt;Here are some examples of EXI (efficient XML interchange) unsigned integers. EXI is little-endian, so the &lt;i&gt;A&lt;/i&gt;s are the low bits and the &lt;i&gt;C&lt;/i&gt;s are the high bits.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;0b0AAAAAAA&lt;/code&gt; (EXI encoding for 1-byte)&lt;/li&gt;&lt;li&gt;&lt;code&gt;0b1AAAAAAA,0b0BBBBBBB&lt;/code&gt; (EXI encoding for 2-bytes)&lt;/li&gt;&lt;li&gt;&lt;code&gt;0b1AAAAAAA,0b1BBBBBBB,0b0CCCCCCC&lt;/code&gt; (3-bytes)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Here are some examples of UTF (Unicode transformation format) characters. UTF-8 is big-endian, so the &lt;i&gt;C&lt;/i&gt;s are the low bits and the &lt;i&gt;A&lt;/i&gt;s are the high bits.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;0b0AAAAAAA&lt;/code&gt; (UTF-8 encoding for 1-byte)&lt;/li&gt;&lt;li&gt;&lt;code&gt;0b110AAAAA,0b10BBBBBB&lt;/code&gt; (UTF-8 encoding for 2-bytes)&lt;/li&gt;&lt;li&gt;&lt;code&gt;0b1110AAAA,0b10BBBBBB,0b10CCCCCC&lt;/code&gt; (3-bytes)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;In the C programming language, all &lt;b&gt;struct&lt;/b&gt;s can be thought of as parsers. In the Haskell programming language, one can write parsers quite easily with the help of a library called &lt;b&gt;Parsec&lt;/b&gt;, which stands for &lt;i&gt;&lt;b&gt;parse&lt;/b&gt;r &lt;b&gt;c&lt;/b&gt;ombinators&lt;/i&gt;. Suppose we have a  &lt;code&gt;Bit&lt;/code&gt; datatype with the constructors &lt;code&gt;On&lt;/code&gt; and &lt;code&gt;Off&lt;/code&gt;, and suppose we have definitions for the following functions in Haskell:&lt;/p&gt;&lt;pre&gt;bit :: Bit -&gt; Parser Bit&lt;br /&gt;bitstring :: [Bit] -&gt; Parser [Bit]&lt;br /&gt;manyBits :: Int -&gt; Parser [Bit]&lt;br /&gt;oneBit :: Parser Bit&lt;/pre&gt;&lt;p&gt;These parsers would allow writing versions of EXI and UTF-8 parsers without any knowledge of characters. An EXI parser can be described as follows&lt;/p&gt;&lt;pre&gt;exi :: Parser [Bit]&lt;br /&gt;&lt;b&gt;exi&lt;/b&gt; = do&lt;br /&gt;  firstBit &lt;- oneBit&lt;br /&gt;  restBits &lt;- manyBits 7&lt;br /&gt;  case firstBit of&lt;br /&gt;    Off -&gt; return restBits&lt;br /&gt;    On -&gt; do &lt;br /&gt;      highBits &lt;- &lt;b&gt;exi&lt;/b&gt;&lt;br /&gt;      return (highBits ++ restBits)&lt;/pre&gt;&lt;p&gt;and a UTF-8 parser can be described as&lt;/p&gt;&lt;pre&gt;utf8continue = do&lt;br /&gt;  bitstring [On, Off]&lt;br /&gt;  manyBits 6&lt;br /&gt;&lt;br /&gt;utf8 :: Parser [Bit]&lt;br /&gt;&lt;b&gt;utf8&lt;/b&gt; =  do bit Off&lt;br /&gt;           manyBits 7&lt;br /&gt;&lt;br /&gt;    &lt;|&gt; do bitstring [On, On, Off]&lt;br /&gt;           highBits &lt;- manyBits 5&lt;br /&gt;           restBits &lt;- utf8continue &lt;br /&gt;           return (highBits ++ restBits)&lt;br /&gt;&lt;br /&gt;    &lt;|&gt; do bitstring [On, On, On, Off]&lt;br /&gt;           highBits &lt;- manyBits 4&lt;br /&gt;           rests &lt;- sequence (replicate 2 utf8continue)&lt;br /&gt;           return (highBits ++ (concat rests))&lt;br /&gt;&lt;br /&gt;    &lt;|&gt; do bitstring [On, On, On, On, Off]&lt;br /&gt;           highBits &lt;- manyBits 3&lt;br /&gt;           rests &lt;- sequence (replicate 3 utf8continue)&lt;br /&gt;           return (highBits ++ (concat rests))&lt;/pre&gt;&lt;p&gt;As you can see, EXI has a much more elegant implementation in Haskell. Although Parsec was designed to be used on characters and strings, similar techniques can be used for byte-parsers and bit-parsers as shown above. Since C &lt;b&gt;struct&lt;/b&gt;s can be viewed as byte-parsers, it should be possible to build Parsec style parsers for some common C &lt;b&gt;struct&lt;/b&gt;s and common file formats like &lt;a href="http://www.jpeg.org/"&gt;JPEG&lt;/a&gt; or &lt;a href="http://www.mpeg.org/"&gt;MPEG&lt;/a&gt;. Bringing this to its logical conclusion, most file formats could be described as some kind of bit-parser or byte-parser, so if such parsers were written in Haskell, what would they look like?&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-5831203156344949323?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/5831203156344949323/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2009/05/haskell-exi-and-utf-8-encodings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/5831203156344949323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/5831203156344949323'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2009/05/haskell-exi-and-utf-8-encodings.html' title='Haskell - Encodings'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9161886791806233869.post-3296174938669911867</id><published>2009-04-28T16:21:00.000-07:00</published><updated>2009-04-28T18:29:44.130-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><title type='text'>XML - Entity References</title><content type='html'>&lt;p&gt;When we go about writing a web page, often enough, we like using all sorts of characters in our text, like exclamation points (!), ampersands (&amp;amp;), and less than signs (&amp;lt;). Sooner or later, it becomes obvious that we need a way to put a character in our web pages without using the character itself. For example, the less than sign (&amp;lt;) is part of XML markup, so it cannot be used in the text itself, so to remedy this situation the entity reference &lt;code&gt;&amp;amp;lt;&lt;/code&gt; is used. This expands to (&amp;lt;) when the page is viewed in a browser, so the desired effect is achieved.&lt;/p&gt;&lt;p&gt;The concept of XML entities was borrowed from SGML, and so their inner workings are very similar. Another borrowing from SGML is the &lt;code&gt;DOCTYPE&lt;/code&gt; declaration. While backwards-compatibility was an important objective for XML 1.0, it is a low priority now that XML processors are ubiquitous, and rarely depend on more general SGML processing. In fact, now that &lt;a href="http://www.w3.org/TR/xmlschema11-1/"&gt;XML Schema&lt;/a&gt; has replaced almost every aspect of the Document Type Declaration (DTD), it is likely that the use of DTDs will diminish. Since &lt;a href="http://www.w3.org/TR/xmlschema11-1/"&gt;XML Schema&lt;/a&gt; provides a richer environment for declaring elements and defining types, it seems painful to have to use DTDs. This naturally leads to the question of whether or not DTDs can be removed from the XML specification.&lt;/p&gt;&lt;p&gt;Suppose DTDs were removed from the &lt;a href="http://www.w3.org/TR/REC-xml/"&gt;XML specification&lt;/a&gt; (perhaps for XML 1.5). What else would have to be changed in order to maintain consistency? Surprisingly, &lt;i&gt;only entities&lt;/i&gt;. Everything else can be equivalently (or better) declared in XML Schema, which also provides rich types that can increase validity constraints where DTDs would not. However, XML Schema does not provide a way to define entities. So if a &lt;span style="font-style: italic;"&gt;new&lt;/span&gt; mechanism for entity definition is required, then it could be one of the following options:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Use a simplified &lt;code&gt;DOCTYPE&lt;/code&gt; declaration for compatibility.&lt;/li&gt;&lt;li&gt;Create a new processing instruction to include entities.&lt;/li&gt;&lt;li&gt;Let the user agent handle entities however it wants.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Of these options, the new processing instruction would be the most consistent with W3C's other specifications, such as &lt;a href="http://www.w3.org/TR/xml-stylesheet/"&gt;Associating Style Sheets with XML documents&lt;/a&gt;. Also, it would be a chance to codify current best practice. XML allows entities to be defined internally (within the document) and externally (in another file). Most documents that use entities either depend on a standard list of entities (like &lt;a href="http://www.w3.org/TR/html4/sgml/entities.html"&gt;HTML Entities&lt;/a&gt;) or directly include a file which has entity definitions. So while a hypothetical processing instruction &lt;code&gt;&amp;lt;?xml-entity copy "&amp;amp;#169;"?&amp;gt;&lt;/code&gt; would do the job, it would go against everything. A hypothetical processing instruction &lt;code&gt;&amp;lt;?xml-entities href="htmllat1.ent"?&amp;gt;&lt;/code&gt; would be more in line with current usage. Since this would introduce a new language for this external file, there would have to be at least two parts to a specification of this idea:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;pre&gt;entSubset  ::= (&lt;a href="http://www.w3.org/TR/REC-xml/#NT-GEDecl"&gt;GEDecl&lt;/a&gt; | &lt;a href="http://www.w3.org/TR/REC-xml/#NT-Comment"&gt;Comment&lt;/a&gt; | &lt;a href="http://www.w3.org/TR/REC-xml/#NT-S"&gt;S&lt;/a&gt;)*&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;pre&gt;EntitiesPI ::= '&amp;lt;?xml-entities' &lt;a href="http://www.w3.org/TR/REC-xml/#NT-S"&gt;S&lt;/a&gt; &lt;a href="http://www.w3.org/TR/xml-stylesheet/#NT-PseudoAtt"&gt;PseudoAtt&lt;/a&gt; &lt;a href="http://www.w3.org/TR/REC-xml/#NT-S"&gt;S&lt;/a&gt;? '?&amp;gt;'&lt;/pre&gt;where the allowed pseudo-attributes are:&lt;br /&gt;&lt;pre&gt;href    CDATA #REQUIRED&lt;br /&gt;charset CDATA #IMPLIED&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Another benefit of using a processing instruction instead of some other method is that you do not have to wait until a new XML processor is implemented. In the worst case scenario, you could pass the document through a tool that understands that processing instruction, and the rest can be handled by a normal XML processor. Thus, you can live in a DTD-free world without waiting for XML 1.5 ... you can have it your way, today.&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9161886791806233869-3296174938669911867?l=straymindcough.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://straymindcough.blogspot.com/feeds/3296174938669911867/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://straymindcough.blogspot.com/2009/04/xml-entity-references.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/3296174938669911867'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9161886791806233869/posts/default/3296174938669911867'/><link rel='alternate' type='text/html' href='http://straymindcough.blogspot.com/2009/04/xml-entity-references.html' title='XML - Entity References'/><author><name>Andrew Robbins</name><uri>http://www.blogger.com/profile/09074689878199168258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
