.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/bool.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_bool.py: Boolean data type example and test ================================== .. GENERATED FROM PYTHON SOURCE LINES 5-42 .. code-block:: Python from __future__ import annotations from egglog import * T = Bool(True) F = Bool(False) egraph = EGraph() egraph.check(eq(T & T).to(T)) egraph.check(eq(T & F).to(F)) egraph.check(eq(T | F).to(T)) egraph.check((T | F) != F) egraph.check(eq(i64(1).bool_lt(2)).to(T)) egraph.check(eq(i64(2).bool_lt(1)).to(F)) egraph.check(eq(i64(1).bool_lt(1)).to(F)) egraph.check(eq(i64(1).bool_le(2)).to(T)) egraph.check(eq(i64(2).bool_le(1)).to(F)) egraph.check(eq(i64(1).bool_le(1)).to(T)) R = egraph.relation("R", i64) @egraph.function def f(i: i64Like) -> Bool: # type: ignore[empty-body] ... i = var("i", i64) egraph.register( rule(R(i)).then(set_(f(i)).to(T)), R(i64(0)), ) egraph.run(3) egraph.check(eq(f(0)).to(T)) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.017 seconds) .. _sphx_glr_download_auto_examples_bool.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: bool.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: bool.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_