functional-programmingschemelisplambda-calculuschurch-encoding

Looking for a Church-encoding (lambda calculus) to define < , > , !=


I have to create some Lambda functions for > , < and !=

I don't have an idea how to , could anyone help me please ? PS: We just started with Lambda Calculus, so please do not assume any previous knowledge.

Thank you in anticipation !

Edit - What I meant was Arithmetic in Lambda Calculus

Edit 2 - More accurate : Looking for a Church-encoding (lambda calculus) to define < , > , !=


Editor's Note: I think this is what the OP is trying to ask:

I am trying to implement the following operations in the untyped lambda calculus using Church encoding:

  1. Greater than (GT or >).
  2. Lesser than (LT or <).
  3. Not equal to (NE or !=).

I already know how to implement the following:

  1. Boolean true (TRUE or λx.λy.x).
  2. Boolean false (FALSE or λx.λy.y).
  3. Logical and (AND or λp.λq.p q p).
  4. Logical or (OR or λp.λq.p p q).
  5. Logical not (NOT or λp.λa.λb.p b a).

How would you write the GT, LT and NE functions in the untyped lambda calculus?


Solution

  • You also need the implementation of natural numbers. That's what you're going to write comparision operators for, isn't it.

    I think that I remember the implementation of natural numbers. A number n is represented as a function taking a function f and a value x, and applying f n times on x.

    zero = λf . λx . x
    succ = λn . λf . λx . n f (f x)