# The “Science” of meditation

You may wonder “what is meditation really?”. Or perhaps you have a precached notion of meditation as something only hippies and monks do, a religious ritual at best. But really there is much more.

In the broadest sense, it is the “science” of the mind.

First I’m going to shadow your definition of “science” with mine, so that there is no confusion. Hopefully it is sufficiently close to yours so that you can glean some benefit from the discussion. By “science”, I mean the acquisition of knowledge about the “outside” world, through logic (truth preserving transformations) and observation, the prediction of future observations given past observations. I make this distinction because the application of “science” directly to the mind gets a bit tricky.

The universe simulates quantum mechanics at some scale, chemistry at a larger scale, Newtonian physics at a still larger scale, general relativity, etc. None of these scientific frameworks are true, but they are convenient abstractions for predicting future observations from past observations to some degree of accuracy. We know that they are not true because there are “leaks” in the abstraction, some things that don’t fit. QM cannot currently reconcile with GR, so we know we must jump to a “larger” theory to unify them. What if at some point we find no leaks? Does this mean we now know what is “true”? Well not necessarily. The universe could be a perfect simulation in a larger universe, a dream in the mind of a god, a quantum fluctuation that exists only for an instant with our memories an illusion.

How can we distinguish these possibilities? There is no way, so long as there is no observable difference. For this reason I suggest that my definition of “science” is a useful one.

This shift in perspective begs a question: If we can’t really say anything about what’s true “out there”, but can only make statements about observations, what exactly is an observation?! It seems obvious that we need to look deeper inside the mind, in the realm of sensory perception to answer this question. Normally in science we make some basic assumptions, like “objective reality exists”. This is generally a nice assumption to make. But in doing so we make some implicit assumptions that our senses relay accurate information and are not subject to introspection. This leads to problems like the above, where you can make nonsense statements about indistinguishable realities.

So observations are kind of like senses? Well, “sense” is rather arbitrary (in addition to the 5 there’s balance, proprioception, hunger, bladder fullness, etc. depending on how liberal you want to be), but more importantly it relies on assumptions of the outside world. For you, the observer, what does a sense mean? Consider all the preprocessing the retina does before it forwards the image to the rest of the brain. You would still call sight a “sense” yes? Then I suggest that, to the observer, a sense is just a nerve module feeding data that the brain views as “primitive”. So anything that “feels different” is a different sense. Pain, tickle, pressure, etc. are all different senses under this definition!

If we take this notion to it’s logical conclusion, we see also that emotions are senses too. Though it acts on a much larger scale, an emotion is just a preprocessing of your general state to give a heuristic on how to think. It seems weird at first to think this way, but we’ve known it all along. This is why we “feel” sad, or “feel” happy, the same way we “feel” the wind through our hair.

So now it seems clear “Yes, of course we should study our senses if we want to know anything about our relation to this world!”. But there’s a big problem which has prevented “meditative sciences” from becoming “real sciences”, and that’s reproducibility. The scientific method is in many ways the optimal tool for conducting “science” on the natural world. One of the most fundamental and useful assumptions of science are that the laws of nature are the same everywhere, so if we set up two comparable experiments in two comparable places, we should get comparable results. But when we try to apply this to meditation, it all comes crashing down. To the pure observer, there is no “everywhere”, there is only “here” and “now”. We cannot take for granted “elsewhere” or even our past; consider that memories too are a sense, replaying input through the same channels it came in the first time.

It may seem a wonder that with these limitations we could say anything useful at all! Is this a fundamental limitation? Well, yes and no. We’ve already accepted a far greater weakness, that no logic system can prove it’s own consistency. Essentially (with much abuse of rigor), we can never “prove” anything at all, at least by most people’s definition of “prove”. But incompleteness doesn’t stop us from pushing forward to find “truth”,  and neither should this. It is convenient to assume that “math works”, if we can just get math right, and so too it is convenient to assume that our senses betray some greater external reality, if we can just interpret them correctly.There’s a reason that most philosophers disregard solipsism, because it’s mostly useless! But considering it seriously prevents one common epistemic trap. If you can’t experientially distinguish between one possible reality and another, it is meaningless to consider which is “real”. But we generalize “experience” from the typical all or nothing definition, so we really mean It is not meaningful to distinguish between two models that give identical predictions of future experience. Essentially we’ve weakened “reality” to “convenient model”, and the practical results becomes obvious.

But this is all philosophical exploration, which has been reinvented many times over. The  real, practical reason that meditation has never been seriously considered is still reproducability. The mind is in constant flux. You are continuously transforming, never the same person at two points in time. Clearly this wreaks havoc on reproducability! How can you ever repeat an experiment if you already expect a result? ”All the theorems assume that how you think doesn’t affect reality apart from your actual actions”. But in meditation, that is exactly what you’re doing! Meditation is essentially conscious control of the placebo effect! Normally we account for placebo through replication and controls. But what does a meditation control look like? You must always be thinking something! There is no “null thought” by which to compare, or rather, the default is specific to each person. If we had a battalion of identical personalities, this may be possible. As crazy as it sounds, I expect this to be within the reach of science.

Another problem is that we cannot directly share our experiences in a reliable way. One person says “If you do A, you will feel X”, and another asks “Great! What what is X like”, and the original replies “I cannot tell you, you must experience it yourself”. This is actually not so much a problem, what we’re doing here is describing an experiment that will lead to observation X; this is the best we can do when language fails to encode all of our experience. The real difficulty is in determining “feeling equality”. So you’ve done A, but how do you know the X’ you feel is the same as the master’s X? If we have good reason to believe that consciousness is embedded in the physical world (we do), then we can eventually tie a neuronal activity profile to each feeling (or an equivalence class of such profiles, as the case more likely will be).

Meditation makes no assumptions of an external world, it is the pure observation of our existence. Because our senses are the most primitive thing we can observe, meditation requires no tools, no prior knowledge of the world, and no assumptions. It is the study of the “self”, at the purest level. Bridging between this knowledge of the “self” and our understanding of scientific reality requires technical advances that are not available yet, but this does not mean it should be relegated to philosophy alone. Science presses forwards, slowly consuming the domains of philosophy and religion into the sphere of applicable knowledge. We need first only recognize that it is applicable!

# Algebraic Data Part 1 – Golden Trees

This post is literate haskell (ignoring the latex images) so before we set off

> {-#LANGUAGE TypeOperators#-}
> import Control.Category
> import Prelude hiding ((.),id)

Haskell datatypes form an algebra, complete with sums $(a + b \equiv \text{Either a b})$, products $(a*b \equiv (a,b))$ and even exponentials $(b^a \equiv a \to b)$

So what can we do with this correspondence? Well lots of things, but today I’m going to focus on type isomorphisms.

Notice first that all (unquantified) data declarations can be converted into a standard form. For example:

data List a = Nil | Cons a (List a)

is converted to:

type GenericList a = Either () (a,GenericList a)

This is the basis of Haskell Generics (ex. in GHC.Generics). By converting data into a universal form we can manipulate different structures in a uniform way. Essentially what we are doing here is just “stripping off the tags” that make isomorphic algebraic types distinct.

Each generic representation gives rise to a type equation.For list: $\text{List}(x) \cong 1 + x\text{List}(x)$

We can do some pretty mindbending stuff with these equations due to a result from category theory. By expanding the equation we get the generating function

$[x] \cong 1 + x + x^2 + x^3 + \ldots$

we can think of a list as either the empty list, a sequence of one element, a sequence of two elements, a sequence of 3 elements etc. etc.

But also, by manipulating the recursive equation into closed form, we see that $[x] \cong \frac{1}{1-x}$

Even though this doesn’t have any sensible interpretation as a datatype, we can take a jaunt through the complex numbers so long as we return to a form without division or subtraction and so long as no side is purely constant.

We need this last constraint to prevent things like shoving a tree into the unit type as follows:

> data Tree a = O a | T (Tree a) (Tree a) deriving (Show,Eq)

$T(a) \cong a + T^2(a)\\ \Rightarrow T(a) \cong \frac{1\pm\sqrt{1-4a}}{2}$

By setting $a=1$ the unit type,  we get $T(1) \cong \frac{1\pm i \sqrt{3}}{2}$ which is a sixth root of unity. So since $T^6(1) = 1$ we would expect an unlabeled tree to be equivalent to the unit type. But of course this makes no sense! As it turns out, One tree IS equivalent to seven trees. There are an infinite number of trees, but the unit type has only a finite number of inhabitants (exactly 1!), which is why we make the stipulation that no final result be constant.

Notice that so far our data declarations only give us equations of the form $X = F(X)$
Is it possible to get other types of equations? Specifically can we construct a “golden” datatype that satisfies the equation $G^2 \cong G+1$ giving the closed form $G \cong \phi \equiv \frac{1+\sqrt{5}}{2}$, the golden ratio

We already have our tree equation $T(x) \cong \frac{1\pm\sqrt{1-4a}}{2}$ which resolves to $\phi$ when a=(-1). But what kind of type looks like -1? Well, looking back at our list equation $L(a) \cong \frac{1}{1-a}$ resolves to -1 when a=2. So what’s 2? Why, it’s just the Boolean type $1+1$! So composing all these together we find our “golden type” to be a tree of lists of booleans, or equivalently, a tree with leaves labeled by (possibly empty) bitstrings.

Now this is a nice result, but it may leave you scratching your head about exactly how the the identity $G^2 \cong G +1$ holds.

So lets construct an isomorphism explicitly.

Lets first definite some convenience types

> data a :+ b = L a | R b deriving (Show,Eq) -- Sum type
> data a :* b = a :* b deriving (Show,Eq) -- Product type
> infixl 6 :+
> infixl 7 :*
> type X = [Bool]
> type G = G = Tree X
> f # g = g . f -- this will come in handy later

Since we’re talking about isomorphisms, we might as well make it explicit

> data a :~ b = ISO {to :: a->b, from :: b -> a}
> instance Category (:-) where
>     id = ISO id id
>     ISO f g . ISO f' g' = ISO (f . f') (g' . g)
> infixr 0 :-

And include some simple unrapping isomorphisms for trees and lists

> tWrap :: Tree a :- Tree a :* Tree a :+ a
> tWrap = ISO f g where
>     f (O a) = R a
>     f (T t1 t2) = L $t1:*t2 > g (R a) = O a > g (L (t1 :* t2)) = T t1 t2 > lWrap :: [a] :- a:*[a] :+ () > lWrap = ISO f g where > f [] = R () > f (a:as) = L$ a:*as
>     g (R ()) = []
>     g (L (a:*as)) = a:as

The following derivation is based on the one presented in This Week’s Find

First notice that if we can decompose a type $Z \cong Z' + X$ where X=[Bool] satisfies the equation of lWrap, then $Z + x + 1 \cong Z' + 2X + 1\\ \cong Z' + X \\ \cong Z$

> lemma1 :: (z :~ z' :+ X) -> (z :+ X :+ () :~ z)
> lemma1 f = ISO ff gg where
>  ff zz = from f $case zz of > R () -> R [] > L (R xs) -> R (False:xs) > L (L z) -> case to f z of > R xs -> R (True:xs) > L z' -> L z' Given an isomorphism $f : Z \leftrightarrow Z' + X$, we get an isomorphism $f' : Z \leftrightarrow Z + X + 1$ Convince yourself that the above works and play with it a bit. It’s only going to get messier from here. Before we continue we should build some convenience functions to handle basic manipulations of generic terms. For everyday arithmetic we use the commutative, associative and distributive laws without giving it a second thought, but here we need to choose them explicitly. Note that our constructors are left associative and :+ binds less tightly than :* , so for example (a:+b:+c:+d:*e) is the same as (((a:+b):+c):+(d:*e)) > cP :: a :+ b :- b :+ a -- Commutativity of addition > cP = ISO f f where; f x = case x of; L a -> R a; R b -> L b > cT :: a :* b := b :* a -- Commutativity of multiplication > cT = ISO f f where f (a :* b) = b :* a > aP :: (a :+ b) :+ c :- a :+ (b :+ c) -- Associativity of addition > aP = ISO f g where > f x = case x of > L (L a) -> L a > L (R b) -> R$ L b
>     R c -> R $R c > g x = case x of > L a -> L$ L a
>     R (L b) -> L $R b > R (R c) -> R c > aT :: (a :* b) :* c :~ a :* (b :* c) -- Associativity of multiplication > aT = ISO (\((a:*b):*c) -> a:*(b:*c)) (\(a:*(b:*c)) -> (a:*b):*c) > unit :: a :- ():*a -- Multiplicative identity > dist :: a:*(b:+c) :- a:*b :+ (b:*c) -- Distributive law > dist = ISO f g where > f (a:*x) = case x of; L b -> L$ a:*b; R c -> R \$ a:*c
>   g (L (a:*b)) = a:*(L b)
>   g (R (a:*c)) = a:*(R c)
{- Isomorphism combinators. These are analogous to the arrow opperators of the same name -}
> (+++) :: (a :- b) -> (c :- d) -> (a:+c :- b:+d)
> f +++ g = ISO (to f pp to g) (from f pp from g) where
>   pp f' g' x = case x of; L a -> L (f' a); R b -> R (g' b)
> (***) :: (a :- b) -> (c :- d) -> (a:*c :- b:*d)
> f *** g = ISO (to f pp to g) (from f pp from g) where
>   pp f' g' (a:*b) = f' a :* g' b

Now we unwrap the tree into a list and a pair of trees, and unwrap the list into () or a bool and a list, giving $G \cong X + G \cong 2X + 1 + G^2$

> lemma2 :: G :~ B:*X :+ () :+ G:*G
> lemma2 = cP . (id +++ listWrap) . treeWrap

Now we apply this identity to $G^2 \cong (X+G^2)^2 \cong (2X + 1 + G^2)^2$ and expand just enough to get a free X on the rightmost side. SInce the expansion contains an X term, it is of the form $Z' + x$ for some $Z'$. But really, we don’t care what it is since it gets absorbed by lemma1 , we just need to separate an X. Nevertheless, the tangle of commutation and association gets a bit hairy.

> lemma3 :: B:*a :~ a:+a
> lemma3 = ISO f g where
>  f (b:*a) = case b of;Z -> L a; U -> R a
>  g x = case x of; L a -> Z:*a; R a -> U:*a
> lemma4 = -- Show that G^2 = Z' + X for some (ugly) Z'
>  (lemma2 *** lemma2) # d # (d+++id) # aP # (id +++ cP) # inv aP #
>  (id +++ id +++ (cP.aP.inv u . cT)) #
>  inv aP #
>  (id +++ lemma3) #
>  inv aP

Fire up a GHCI session and try to follow each step of lemma4 to get a feel for how to manipulate complex expressions. This may seem messy but imagine trying to write a correct function like this with only case statements as we did for lemma1! Now that the heavy lifting is out of the way the rest falls into our laps

> lemma5 :: G:*G :+ X :+ () :- G:*G
> lemma5 = lemma1 lemma4

And finally we get our isomorphism by unwrapping the left hand side and applying lemma5

> golden :: G :+ () :- G:*G
> golden = (treeWrap +++ id) # lemma5

So what kind of mapping do we have? I’m not sure that derivation made it any clearer, but at least we have an honest isomorphism now.  With a bit of playing around we notice the following (much simpler) correspondence.

L (O x)       <=> O (True:False:xs) :* O []
R ()          <=> O [True] :* O []
(L (T t1 t2)) <=> t1 :* t2

Of course, this isomorphism is not canonical, the specifics depend on exactly how you wire lemma4, but it is an isomorphism nevertheless! We can prove this by simply following the types and ensuring that all of our combinators are indeed isomorphisms and that composition of isomorphisms type is an isomorphism; an exercise that I will leave to the motivated reader.

# Language Proposal: Meme dereferencing operator

I lied, no programming today. Instead, metaphysics! But actually, natural language is very similar to computer language, except everyone’s afraid to write a standard for it.

Before we start, I’d like to clarify my meaning of meme, given the cultural baggage it has aquired (http://www.dispatch.com/content/graphics/2012/12/06/1a-grumpy-cat-art-gu8kjvrb-1good-morning-cat.jpg). By meme I refer to “formal cultural entities”, such as religions, companies, political parties, etc. But also to such phenomena as “the fashion of Victorian nobles (http://en.wikipedia.org/wiki/File:Victorian_Woman.jpeg).

Additionally, I use “thought” not necessarily to mean a thing which one thinks, but as a thing which one may think, a conceptual ideal. This definition is tricky. In some sense, thoughts are everything. For if you cannot think it, you cannot perceive it, and so it exists in no meaningful sense.

Now, let us proceed by analogy and trust for now that there is a point hidden here somewhere.

(1) You can write point-free style in Perl with a little (a lot) of finagling, but would you WANT to? Of course not! By not allowing functions (and higher order combinators) as first class, you discourage the use of certain styles. In the same way, EVERY language feature subtly affects the kinds of programs that are commonly expressed in the language.
Now, a program (source code) is merely a description of a procedure  In an ideal world, we’d be able to traverse the space of procedures and pluck the right one directly. But the space of procedures is too large to be first class in our universe, so we need programs to give us a handle into this space.

(2) Now consider a similar problem:
One of the great abstractions of “high level” languages is being able to pretend that we’re really dealing with values directly: the addresses are hidden. In reality the machines have to identify addresses to push data around to, a fact that becomes painfully apparent when working with (ex.) Assembly or C pointers. But actually, C pointers are an elegant approach to address specification. With pointers, we do not specify memory addresses directly, the space of address is too big to be practical. (Though, we could specify them directly if we chose, the space is not so big as to be impossible.) Instead, we obtain the address of the relevant data through the reference operator.

Enough computers, what does this have to do with natural language?

Recall problem (1). Natural language serves the same purpose as a program, where procedures are thoughts. We have no way to directly specify objects in this (mindbogglingly infinite) “thoughtspace” so we use words as a handle into the space. But here’s a problem: thoughtspace is big. Really big. Armed with only our limited language, some ideas will take infinite time to express (consider the completion of the rationals to the reals). Now, you may wonder if only infinite ideas require infinite time. That would certainly be a nice property and is a valid question. However, given the incredible vastness of thoughtspace, I suspect that there exists an infinite family of “holes”: Seemingly innocuous ideas which nevertheless cannot be expressed in finite time (imagine spiraling towards a central point, refining your statement with an infinite series of words.) Even if this is not the case, weaken “infinite time” to “prohibitively long time”, and I think there is little question that this is a true problem.
Any given hole can be plugged by anchoring it to a reference point in our universe, either a physical pattern (“that’s a tree”), or via reference (“the way that a clock moves is clockwise”). Thus, the holes are dependent on the language; the language shapes the ideas we can express.

Necessarily, the things which exist, the “reified thoughts”, are only a small subset of possible thoughts. This shapes our own language, as things which readily exist are much easier to encode in speech than those which must be conceived by analogy. As beings of abstraction, we can perceive certain high level abstractions directly, as “first class”. Ex. A forest is a collection of trees, but a tree is a tree. We naturally perceive it as a unit, though in reality a tree is a complex collection of processes. We can easily do this for things which exist at a “level of abstraction” ≤ our own (The case of equality is particularly interesting, but I will not get into it at the moment).

Finally, we may consider memes. Memes are in some sense, the simplest step up from our current level of abstraction. We cannot perceive them directly as a single unit because we are a part of them (or they a part of us, depending on your perspective), in the same way that a (very intelligent) cell could not easily conceive of the body to which it belongs. Because of this, we find it hard to describe memes. A common way of referring to complicated memes without regurgitating their entire description is by implicitly tying them to more easily expressible notions, kind of like a generalized synecdoche. That is, by listing other easily named memes which are “commonly” associated with it under certain circumstances.

This method causes a host of problems, which unecessarily limit the expressible statements. Of primary concern is ambiguity. It is often not clear when one is refering to the literal idea or the meme associated with the idea. This problem is often resolved by cultural context. That is, people of a certain similar mindset will understand the difference in their own communication, but this is not stable across mindsets, it is almost impossible to communicate in this way across large cultural gaps.
There’s a related problem. By nature of our language, an unqualified statement (usually) contains an implicit ∀. This directly conflicts with implicit meme dereferencing, and the interpretation of which is intended is subject to ambiguous context. Mixing up ∀ and “associated meme” is a dangerous thing to do and can lead to sweeping generalizations. Remember, we are referring to people here, and sweeping generalizations lead to various forms of prejudice.
This is the heart of the problem: the meme is referred to by association with a concrete idea, but exact relation between the concrete idea and the meme is unspecified and ambiguous. It can be avoided by making the link explicit, but the amount of qualification required to avoid this ambiguity is prohibitively expensive, so these types of statements tend to simply be avoided, limiting our expressive power greatly.

While truly fixing this problem essentially requires a new, carefully designed language, we can make an immediate improvement by at least specifying when we are making a connection. To this end, I propose a new primitive connective: ☀ to mean roughly “The meme primarily inhabiting  and to be used as a sort of “dereference” operator. This will at least allow an unambiguous instantiation of “association”. While it cannot represent more complicated associations than “primarily inhabiting , it covers most common use cases. There are issues with ambiguity when multiple memes may inhabit the same collection of people, which becomes more severe when the memes are mutually exclusive. Correct and clever usage of ☀ can remedy this. It is helpful to imagine trying to indicate an animal to someone where you are only allowed to speak of its environment. Ex: ☀Temperate city skies. Can you guess Pigeon?

I’ve played a little trick here. It is not immediately clear that “people inhabited  is a consistent description of memes. Why should memes associate like that? Genes associate because they can only be combined in discrete pairings with small mutation (mating), so you’re going to get something close to the parents. Memes combine in much more complicated ways, and it’s not clear that they would preserve these associations  In fact, there’s a deeper reason for why these associations hold. In biological evolution, organisms reflect their environment. In some sense, a successful organism is a “statement about how to survive in that environment”. What’s interesting about memes is that they act as both the environment and the replicator. More on this later.

# Minimalist Programming

I’d like to take some time to speak on Minimalism. I don’t mean anything like http://www.wikipaintings.org/en/kazimir-malevich/black-square-1915.

Nor, at the moment, do I mean this:

#include <stdio.h>
void main() {
printf("It's so simple!");
}


But perhaps something more like this:

You may at first think of C as the de-facto ‘minimalist’ language. There is certainly something quite charming about the simplicity of undecorated C. It has regular syntax, simple semantics, and a direct cost model. Certainly, the very definition of minimalist, with all its benefits! So what’s the problem? There are no doubt die-hard C fans wondering the same thing.

I will skip the mystery. The problem with C is reusability, for a variety of reasons. Steadfast C programmers routinely roll their own hash maps, linked lists and trees, yikes. This is the price we’ve come to accept for C’s minimalism.

C++ (and later D) attempted to solve this problem by bolting on an object and accidentally conceived template system. Actually, D can be quite nice, but you can hardly call either of them minimal.

In Guy Steele’s classic talk, he addresses (among many other things) the problem of minimalism from a language designer’s perspective. At the time, the solution of “minimal with user extensibility” chosen for The Java Programming Language© proved greatly effective for its success. However, even Java enthusiasts would likely agree that modern Java is brimming with user-built complexity.

It is often said, “never write the same code twice”, but I should say “never solve the same problem twice”. The subtle difference being that you may unknowingly write different code to solve the same problem! What use are 20 physics libraries when none of them do what I want? Java’s extensibility is not always the right kind of extensibility.

To take advantage of problem similarities, we need a more generic view of programming. One way this can be achieved is through higher order functions, and a whole host of other generic goodies provided by the so called “functional languages”. In this approach, the “scaffolding” is disentangled from the solution, allowing the same solution to be fit into different shaped problems. I will return to this notion of composability in the future, as there is quite a bit to say.

Of course now we’ve just gone and thrown minimalism out the window again.

Should we give up this dream of practical minimalism? I think not! Is mininamlism the right fit for all problems? Maybe not; it may be that verbosity is a price to pay for flexibility, but we can certainly do much better than at present. To achieve minimalism we must fearlessly distinguish the necessary primitives and forsake the unnecessary components without remorse. In the next few posts I will detail some of what I think may be key to its substantiation.

# The Gate is Open

“Though we may never see precisely how the protean dancing stuff of everything endlessly becomes itself, we have no choice, being human and full of desire, but to go on perpetually seeking clarity of vision. The ultimate form within forms, the final shape of change, may elude us, The pursuit of the idea of form – even the form of force, of endlessly interacting process – is man’s inevitable, crucial need”
-John Unterecker