Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can follow the following steps to reduce lambda expressions:</p> <ol> <li>Fully parenthesize the expression to avoid mistakes and make it more obvious where function application takes place.</li> <li>Find a function application, i.e. find an occurrence of the pattern <code>(λX. e1) e2</code> where <code>X</code> can be any valid identifier and <code>e1</code> and <code>e2</code> can be any valid expressions.</li> <li>Apply the function by replacing <code>(λx. e1) e2</code> with <code>e1'</code> where <code>e1'</code> is the result of replacing each free occurrence of <code>x</code> in <code>e1</code> with <code>e2</code>.</li> <li>Repeat 2 and 3 until the pattern no longer occurs. Note that this can lead to an infinite loop for non-normalizing expressions, so you should stop after 1000 iterations or so ;-)</li> </ol> <p>So for your example we start with the expression</p> <pre><code>((λm. (λn. (λa. (λb. (m ((n a) b)) b)))) (λf. (λx. x))) (λf. (λx. (f x))) </code></pre> <p>Here the subexpression <code>(λm. (λn. (λa. (λb. (m ((n a) b)) b)))) (λf. (λx. x))</code> fits our pattern with <code>X = m</code>, <code>e1 = (λn. (λa. (λb. (m ((n a) b)) b))))</code> and <code>e2 = (λf. (λx. x))</code>. So after substitution we get <code>(λn. (λa. (λb. ((λf. (λx. x)) ((n a) b)) b)))</code>, which makes our whole expression:</p> <pre><code>(λn. (λa. (λb. ((λf. (λx. x)) ((n a) b)) b))) (λf. (λx. (f x))) </code></pre> <p>Now we can apply the pattern to the whole expression with <code>X = n</code>, <code>e1 = (λa. (λb. ((λf. (λx. x)) ((n a) b)) b))</code> and <code>e2 = (λf. (λx. (f x)))</code>. So after substituting we get:</p> <pre><code>(λa. (λb. ((λf. (λx. x)) (((λf. (λx. (f x))) a) b)) b)) </code></pre> <p>Now <code>((λf. (λx. (f x))) a)</code> fits our pattern and becomes <code>(λx. (a x))</code>, which leads to:</p> <pre><code>(λa. (λb. ((λf. (λx. x)) ((λx. (a x)) b)) b)) </code></pre> <p>This time we can apply the pattern to <code>((λx. (a x)) b)</code>, which reduces to <code>(a b)</code>, leading to:</p> <pre><code>(λa. (λb. ((λf. (λx. x)) (a b)) b)) </code></pre> <p>Now apply the pattern to <code>((λf. (λx. x)) (a b))</code>, which reduces to <code>(λx. x)</code> and get:</p> <pre><code>(λa. (λb. b)) </code></pre> <p>Now we're done.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload