Latest / CyberSecurity Summary / Interpreting LISP: Programming and Data Structures
Transcript
- 0:00Speaker 1: You know, if you look at almost any programming language today,
- 0:03Speaker 1: there's this well there's a very strict, undeniable wall between
- 0:07Speaker 1: the instructions you write and the data those instructions process.
- 0:12Speaker 2: Right, Yeah, it's a very clear divide.
- 0:13Speaker 1: Yeah. Think of it like a factory. Right. The code
- 0:16Speaker 1: is like the heavy machinery that's just bolted to the floor,
- 0:20Speaker 1: and the data is just the raw material moving along
- 0:23Speaker 1: the conveyor belt exactly.
- 0:24Speaker 2: That is the standard paradigm most of us are used to.
- 0:27Speaker 2: You know, the machine stamps the metal and the machine
- 0:30Speaker 2: in the metal. They never switch places, right.
- 0:33Speaker 1: But imagine if that factory operated completely differently, Like what
- 0:36Speaker 1: if the machines on the conveyor belt were constructed out
- 0:39Speaker 1: of the exact same material as the widgets they were building.
- 0:41Speaker 2: Oh man, that would be chaotic.
- 0:44Speaker 1: It really would, to the point where at any given moment,
- 0:46Speaker 1: the factory could just decide to melt down a machine
- 0:49Speaker 1: and treat it like raw material, or take a piece
- 0:51Speaker 1: of raw material and suddenly turn it on like it's
- 0:53Speaker 1: a machine.
- 0:54Speaker 2: It completely shatters how you approach problem solving. I mean,
- 0:58Speaker 2: when the boundary between the action and the object just disappears,
- 1:01Speaker 2: the system gains this kind of terrifying flexibility, and.
- 1:05Speaker 1: That flexibility is exactly what we're getting into today. Welcome
- 1:09Speaker 1: to the deep dive. Today we are exploring this classic
- 1:12Speaker 1: piece of computer science literature, Interpreting Lisp Programming and Data
- 1:18Speaker 1: Structures by Gary D. Knot.
- 1:20Speaker 2: It's a fantastic text, really foundational.
- 1:22Speaker 1: Yeah, and before we get started, I want to clarify
- 1:24Speaker 1: our mission here is not to force you to sit
- 1:27Speaker 1: through a coding boot camp.
- 1:29Speaker 2: No, definitely not.
- 1:30Speaker 1: We're unpacking LISP, which by the way, stands for list processing,
- 1:34Speaker 1: really just to understand how it fundamentally changed our relationship
- 1:37Speaker 1: with computers.
- 1:38Speaker 2: Right, We're going to look at how it's incredibly elegant
- 1:40Speaker 2: design sort of paved the way for early artificial intelligence.
- 1:43Speaker 1: Yeah, like teaching machines to do calculus and play chess.
- 1:46Speaker 2: Exactly, because LASP offers this brilliant window into the literal
- 1:51Speaker 2: mechanics of how computers evaluate truth and information.
- 1:54Speaker 1: So how does it actually work at a basic level, Well,
- 1:57Speaker 1: it's what we classify as an applicative language.
- 2:00Speaker 2: At its heart. You were just writing functions and applying
- 2:03Speaker 2: them to arguments, and you do this in prefix form,
- 2:05Speaker 2: meaning the action always comes first.
- 2:07Speaker 1: Wait prefix form, so you don't write it out like
- 2:10Speaker 1: normal math.
- 2:11Speaker 2: No, not at all. For instance, you wouldn't write one
- 2:14Speaker 2: point five plus two. Yeah, you would write an expression
- 2:16Speaker 2: like open parentheses plus one point five space too close parenthesis, Oh,
- 2:21Speaker 2: I see, and then the system evaluates that to three
- 2:23Speaker 2: point five.
- 2:24Speaker 1: So the verb always precedes the nouns. Okay, Well, to
- 2:28Speaker 1: understand how a language can blur that line between code
- 2:31Speaker 1: and data like we were talking about, we first need
- 2:34Speaker 1: to look at what that data actually is.
- 2:35Speaker 2: Right, you have to start at the bottom, and.
- 2:37Speaker 1: According to the text, LISP categorizes the entire universe of
- 2:41Speaker 1: information into just two fundamental concepts, atoms and s expressions.
- 2:46Speaker 1: So if I'm trying to build something in this language,
- 2:48Speaker 1: what exactly is an atom?
- 2:50Speaker 2: Think of an atom as well, the absolute bedrock of
- 2:53Speaker 2: the language. It's the smallest indivisible unit. And Lisp keeps
- 2:56Speaker 2: track of these in two main registries.
- 2:58Speaker 1: Okay, two registerries.
- 2:59Speaker 2: Yeah. First you have the number table, which simply stores
- 3:02Speaker 2: the constant numbers your program is using, like the number
- 3:04Speaker 2: three or fifty two makes sense. Then you have the
- 3:07Speaker 2: atom table. This stores ordinary atoms, which can be built
- 3:11Speaker 2: in function names like plus or logical concepts like nil,
- 3:15Speaker 2: which basically represents false, or an empty list.
- 3:18Speaker 1: Okay, so wait, what exactly is inside one of those
- 3:22Speaker 1: atom table entries. Is it just the name?
- 3:24Speaker 2: Oh no, it's a bit more detailed than that. An
- 3:26Speaker 2: atom table entry has a name, a type of value,
- 3:29Speaker 2: something called a plist, which is a property list, and
- 3:32Speaker 2: a buying list.
- 3:33Speaker 1: Okay, so an atom is essentially a labeled box that
- 3:35Speaker 1: holds a single unbreakable concept, but it's got these specific
- 3:39Speaker 1: compartments for its properties. It's either a specific number, a
- 3:42Speaker 1: specific function, or a core logical state exactly.
- 3:46Speaker 2: That covers the atomic level. Yes, but I mean single
- 3:49Speaker 2: atoms aren't very useful entirely on their own, right.
- 3:51Speaker 1: Right, You can't build much with just one brick exactly.
- 3:54Speaker 2: To build complexity, you can bind them into S expressions,
- 3:57Speaker 2: which stands for symbolic expressions. Combined atoms, you create something
- 4:02Speaker 2: called a dotted pair.
- 4:03Speaker 1: A dotted pair, and that's written with parentheses, right, like
- 4:06Speaker 1: a dot B.
- 4:07Speaker 2: You got it. Structurally, a non atomic S expression forms
- 4:11Speaker 2: a binary tree. So imagine a tree branching off into
- 4:16Speaker 2: two over and over until you reach the very tips
- 4:20Speaker 2: of the branches.
- 4:20Speaker 1: Okay, I'm picturing it.
- 4:22Speaker 2: Those terminal nodes at the ends of the branches, those
- 4:25Speaker 2: are your atoms.
- 4:26Speaker 1: And because it's an applicative language, we need a way
- 4:29Speaker 1: to actually process these trees, right, like making the tree
- 4:32Speaker 1: actually do something.
- 4:33Speaker 2: Yeah, and that duty falls to something called the V operator.
- 4:37Speaker 2: It is essentially the meta evaluator of the entire language.
- 4:40Speaker 1: The V operator.
- 4:40Speaker 2: Okay, when you feed lisp and s expression, the V
- 4:44Speaker 2: operator is the engine that actually computes its value. So
- 4:47Speaker 2: if you hand it an ordinary atom, it just looks
- 4:49Speaker 2: up the value associated with that atom and the table, right.
- 4:52Speaker 2: But if you handed a function call, it goes to
- 4:55Speaker 2: work evaluating the arguments and running the function.
- 4:57Speaker 1: So if I'm picturing these dotted these like structures linking
- 5:01Speaker 1: things together, I'm sort of imagining a two box train car.
- 5:05Speaker 2: Oh, that's a really good way to visualize it.
- 5:07Speaker 1: Yeah, and to interact with them. The source mentions three
- 5:10Speaker 1: functions with some very honestly historically quirky names, car, CDR,
- 5:15Speaker 1: and cons ah the classics. So, using my train analogy,
- 5:21Speaker 1: is it fair to say CAR opens up the front
- 5:23Speaker 1: box of the train car to see what atom is inside,
- 5:25Speaker 1: and CDR opens the back box.
- 5:27Speaker 2: That analogy holds up beautifully actually, CAR extracts the first
- 5:30Speaker 2: element of the dotted pair and CDR extracts the second,
- 5:33Speaker 2: and then CONNS, which is short for construction, takes two
- 5:37Speaker 2: separate expressions and essentially hooks them together to build a
- 5:39Speaker 2: brand new train car.
- 5:40Speaker 1: I just love that those names CARR and CDR are
- 5:43Speaker 1: literally acronyms from the nineteen fifty eight IBM seven oh
- 5:46Speaker 1: four mainframe that LISP was first built on.
- 5:49Speaker 2: Yeah, it's such a fascinating quirk of history.
- 5:51Speaker 1: Right, Like the CAR meant contents of the address register,
- 5:54Speaker 1: and CDR was contents of the decremont register, and literally
- 5:57Speaker 1: just hard coded the physical hardware architecture of a nineteen
- 6:00Speaker 1: fifties machine into the language vocabulary forever.
- 6:03Speaker 2: It really is a great piece of history, and those
- 6:04Speaker 2: three tools car, CDR, and cones are literally the only
- 6:08Speaker 2: tools you need to navigate and build the massive binary
- 6:10Speaker 2: trees that make up all LSP data structures.
- 6:13Speaker 1: Okay, pulling back for a second though, hooking endless train
- 6:17Speaker 1: cars together inside a computer memory bank sounds great in theory,
- 6:22Speaker 1: but I mean, we are talking about computers from the
- 6:24Speaker 1: late fifties and sixties.
- 6:25Speaker 2: Here, right, very limited resources.
- 6:27Speaker 1: Exactly, how on earth does the machine keep track of
- 6:31Speaker 1: thousands of these nested lists without grinding to a halt
- 6:35Speaker 1: or just getting totally lost in its own memory.
- 6:38Speaker 2: Well, this is where we get into the genius of
- 6:39Speaker 2: typed pointers. When Lisp is running your program, it doesn't
- 6:44Speaker 2: actually pass the bulky data structures around internally. That would
- 6:48Speaker 2: be way, way too slow.
- 6:49Speaker 1: So what does it do?
- 6:50Speaker 2: Instead? It passes around integer into cs pointers that just
- 6:53Speaker 2: tell the system the exact address of where to look
- 6:56Speaker 2: in the memory bank.
- 6:57Speaker 1: But wait, if I hand you a pointer, you still
- 6:59Speaker 1: need to know what what kind of object is waiting
- 7:01Speaker 1: for you at that address, right, because if I just
- 7:03Speaker 1: blindly follow on address, I don't know if I'm about
- 7:05Speaker 1: to find a single number, a built in function, or
- 7:07Speaker 1: the start of a massive nested list.
- 7:09Speaker 2: Exactly. To solve this, Lisp packs both the categorization and
- 7:13Speaker 2: the location into a single thirty two big computer word.
- 7:16Speaker 2: The leftmost four bits are dedicated as the type code
- 7:20Speaker 2: that essentially tells the system what kind of object it is.
- 7:23Speaker 2: The remaining twenty eight bits are the actual index or pointer,
- 7:27Speaker 2: telling the system where the object lives.
- 7:30Speaker 1: So four bits say what and twenty eight bits say where.
- 7:33Speaker 1: That seems straightforward enough.
- 7:36Speaker 2: It gets much more clever than that. Actually, you have
- 7:38Speaker 2: to remember how binary integers work. At the hardware level.
- 7:42Speaker 2: The very first bit, the leftmost bit of a thirty
- 7:45Speaker 2: two bit word, determines the mathematical sign of the interrant.
- 7:47Speaker 1: Oh right, So a zero means it's a positive number,
- 7:50Speaker 1: and a one means it's a negative number.
- 7:52Speaker 2: Right, So keeping that in mind, the creators assigned the
- 7:55Speaker 2: type code zero zero zero zero to dotted pairs our
- 7:58Speaker 2: train cars. Because that code starts with a zero, any
- 8:02Speaker 2: thirty two bit word pointing to a list structure is
- 8:04Speaker 2: mathematically a positive integer.
- 8:06Speaker 1: Okay, I'm tracking with you so far.
- 8:08Speaker 2: But ordinary atoms, numbers, and functions they were assigned type
- 8:11Speaker 2: code starting with a one, like one zero zero zero
- 8:14Speaker 2: for an atom, or one zero zero one for a number,
- 8:17Speaker 2: or one zero one zero for a built in function.
- 8:19Speaker 1: And because they start with a one, because they start.
- 8:21Speaker 2: With a one, any word pointing to an atom is
- 8:24Speaker 2: mathematically a negative integer.
- 8:26Speaker 1: Wait seriously, so they literally hacked the positive and negative
- 8:30Speaker 1: sign of binary numbers just so the computer could sort
- 8:33Speaker 1: lists from atoms.
- 8:35Speaker 2: Yes, it's one of the most elegant hacks in computing history.
- 8:39Speaker 2: Lisp can instantly know if a pointer leads to a
- 8:42Speaker 2: list node or to a fundamental atom. Just by checking
- 8:46Speaker 2: if the thirty two bit integer is positive or negative.
- 8:49Speaker 2: It completely bypasses any complex lookup tables.
- 8:53Speaker 1: That is wild. It's like having a bouncer at a
- 8:56Speaker 1: club who doesn't even need to read your ID. He
- 8:58Speaker 1: just looks at whether your card is red or blue
- 9:00Speaker 1: from ten feet away and instantly points to you to
- 9:02Speaker 1: either the dance floor or the exit.
- 9:04Speaker 2: That's a perfect way to put it.
- 9:05Speaker 1: But I mean, why go to all that trouble? Was
- 9:07Speaker 1: that microsecond of time saving really that crucial back then?
- 9:10Speaker 2: Oh? Absolutely crucial. Think about that con and S function
- 9:12Speaker 2: we talked about, the one that builds new train cars.
- 9:15Speaker 2: LASP consumes memory relentlessly because it is constantly creating new
- 9:20Speaker 2: list nodes on the fly. In the nineteen sixties, memory
- 9:23Speaker 2: was incredibly scarce, measured in kilobytes not gigabytes. The system
- 9:27Speaker 2: needed blazing fast ways to categorize data so it could
- 9:30Speaker 2: quickly trace what memory was being used and what could
- 9:33Speaker 2: be recycled. Checking the mathematical sign of a single integer
- 9:36Speaker 2: is an operation the processor can do almost instantaneously.
- 9:39Speaker 1: Wow, that makes total sense. So okay, we've got our data,
- 9:43Speaker 1: and it's elegantly packed into memory using these positive and
- 9:47Speaker 1: negative type pointers. If we want to start manipulating this data.
- 9:50Speaker 1: The source outlines this massive philosophical divide in how Lisp
- 9:54Speaker 1: executes commands. There are ordinary functions and then there are
- 9:58Speaker 1: special forms.
- 9:59Speaker 2: What is the difference there, Well, the difference really comes
- 10:02Speaker 2: down to the rules of evaluation. An ordinary function like
- 10:06Speaker 2: plus operates under a very strict rule. It demands that
- 10:10Speaker 2: all of its arguments be fully evaluated before the function
- 10:13Speaker 2: itself does any work. Okay, special forms break that rule.
- 10:16Speaker 2: They can selectively evaluate their arguments or even choose to
- 10:19Speaker 2: receive them completely unevaluated.
- 10:21Speaker 1: Let me see them tracking this. If I'm thinking about cooking,
- 10:24Speaker 1: is an ordinary function kind of like a chef who
- 10:28Speaker 1: refuses to turn on the stove until every single ingredient
- 10:31Speaker 1: is fully peeled, chopped, and measured into little bowls. Like
- 10:34Speaker 1: everything has to be resolved first.
- 10:36Speaker 2: That's a great way to put it. The function needs
- 10:38Speaker 2: the final values, not the formulas for those values.
- 10:42Speaker 1: So then a special form would be a chef who says,
- 10:44Speaker 1: hang on, don't chop that onion yet, bring it to
- 10:47Speaker 1: me whole. Let me look at the raw state of
- 10:49Speaker 1: the kitchen, and I'll decide if that onion even needs
- 10:52Speaker 1: chopping based on what we're actually cooking precisely.
- 10:55Speaker 2: And a primary example of this is the special form setq,
- 10:58Speaker 2: which you use to assign a value to a variable.
- 11:01Speaker 1: Okay, how does that work?
- 11:02Speaker 2: Say you want the atom A to equal three. You
- 11:04Speaker 2: type open parentheses, setqa three, close parentheses. If setq were
- 11:10Speaker 2: an ordinary function, you would try to evaluate A before
- 11:13Speaker 2: doing the assignment.
- 11:14Speaker 1: But A doesn't mean anything yet, right.
- 11:16Speaker 2: If A doesn't have a value yet, the program would crash.
- 11:19Speaker 2: But because it's a special form, it receives the atom
- 11:21Speaker 2: A in its raw unevaluated state, evaluates the three and
- 11:26Speaker 2: successfully binds them together.
- 11:28Speaker 1: Ah okay. That makes special forms sound less like strict
- 11:31Speaker 1: instructions and more like I don't know intelligent managers.
- 11:35Speaker 2: They really are. And the most important manager of all
- 11:37Speaker 2: is condy short for conditional. This is lisp's branching operator.
- 11:42Speaker 2: It essentially takes the place of standard if then statements.
- 11:46Speaker 1: Okay, conditional, got it.
- 11:47Speaker 2: Condy uses what we call lazy evaluation. You handed a
- 11:50Speaker 2: list of conditions and it evaluates them from left to
- 11:53Speaker 2: right the millisecond it finds a true condition it executes
- 11:57Speaker 2: that path and completely ignores the rest.
- 11:59Speaker 1: Of the arguments, hence the word lazy. It stops working
- 12:02Speaker 1: the moment its job is done exactly.
- 12:04Speaker 2: And the history behind con highlights exactly why lazy evaluation
- 12:07Speaker 2: is so necessary. John McCarthy the inventor of LISP. He
- 12:11Speaker 2: was trying to write a chess program in Fortran around
- 12:14Speaker 2: nineteen fifty seven.
- 12:15Speaker 1: Oh wow, chess in nineteen fifty seven.
- 12:17Speaker 2: Yeah, and the for tran f statement back then was
- 12:19Speaker 2: an ordinary function. It required all arguments, all possible paths
- 12:23Speaker 2: to be evaluated before it made a decision.
- 12:25Speaker 1: Wait, if you're programming chess and you force the computer
- 12:28Speaker 1: to fully calculate every possible sequence of moves for the
- 12:31Speaker 1: rest of the game just to evaluate a single if
- 12:33Speaker 1: then statement.
- 12:34Speaker 2: The system would crash. Yeah, I mean, the exponential explosion
- 12:38Speaker 2: of possible chess moves is astronomical. You absolutely cannot evaluate
- 12:42Speaker 2: paths that you aren't actually going to take. McCarthy needed
- 12:46Speaker 2: a way to evaluate only the single true path and
- 12:49Speaker 2: abandon the rest, so out of sheer frustration with Fortran,
- 12:53Speaker 2: he invented the true conditional expression, which became con I.
- 12:57Speaker 1: Love that I love how many world changing paradise in
- 13:00Speaker 1: computer science just come from a programmer being annoyed that
- 13:02Speaker 1: they can't build a game fast enough.
- 13:04Speaker 2: It happens more often than you'd think.
- 13:06Speaker 1: So if con handles branching logic, what handles creating new
- 13:10Speaker 1: tools entirely? The source spends a lot of time on
- 13:12Speaker 1: something called lambdda ah.
- 13:14Speaker 2: Yes. Lambda is a special form borrowed straight from Alonzo
- 13:18Speaker 2: Church's mathematical lamb to calculus. Okay, In practical terms, it
- 13:22Speaker 2: allows you to create your own user defined functions on
- 13:24Speaker 2: the fly. When you write a lambda expression, you are
- 13:28Speaker 2: essentially conjoining a list of formal arguments with a body
- 13:32Speaker 2: of logic and packing them into one of our dotted
- 13:34Speaker 2: pair train cars.
- 13:35Speaker 1: So it's an anonymous piece of logic. You're saying, here
- 13:37Speaker 1: are the inputs, here's what you do with them, and
- 13:39Speaker 1: it just sits there as a raw piece of data
- 13:41Speaker 1: until you assign it a name or actually run it.
- 13:44Speaker 2: It brings us right back to your factory analogy at
- 13:46Speaker 2: the start. The lambbyda expression is literally data, the list
- 13:50Speaker 2: structure that access code.
- 13:52Speaker 1: That this brings up a logistical nightmare, doesn't it. If
- 13:55Speaker 1: you are creating all these custom lambda functions. You in
- 13:59Speaker 1: ev PVI have to pass variables around. How does LSP
- 14:03Speaker 1: Nott get completely confused about who owns what variable?
- 14:06Speaker 2: What do you mean?
- 14:07Speaker 1: Well, because if I have a variable name X in
- 14:09Speaker 1: three different functions, how does the computer know which X
- 14:13Speaker 1: I'm talking about at any given millisecond?
- 14:15Speaker 2: Oh, you've just hit on one of the most hotly
- 14:16Speaker 2: debated topics in early computer science, dynamic versus lexical scoping.
- 14:21Speaker 1: Okay, scoping, right, how.
- 14:22Speaker 2: Do we bind the value to a variable? Original lisp
- 14:26Speaker 2: used dynamic scoping, which was managed by something called an
- 14:29Speaker 2: association list. When a function is called, the actual values
- 14:33Speaker 2: given to it are pushed onto this master list. Then,
- 14:36Speaker 2: whenever any variable needs to be evaluated, LISP searches this
- 14:41Speaker 2: association list from the front to the back, looking for
- 14:43Speaker 2: the most recent binding.
- 14:45Speaker 1: Wait, hang on, let me push back on this. You're
- 14:47Speaker 1: saying it just looks for whatever was most recently used
- 14:49Speaker 1: in time, not what's written in the code.
- 14:51Speaker 2: That's right.
- 14:52Speaker 1: But if I write a custom function and I use
- 14:54Speaker 1: a variable X, I want X to mean what I
- 14:57Speaker 1: defined it as in my specific block text, like in
- 15:01Speaker 1: ALGOHOL or C. I don't want to hijacked just because
- 15:05Speaker 1: some random program three levels deep happened to use the
- 15:08Speaker 1: name X a microsecond before my function ran.
- 15:10Speaker 2: Your concern is completely valid. It's so valid, in fact,
- 15:14Speaker 2: that it has a very specific name, the foon arg
- 15:17Speaker 2: or functional argument fonarg problem. Okay, because Lisp uses this
- 15:21Speaker 2: latest possible call time binding, a free variable inside your
- 15:25Speaker 2: function might accidentally grab a value from a completely unrelated
- 15:29Speaker 2: function that just happened to execute right before it and
- 15:32Speaker 2: use the same variable name.
- 15:34Speaker 1: That sounds an absolute disaster for debugging. I mean, imagine
- 15:37Speaker 1: you're trying to trace a bug and your variable is
- 15:39Speaker 1: just shape shifting based on the temporal execution path of
- 15:41Speaker 1: the whole system.
- 15:42Speaker 2: It can definitely get messy.
- 15:44Speaker 1: If dynamic scoping causes this fune arg chaos. Why did
- 15:48Speaker 1: they build it that way? Was it just a bug
- 15:50Speaker 1: they called a feature or what?
- 15:52Speaker 2: No, it wasn't a mistake. It was a deliberate trade
- 15:54Speaker 2: off for extreme flexibility. Dynamic scoping enables a technique called
- 15:58Speaker 2: skip binding. Skip binding. Yeah, imagine a deeply nested function
- 16:03Speaker 2: that needs a variable established by a high level master function.
- 16:07Speaker 2: With lexical scoping, you'd have to explicitly pass that variable
- 16:11Speaker 2: through every single intermediate function along the way.
- 16:14Speaker 1: Oh like a relay race where you have to hand
- 16:16Speaker 1: the baton to every single runner, even if runner number
- 16:19Speaker 1: two and three don't actually need it at all.
- 16:20Speaker 2: Exactly, Dynamic scoping lets you throw the baton straight from
- 16:24Speaker 2: the first runner to the fourth. The nested function just
- 16:27Speaker 2: accesses the variable, knowing it will be sitting there on
- 16:30Speaker 2: the master association list. It creates highly adaptable code.
- 16:34Speaker 1: Okay, I see the appeal there.
- 16:35Speaker 2: However, you are right about the drawbacks. Searching a giant
- 16:38Speaker 2: master list for variables is terribly slow. So modern Lisp
- 16:42Speaker 2: implementations use a clever compromise mentioned in the text called
- 16:46Speaker 2: shallow binding.
- 16:47Speaker 1: And how does shallow binding fix the speed issue?
- 16:50Speaker 2: Well, instead of one giant master list, shallow binding gives
- 16:54Speaker 2: every individual ordinary atom its own private pushdown stack.
- 16:58Speaker 1: Oh so they each get their own list right.
- 17:00Speaker 2: When an atom is assigned a new temporary value, its
- 17:03Speaker 2: current value is pushed down into the stack, safely preserved,
- 17:06Speaker 2: and the new value sits right on top. When the
- 17:08Speaker 2: function finishes, the stack simply pops the top value off
- 17:12Speaker 2: and the old value is instantly restored.
- 17:15Speaker 1: Oh wow.
- 17:15Speaker 2: It keeps the flexibility of dynamic scoping, but makes finding
- 17:19Speaker 2: the current value instantaneous.
- 17:21Speaker 1: That is incredibly smart. Okay, so we've covered a huge
- 17:25Speaker 1: amount of ground here. We have data trees, type pointers, hacking,
- 17:28Speaker 1: binary signs, lazy evaluation, private memory stacks for variables. But
- 17:33Speaker 1: what does this actually look like when you unleash it
- 17:35Speaker 1: on a real problem?
- 17:36Speaker 2: Right? The application?
- 17:37Speaker 1: Yeah, the source highlights two really fascinating areas, symbolic math
- 17:42Speaker 1: and gameplaying. Let's look at math first. How on earth
- 17:45Speaker 1: does LASP do calculus?
- 17:47Speaker 2: Well? LASP is staggeringly good at symbolic differentiation because the
- 17:51Speaker 2: rules of calculus are inherently recursive. Taking the derivative of
- 17:55Speaker 2: a complex equation usually involves breaking it down into smaller parts,
- 17:58Speaker 2: applying the chain rule, and taking the derivative of those parts.
- 18:02Speaker 1: But wait, humans, right math with infixed notation right like
- 18:05Speaker 1: x plus y. But LASP demands prefix notation like plssxy.
- 18:11Speaker 1: How does it bridge that gap?
- 18:12Speaker 2: Ah? The system uses a special form often called SS
- 18:16Speaker 2: in our texts framework to parse standard human mathematical notation.
- 18:20Speaker 2: It actually uses the Bower Samilson Ershov postfix polish translation.
- 18:25Speaker 1: So what that's a mouthful?
- 18:26Speaker 2: Yeah, the Bower Sanmilson Ershov post fixed polish translation. It
- 18:30Speaker 2: basically reads your equation and translates it into a native
- 18:32Speaker 2: lspes expression a binary tree.
- 18:35Speaker 1: Okay, got it.
- 18:36Speaker 2: Then another form called DSP recursively walks down that tree.
- 18:39Speaker 2: It applies the mathematical rules of differentiation at every note,
- 18:42Speaker 2: symbol by symbol to generate a brand new tree that
- 18:44Speaker 2: represents the derivative.
- 18:46Speaker 1: So it's not actually crunching numbers like a calculator. It's
- 18:49Speaker 1: literally just manipulating symbols, rearranging our train cars according to
- 18:53Speaker 1: the laws of calculus to build a new function.
- 18:55Speaker 2: Exactly.
- 18:55Speaker 1: That is wild. Okay, Now what about the game playing.
- 18:59Speaker 1: The TX mentions zero sum perfect information games like chess
- 19:04Speaker 1: or nim right, So.
- 19:05Speaker 2: Perfect information means there is no hidden data, both players
- 19:09Speaker 2: see the whole board at all times, and zero sum
- 19:12Speaker 2: means one player's advantage is mathematically identical to the other
- 19:16Speaker 2: player's disadvantage.
- 19:17Speaker 1: Like tug of war.
- 19:18Speaker 2: Exactly, So LISP models this using asymmetric valuation. The computer
- 19:24Speaker 2: plays for a score of one and assumes the opponent
- 19:26Speaker 2: is playing for a score of negative one.
- 19:28Speaker 1: So the computer is constantly trying to maximize the score,
- 19:31Speaker 1: and it assumes you're constantly trying to minimize it.
- 19:33Speaker 2: Yes, it maps out future moves by building a massive
- 19:37Speaker 2: game tree and uses the minimax algorithm, which by the way,
- 19:40Speaker 2: draws on von Neumann and Morgenstern's game theory and Bellman's
- 19:44Speaker 2: dynamic programming.
- 19:45Speaker 1: Okay, so a lot of heavy mathematical theory backing.
- 19:48Speaker 2: It up definitely. It simulates down to the end of
- 19:50Speaker 2: the game and then backs up the values. If it's
- 19:53Speaker 2: the computer's turn, it chooses the maximum value. If it's
- 19:57Speaker 2: the opponent's turn, it expects them to choose the minimum.
- 20:00Speaker 1: But wait, we literally just talked about this with the
- 20:02Speaker 1: McCarthy four trend problem. You can't map out the entire
- 20:05Speaker 1: chest tree. It's way too big.
- 20:06Speaker 2: Right, which is why they implement the alpha beta algorithm,
- 20:09Speaker 2: often called ABPCK in this context, which is essentially a
- 20:12Speaker 2: form of pruning.
- 20:13Speaker 1: Okay, pruning. Let me see if this analogy works for
- 20:16Speaker 1: that is alpha beta pruning basically like trying to find
- 20:22Speaker 1: the most affordable restaurant in town by looking at menus
- 20:24Speaker 1: in the window. But the moment you look at one
- 20:27Speaker 1: menu and see a single appetizer costs one hundred dollars,
- 20:30Speaker 1: you just immediately walk away.
- 20:32Speaker 2: That's yeah, that's exactly it.
- 20:33Speaker 1: Like you don't bother reading the entrees or the desserts
- 20:36Speaker 1: because you already have enough information to know this entire
- 20:39Speaker 1: branch of the tree is a loser.
- 20:41Speaker 2: That captures the logic perfectly. If the algorithm evaluates a
- 20:45Speaker 2: single branch and proves that we yield a worse outcome
- 20:48Speaker 2: than a move it already evaluated on a previous branch,
- 20:51Speaker 2: it severs that entire timeline. It just completely stops evaluating it. Wow,
- 20:55Speaker 2: this shortcut saves unimaginable amounts of computational time while guaranteeing
- 21:00Speaker 2: the exact same final decision.
- 21:02Speaker 1: And it all ties right back to lazy evaluation, doesn't it?
- 21:05Speaker 1: Like Conde only do the work that absolutely must be
- 21:09Speaker 1: done exactly Okay. To sort of bring this all together
- 21:12Speaker 1: for everyone listening, we started with this mind bending premise
- 21:16Speaker 1: that a factory could be made of the exact same
- 21:19Speaker 1: stuff as its raw materials, right, and we've seen how
- 21:21Speaker 1: lasp achieves that. By using simple atoms and dotted pairs,
- 21:25Speaker 1: combined with some incredibly clever memory tricks like hacking the
- 21:29Speaker 1: thirty two bit sign and lazy evaluation, it creates an
- 21:32Speaker 1: environment powerful enough to do calculus and master chess.
- 21:35Speaker 2: It really is a towering achievement in computer science. And
- 21:38Speaker 2: I think the most profound takeaway from the text something
- 21:40Speaker 2: for you to ponder is a concept called minimal Lisp.
- 21:43Speaker 1: Minimal LIS.
- 21:44Speaker 2: Yeah, when you strip away all the conveniences and built
- 21:47Speaker 2: in libraries, you can express absolutely any computable function using
- 21:51Speaker 2: just nine fundamental Lisp components.
- 21:53Speaker 1: Wait, just nine for the entire language.
- 21:56Speaker 2: Just nine quote, atom, eq, con car, cdr, con, Lamaday,
- 22:03Speaker 2: and label. With just those nine rules interacting, you can
- 22:07Speaker 2: simulate the complexity of the entire digital universe.
- 22:10Speaker 1: That is staggering.
- 22:11Speaker 2: It really forces you to Viewlisp not just as a
- 22:14Speaker 2: piece of software or a tool, but as a foundational
- 22:17Speaker 2: mathematical model of computation itself. It is on par with
- 22:21Speaker 2: the Turing machine, just a handful of simple rules that,
- 22:24Speaker 2: when combined, can evaluate anything that can possibly be evaluated.
- 22:27Speaker 1: Code is data, data is code, and with just nine
- 22:30Speaker 1: tools you can map the universe. I think that is
- 22:32Speaker 1: an incredible place to leave it. Thank you so much
- 22:35Speaker 1: for joining us on this deep dive into LSP. We'll
- 22:37Speaker 1: see you next time.
- 22:38Speaker 2: Take care of everyone,