Schedule demo#

%3 outer_cluster_right-5871781006564002453-value cluster_right-5871781006564002453-value outer_cluster_left-17615343019692007359-value cluster_left-17615343019692007359-value outer_cluster_left-10912160959110460649-value cluster_left-10912160959110460649-value outer_cluster_left-11743562013128004906-value cluster_left-11743562013128004906-value outer_cluster_right-4208978898528913939-value cluster_right-4208978898528913939-value outer_cluster_right-0-value cluster_right-0-value outer_cluster_left-10080759905092916392-value cluster_left-10080759905092916392-value outer_cluster_right-11743562013128004906-value cluster_right-11743562013128004906-value outer_cluster_right-10912160959110460649-value cluster_right-10912160959110460649-value outer_cluster_right-17615343019692007359-value cluster_right-17615343019692007359-value outer_cluster_left-5871781006564002453-value cluster_left-5871781006564002453-value outer_cluster_right-10080759905092916392-value cluster_right-10080759905092916392-value outer_cluster_left-0-value cluster_left-0-value outer_cluster_left-5040379952546458196-value cluster_left-5040379952546458196-value outer_cluster_left-3377577844511369682-value cluster_left-3377577844511369682-value outer_cluster_right-5040379952546458196-value cluster_right-5040379952546458196-value outer_cluster_right-15952540911656918845-value cluster_right-15952540911656918845-value outer_cluster_left-16783941965674463102-value cluster_left-16783941965674463102-value outer_cluster_left-4208978898528913939-value cluster_left-4208978898528913939-value outer_cluster_left-15952540911656918845-value cluster_left-15952540911656918845-value outer_cluster_right-16783941965674463102-value cluster_right-16783941965674463102-value outer_cluster_i64-11743562013128004906 cluster_i64-11743562013128004906 outer_cluster_i64-0 cluster_i64-0 outer_cluster_i64-17615343019692007359 cluster_i64-17615343019692007359 outer_cluster_i64-5040379952546458196 cluster_i64-5040379952546458196 outer_cluster_i64-3377577844511369682 cluster_i64-3377577844511369682 outer_cluster_i64-15952540911656918845 cluster_i64-15952540911656918845 outer_cluster_i64-10912160959110460649 cluster_i64-10912160959110460649 outer_cluster_i64-10080759905092916392 cluster_i64-10080759905092916392 outer_cluster_i64-5871781006564002453 cluster_i64-5871781006564002453 outer_cluster_i64-4208978898528913939 cluster_i64-4208978898528913939 outer_cluster_i64-16783941965674463102 cluster_i64-16783941965674463102 right-5871781006564002453:s->i64-5871781006564002453 left-17615343019692007359:s->i64-17615343019692007359 left-10912160959110460649:s->i64-10912160959110460649 left-11743562013128004906:s->i64-11743562013128004906 right-4208978898528913939:s->i64-4208978898528913939 right-0:s->i64-0 left-10080759905092916392:s->i64-10080759905092916392 right-11743562013128004906:s->i64-11743562013128004906 right-10912160959110460649:s->i64-10912160959110460649 right-17615343019692007359:s->i64-17615343019692007359 left-5871781006564002453:s->i64-5871781006564002453 right-10080759905092916392:s->i64-10080759905092916392 left-0:s->i64-0 left-5040379952546458196:s->i64-5040379952546458196 left-3377577844511369682:s->i64-3377577844511369682 right-5040379952546458196:s->i64-5040379952546458196 right-15952540911656918845:s->i64-15952540911656918845 left-16783941965674463102:s->i64-16783941965674463102 left-4208978898528913939:s->i64-4208978898528913939 left-15952540911656918845:s->i64-15952540911656918845 right-16783941965674463102:s->i64-16783941965674463102 right-5871781006564002453 right i64-5871781006564002453 1 right-5871781006564002453-value () left-17615343019692007359 left i64-17615343019692007359 3 left-17615343019692007359-value () left-10912160959110460649 left i64-10912160959110460649 5 left-10912160959110460649-value () left-11743562013128004906 left i64-11743562013128004906 2 left-11743562013128004906-value () right-4208978898528913939 right i64-4208978898528913939 7 right-4208978898528913939-value () right-0 right i64-0 0 right-0-value () left-10080759905092916392 left i64-10080759905092916392 8 left-10080759905092916392-value () right-11743562013128004906 right right-11743562013128004906-value () right-10912160959110460649 right right-10912160959110460649-value () right-17615343019692007359 right right-17615343019692007359-value () left-5871781006564002453 left left-5871781006564002453-value () right-10080759905092916392 right right-10080759905092916392-value () left-0 left left-0-value () left-5040379952546458196 left i64-5040379952546458196 4 left-5040379952546458196-value () left-3377577844511369682 left i64-3377577844511369682 10 left-3377577844511369682-value () right-5040379952546458196 right right-5040379952546458196-value () right-15952540911656918845 right i64-15952540911656918845 9 right-15952540911656918845-value () left-16783941965674463102 left i64-16783941965674463102 6 left-16783941965674463102-value () left-4208978898528913939 left left-4208978898528913939-value () left-15952540911656918845 left left-15952540911656918845-value () right-16783941965674463102 right right-16783941965674463102-value ()


from __future__ import annotations

from egglog import *

left = relation("left", i64)
right = relation("right", i64)


x, y = vars_("x y", i64)
step_left = ruleset(
    rule(
        left(x),
        right(x),
    ).then(left(x + 1)),
)
step_right = ruleset(
    rule(
        left(x),
        right(y),
        eq(x).to(y + 1),
    ).then(right(x)),
)

egraph = EGraph()
egraph.register(left(i64(0)), right(i64(0)))
egraph.run((step_right.saturate() + step_left.saturate()) * 10)
egraph.check(left(i64(10)), right(i64(9)))
egraph.check_fail(left(i64(11)), right(i64(10)))
egraph

Total running time of the script: (0 minutes 0.576 seconds)

Gallery generated by Sphinx-Gallery