Skip to content

Commit

Permalink
correct README statement about recursive terms
Browse files Browse the repository at this point in the history
BetaNormalisingVisitor can not produce cycles
because it does not modify terms, preventing them
from referencing terms available after their construction.
  • Loading branch information
Deric-W committed Sep 22, 2022
1 parent b2d85d4 commit b1e10a0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ use predefined ones from the `terms` subpackage.

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

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

This results in the Visitor for term normalisation included in this package (`BetaNormalisingVisitor`)
having problems when handling terms which are passed a reference to themselves during evaluation,
which is the case for all recursive functions.

`RecursionError` may be raised if the visitors get passed an infinite term.
`RecursionError` may be raised if the visitors get passed an infinite term or the evaluation is too complex.

## Requirements

Expand Down
2 changes: 1 addition & 1 deletion lambda_calculus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from .terms import Variable, Abstraction, Application

__version__ = "2.2.0"
__version__ = "2.2.1"
__author__ = "Eric Niklas Wolf"
__email__ = "[email protected]"
__all__ = (
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "lambda_calculus"
version = "2.2.0"
version = "2.2.1"
description = "Implementation of the Lambda calculus"
requires-python = ">=3.10"
keywords = []
Expand Down
11 changes: 11 additions & 0 deletions tests/visitors/test_normalisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,14 @@ def test_skip_intermediate(self) -> None:
),
Variable("z")
)

def test_self_argument(self) -> None:
"""test behavior when applying a term to itself"""
term = Variable("a").apply_to(Variable("b")).abstract("a")
term_copy = Variable("a").apply_to(Variable("b")).abstract("a")
self.assertEqual(
self.visitor.skip_intermediate(term.apply_to(term)),
Variable("b").apply_to(Variable("b"))
)
# prevent original for being modified
self.assertEqual(term, term_copy)

0 comments on commit b1e10a0

Please sign in to comment.