## Using recursion in NLP

## NLP is said to be recursive. What does that mean?

From a conversation on NLP connections:

innovating new high-level models in NLP? … is expected to be out of reach for most.

Richard also encourages people to go out and invent their own stuff. I don’t really think NLP is a field, the way, say, optics is a field. NLP is a particular approach to psychology, but to become self-sustaining, it needs enough organizational, research, and development infrastructure to outlast its creators. That infrastructure just isn’t there.

Bizarrely, EMDR might end up lasting longer, more widely used and accepted, than NLP, even though Grinder claims EMDR’s Francine Shapiro basically took one tiny NLP concept, relabeled it, and went out and sold it (successfully) to the established psychological machine.

So as an open question, what specific parts of computer science … to build recursive and generative models

Well, for one, go study recursive functions in computer science. If you work your way through the book Structure and Interpretation of Computer Programs by Sussman and Abelson, you’ll know recursion like the back of your hand. (You actually have to do the problem sets, though. Understanding it is very different from being able to do it. The book is now freely available on the web.)

Recursion is the programming equivalent of mathematical induction, by the way. It’s hard to understand without learning it deliberately. And it’s hard to use without a learning curve. Many people throw the word around with no understanding or concept of what it means. I used to TA a course in computer science taught using the programming language LISP. LISP is notable, among other reasons, because it’s designed to find recursive solutions to problems. Some people “got it,” but many people didn’t, even very, very smart people.

Recursion is defining a function in terms of itself. Consider the Fibonacci series: 1, 1, 2, 3, 5, 8, … Each term is made by summing the previous two terms. If you were to try to write a normal math function that would generate the sequence, it would be very long and complicated.

But you can express it recursively very simple:

The Nth fibonacci number = The N-1th fibonacci number + the n-2th fibonacci number

or in math terms: Fib(N) = Fib(N-1) + Fib(N-2)

If you think about this, it works, except somewhere you need to specify two consecutive Fib numbers so all future ones can be computed. The final recursive definition looks like this:

Fib(N) = Fib(N-1) + Fib(N-2)

Fib(1) = 1

Fib(2) = 1

So now we know:

Fib(3) = Fib(2) + Fib (1) = 1 + 1 = 2

Fib(4) = Fib(3) + Fib(2) = 2 + 1 = 3

etc.

In some sense, the later Fib() functions are built up of earlier Fib() functions.

In LISP, recursion is sometimes used to build self-modifying programs. Since the program is essentially defined in terms of its earlier self, it’s recursive.

**How does recursion apply in NLP?**

One place recursion applies in NLP is in strategies. A non-recursive strategy is attached to a specific time and place. For example, “Go into a bar. See attractive person. Feel confident. Walk up and offer to buy a drink.” There’s no recursion in that.

A recursive strategy in some way refers to itself or builds a stronger version of itself. For example, “Go into a bar. Remember what you did last time and generate a dozen new possiblities for how to behave to meet someone. Go do that. Afterwards, future pace that behavior if applicable to a dozen new contexts.” That’s recursive because the behavior in any one time is built on past runnings of the strategy. The strategy is also self-modifying and self-improving.

In Richard’s trainer’s training, he teaches some specific skills. A big piece of the strategy he installs, however, is essentially, “When in a troublesome situation you’ve never been in before, enter a resourceful state and invent a new strategy on the fly.” That’s recursive because it’s a strategy-modifying strategy.

Make sense?