Help understand beta reduction example












4














I am currently reading a text book on distributed computing systems that includes a short introduction to $lambda$-calculus. There is an example of evaluating the sequence $(((if space space true) space space 4) space space 5)$ which is written below.




  1. $spacespace(((lambda b.lambda t.lambda e.((b space t) space e) space lambda x.lambda y.x) space 4) space 5) $


  2. $spacespace((lambda t.lambda e ((lambda x.lambda y.x space space t) space e) space 4) space 5) $


  3. $spacespace(lambda e ((lambda x.lambda y.x space space 4) space space e) space space 5) $


  4. $spacespace((lambda x.lambda y.x space space 4) space space 5) $


  5. $spacespace(lambda y.4 space space 5) $


  6. $spacespace 4$



The author has used $beta$-reduction on each line and I can follow up until the second to last reduction. Could someone explain how we get from line 4 to line 6?










share|cite|improve this question




















  • 2




    This was down-voted within 30 seconds of posting - if I can improve the question please let me know!
    – EdwardHaigh
    Nov 24 at 21:31








  • 1




    In the first line there is a typo because $(((λb.λt.λe((b t) e) λx.λt.λx) 4) 5)$ is not a $lambda$-term. In particular, what does $lambda x ) 4$ mean?
    – Taroccoesbrocco
    Nov 24 at 22:25






  • 1




    @Taroccoesbrocco - You're quite right, I made two typos. It should now be correct.
    – EdwardHaigh
    Nov 24 at 22:31
















4














I am currently reading a text book on distributed computing systems that includes a short introduction to $lambda$-calculus. There is an example of evaluating the sequence $(((if space space true) space space 4) space space 5)$ which is written below.




  1. $spacespace(((lambda b.lambda t.lambda e.((b space t) space e) space lambda x.lambda y.x) space 4) space 5) $


  2. $spacespace((lambda t.lambda e ((lambda x.lambda y.x space space t) space e) space 4) space 5) $


  3. $spacespace(lambda e ((lambda x.lambda y.x space space 4) space space e) space space 5) $


  4. $spacespace((lambda x.lambda y.x space space 4) space space 5) $


  5. $spacespace(lambda y.4 space space 5) $


  6. $spacespace 4$



The author has used $beta$-reduction on each line and I can follow up until the second to last reduction. Could someone explain how we get from line 4 to line 6?










share|cite|improve this question




















  • 2




    This was down-voted within 30 seconds of posting - if I can improve the question please let me know!
    – EdwardHaigh
    Nov 24 at 21:31








  • 1




    In the first line there is a typo because $(((λb.λt.λe((b t) e) λx.λt.λx) 4) 5)$ is not a $lambda$-term. In particular, what does $lambda x ) 4$ mean?
    – Taroccoesbrocco
    Nov 24 at 22:25






  • 1




    @Taroccoesbrocco - You're quite right, I made two typos. It should now be correct.
    – EdwardHaigh
    Nov 24 at 22:31














4












4








4







I am currently reading a text book on distributed computing systems that includes a short introduction to $lambda$-calculus. There is an example of evaluating the sequence $(((if space space true) space space 4) space space 5)$ which is written below.




  1. $spacespace(((lambda b.lambda t.lambda e.((b space t) space e) space lambda x.lambda y.x) space 4) space 5) $


  2. $spacespace((lambda t.lambda e ((lambda x.lambda y.x space space t) space e) space 4) space 5) $


  3. $spacespace(lambda e ((lambda x.lambda y.x space space 4) space space e) space space 5) $


  4. $spacespace((lambda x.lambda y.x space space 4) space space 5) $


  5. $spacespace(lambda y.4 space space 5) $


  6. $spacespace 4$



The author has used $beta$-reduction on each line and I can follow up until the second to last reduction. Could someone explain how we get from line 4 to line 6?










share|cite|improve this question















I am currently reading a text book on distributed computing systems that includes a short introduction to $lambda$-calculus. There is an example of evaluating the sequence $(((if space space true) space space 4) space space 5)$ which is written below.




  1. $spacespace(((lambda b.lambda t.lambda e.((b space t) space e) space lambda x.lambda y.x) space 4) space 5) $


  2. $spacespace((lambda t.lambda e ((lambda x.lambda y.x space space t) space e) space 4) space 5) $


  3. $spacespace(lambda e ((lambda x.lambda y.x space space 4) space space e) space space 5) $


  4. $spacespace((lambda x.lambda y.x space space 4) space space 5) $


  5. $spacespace(lambda y.4 space space 5) $


  6. $spacespace 4$



The author has used $beta$-reduction on each line and I can follow up until the second to last reduction. Could someone explain how we get from line 4 to line 6?







computer-science lambda-calculus






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Nov 24 at 23:09









Taroccoesbrocco

4,92761838




4,92761838










asked Nov 24 at 21:29









EdwardHaigh

285




285








  • 2




    This was down-voted within 30 seconds of posting - if I can improve the question please let me know!
    – EdwardHaigh
    Nov 24 at 21:31








  • 1




    In the first line there is a typo because $(((λb.λt.λe((b t) e) λx.λt.λx) 4) 5)$ is not a $lambda$-term. In particular, what does $lambda x ) 4$ mean?
    – Taroccoesbrocco
    Nov 24 at 22:25






  • 1




    @Taroccoesbrocco - You're quite right, I made two typos. It should now be correct.
    – EdwardHaigh
    Nov 24 at 22:31














  • 2




    This was down-voted within 30 seconds of posting - if I can improve the question please let me know!
    – EdwardHaigh
    Nov 24 at 21:31








  • 1




    In the first line there is a typo because $(((λb.λt.λe((b t) e) λx.λt.λx) 4) 5)$ is not a $lambda$-term. In particular, what does $lambda x ) 4$ mean?
    – Taroccoesbrocco
    Nov 24 at 22:25






  • 1




    @Taroccoesbrocco - You're quite right, I made two typos. It should now be correct.
    – EdwardHaigh
    Nov 24 at 22:31








2




2




This was down-voted within 30 seconds of posting - if I can improve the question please let me know!
– EdwardHaigh
Nov 24 at 21:31






This was down-voted within 30 seconds of posting - if I can improve the question please let me know!
– EdwardHaigh
Nov 24 at 21:31






1




1




In the first line there is a typo because $(((λb.λt.λe((b t) e) λx.λt.λx) 4) 5)$ is not a $lambda$-term. In particular, what does $lambda x ) 4$ mean?
– Taroccoesbrocco
Nov 24 at 22:25




In the first line there is a typo because $(((λb.λt.λe((b t) e) λx.λt.λx) 4) 5)$ is not a $lambda$-term. In particular, what does $lambda x ) 4$ mean?
– Taroccoesbrocco
Nov 24 at 22:25




1




1




@Taroccoesbrocco - You're quite right, I made two typos. It should now be correct.
– EdwardHaigh
Nov 24 at 22:31




@Taroccoesbrocco - You're quite right, I made two typos. It should now be correct.
– EdwardHaigh
Nov 24 at 22:31










2 Answers
2






active

oldest

votes


















2














In line 4. there is a $beta$-redex $(lambda x lambda y. x 4)$, where $lambda x lambda y. x$ is applied to $4$.
This means that $(lambda x lambda y. x 4)$ rewrites$-$via a $beta$-step$-$to $(lambda y. x){4 / x} $ (which is $(lambda y. x)$ where the free occurrence of $x$ is replaced by $4$), i.e. $ lambda y. 4$.



Since the $beta$-redex $(lambda x lambda y. x 4)$ is inside a context (i.e. it is a sub-term of a bigger term), then from line 4., if we put the sub-term $(lambda x lambda y. x 4)$ into its context, we have:
begin{align}
((lambda x lambda y. x 4) 5) &to_beta (lambda y. x 5){4 / x} = (lambda y. 4 5)
\ &to_beta 4 {5/y} = 5
end{align}

where, again, $(lambda y. 4 5) $ is a $beta$-redex and then rewrites$-$via a $beta$-step$-$to $4 {5/y}$ (which is $4$ where the free occurrences of $y$ are replaced by $5$), i.e. $4$ because there are not free occurrences of $y$ in $4$.






share|cite|improve this answer





























    2














    When going from line 4 to line 5, we substitute $x=4$ into $lambda y. x$, because the inner argument is bound to the $lambda x$. The 5 is then passed to the result and bound to the $lambda y$, so that we substitute $y=5$ into $lambda y. 4$. Since $y$ does not appear free in $4$, this does not alter the expression, so we end up with $4$.






    share|cite|improve this answer





















      Your Answer





      StackExchange.ifUsing("editor", function () {
      return StackExchange.using("mathjaxEditing", function () {
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
      });
      });
      }, "mathjax-editing");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "69"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      noCode: true, onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3012109%2fhelp-understand-beta-reduction-example%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      In line 4. there is a $beta$-redex $(lambda x lambda y. x 4)$, where $lambda x lambda y. x$ is applied to $4$.
      This means that $(lambda x lambda y. x 4)$ rewrites$-$via a $beta$-step$-$to $(lambda y. x){4 / x} $ (which is $(lambda y. x)$ where the free occurrence of $x$ is replaced by $4$), i.e. $ lambda y. 4$.



      Since the $beta$-redex $(lambda x lambda y. x 4)$ is inside a context (i.e. it is a sub-term of a bigger term), then from line 4., if we put the sub-term $(lambda x lambda y. x 4)$ into its context, we have:
      begin{align}
      ((lambda x lambda y. x 4) 5) &to_beta (lambda y. x 5){4 / x} = (lambda y. 4 5)
      \ &to_beta 4 {5/y} = 5
      end{align}

      where, again, $(lambda y. 4 5) $ is a $beta$-redex and then rewrites$-$via a $beta$-step$-$to $4 {5/y}$ (which is $4$ where the free occurrences of $y$ are replaced by $5$), i.e. $4$ because there are not free occurrences of $y$ in $4$.






      share|cite|improve this answer


























        2














        In line 4. there is a $beta$-redex $(lambda x lambda y. x 4)$, where $lambda x lambda y. x$ is applied to $4$.
        This means that $(lambda x lambda y. x 4)$ rewrites$-$via a $beta$-step$-$to $(lambda y. x){4 / x} $ (which is $(lambda y. x)$ where the free occurrence of $x$ is replaced by $4$), i.e. $ lambda y. 4$.



        Since the $beta$-redex $(lambda x lambda y. x 4)$ is inside a context (i.e. it is a sub-term of a bigger term), then from line 4., if we put the sub-term $(lambda x lambda y. x 4)$ into its context, we have:
        begin{align}
        ((lambda x lambda y. x 4) 5) &to_beta (lambda y. x 5){4 / x} = (lambda y. 4 5)
        \ &to_beta 4 {5/y} = 5
        end{align}

        where, again, $(lambda y. 4 5) $ is a $beta$-redex and then rewrites$-$via a $beta$-step$-$to $4 {5/y}$ (which is $4$ where the free occurrences of $y$ are replaced by $5$), i.e. $4$ because there are not free occurrences of $y$ in $4$.






        share|cite|improve this answer
























          2












          2








          2






          In line 4. there is a $beta$-redex $(lambda x lambda y. x 4)$, where $lambda x lambda y. x$ is applied to $4$.
          This means that $(lambda x lambda y. x 4)$ rewrites$-$via a $beta$-step$-$to $(lambda y. x){4 / x} $ (which is $(lambda y. x)$ where the free occurrence of $x$ is replaced by $4$), i.e. $ lambda y. 4$.



          Since the $beta$-redex $(lambda x lambda y. x 4)$ is inside a context (i.e. it is a sub-term of a bigger term), then from line 4., if we put the sub-term $(lambda x lambda y. x 4)$ into its context, we have:
          begin{align}
          ((lambda x lambda y. x 4) 5) &to_beta (lambda y. x 5){4 / x} = (lambda y. 4 5)
          \ &to_beta 4 {5/y} = 5
          end{align}

          where, again, $(lambda y. 4 5) $ is a $beta$-redex and then rewrites$-$via a $beta$-step$-$to $4 {5/y}$ (which is $4$ where the free occurrences of $y$ are replaced by $5$), i.e. $4$ because there are not free occurrences of $y$ in $4$.






          share|cite|improve this answer












          In line 4. there is a $beta$-redex $(lambda x lambda y. x 4)$, where $lambda x lambda y. x$ is applied to $4$.
          This means that $(lambda x lambda y. x 4)$ rewrites$-$via a $beta$-step$-$to $(lambda y. x){4 / x} $ (which is $(lambda y. x)$ where the free occurrence of $x$ is replaced by $4$), i.e. $ lambda y. 4$.



          Since the $beta$-redex $(lambda x lambda y. x 4)$ is inside a context (i.e. it is a sub-term of a bigger term), then from line 4., if we put the sub-term $(lambda x lambda y. x 4)$ into its context, we have:
          begin{align}
          ((lambda x lambda y. x 4) 5) &to_beta (lambda y. x 5){4 / x} = (lambda y. 4 5)
          \ &to_beta 4 {5/y} = 5
          end{align}

          where, again, $(lambda y. 4 5) $ is a $beta$-redex and then rewrites$-$via a $beta$-step$-$to $4 {5/y}$ (which is $4$ where the free occurrences of $y$ are replaced by $5$), i.e. $4$ because there are not free occurrences of $y$ in $4$.







          share|cite|improve this answer












          share|cite|improve this answer



          share|cite|improve this answer










          answered Nov 24 at 23:03









          Taroccoesbrocco

          4,92761838




          4,92761838























              2














              When going from line 4 to line 5, we substitute $x=4$ into $lambda y. x$, because the inner argument is bound to the $lambda x$. The 5 is then passed to the result and bound to the $lambda y$, so that we substitute $y=5$ into $lambda y. 4$. Since $y$ does not appear free in $4$, this does not alter the expression, so we end up with $4$.






              share|cite|improve this answer


























                2














                When going from line 4 to line 5, we substitute $x=4$ into $lambda y. x$, because the inner argument is bound to the $lambda x$. The 5 is then passed to the result and bound to the $lambda y$, so that we substitute $y=5$ into $lambda y. 4$. Since $y$ does not appear free in $4$, this does not alter the expression, so we end up with $4$.






                share|cite|improve this answer
























                  2












                  2








                  2






                  When going from line 4 to line 5, we substitute $x=4$ into $lambda y. x$, because the inner argument is bound to the $lambda x$. The 5 is then passed to the result and bound to the $lambda y$, so that we substitute $y=5$ into $lambda y. 4$. Since $y$ does not appear free in $4$, this does not alter the expression, so we end up with $4$.






                  share|cite|improve this answer












                  When going from line 4 to line 5, we substitute $x=4$ into $lambda y. x$, because the inner argument is bound to the $lambda x$. The 5 is then passed to the result and bound to the $lambda y$, so that we substitute $y=5$ into $lambda y. 4$. Since $y$ does not appear free in $4$, this does not alter the expression, so we end up with $4$.







                  share|cite|improve this answer












                  share|cite|improve this answer



                  share|cite|improve this answer










                  answered Nov 24 at 23:01









                  Kevin

                  1,597722




                  1,597722






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Mathematics Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      Use MathJax to format equations. MathJax reference.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3012109%2fhelp-understand-beta-reduction-example%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Le Mesnil-Réaume

                      Ida-Boy-Ed-Garten

                      web3.py web3.isConnected() returns false always