Hey! A topical post!
Rock Brentwood <
rockbr...@gmail.com> writes:
> On Tuesday, December 28, 2021 at 1:11:43 AM UTC-6, Jeffrey Rubard wrote:
>> Maybe not everyone knows that 'Turing-complete' programming languages have several other models equivalent to the Turing machine. Could you 'rate' the different formalisms?
>> 1) Turing Machines
>> 2) Lambda Calculus
>
> Lambda Calculus with infinitary terms (and the conditional operator).
> Notation: x = A, B means (lambda x B) A
Curious notation. Is it your own? Presumably
x=A, y=B, C
means
(lambda x ((lambda y C) B)) A
rather than the more usual
(lambda x (lambda y C)) A B
I say "more usual" because this is the way a Curried function with two
arguments would usually be written.
> Notation: A? B: C is B is A is true and is C if A is false
So it would seem that this is not the pure lambda calculus as true and
false, along with the conditional form are language primitives and not
defined expressions.
> Example 1:
> x = 0, y = 1, x < n? (x = x + 1, y = y*x, x < n? (x = x + 1, y = y*x, x < n? (...): y): y): y
> where the infinitary term denoted by (...) is an exact replica of (x =
> x + 1, y = y*x, x< n? (...): y).
>
> The value of this expression is n!, the factorial of n, assuming that
> n is a non-negative integer.
I can see you need y*x be to be evaluated in an environment that has
already bound x to x+1 so
x=A, y=B, C must be (lambda x ((lambda y C) B)) A
This raises the question of how you write
(lambda x (lambda y C)) A B
in this notation.
> The value is 1, if n is a negative integer.
>
> Notation: Use L: E as a way to denote the (possibly infinitary)
> subexpression E by the label L
> Notation: Use "goto L" as a way to refer to the subexpression that the
> label L denotes
> Example 2:
> x? (y? (z? A: B): C): (z? A: B)
> may be rewritten as
> x? (y? goto W: C): goto W
> W: z? A: B
>
> Example 3: Example 1 rewritten with labels and gotos
> x = 0, y = 1, goto Z
> Z: x < n? (x = x + 1, y = y*x, goto Z): y
I think this is going to get hard to follow because the expression named
Z is no longer nested inside the lambda forms that bind some of the
names within it.
I would find a named, nested expression easier to follow:
x = 0, y = 1, BODY:[x < n? (x = x + 1, y = y*x, BODY): y]
I'm not seeing the advantages of this notation.
--
Ben.