Difference between revisions of "Beta reduction"

From HaskellWiki
Jump to navigation Jump to search
(Add infobox)
(x is bound in the function, cannot replace free occurrence)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
A ''beta reduction'' (also written ''β reduction'') is where you actually apply a lambda function to an expression to generate a result.
+
A ''beta reduction'' (also written ''β reduction'') is the process of calculating a result from the application of a function to an expression.
   
 
{{Foundations infobox}}
 
{{Foundations infobox}}
For example, suppose we have
+
For example, suppose we apply the function
 
<haskell>
 
<haskell>
2*x*x + y
+
(\x -> 2*x*x + y)
 
</haskell>
 
</haskell>
If we now replace every occurance of <hask>x</hask> with 7, we arrive at
+
to the value <hask>7</hask>. To calculate the result, we substitute <hask>7</hask> for every occurrence of <hask>x</hask>, and so the application of the function
  +
<haskell>
  +
(\x -> 2*x*x + y)(7)
  +
</haskell>
  +
is ''reduced'' to the result
 
<haskell>
 
<haskell>
 
2*7*7 + y
 
2*7*7 + y
 
</haskell>
 
</haskell>
We have thus performed a ''beta reduction''.
+
This is a ''beta reduction''.
  +
  +
(Further reductions could be applied to reduce <hask>2*7*7</hask> to <hask>98</hask>. Although the lambdas are not explicit, they exist hidden in the definition of <hask>(*)</hask>.)
   
 
Also see [[Lambda calculus]] and the [http://en.wikipedia.org/wiki/Lambda_calculus wikipedia lambda calculus article].
 
Also see [[Lambda calculus]] and the [http://en.wikipedia.org/wiki/Lambda_calculus wikipedia lambda calculus article].

Latest revision as of 16:57, 6 February 2016

A beta reduction (also written β reduction) is the process of calculating a result from the application of a function to an expression.

Haskell theoretical foundations

General:
Mathematics - Category theory
Research - Curry/Howard/Lambek

Lambda calculus:
Alpha conversion - Beta reduction
Eta conversion - Lambda abstraction

Other:
Recursion - Combinatory logic
Chaitin's construction - Turing machine
Relational algebra

For example, suppose we apply the function

(\x -> 2*x*x + y)

to the value 7. To calculate the result, we substitute 7 for every occurrence of x, and so the application of the function

(\x -> 2*x*x + y)(7)

is reduced to the result

2*7*7 + y

This is a beta reduction.

(Further reductions could be applied to reduce 2*7*7 to 98. Although the lambdas are not explicit, they exist hidden in the definition of (*).)

Also see Lambda calculus and the wikipedia lambda calculus article.