runtimeverification / haskell-backend

The symbolic execution engine powering the K Framework
BSD 3-Clause "New" or "Revised" License
210 stars 42 forks source link

Revise different test data generators for `TermLike` #3259

Closed jberthold closed 1 year ago

jberthold commented 2 years ago

We currently have several test data generators that generate similar things, in Test.ConsistentKore and in Test.Kore. The TermLike generator in Test.ConsistentKore has been specialised to actual terms in #3256 but the one in Test.Kore continues to be provided to other modules from Test.Kore.TermLike.

jberthold commented 2 years ago

Test.ConsistentKore

Test.Kore

Test.Kore.Internal.TermLike

Usage (including indirect)

ana-pantilie commented 2 years ago

@ana-pantilie take a look at ^.

@jberthold when you see the simplification timeout happening please record the pattern here.

jberthold commented 2 years ago

Latest observed Timeout

WARNING: unable to simplify pattern
\and{mapSort{}}(
    /* term: */
    /*  */
    \or{mapSort{}}(
        /*  */
        \and{mapSort{}}(
            /* D Spa */
            elementMap{}(
                /* D Sfa Cl */
                sigma{}(
                    /* Fl Fn D Sfa Cl */ d{}(),
                    /* D Sfa Cl */
                    functionalConstr20{}(
                        /* D Sfa Cl */
                        functionalConstr30{}(
                            /* D Sfa Cl */
                            constr10{}(
                                /* D Sfa Cl */
                                functionalConstr30{}(
                                    /* D Sfa Cl */ constr00{}(),
                                    /* D Sfa Cl */
                                    functionalTopConstr20{}(
                                        /* Fl Fn D Sfa Cl */ aTopSort{}(),
                                        /* D Sfa Cl */
                                        constr10{}(/* Fl Fn D Sfa Cl */ a{}())
                                    ),
                                    /* D Sfa Cl */ constr00{}()
                                )
                            ),
                            /* D Sfa Cl */
                            functionalConstr21{}(
                                /* D Sfa Cl */
                                functionalConstr30{}(
                                    /* D Sfa Cl */
                                    constr11{}(
                                        /* Fl Fn D Sfa Cl */
                                        functionalConstr11{}(
                                            /* Fl Fn D Sfa Cl */ e{}()
                                        )
                                    ),
                                    /* D Sfa Cl */
                                    functionalConstr10{}(
                                        /* D Sfa Cl */
                                        constr11{}(/* Fl Fn D Sfa Cl */ b{}())
                                    ),
                                    /* Fl Fn D Sfa Cl */
                                    functionalConstr11{}(
                                        /* Fl Fn D Sfa Cl */
                                        functionalConstr11{}(
                                            /* Fl Fn D Sfa Cl */ a{}()
                                        )
                                    )
                                ),
                                /* Fl Fn D Sfa Cl */ d{}()
                            ),
                            /* Fl Fn D Sfa Cl */ c{}()
                        ),
                        /* D Sfa Cl */ constr00{}()
                    )
                ),
                /* D Sfa Cl */
                functionalConstr30{}(
                    /* D Sfa Cl */
                    functionalConstr30{}(
                        /* D Sfa Cl */
                        constr20{}(
                            /* D Sfa Cl */
                            constr20{}(
                                /* D Sfa Cl */
                                functionalConstr12{}(
                                    /* D Sfa Cl */
                                    constr10{}(/* D Sfa Cl */ constr00{}())
                                ),
                                /* D Sfa Cl */
                                sigma{}(
                                    /* Fl Fn D Sfa Cl */ b{}(),
                                    /* D Sfa Cl */
                                    constr11{}(
                                        /* Fl Fn D Sfa Cl */
                                        functionalConstr11{}(
                                            /* Fl Fn D Sfa Cl */ e{}()
                                        )
                                    )
                                )
                            ),
                            /* D Sfa Cl */
                            functionalConstr20{}(
                                /* D Sfa Cl */
                                functionalConstr21{}(
                                    /* D Sfa Cl */
                                    functionalConstr21{}(
                                        /* Fl Fn D Sfa Cl */ d{}(),
                                        /* D Sfa Cl */ constr00{}()
                                    ),
                                    /* D Sfa Cl */
                                    constr11{}(
                                        /* D Sfa Cl */
                                        constr10{}(/* Fl Fn D Sfa Cl */ a{}())
                                    )
                                ),
                                /* Fl Fn D Sfa Cl */ a{}()
                            )
                        ),
                        /* Fl Fn D Sfa Cl */ d{}(),
                        /* Fl Fn D Sfa Cl */
                        functionalConstr20{}(
                            /* Fl Fn D Sfa Cl */
                            functionalConstr10{}(
                                /* Fl Fn D Sfa Cl */
                                functionalConstr20{}(
                                    /* Fl Fn D Sfa Cl */
                                    sigma{}(
                                        /* Fl Fn D Sfa Cl */
                                        functionalTopConstr21{}(
                                            /* Fl Fn D Sfa Cl */ a{}(),
                                            /* Fl Fn D Sfa Cl */ aTopSort{}()
                                        ),
                                        /* Fl Fn D Sfa Cl */
                                        functionalTopConstr21{}(
                                            /* Fl Fn D Sfa Cl */ b{}(),
                                            /* Fl Fn D Sfa Cl */ aTopSort{}()
                                        )
                                    ),
                                    /* Fl Fn D Sfa Cl */ a{}()
                                )
                            ),
                            /* Fl Fn D Sfa Cl */ d{}()
                        )
                    ),
                    /* Fl Fn D Sfa Cl */
                    functionalConstr10{}(/* Fl Fn D Sfa Cl */ a{}()),
                    /* D Sfa Cl */ constr10{}(/* Fl Fn D Sfa Cl */ c{}())
                )
            ),
            /*  */
            \and{mapSort{}}(
                /* Fn */
                concatMap{}(
                    /* Fn */
                    concatMap{}(
                        /* Fl Fn D */ unitMap{}(),
                        /* Fl Fn D */ unitMap{}()
                    ),
                    /* Fn */
                    concatMap{}(
                        /* Fl Fn D */ unitMap{}(),
                        /* Fn */
                        opaqueMap{}(
                            /* Fn */
                            functionSMT{}(/* Fl Fn D */ functional00{}())
                        )
                    )
                ),
                /*  */
                \and{mapSort{}}(
                    /* D Spa */
                    elementMap{}(
                        /* Fl Fn D Sfa Cl */
                        functionalTopConstr20{}(
                            /* Fl Fn D Sfa Cl */ aTopSort{}(),
                            /* Fl Fn D Sfa Cl */ e{}()
                        ),
                        /* D Sfa Cl */
                        functionalConstr20{}(
                            /* Fl Fn D Sfa Cl */ b{}(),
                            /* D Sfa Cl */
                            functionalConstr30{}(
                                /* Fl Fn D Sfa Cl */ a{}(),
                                /* D Sfa Cl */
                                functionalConstr30{}(
                                    /* Fl Fn D Sfa Cl */
                                    functionalConstr11{}(
                                        /* Fl Fn D Sfa Cl */
                                        functionalConstr30{}(
                                            /* Fl Fn D Sfa Cl */ a{}(),
                                            /* Fl Fn D Sfa Cl */ b{}(),
                                            /* Fl Fn D Sfa Cl */ e{}()
                                        )
                                    ),
                                    /* D Sfa Cl */
                                    constr10{}(
                                        /* D Sfa Cl */
                                        constr20{}(
                                            /* Fl Fn D Sfa Cl */ e{}(),
                                            /* Fl Fn D Sfa Cl */ d{}()
                                        )
                                    ),
                                    /* Fl Fn D Sfa Cl */
                                    functionalTopConstr21{}(
                                        /* Fl Fn D Sfa Cl */ b{}(),
                                        /* Fl Fn D Sfa Cl */ aTopSort{}()
                                    )
                                ),
                                /* D Sfa Cl */
                                sigma{}(
                                    /* D Sfa Cl */
                                    constr10{}(/* Fl Fn D Sfa Cl */ c{}()),
                                    /* Fl Fn D Sfa Cl */
                                    functionalTopConstr20{}(
                                        /* Fl Fn D Sfa Cl */ aTopSort{}(),
                                        /* Fl Fn D Sfa Cl */ b{}()
                                    )
                                )
                            )
                        )
                    ),
                    /* D */
                    \or{mapSort{}}(
                        /*  */
                        \and{mapSort{}}(
                            /* D */
                            \or{mapSort{}}(
                                /* Fn Spa */
                                opaqueMap{}(/* Fl Fn D Sfa Cl */ c{}()),
                                /* Fl Fn D */ unitMap{}()
                            ),
                            /*  */
                            opaqueMap{}(
                                /*  */
                                functional11{}(
                                    /*  */ injective11{}(/* Fn */ cf{}())
                                )
                            )
                        ),
                        /* D Spa */
                        elementMap{}(
                            /* D Sfa Cl */
                            constr11{}(
                                /* D Sfa Cl */
                                functionalConstr30{}(
                                    /* D Sfa Cl */ constr00{}(),
                                    /* Fl Fn D Sfa Cl */
                                    functionalConstr21{}(
                                        /* Fl Fn D Sfa Cl */ e{}(),
                                        /* Fl Fn D Sfa Cl */ d{}()
                                    ),
                                    /* Fl Fn D Sfa Cl */
                                    functionalTopConstr20{}(
                                        /* Fl Fn D Sfa Cl */ aTopSort{}(),
                                        /* Fl Fn D Sfa Cl */ a{}()
                                    )
                                )
                            ),
                            /* D Sfa Cl */
                            functionalTopConstr21{}(
                                /* D Sfa Cl */
                                constr20{}(
                                    /* D Sfa Cl */
                                    functionalTopConstr21{}(
                                        /* D Sfa Cl */
                                        constr11{}(/* Fl Fn D Sfa Cl */ e{}()),
                                        /* Fl Fn D Sfa Cl */ aTopSort{}()
                                    ),
                                    /* Fl Fn D Sfa Cl */ b{}()
                                ),
                                /* Fl Fn D Sfa Cl */ aTopSort{}()
                            )
                        )
                    )
                )
            )
        ),
        /*  */
        concatMap{}(
            /*  */
            concatMap{}(
                /* D */
                \or{mapSort{}}(
                    /* Fl Fn D Spa */
                    elementMap{}(
                        /* Fl Fn D Sfa Cl */ d{}(),
                        /* Fl Fn D Sfa Cl */ b{}()
                    ),
                    /*  */
                    concatMap{}(
                        /*  */
                        \and{mapSort{}}(
                            /*  */
                            \and{mapSort{}}(
                                /*  */
                                \and{mapSort{}}(
                                    /* Fl Fn D */ unitMap{}(),
                                    /* D */
                                    \or{mapSort{}}(
                                        /* Fl Fn D */ unitMap{}(),
                                        /* Fn */
                                        concatMap{}(
                                            /* Fl Fn D */ unitMap{}(),
                                            /* Fl Fn D */ unitMap{}()
                                        )
                                    )
                                ),
                                /* Fn Spa */
                                opaqueMap{}(/* Fl Fn D Sfa Cl */ c{}())
                            ),
                            /*  */
                            concatMap{}(
                                /* Fn Spa */
                                opaqueMap{}(/* Fl Fn D Sfa Cl */ d{}()),
                                /*  */
                                concatMap{}(
                                    /* Fl Fn D Spa */
                                    elementMap{}(
                                        /* Fl Fn D Sfa Cl */ b{}(),
                                        /* Fl Fn D Sfa Cl */
                                        sigma{}(
                                            /* Fl Fn D Sfa Cl */ d{}(),
                                            /* Fl Fn D Sfa Cl */ d{}()
                                        )
                                    ),
                                    /*  */
                                    \and{mapSort{}}(
                                        /* Fn */ opaqueMap{}(/* Fn */ ch{}()),
                                        /* Fn */
                                        concatMap{}(
                                            /* Fl Fn D */ unitMap{}(),
                                            /* Fl Fn D */ unitMap{}()
                                        )
                                    )
                                )
                            )
                        ),
                        /*  */
                        \and{mapSort{}}(
                            /*  */
                            opaqueMap{}(
                                /*  */
                                \and{testSort{}}(
                                    /* Fn */ ch{}(),
                                    /* Fn */
                                    functionalConstr11{}(
                                        /* Fn */
                                        constrFunct20TestMap{}(
                                            /* Fn */ ch{}(),
                                            /* Fl Fn D */ unitMap{}()
                                        )
                                    )
                                )
                            ),
                            /* D Spa */
                            elementMap{}(
                                /* D Sfa Cl */
                                functionalConstr30{}(
                                    /* Fl Fn D Sfa Cl */
                                    functionalConstr30{}(
                                        /* Fl Fn D Sfa Cl */ b{}(),
                                        /* Fl Fn D Sfa Cl */
                                        functionalTopConstr21{}(
                                            /* Fl Fn D Sfa Cl */ e{}(),
                                            /* Fl Fn D Sfa Cl */ aTopSort{}()
                                        ),
                                        /* Fl Fn D Sfa Cl */
                                        sigma{}(
                                            /* Fl Fn D Sfa Cl */ c{}(),
                                            /* Fl Fn D Sfa Cl */ c{}()
                                        )
                                    ),
                                    /* D Sfa Cl */
                                    constr20{}(
                                        /* D Sfa Cl */
                                        constr11{}(/* Fl Fn D Sfa Cl */ a{}()),
                                        /* Fl Fn D Sfa Cl */ c{}()
                                    ),
                                    /* D Sfa Cl */
                                    constr20{}(
                                        /* D Sfa Cl */
                                        constr11{}(/* Fl Fn D Sfa Cl */ d{}()),
                                        /* D Sfa Cl */
                                        functionalConstr21{}(
                                            /* Fl Fn D Sfa Cl */ a{}(),
                                            /* D Sfa Cl */ constr00{}()
                                        )
                                    )
                                ),
                                /* Fl Fn D Sfa Cl */ d{}()
                            )
                        )
                    )
                ),
                /* Fl Fn D */ unitMap{}()
            ),
            /* D */
            \or{mapSort{}}(
                /*  */
                concatMap{}(
                    /*  */
                    concatMap{}(
                        /*  */
                        concatMap{}(
                            /*  */
                            \and{mapSort{}}(
                                /* Fl Fn D */ unitMap{}(),
                                /* D Spa */
                                elementMap{}(
                                    /* D Sfa Cl */
                                    functionalConstr30{}(
                                        /* D Sfa Cl */
                                        constr11{}(/* Fl Fn D Sfa Cl */ b{}()),
                                        /* Fl Fn D Sfa Cl */
                                        functionalConstr12{}(
                                            /* Fl Fn D Sfa Cl */ e{}()
                                        ),
                                        /* D Sfa Cl */
                                        constr10{}(/* D Sfa Cl */ constr00{}())
                                    ),
                                    /* Fl Fn D Sfa Cl */ e{}()
                                )
                            ),
                            /*  */
                            concatMap{}(
                                /*  */
                                concatMap{}(
                                    /*  */
                                    concatMap{}(
                                        /* Fn */
                                        opaqueMap{}(
                                            /* Fl Fn D */ functional00{}()
                                        ),
                                        /* D */
                                        \or{mapSort{}}(
                                            /* Fl Fn D */ unitMap{}(),
                                            /* Fl Fn D */ unitMap{}()
                                        )
                                    ),
                                    /*  */
                                    \and{mapSort{}}(
                                        /* Fl Fn D */ unitMap{}(),
                                        /* D */
                                        \or{mapSort{}}(
                                            /* Fl Fn D */ unitMap{}(),
                                            /* Fl Fn D */ unitMap{}()
                                        )
                                    )
                                ),
                                /* Spa */
                                concatMap{}(
                                    /* D Spa */
                                    elementMap{}(
                                        /* Fl Fn D Sfa Cl */ e{}(),
                                        /* D Sfa Cl */
                                        constr10{}(/* Fl Fn D Sfa Cl */ d{}())
                                    ),
                                    /* Fn Spa */
                                    opaqueMap{}(
                                        /* Fl Fn D Spa */
                                        functional10{}(
                                            /* Fl Fn D Sfa Cl */ c{}()
                                        )
                                    )
                                )
                            )
                        ),
                        /* Fn Spa */ opaqueMap{}(/* Fl Fn D Sfa Cl */ b{}())
                    ),
                    /* Fl Fn D */ unitMap{}()
                ),
                /* Fl Fn D */ unitMap{}()
            )
        )
    ),
\and{mapSort{}}(
    /* predicate: */
    /*  */
    \in{testSort{}, mapSort{}}(
        /* Fn */
        functionalConstr10{}(
            /* Fn */
            sigma{}(
                /* Fl Fn D Sfa Cl */ e{}(),
                /* Fn */
                function20MapTest{}(
                    /* Fl Fn D */ unitMap{}(),
                    /* Fn */
                    constrFunct20TestMap{}(
                        /* Fn */ f{}(/* Fn */ cg{}()),
                        /* Fn */
                        concatMap{}(
                            /* Fl Fn D */ unitMap{}(),
                            /* Fn */ opaqueMap{}(/* Fn */ ch{}())
                        )
                    )
                )
            )
        ),
        /* Fl Fn D Spa */ functional11{}(/* Fl Fn D Sfa Cl */ c{}())
    ),
    /* substitution: */
    \top{mapSort{}}()
))
TEST RUN PASSED

Duration:  35.251s
Passed:    5149
ana-pantilie commented 2 years ago

I found another instance of the failing property test, on https://github.com/runtimeverification/haskell-backend/pull/3276/commits/3c432059d822cc73f12066d89c56913441d47228.

Test suite kore-test: RUNNING...
↓ test/Driver.hs
↓ Test
↓ Kore
↓ Rewrite
↓ MockSymbols
↓ can generate consistent terms for all given sorts
↓ "mapSort"
✗ Size 9

  ✗ Size 9 failed at test/Test/Kore/Rewrite/MockSymbols.hs:2371:56
    after 1 test.

         ┏━━ test/Test/Kore/Rewrite/MockSymbols.hs ━━━
    2359 ┃ test_canGenerateConsistentTerms :: TestTree
    2360 ┃ test_canGenerateConsistentTerms =
    2361 ┃     testGroup "can generate consistent terms for all given sorts" $
    2362 ┃         map mkTest testSorts
    2363 ┃   where
    2364 ┃     testSorts = ConsistentKore.allSorts generatorSetup
    2365 ┃     sizes = map Range.Size [1 .. 10]
    2366 ┃ 
    2367 ┃     mkTest :: Sort -> TestTree
    2368 ┃     mkTest sort@(SortActualSort SortActual{sortActualName = InternedId{getInternedId}}) =
    2369 ┃         testGroup
    2370 ┃             (show getInternedId)
    2371 ┃             [ testProperty (show size) . withTests 1 . property $ do
         ┃             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         ┃             │ ━━━ Exception (ErrorCall) ━━━
         ┃             │ Cannot generate terms for SortActualSort (SortActual {sortActualName = InternedId {getInternedId = "mapSort", internedIdLocation = AstLocationTest}, sortActualSorts = []})
         ┃             │ CallStack (from HasCallStack):
         ┃             │   error, called at test/Test/ConsistentKore.hs:231:20 in main:Test.ConsistentKore
    2372 ┃                 r <-
    2373 ┃                     forAll . Gen.resize size $
    2374 ┃                         ConsistentKore.runKoreGen
    2375 ┃                             generatorSetup
    2376 ┃                             (ConsistentKore.termLikeGenWithSort sort)
    2377 ┃                 -- just test that this works
    2378 ┃                 Hedgehog.diff 0 (<) (length $ show r)
    2379 ┃             | size <- sizes
    2380 ┃             ]
    2381 ┃     mkTest SortVariableSort{} =
    2382 ┃         error "Found a sort variable in the generator setup"

    This failure can be reproduced by running:
    > recheck (Size 0) (Seed 4041433232755941645 627379784105931223) Size 9

Use '--hedgehog-replay "Size 0 Seed 4041433232755941645 627379784105931223"' to reproduce.