Questions tagged [k-combinator]

Use k-combinator for questions related to programmatically creating a constant function.

When the k-combinator K is applied to another combinator x, it yields a combinator that always evaluates to x, for example:

K x y = x

References


Related tags
s-combinator

12 questions
20
votes
1 answer

(Kestrel) K-combinator: why is it useful?

I have been taking up F# recently (my background is C#) and am reading the site http://fsharpforfunandprofit.com, which I am finding very helpful. I've got to http://fsharpforfunandprofit.com/posts/defining-functions/ which is the section on…
Richiban
  • 5,569
  • 3
  • 30
  • 42
6
votes
4 answers

Conversion from lambda term to combinatorial term

Suppose there are some data types to express lambda and combinatorial terms: data Lam α = Var α -- v | Abs α (Lam α) -- λv . e1 | App (Lam α) (Lam α) -- e1 e2 deriving (Eq,…
6
votes
2 answers

How to create a K combinator in the enchanted forest? (To Mock a Mockingbird)

Recall that the K combinator is a constant function. It always returns its first argument: Kxy = x for all y In the book To Mock a Mockingbird the author presents an example of an enchanted forest containing talking birds. The birds have behavior:…
3
votes
1 answer

Fixed point of K combinator

The K combinator is K := (λxy.x) and the fixed point combinator is Y := λf.(λx.f x x) (λx.f x x). I tried to calculate YK: YK = (λx.Kxx)(λx.Kxx) = (λx.x)(λx.x) = (λx.x) = I So because YK is the fixed point of K: K(YK) = YK KI = I KIe = Ie = e for…
xuanji
  • 5,007
  • 2
  • 26
  • 35
3
votes
2 answers

To prove SKK and II are beta equivalent, lambda calculus

I am new to lambda calculus and struggling to prove the following. SKK and II are beta equivalent. where S = lambda xyz.xz(yz) K = lambda xy.x I = lambda x.x I tried to beta reduce SKK by opening it up, but got nowhere, it becomes to messy. Dont…
3
votes
1 answer

Function signature of Tap (K-combinator)

I've read in a book that the function signature of tap function (also called K-Combinator) is below: tap :: (a -> *) -> a -> a "This function takes an input object a and a function that performs some action on a. It runs the given function with…
3
votes
1 answer

convert flip lambda into SKI terms

I'm having trouble converting the lambda for flip into the SKI combinators (I hope that makes sense). Here is my conversion: /fxy.fyx /f./x./y.fyx /f./x.S (/y.fy) (/y.x) /f./x.S f (/y.x) /f./x.S f (K x) /f.S (/x.S f) (/x.K x) /f.S (/x.S f) K /f.S (S…
Brad
  • 705
  • 7
  • 17
2
votes
1 answer

How to type the simply typed lambda calculus term (S K K)

I am attempting to implement a simply typed lambda calculus type checker. When running sanity tests I tried typing (S K K) and my type checker throws this error: TypeMismatch {firstType = t -> t, secondType = t -> t -> t} The offending term is…
1
vote
1 answer

Does SKS equal SKK?

Context I started teaching myself lambda calculus last night and I am trying to determine if what I understand so far is correct. Understanding SKK is equivalent to the Identity combinator, I. Where L stands for lambda: S = LxLyLz((xz)(yz)) K =…
1
vote
1 answer

How to create a sequence of actions mid-expression in ReasonML (and avoid creating a tuple)?

I want to bail out of a function early, if given unsuitable arguments The imperative solution in Javascript is elegant: arg=>{ if(arg>limit) return 42; //perform complex operations return x+y } ReasonML as a functional language has no…
MKaama
  • 1,732
  • 2
  • 19
  • 28
1
vote
1 answer

Lambda reductions prove S K = K I

Hello I am having trouble proving these combinators S K = K I The steps with the brackets [] are just telling you the step i am doing. For example [λxy.x / x] in λyz.x z(y z) means I am about to substitute (λxy.x) for every x in the expression…
0
votes
2 answers

Evaluating SKI-combinators with not enough arguments

I was tasked with showing that S(KK)I = K Now since S takes three arguments, I was simply stuck at the beginning not knowing how to tackle this. I see two arguments, namely (KK) and I but there is no third one I can "spot". What happens in this…