[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-detail-83574-en":3,"doc-seo-83574-105":28,"detail-sidebar-cat-0-en-105":89},{"code":4,"msg":5,"data":6},0,"success",{"doc_id":7,"user_id":8,"nickname":9,"user_avatar":10,"doc_module":4,"category_id":11,"category_name":12,"doc_title":13,"doc_description":14,"doc_content":15,"file_id":16,"file_url":17,"file_type":18,"file_size":19,"view_count":20,"is_deleted":4,"is_public":20,"is_downloadable":20,"audit_status":20,"page_count":21,"language":22,"language_code":23,"site_id":24,"html_lang":23,"table_of_contents":25,"faqs":26,"seo_title":13,"seo_description":14,"update_tm":27,"read_time":11},83574,34359740700684,"Finn","https://ap-avatar.wpscdn.com/avatar/1f400023980c374ae676?_k=1777273430885731487",8,"Research & Report","Folding an e-graph in pure egglog","Folding a recursive data structure, also known as catamorphism, is a key operation in functional programming, enabling declarative computation by composing solutions of subproblems into a parent solution. For e-graphs, folding can provide memoization and reduce computation by operating on e-classes rather than concrete sub-terms. This short report presents an initial, reusable implementation of catamorphism in pure egglog. It focuses on staging inference rules to avoid re-propagation of updated values and addresses rule scheduling for correct dependency order.","Folding an e-graph in pure egglog  \nZeng Ren  \nEPFL  \nAbstract  \nFolding over a recursive data structure (also known as“catamorphism”) is an essential operation in functional programming [1] . It allows one to declaratively define arecursive computation by focusing on how solutions of subproblems are combined into the solution of the parent problem. Folding in the context of e-graphs can have several benefits. Not only do we get memoization for free, but also computation is drastically reduced since the subproblems are defined over e-classes as opposed to concrete sub-terms. This short report presents our initial attempt at defining and implementing catamorphism, a general notion of a fold, in pure egglog. We discuss a reusable implementation trick to stage the inference rules so that there is no re-propagation of updated values.  \n1 Introduction  \nMany analyses on e-graph over a least fixed-point type Fix 􀀄 are defined as a mutual recursion between e-node values and e-class values. 1 The e-node computation 􀀅 :  \n􀀄 􀀈 → 􀀈 specifies how values of child e-class is combined into the value of the e-node, while the e-class computation 􀀊 : Multiset 􀀈 → 􀀈 specifies how a collection of e-node values is combined into the values of the e-class consisting of thesee-nodes.  \nThis abstract description fits many useful bottom-up analyses on e-graphs. For example, in Babble’s e-class antiunification algorithm [2], the 􀀊 part corresponds to the Dominant function, which filters a collection of patterns based on a partial order, while 􀀅 part follows from traditional term-wise anti-unification. Another example is in Babble’s cost-set analysis algorithm, where the 􀀊 part corresponds to the partial order reduction followed by top-k pruning, while the 􀀅 part carries the core logic of reasoning about the set of candidate library and its use cost. These two algorithms were originally implemented using egg [3] (and before egglog was published) while the bulk of the algorithms logic  \nThis work is licensed under a Creative Commons Attribution International 4.0 License.  \n, , , .  \n©︎ Copyright held by the owner/author(s) . ACM ISBN 979-8-0000-0000-0/00/00…$15.00  \n1This is natural since each e-node points to e-classes, which further contains multiple e-nodes.  \nMaddy Bowers  \nMIT  \nis in rust. Can we implement such algorithms declarativelyin pure egglog[4]?  \nCurrent egglog is built-on the assumption that the e-class analysis value is defined as the aggregated e-node values under a custom binary merge function. But there are some analysis on e-classes, besides the two examples from Babble that depends on all the its e-node analysis values.  \nHere we sketch out an implementation of such general catamorphisms on e-graphs in pure egglog.  \n2 Folding an e-graph  \nWe need to split e-class analysis 􀀑 into two functions: 􀀑Final denotes the finalized analysis of an e-class (the result of after the merge function 􀀊), and 􀀑on-going denotes the building up multi-set of e-node analysis of a e-class.  \nFor the e-node values function 􀀅 , it can be translated toa collection of egglog rules (see Figure 1), whose premises establish binding to the values for sub-term (e-class), and whose action inserts a e-node analysis value to its corresponding e-class aggregated value set. 2 There will be a rule for each constructor of the datatype, mirroring the different cases for of the function 􀀅 to pattern match on. Let’s call this rule set “inductive-rules”.  \n􀀗 = 􀀙Fix 􀀚 1 … 􀀚 􀀝  \n􀀞 1 = 􀀑Final 􀀚 1 ⋮  \n 􀀞􀀝 = 􀀑Final 􀀚 􀀝  inductive  \n􀀑on-going 􀀗  {􀀅 (􀀙Base 􀀞 1 … 􀀞􀀝)}  \nFigure 1: A first step translation of e-node value computation (parametrized by an algebra 􀀅) to an egglog rule. 􀀙Fix as a constructor of the fixed-point type, whose base functor  \nhas the corresponding constructor 􀀙Base  \nFor the e-class value computation, we also have a simple translation (see Figure 2) . Let’s call this rule set “resolverules” as it resolves the functional dependency for egglog functions.  \n2It mi","cbCaidvDtobOZzch","https://ap.wps.com/l/cbCaidvDtobOZzch","pdf",154026,1,3,"English","en",105,"# Introduction\n# Folding an e-graph\n## Inductive-rules\n## Resolve-rules\n# Rule scheduling","[{\"question\":\"What problem does folding an e-graph address in the context of catamorphism?\",\"answer\":\"It defines how to implement catamorphism over e-graphs by combining analysis results from child e-classes into parent e-class values, enabling declarative recursive computation.\"},{\"question\":\"How does the document propose separating e-class analysis into finalized and ongoing parts?\",\"answer\":\"It splits e-class analysis into a Final function (after applying the merge function) and an on-going function that accumulates the multiset of e-node analysis values belonging to that e-class.\"},{\"question\":\"Why is careful rule scheduling necessary for the resolve rules?\",\"answer\":\"Resolve rules must trigger only after all e-node values for an e-class are computed; otherwise, the system may propagate incorrect intermediate values. The document introduces an AllAnalyzed relation to enforce this dependency.\"}]",1784188936,{"code":4,"msg":29,"data":30},"ok",{"site_id":24,"language":23,"slug":31,"title":13,"keywords":32,"description":14,"schema_data":33,"social_meta":84,"head_meta":86,"extra_data":88,"updated_unix":27},"folding-an-e-graph-in-pure-egglog","",{"@graph":34,"@context":83},[35,51,66],{"@type":36,"itemListElement":37},"BreadcrumbList",[38,42,46,48],{"item":39,"name":40,"@type":41,"position":20},"https://docshare.wps.com","Home","ListItem",{"item":43,"name":44,"@type":41,"position":45},"https://docshare.wps.com/document/","Document",2,{"item":47,"name":12,"@type":41,"position":21},"https://docshare.wps.com/document/research-report/",{"item":49,"name":13,"@type":41,"position":50},"https://docshare.wps.com/document/folding-an-e-graph-in-pure-egglog/83574/",4,{"url":49,"name":13,"@type":52,"author":53,"headline":13,"publisher":55,"fileFormat":58,"inLanguage":23,"description":14,"dateModified":59,"datePublished":60,"encodingFormat":58,"isAccessibleForFree":61,"interactionStatistic":62},"DigitalDocument",{"name":9,"@type":54},"Person",{"url":39,"name":56,"@type":57},"DocShare","Organization","application/pdf","2026-07-18","2026-07-16",true,{"@type":63,"interactionType":64,"userInteractionCount":20},"InteractionCounter",{"@type":65},"ViewAction",{"@type":67,"mainEntity":68},"FAQPage",[69,75,79],{"name":70,"@type":71,"acceptedAnswer":72},"What problem does folding an e-graph address in the context of catamorphism?","Question",{"text":73,"@type":74},"It defines how to implement catamorphism over e-graphs by combining analysis results from child e-classes into parent e-class values, enabling declarative recursive computation.","Answer",{"name":76,"@type":71,"acceptedAnswer":77},"How does the document propose separating e-class analysis into finalized and ongoing parts?",{"text":78,"@type":74},"It splits e-class analysis into a Final function (after applying the merge function) and an on-going function that accumulates the multiset of e-node analysis values belonging to that e-class.",{"name":80,"@type":71,"acceptedAnswer":81},"Why is careful rule scheduling necessary for the resolve rules?",{"text":82,"@type":74},"Resolve rules must trigger only after all e-node values for an e-class are computed; otherwise, the system may propagate incorrect intermediate values. The document introduces an AllAnalyzed relation to enforce this dependency.","https://schema.org",{"og:url":49,"og:type":85,"og:title":13,"og:site_name":56,"og:description":14},"article",{"robots":87,"canonical":49},"index,follow",{"doc_id":7,"site_id":24},{"code":4,"msg":5,"data":90},[91,95,99,103,108,113,118,121,126,129,133],{"id":20,"doc_module":4,"doc_module_name":44,"category_name":92,"show_sort_weight":93,"slug":94},"Story & Novel",90,"story-novel",{"id":45,"doc_module":4,"doc_module_name":44,"category_name":96,"show_sort_weight":97,"slug":98},"Literature",80,"literature",{"id":50,"doc_module":4,"doc_module_name":44,"category_name":100,"show_sort_weight":101,"slug":102},"Exam",70,"exam",{"id":104,"doc_module":4,"doc_module_name":44,"category_name":105,"show_sort_weight":106,"slug":107},5,"Comic",60,"comic",{"id":109,"doc_module":4,"doc_module_name":44,"category_name":110,"show_sort_weight":111,"slug":112},6,"Technology",50,"technology",{"id":114,"doc_module":4,"doc_module_name":44,"category_name":115,"show_sort_weight":116,"slug":117},7,"Healthcare",40,"healthcare",{"id":11,"doc_module":4,"doc_module_name":44,"category_name":12,"show_sort_weight":119,"slug":120},30,"research-report",{"id":122,"doc_module":4,"doc_module_name":44,"category_name":123,"show_sort_weight":124,"slug":125},9,"Religion & Spirituality",20,"religion-spirituality",{"id":124,"doc_module":4,"doc_module_name":44,"category_name":127,"show_sort_weight":124,"slug":128},"World Cup","world-cup",{"id":130,"doc_module":4,"doc_module_name":44,"category_name":131,"show_sort_weight":130,"slug":132},10,"Lifestyle","lifestyle",{"id":134,"doc_module":4,"doc_module_name":44,"category_name":135,"show_sort_weight":104,"slug":136},19,"General","general"]