lambda-calculus

convert flip lambda into SKI terms

百般思念 提交于 2020-01-02 06:58:24
问题 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 (/x.S) (/x.f)) K /f.S (S (K S) (K f)) K S (/f.S (S (K S) (K f))) (/f.K) S (/f.S (S (K S) (K f))) (K K) S (S (/f.S) (/f.S (K S) (K f))) (K K) S (S (K S) (/f.S (K S) (K f))) (K K) S (S (K S) (S (/f.S (K S)) (/f.K f))) (K K) S (S (K S) (S (/f.S (K S)

What are some resources for learning Lambda Calculus? [closed]

元气小坏坏 提交于 2019-12-31 08:04:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . So the Wikipedia entry on Lambda Calculus was interesting but I've finished it. I wish to dive a little deeper and get a better understanding of Lambda Calculus. Can anyone recommend what they consider to be the best book or primer to Lambda Calculus? 回答1: If you are done with the Wikipedia entry, follow its

Subtraction of church numerals in haskell

不羁岁月 提交于 2019-12-30 00:52:11
问题 I'm attempting to implement church numerals in Haskell, but I've hit a minor problem. Haskell complains of an infinite type with Occurs check: cannot construct the infinite type: t = (t -> t1) -> (t1 -> t2) -> t2 when I try and do subtraction. I'm 99% positive that my lambda calculus is valid (although if it isn't, please tell me). What I want to know, is whether there is anything I can do to make haskell work with my functions. module Church where type (Church a) = ((a -> a) -> (a -> a))

Primitive recursion

一个人想着一个人 提交于 2019-12-25 04:33:41
问题 Merged with How can I simplify a basic arithmetic expression?. how will i define the function 'simplify' using primitive recursion? simplify :: Expr -> Expr ... simplify Simplify an expression using basic arithmetic, e.g. simplify (Plus (Var "x") (Const 0)) = Var "x" 来源: https://stackoverflow.com/questions/324003/primitive-recursion

Lambda Calculus CONS Pair implementation with Lisp

 ̄綄美尐妖づ 提交于 2019-12-24 14:41:17
问题 I'm trying to implement a Church Pair Lambda Calc. style with CLisp. According with Wikipedia: pair ≡ λx.λy.λz.z x y So far, this is my code: (defvar PAIR #'(lambda(x) #'(lambda(y) #'(lambda(z) (funcall (funcall z x) y)))) ) These are my FIRST and SECOND Functions: (defvar FIRST #'(lambda(p) (funcall(p TRUE))) ) (defvar SECOND #'(lambda(p) (funcall(p FALSE))) ) This 2 functions convert from Int to ChurchNumber (defun church2int(numchurch) (funcall (funcall numchurch #'(lambda (x) (+ x 1))) 0)

Why the definition of Church's Numerals

99封情书 提交于 2019-12-23 12:19:57
问题 I want to understand, why Church define the numerals like: 0 = λ f . λ x . x 1 = λ f . λ x . f x 2 = λ f . λ x . f f x 3 = λ f . λ x . f f f x 4 = λ f . λ x . f f f f x What is the logic behind? Why 0 is represent like: 0 = λ f . λ x . x 回答1: Church wasn't trying to be practical. He was trying to prove results about the expressive power of lambda calculus — that in principle any possible computation can be done in lambda calculus, hence lambda calculus can serve as a theoretical foundation

Lambda calculus and church numerals confusion

前提是你 提交于 2019-12-23 06:59:09
问题 I'm trying to understand the basics of lambda calculus and Church numerals. I have been doing a lot of reading and practising, but I seem to keep getting stuck with trying to see how some functions work. The example I am stuck on is as follows. Perhaps someone can explain where I have gone wrong. The Church numeral for 1 can be represented as: λf. λx. f x The exponentiation function on Church numerals (m n ) can be given as: λm. λn. n m All I want to do is show that by applying the

To prove SKK and II are beta equivalent, lambda calculus

浪尽此生 提交于 2019-12-22 10:12:08
问题 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 think SKK can be reduced further without expanding S, K. 回答1: SKK = (λxyz.xz(yz))KK → λz.Kz(Kz) (in two steps actually, for the two parameters) Kz = (λxy.x)z → λy.z λz.Kz(Kz) → λz.(λy.z)(λy.z) (again, several steps) → λz.z = I (You should be able to

SystemT Compiler and dealing with Infinite Types in Haskell

跟風遠走 提交于 2019-12-22 09:20:09
问题 I'm following this blog post: http://semantic-domain.blogspot.com/2012/12/total-functional-programming-in-partial.html It shows a small OCaml compiler program for System T (a simple total functional language). The entire pipeline takes OCaml syntax (via Camlp4 metaprogramming) transforms them to OCaml AST that is translated to SystemT Lambda Calculus (see: module Term ) and then finally SystemT Combinator Calculus (see: module Goedel ). The final step is also wrapped with OCaml

How would you implement a beta-reduction function in F#?

孤街醉人 提交于 2019-12-22 06:35:14
问题 I am writing a lambda calculus in F#, but I am stuck on implementing the beta-reduction (substituting formal parameters with the actual parameters). (lambda x.e)f --> e[f/x] example of usage: (lambda n. n*2+3) 7 --> (n*2+3)[7/n] --> 7*2+3 So I'd love to hear some suggestions in regards to how others might go about this. Any ideas would be greatly appreciated. Thanks! 回答1: Assuming your representation of an expression looks like type expression = App of expression * expression | Lambda of