Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test_pattern_match_edgecases.jl] Add stronger HardFail inference for pattern_match on 3 or more VarNodes #49

Open
Whebon opened this issue May 6, 2024 · 0 comments

Comments

@Whebon
Copy link
Contributor

Whebon commented May 6, 2024

Variable :x is assigned to the first RuleNode r1 encountered.
Other matches with variable :x are then pairwise compared to RuleNode r1.
Any SoftFails involved are not combined to a HardFail.
The tests below demonstrate HardFails that are not caught by the pattern_match:

    @testset "3 VarNodes: pairwise Softfail, triplewise HardFail" begin
        #TODO: this test fails because, in the current implementation, variable comparisons are done pairwise
        # domains of holes within vars should be updated for stronger inference
        rn = RuleNode(4, [
            RuleNode(4, [Hole(BitVector((1, 1, 0))), Hole(BitVector((0, 1, 1)))]), 
            Hole(BitVector((1, 0, 1)))
        ])
        mn = RuleNode(4, [
            RuleNode(4, [VarNode(:x), VarNode(:x)]),
            VarNode(:x)
        ])
        @test pattern_match(rn, mn) isa HerbConstraints.PatternMatchHardFail
    end

    @testset "3 VarNodes: HardFail on instance 2 and 3" begin
        #TODO: this test fails because, in the current implementation, only (1, 2) and (1, 3) are compared
        # domains of holes within vars should be updated for stronger inference
        rn = RuleNode(4, [
            RuleNode(4, [Hole(BitVector((1, 1, 1))), RuleNode(1)]), 
            RuleNode(2)
        ])
        mn = RuleNode(4, [
            RuleNode(4, [VarNode(:x), VarNode(:x)]),
            VarNode(:x)
        ])
        @test pattern_match(rn, mn) isa HerbConstraints.PatternMatchHardFail
    end

Why is this not here yet

Forbidden constraints with 3 or more occurrences of the same VarNode are considered an edgecase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant