Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Lambda calculus
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Logic and predicates === By convention, the following two definitions (known as Church Booleans) are used for the Boolean values {{Mono|TRUE}} and {{Mono|FALSE}}: : {{Mono|1=TRUE := λ''x''.λ''y''.''x''}} : {{Mono|1=FALSE := λ''x''.λ''y''.''y''}} Then, with these two lambda terms, we can define some logic operators (these are just possible formulations; other expressions could be equally correct): : {{Mono|1=AND := λ''p''.λ''q''.''p'' ''q'' ''p''}} : {{Mono|1=OR := λ''p''.λ''q''.''p'' ''p'' ''q''}} : {{Mono|1=NOT := λ''p''.''p'' FALSE TRUE}} : {{Mono|1=IFTHENELSE := λ''p''.λ''a''.λ''b''.''p'' ''a'' ''b''}} We are now able to compute some logic functions, for example: : {{Mono|AND TRUE FALSE}} :: {{Mono|≡ (λ''p''.λ''q''.''p'' ''q'' ''p'') TRUE FALSE →<sub>β</sub> TRUE FALSE TRUE}} :: {{Mono|≡ (λ''x''.λ''y''.''x'') FALSE TRUE →<sub>β</sub> FALSE}} and we see that {{Mono|AND TRUE FALSE}} is equivalent to {{Mono|FALSE}}. A ''predicate'' is a function that returns a Boolean value. The most fundamental predicate is {{Mono|ISZERO}}, which returns {{Mono|TRUE}} if its argument is the Church numeral {{Mono|0}}, but {{Mono|FALSE}} if its argument were any other Church numeral: : {{Mono|1=ISZERO := λ''n''.''n'' (λ''x''.FALSE) TRUE}} The following predicate tests whether the first argument is less-than-or-equal-to the second: : {{Mono|1=LEQ := λ''m''.λ''n''.ISZERO (SUB ''m'' ''n'')}}, and since {{Mono|1=''m'' = ''n''}}, if {{Mono|LEQ ''m'' ''n''}} and {{Mono|LEQ ''n'' ''m''}}, it is straightforward to build a predicate for numerical equality. The availability of predicates and the above definition of {{Mono|TRUE}} and {{Mono|FALSE}} make it convenient to write "if-then-else" expressions in lambda calculus. For example, the predecessor function can be defined as: : {{Mono|1=PRED := λ''n''.''n'' (λ''g''.λ''k''.ISZERO (''g'' 1) ''k'' (PLUS (''g'' ''k'') 1)) (λ''v''.0) 0}} which can be verified by showing inductively that {{Mono|''n'' (λ''g''.λ''k''.ISZERO (''g'' 1) ''k'' (PLUS (''g'' ''k'') 1)) (λ''v''.0)}} is the add {{Mono|''n''}} − 1 function for {{Mono|''n''}} > 0.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Lambda calculus
(section)
Add topic