Repository navigation
Conversation
Four core strategies raised an AssertionError on a basis holding the one-point pattern, and so did find_strategies, as they passed the empty permutation to helpers that assert a non-empty input. The other four applied. The paper's corollaries add patterns 1 + p with p non-empty, so each of their classes contains 1 and none is Av(1). Each is_valid_extension now returns False for a pattern of fewer than two points, before any helper sees it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tests gave only the pattern 1, so a guard one point too wide, or a one-point check in zero_plus_sumind in place of the guard, passed them all. The new test checks that 12 stays an extra pattern for every core strategy but Ru2143CoreStrategy, that 21 is one for none, and that each strategy applies to Av(12) and Av(21) as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every core strategy now refuses a basis that holds the one-point pattern 1, such as
[Perm((0,))], whose class Av(1) holds only the empty permutation. Before, four of them,RdCdCuCoreStrategy,RdCuCoreStrategy,Rd2134CoreStrategyandRu2143CoreStrategy, raised anAssertionError, and so didfind_strategies. The other four applied, though no corollary of the paper covers Av(1). The fix is in each strategy'sis_valid_extension, inpermuta/enumeration_strategies/core_strategies.py, which now returnsFalsefor the pattern 1:On
developthis raises anAssertionError. The two strategies left are right to apply, as Av(1) is finite. Every pattern of two or more points gets the same answer as before.Details
Why
A core strategy checks a class against a corollary of Bean, Nadeau and Ulfarsson, "Enumeration of Permutation Classes and Weighted Labelled Independent Sets" (arXiv:1912.07503). Each corollary's class is Av(N, 1 ⊕ P), for the strategy's needed patterns N and a set P with the corollary's conditions, in Sections 4 to 10 alike. At the end of Section 3 the paper assumes throughout that the empty permutation is not in P. So each such class contains the permutation 1, none is Av(1), and 1 = 1 ⊕ ε is never an extra basis pattern.
is_valid_extensiondid not check this. Four strategies strip the pattern 1 down to the empty permutation, withbstriporfstrip, and hand it to a helper that asserts its input is not empty (zero_plus_sumind,last_sum_componentorlast_skew_component), so they raised.find_strategiesraised too, when it reached the first of them. The other four accepted 1, as the empty permutation is neither sum- nor skew-decomposable, andRuCuRdCdCoreStrategychecks only the leading 1.The fix is for anyone who passes a basis that may hold 1 to
find_strategiesor to a core strategy, such as a basis a program builds.What changes
is_valid_extensionmethods returnsFalsefor the pattern 1 before it reaches a helper that would fail on the empty permutation. Six do so withlen(patt) > 1 and ….Rd2134CoreStrategyreturns early for fewer than two points, before its first line takes the last sum component of the stripped pattern.Ru2143CoreStrategychecks that the patternfstripleaves is not empty, before taking its last skew component.RdCdCuCoreStrategyandRdCuCoreStrategypass 1 tozero_plus_sumindfor the extra pattern 12, which they accept ondevelopand which Corollaries 7.4 and 8.3 allow: 1^× is the empty permutation, sum-indecomposable as the paper defines it. Sozero_plus_sumindmust keep accepting 1.CoreStrategy.is_valid_extension's docstring now says what an extra pattern is and why 1 is never one, with examples.test_no_core_strategy_applies_to_av_1intests/enumeration_strategies/test_core_strategies.py, run for each core strategy by name. The pattern 1 is not a valid extension, and the strategy applies neither to[1]nor to its needed patterns with 1.test_a_two_point_pattern_is_judged_as_before, beside it, also for each core strategy, which pins the guard at two points: 12 stays an extra pattern for every strategy butRu2143CoreStrategy, 21 for none, and each strategy applies to Av(12) and Av(21) as before.test_find_strategies_for_av_1intests/enumeration_strategies/test_enumeration_strategies.py, the example above.CHANGELOG.md: an entry under Unreleased, Fixed.Checks
develop: the nine tests of the pattern 1 fail: four strategies raise, four apply, andfind_strategiesraises. The test of 12 and 21 passes there, as it should, and so do the other 37 tests in the two files.developwith this Permuta, on both Pythons.is_valid_extensionon every pattern of length 0 to 7, andapplies()on[q]and on its needed patterns with q for every q of length 1 to 5, and on[1, q]and its needed patterns with 1 and q for every q of length 2 to 4, were compared withdevelop. Every answer that differs is on a pattern or basis holding a pattern of at most one point, and goes from raising orTruetoFalse. On this branch no core strategy applies to a basis holding 1. The empty permutation, which no basis can hold (Avrefuses it), still makesRu2143CoreStrategy.is_valid_extensionraise, as ondevelop.zero_plus_sumindin place of the guard, which the test of 12 and 21 catches.applies()on 7,920 bases, each class built afresh, is no slower than ondevelop: level or faster under CPython in every round, and level under PyPy over 8 paired hash seeds, within the spread of two copies ofdevelop.is_valid_extensioncalled alone pays for its one comparison, about 0.1 µs a call under CPython.AI assistance: written with Claude Code (Opus 5.5) as the Permuta developer, and reviewed before submission by Claude Code (Opus 5.5) as an automated reviewer; Henning Ulfarsson checked and opened it.