Repository navigation
Conversation
LAGraphX.h documents constraint 1 of indexed rules: a symbol indexed in one rule must be indexed in every rule where it appears. It was not checked: a grammar that breaks it gets a correct answer without OPT_BLOCK and a silently wrong one with it. LAGraph_CFL_reachability_adv now returns GrB_INVALID_VALUE for such a grammar, right after the existing rule validation.
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.
LAGraphX.hdocuments a constraint on indexed rules: "1) If symbol A is indexed in one rule, itmust be indexed in all rules where it appears."
LAGraph_CFL_reachability_advdoes not check it.A grammar that breaks it gets a correct answer without
OPT_BLOCK, and a silently wrong one withit.
1. See it
Before this change:
After it, both runs return
GrB_INVALID_VALUEwith the messageSymbol 6 is used both in an indexed family and alone.:2. The change
find_mixed_symbolmarks every symbol as used alone and/or as a member of an indexed family(
base .. base+indexed_count-1), and returns one symbol that is both.LAGraph_CFL_reachability_advcalls it right after the existing rule validation, and returnsGrB_INVALID_VALUEwhen such a symbol exists. Valid grammars behave exactly as before.CFL_reachability_mixed_indexed_symbolintest_CFL_reachability_adv.c. With therule
X -> [_0it expects the error for all 16 masks; without that rule it expects(0, 2)forall 16 masks.
3. Why
OPT_BLOCKgoes wrongWith
OPT_BLOCK,get_new_symbolsgives each symbol one representation: the one from the firstrule that mentions it.
X -> [_0comes first, so[_0becomes a plain symbol, and the block forthe family
[_iis never built.C_i -> [_ithen reads only[_0, and the pair over[_1 ]_1is lost without an error. With other rule orders the same grammar fails with
-3from a laterstep, or gives the plain rule the whole block.
Testing
test_CFL_reachability_adv:CFG_reachability_null_pointersfails onstrstr(msg, "Adjacency matrices with these indexes are null: 0, 1"). It fails the same way on the branch without this change.