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 tree (NT String tree tree)
                  (T String String))

(function getString (i64) String :no-merge)

(relation Prod (String String String))
(relation End (String String))


(relation P (i64 i64 String))
(function B (i64 i64 String) tree :no-merge)

(rule ((End a s)
       (= s (getString pos)))
      ((P 1 pos a)
       (set (B 1 pos a) (T a s)))) 

(rule ((Prod a b c) ;; a -> bc
       (P p1 s b)
       (P p2 (+ s p1) c))
      ((P (+ p1 p2) s a)))


(rule ((Prod a b c)
       (= f1 (B p1 s b))
       (= f2 (B p2 (+ s p1) c)))
      ((set (B (+ p1 p2) s a) 
       (NT a f1 f2))))


(input Prod "./tests/cykjson_Prod.csv")
(input End "./tests/cykjson_End.csv")

; small size 801
(input getString "./tests/cykjson_small_token.csv")

; medium size 7821 but runs for 2 min.
;(input getString "./tests/cykjson_medium_token.csv")

(run 10000)

(let $test1 (B 801 1 "VAL"))

(check (P 801 1 "VAL"))