|
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="x-ua-compatible" content="ie=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <meta name="referrer" content="no-referrer">
- <title>rf - An Idiot's Guide to Lambda Calculus</title>
- <link rel="stylesheet" href="../../css/default.css" />
- <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"><link rel="shortcut icon" href="../../images/favicons/favicon32.png"><link rel="apple-touch-icon-precomposed" sizes="144x144" href="../../images/favicons/favicon144.png"><link rel="apple-touch-icon-precomposed" sizes="114x114" href="../../images/favicons/favicon114.png"><link rel="apple-touch-icon-precomposed" sizes="72x72" href="../../images/favicons/favicon72.png"><link rel="apple-touch-icon-precomposed" sizes="57x57" href="../../images/favicons/favicon57.png">
- </head>
- <body>
- <header>
- <div class="logo">
- <a href="../../">Regular Flolloping</a>
- </div>
- <nav class="navbar">
- <a href="../../">Home</a>
- <a href="../../about/">About</a>
- <a href="../../contact/">Contact</a>
- <a href="../../archive/">Archive</a>
- </nav>
- </header>
-
- <main role="main">
- <h1>An Idiot's Guide to Lambda Calculus</h1>
- <article>
- <section class="header">
- Posted on August 27, 2018
-
- </section>
- <section>
- <p>clarification: this is not a guide to lambda calculus for idiots, this is a guide to lambda calculus written by an idiot.</p>
- <p>imagine for a second you need to explain our numbering system without <strong><em>any</em></strong> background. any at all, think about that for a second.</p>
- <ul>
- <li>you have no idea what the number symbols mean</li>
- <li>you have no idea what plus minus or anything mean</li>
- <li>you have no idea of anything</li>
- </ul>
- <p>and this isn’t limited to just numbering, because almost anything we do on a computer is based around maths, imagine the same for pretty much literally anything.</p>
- <p>what you would need is….</p>
- <p><strong>is</strong>…</p>
- <p><strong><em>is</em></strong>…</p>
- <h2 id="a-way-to-describe-computability">a way to describe computability</h2>
- <p>and one way of doing that is with lambda calculus. to define lambda calculus we need just a few rules - variables, abstraction, application.</p>
- <p>these concepts aren’t too difficult, so awayyyy we go.</p>
- <h3 id="variables">variables</h3>
- <p>variables are simply a name, most of the time we use letters. there are two catches here, if you’re used to variables in maths or other languages:</p>
- <ul>
- <li><p>unlike pretty much every other language, lambda calc variables don’t have a value, only a name. this is because we don’t have any concept of what a value is.</p></li>
- <li><p>unlike any language worth using, variables in lambda calculus do not have a <em>type</em>. again this is because we don’t have a concept of what type is.</p></li>
- </ul>
- <p>this guide is gonna use lowercase letters for the most part, so the examples are <code>a b c d e f</code> etc etc</p>
- <h3 id="abstraction">abstraction</h3>
- <p>abstractions are the functions of lambda calc, and take the form off:</p>
- <pre><code>(λx.M)</code></pre>
- <p>where <code>λ</code> denotes that this is a function<br />
- <code>x</code> is an argument name (that is local to this function)<br />
- and <code>M</code> is a list of variables that will form the function body</p>
- <p>a quick example of an abstraction is the identity function:</p>
- <pre><code>(λx.x)</code></pre>
- <p>we’ll get onto more to do with fuctions in a bit, but next</p>
- <h3 id="application">application</h3>
- <p>application is what we pretentious people call “actually using a function” and it takes the form of:</p>
- <pre><code>(M N)</code></pre>
- <p>where <code>M</code> is an abstraction, and <code>N</code> is any lambda term at all. i will refer to <code>M</code> as an abstraction and <code>N</code> as the application body</p>
- <p>to do the application we just use <code>N</code> as the argument for <code>M</code>, and then do a find and replace based on the abstraction definition.</p>
- <p>for example, lets do an easy one using the identity function, which is a function that returns its input unchanged:</p>
- <p>if we have the abstraction <code>(λx.x)</code> and the variable <code>y</code> to use for the application, and then lay the application out as so:</p>
- <pre><code>( (λx.x) y )</code></pre>
- <p>we can then begin applying.</p>
- <p>the identity function has <code>x</code> as its argument, so we take the application body, in this case <code>y</code>, and every time we see <code>x</code> in the abstraction body (the bit past <code>.</code>) we replace it with our argument, <code>y</code>.</p>
- <p>so our abstraction body is <code>x</code>, and <code>x</code> is equal to our argument <code>y</code>, so therefore our function will return <code>y</code>, which is the identity.</p>
- <p>a sligtly more interesting example is something like:</p>
- <pre><code>( (λx.xx) y )</code></pre>
- <p>here, our argument to our abstraction is <code>y</code>, which gets bound to <code>x</code> in the abstraction body, which is then fed into the <code>xx</code> to produce:</p>
- <p><code>yy</code></p>
- <p>and thats how we go.</p>
- <p>as a spoiler for what the next lambda calc post will cover, heres a bit of an example, imagine we were using the same abstraction:</p>
- <pre><code>(λx.xx)</code></pre>
- <p>and instead of passing it <code>y</code>, we passed it <strong>another abstraction</strong>… say, itself?</p>
- <pre><code>( (λx.xx) (λx.xx) )</code></pre>
- <p>here, we bind the entire abstraction <code>(λx.xx)</code> to the variable <code>x</code> in the first abstraction.</p>
- <p>when we do the substitution into the body <code>xx</code> we get left with…</p>
- <pre><code>( (λx.xx) (λx.xx) )</code></pre>
- <p>the same thing, which means this is an <strong><em>infinite loop</em></strong></p>
- <p>fun stuff fun stuff imo</p>
- <h2 id="further-thoughts">further thoughts</h2>
- <p>theres a lot more to go before we get to a numbering system, and at this point it may seem like theres not much use to lambda calculus, but i am not joking when i say <strong><em>anything that can be done on a computer can be written in lambda calculus</em></strong>.</p>
- <p>it may be abstracted, it may be thousands of millions of pages long, but it is possible.</p>
- <p>and thats what makes it so wonderful.</p>
- <p>i’ll write more in depth on this at some point in the near future when i’m feeling smarter, less lazy, and don’t wanna write edgy armchair psych pieces instead.</p>
- <p>peace out ny’all, if you’re unlucky i’ll talk about Nock after this.</p>
- </section>
- </article>
-
- </main>
-
- <footer>
- powered by <a href="http://jaspervdj.be/hakyll">Hakyll</a>
- </footer>
- </body>
- </html>
|