egglog 2.0.0

egglog is a language that combines the benefits of equality saturation and datalog. It can be used for analysis, optimization, and synthesis of programs. It is the successor to the popular rust library egg.
Documentation
(datatype Math
  (Num i64)
  (Var String)
  (Mul Math Math))

(function hi (Math) i64 :merge (min old new))
(function lo (Math) i64 :merge (max old new))

(rule ((= mul (Mul a b))
       (= loa (lo a))
       (= lob (lo b))
       (= hia (hi a))
       (= hib (hi b))
      )
      ((set (lo mul) 
          (min (min (* loa lob) (* loa hib))
               (min (* hia lob) (* hia hib))))))

(let $x (Var "x"))
(let $e (Mul $x $x))

(set (lo $x) -10)
(set (hi $x) 10)

(run 1)

(check (= (lo $e) -100))

(rule ((= mul (Mul a a))
       (= loa (lo a))
      )
      ((set (lo mul) (* loa loa))))

(run 1)
(check (= (lo $e) 100))

;; testing extraction of rationals
(extract (lo $e))