lambda-calculus

What does Core Haskell applying types to functions mean?

♀尐吖头ヾ 提交于 2019-12-01 05:47:41
问题 I wrote a custom pretty printer for Core Haskell in order to better study Core's structure. The gist of this pretty printer is that it takes a CoreModule and includes data constructors in the output, which the default Outputable implementation does not seem to do. Here is the code of the module that I am running the pretty printer on: module Bar2 where add :: Int -> Int -> Int add a b = a + b add2 a b = a + b Here is the pretty printer output: ------------------------------- Module Metadata -

Is it actually possible to remove “Pi” from Calculus of Constructions?

萝らか妹 提交于 2019-11-30 21:18:54
The article Simpler, Easier! claims it could be possible to encode dependent type systems even without the presence of "Pi" - that is, you could reuse the "Lam" constructor for it. But how can that be true, if "Pi" and "Lam" are treated differently in some cases? Moreover, could "Star" be removed? I think you could replace all occurrences of it by "λ x . x" (id). That's just overloading like (a, b) in Haskell: it can be both a type and a value. You can use the same binder for Π and λ and typechecker will decide from the context which one you mean. If you typecheck one binder against another,

Relational operations using only increment, loop, assign, zero

萝らか妹 提交于 2019-11-30 20:38:55
This is a follow up question for: Subtraction operation using only increment, loop, assign, zero We're only allowed to use the following operations: incr(x) - Once this function is called it will assign x + 1 to x assign(x, y) - This function will assign the value of y to x (x = y) zero(x) - This function will assign 0 to x (x = 0) loop X { } - operations written within brackets will be executed X times For example, addition can be implemented as follows: add(x, y) { loop x { y = incr(y) } return y } How do I implement the relational operators using these four operations? The relational

Query on Booleans in Lambda Calculus

允我心安 提交于 2019-11-30 09:04:00
This is the lambda calculus representation for the AND operator: lambda(m).lambda(n).lambda (a).lambda (b). m(n a b) b Can anyone help me in understanding this representation? To understand how to represent Booleans in lambda calculus, it helps to think about an IF expression, "if a then b else c". This is an expression which chooses the first branch, b, if it is true, and the second, c, if it is false. Lambda expressions can do that very easily: lambda(x).lambda(y).x will give you the first of its arguments, and lambda(x).lambda(y).y gives you the second. So if a is one of those expressions,

Relational operations using only increment, loop, assign, zero

守給你的承諾、 提交于 2019-11-30 05:14:08
问题 This is a follow up question for: Subtraction operation using only increment, loop, assign, zero We're only allowed to use the following operations: incr(x) - Once this function is called it will assign x + 1 to x assign(x, y) - This function will assign the value of y to x (x = y) zero(x) - This function will assign 0 to x (x = 0) loop X { } - operations written within brackets will be executed X times For example, addition can be implemented as follows: add(x, y) { loop x { y = incr(y) }

Is it actually possible to remove “Pi” from Calculus of Constructions?

百般思念 提交于 2019-11-30 04:57:55
问题 The article Simpler, Easier! claims it could be possible to encode dependent type systems even without the presence of "Pi" - that is, you could reuse the "Lam" constructor for it. But how can that be true, if "Pi" and "Lam" are treated differently in some cases? Moreover, could "Star" be removed? I think you could replace all occurrences of it by "λ x . x" (id). 回答1: That's just overloading like (a, b) in Haskell: it can be both a type and a value. You can use the same binder for Π and λ and

What type of lambda calculus would Lisp loosely be an example of?

南笙酒味 提交于 2019-11-30 03:00:24
I'm trying to get a better grip on how types come into play in lambda calculus. Admittedly, a lot of the type theory stuff is over my head. Lisp is a dynamically typed language, would that roughly correspond to untyped lambda calculus? Or is there some kind of "dynamically typed lambda calculus" that I'm unaware of? Lisp is a dynamically typed language, would that roughly correspond to untyped lambda calculus? Yes, but only roughly. In the "pure" untyped lambda calculus, everything is coded as functions. (You can google for the popular "Church encoding" and the less popular "Scott encoding".)

Subtraction operation using only increment, loop, assign, zero

徘徊边缘 提交于 2019-11-30 02:16:40
I am trying to build up subtraction, addition, division, multiplication and other operations using only following ones: incr(x) - Once this function is called it will assign x + 1 to x assign(x, y) - This function will assign the value of y to x (x = y) zero(x) - This function will assign 0 to x (x = 0) loop X { } - operations written within brackets will be executed X times Using following rules it is straight forward to implement addition (add) like this: ADD (x, y) { loop X { y = incr (y) } return y } However, I'm struggling to implement subtraction . I think that all the other needed

Lambda Calculus reduction

不问归期 提交于 2019-11-30 00:27:06
All, Below is the lambda expression which I am finding difficult to reduce i.e. I am not able to understand how to go about this problem. (λm λn λa λb . m (n a b) b) (λ f x. x) (λ f x. f x) This is what I tried, but I am stuck: Considering the above expression as : (λm.E) M equates to E= (λn λa λb. m (n a b) b) M = (λf x. x)(λ f x. f x) => (λn λa λb. (λ f x. x) (λ f x. f x) (n a b) b) Considering the above expression as (λn. E)M equates to E = (λa λb. (λ f x. x) (λ f x. f x) (n a b) b) M = ?? .. and I am lost!! Can anyone please help me understand that, for ANY lambda calculus expression, what

What is meant by “Capture-avoiding substitutions”?

早过忘川 提交于 2019-11-29 22:16:52
While reading the Lambda Calculus in Wiki, came across the term Capture-avoiding substitutions . Can someone please explain what it means as I couldn't find a definition from anywhere. Thanks PS What I want to know is the reason for telling that operation Capture-avoiding substitutions . It would be a great help if anyone can do that Normally, the specific variable names that we chose in the lambda calculus are meaningless - a function of x is the same thing as a function of a or b or c . In other words: (λx.(λy.yx)) is equivalent to (λa.(λb.ba)) - renaming x to a and y to b does not change