fix(dsl): unify nullary-constant chart encoding across patterns and LFs#54
Open
aaronstevenwhite wants to merge 1 commit into
Open
fix(dsl): unify nullary-constant chart encoding across patterns and LFs#54aaronstevenwhite wants to merge 1 commit into
aaronstevenwhite wants to merge 1 commit into
Conversation
…Fs (0.17.0)
Rule patterns compiled a nullary constant to ("atom", name) while the
lexicon LF evaluator emitted a bare (name,), so a premise mentioning a
constant inside a logical form (e.g. Claim(App(forall_t, X))) compiled
clean and could never match the chart. Lexicon LFs now emit the same
tagged ("atom", name); bound variables are tagged ("var", name) so
alpha-renaming still finds occurrences once constants take the atom tag.
"atom" and "var" are reserved term-algebra tags.
This changes the observable chart encoding of logical forms, so it is a
minor (breaking) bump under pre-1.0 SemVer.
Closes #49
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
A nullary constant had two incompatible chart encodings —
("atom", name)in rule patterns but a bare(name,)in lexicon logical forms — so a rule that mentioned a constant inside an LF (e.g.Claim(App(forall_t, X))) compiled clean and silently never fired. This unifies both positions on one discriminated representation.Motivation
Closes #49. The divergence made a whole class of well-formed rules dead on arrival, and forced the Montague NLI example to carry quantificational force on the determiner's category (
DetEvery/DetSome) instead of on a constant in the logical form. The naive one-line unifications both fail: tagging LFs("atom", …)breaks the alpha-renamer (it matches occurrences by tuple head), and a bare-tuple encoding collides a nullary constant("dog_p",)with a canonical bound variable("#v1",).Changes
Picks one discriminated encoding and carries it through categories, LFs, patterns,
_normalise_binders,_category_depth, goal matching, and the public chart API together:("atom", name)("var", name)(ctor, *args)_TERM_TAG_ATOM/_TERM_TAG_VARtags; a compile-time check rejectingatom/varas atom or binder names;_category_depthtreats both tags as depth-0 leaves;_normalise_bindersmatches and rewrites the("var", name)head; goal matching keyed on the atom tag._varcompiler emits("var", name)for collected bound names (via a new__bound_vars__global) and("atom", name)for constructors;substdocs updated.semantics/grammar.md§3a gains the encoding table;examples/montague-nli.mdand the.qvrexample note the resolved limitation; CHANGELOG + mirrored docs changelog.API impact
("#v1",)is now("var", "#v1"), and a nullary LF constant that was("dog_p",)is now("atom", "dog_p"). Consumers that inspect chart LFs must read the tagged forms. Additionally,atomandvarare now reserved and cannot be declared as atom or binder names. Versioned as a minor bump (0.16.0 → 0.17.0) per pre-1.0 SemVer.Tests
pytest -xpasses (2415 non-CLI tests green).test_rule_pattern_matches_nullary_lf_constant(pins pattern↔LF matching),test_reserved_term_tags_rejected_as_atoms; binder / subst / occurrence tests updated to the tagged forms.Documentation
docs/updated.docs/developer/changelog.mdregenerated from the rootCHANGELOG.md.docs/semantics/updated (encoding table ingrammar.md§3a).Checklist
Made with Cursor