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
;;;;;;;;;;;;;;;;;;
;; From repro-constraineq

;; repro-constraineq
(push)
(rule ((= x 1) (= y x) (= z y)) ())
(run 1)
(pop)

;; repro-constraineq2
(push)
(rule ((= x 1) (= y x)) ())
(run 1)
(pop)

;; repro-constraineq3
(push)
(relation f (i64))

(rule ((= x 1)
       (= x 2))
      ((f x)))
      
(run 1)
(print-function f 10)
(pop)

;;;;;;;;;;;;;;;;;;
;; Atoms need to be order-insensitive

;; Issue #196
(push)
(relation R (i64))

(rule 
  ((= x y)
   (= y 1)) 
  ((R x)))
(run 1)
(check (R 1))
(pop)

(push)
(relation R (i64))

(rule 
  ((= x (+ y 1))
   (= y 1)) 
  ((R x)))
(run 1)
(check (R 2))
(pop)

;; Issue #80
(push)
(datatype TYPE)
(datatype TERM)
(constructor type (TERM) TYPE)
(constructor Ob () TYPE)
(constructor Hom (TERM TERM) TYPE)

(constructor id (TERM) TERM)
(rule ((type (id A)))
      ((type A)))
(rewrite (type (id A)) 
         (Hom A A) 
    :when ((= (type A) (Ob))))

(constructor compose (TERM TERM) TERM)
(rule ((type (compose f g)))  
      ((type f) 
       (type g)))
(rewrite (type (compose f g)) 
         (Hom A C) 
    :when ((= (type f) (Hom A B)) 
           (= (type g) (Hom B C))))

(birewrite (compose (compose f g) h) 
           (compose f (compose g h)) 
    :when ((= (type A) (Ob)) 
           (= (type B) (Ob))
           (= (type C) (Ob))
           (= (type D) (Ob))
           (= (type f) (Hom A B))
           (= (type g) (Hom B C))
           (= (type h) (Hom C D))))
(birewrite (compose f (id B)) f 
    :when ((= (type A) (Ob)) 
           (= (type B) (Ob))
           (= (type f) (Hom A B))))
(birewrite (compose (id A) f) f 
    :when ((= (type A) (Ob)) 
           (= (type B) (Ob))
           (= (type f) (Hom A B))))

(constructor AConst () TERM)
(let $A (AConst))
(constructor BConst () TERM)
(let $B (BConst))
(constructor fConst () TERM)
(let $f (fConst))
(constructor gConst () TERM)
(let $g (gConst))
(let $fog (compose $g $f))
(union (type $f) (Hom $A $B))
(union (type $g) (Hom $B $A))
(union (type $A) (Ob))
(union (type $B) (Ob))
(type $fog)
(run 10)
(print-function type 10)
(check (= (type $f) 
          (type (compose (id $A) 
                         (compose $f (id $B))))))
(check (= (type $fog)
          (Hom $B $B)))
(pop)


;;;;;;;;;;;;;;;;;;
;; Finding the right type in case of container types and primitives

;; Issue #113

(push)
(sort MyMap (Map i64 String))
(sort MyMap1 (Map i64 i64))

(let $my_map1 (map-insert (map-empty) 1 "one"))
(pop)

(push)
(sort MyMap1 (Map i64 i64))
(sort MyMap (Map i64 String))

(let $my_map1 (map-insert (map-empty) 1 "one"))
(pop)