Skip to content

Commit b1e10a0

Browse files
committed
correct README statement about recursive terms
BetaNormalisingVisitor can not produce cycles because it does not modify terms, preventing them from referencing terms available after their construction.
1 parent b2d85d4 commit b1e10a0

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@ use predefined ones from the `terms` subpackage.
1515

1616
This package is intended to be used for educational purposes and is not optimized for speed.
1717

18-
Furthermore, it expects all terms to be finite, which means the absense of cycles.
18+
Furthermore, it expects all terms to be finite, which means the absence of cycles.
1919

20-
This results in the Visitor for term normalisation included in this package (`BetaNormalisingVisitor`)
21-
having problems when handling terms which are passed a reference to themselves during evaluation,
22-
which is the case for all recursive functions.
23-
24-
`RecursionError` may be raised if the visitors get passed an infinite term.
20+
`RecursionError` may be raised if the visitors get passed an infinite term or the evaluation is too complex.
2521

2622
## Requirements
2723

lambda_calculus/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from .terms import Variable, Abstraction, Application
66

7-
__version__ = "2.2.0"
7+
__version__ = "2.2.1"
88
__author__ = "Eric Niklas Wolf"
99
__email__ = "[email protected]"
1010
__all__ = (

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "lambda_calculus"
3-
version = "2.2.0"
3+
version = "2.2.1"
44
description = "Implementation of the Lambda calculus"
55
requires-python = ">=3.10"
66
keywords = []

tests/visitors/test_normalisation.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,14 @@ def test_skip_intermediate(self) -> None:
145145
),
146146
Variable("z")
147147
)
148+
149+
def test_self_argument(self) -> None:
150+
"""test behavior when applying a term to itself"""
151+
term = Variable("a").apply_to(Variable("b")).abstract("a")
152+
term_copy = Variable("a").apply_to(Variable("b")).abstract("a")
153+
self.assertEqual(
154+
self.visitor.skip_intermediate(term.apply_to(term)),
155+
Variable("b").apply_to(Variable("b"))
156+
)
157+
# prevent original for being modified
158+
self.assertEqual(term, term_copy)

0 commit comments

Comments
 (0)