diff --git a/Cargo.lock b/Cargo.lock index a8c6d013..4182a560 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,20 +2,29 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "add_primitive" +version = "0.1.0" +source = "git+https://github.com/egraphs-good/egglog?rev=367a9143be7cb5354a54a9c5660d117440db77a6#367a9143be7cb5354a54a9c5660d117440db77a6" +dependencies = [ + "quote", + "syn 2.0.100", +] + [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "anstream" @@ -34,61 +43,62 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" -version = "0.2.2" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "anstyle-wincon" -version = "3.0.6" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", - "windows-sys 0.59.0", + "once_cell", + "windows-sys", ] [[package]] -name = "arc-swap" -version = "1.6.0" +name = "anyhow" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] -name = "autocfg" -version = "1.1.0" +name = "arc-swap" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" [[package]] -name = "bitflags" -version = "1.3.2" +name = "autocfg" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "bitmaps" @@ -109,10 +119,10 @@ dependencies = [ ] [[package]] -name = "byteorder" -version = "1.5.0" +name = "bumpalo" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "cfg-if" @@ -122,18 +132,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" dependencies = [ "num-traits", ] [[package]] name = "clap" -version = "4.4.6" +version = "4.5.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" +checksum = "2df961d8c8a0d08aa9945718ccf584145eee3f3aa06cddbeac12933781102e04" dependencies = [ "clap_builder", "clap_derive", @@ -141,9 +151,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.6" +version = "4.5.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" +checksum = "132dbda40fb6753878316a489d5a1242a8ef2f0d9e47ba01c951ea8aa7d013a5" dependencies = [ "anstream", "anstyle", @@ -153,37 +163,124 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.2" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" +checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" dependencies = [ - "heck 0.4.1", + "heck", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.100", ] [[package]] name = "clap_lex" -version = "0.5.1" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + +[[package]] +name = "concurrency" +version = "0.1.0" +source = "git+https://github.com/egraphs-good/egglog-backend.git?rev=12e23e1#12e23e1a643543416e6733fe49cc050fb1a08da7" +dependencies = [ + "arc-swap", + "rayon", +] + +[[package]] +name = "core-relations" +version = "0.1.0" +source = "git+https://github.com/egraphs-good/egglog-backend.git?rev=12e23e1#12e23e1a643543416e6733fe49cc050fb1a08da7" +dependencies = [ + "anyhow", + "bumpalo", + "concurrency", + "crossbeam-queue", + "dashmap", + "dyn-clone", + "fixedbitset 0.5.7", + "hashbrown 0.15.2", + "indexmap", + "lazy_static", + "log", + "numeric-id", + "once_cell", + "petgraph", + "rand", + "rayon", + "rustc-hash 2.1.1", + "smallvec", + "thiserror 2.0.12", + "union-find", + "web-time", +] [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] +[[package]] +name = "crossbeam" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.21" @@ -200,6 +297,20 @@ dependencies = [ "typenum", ] +[[package]] +name = "dashmap" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + [[package]] name = "digest" version = "0.10.7" @@ -225,17 +336,25 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "675e35c02a51bb4d4618cb4885b3839ce6d1787c97b664474d9208d074742e20" +[[package]] +name = "dyn-clone" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c7a8fb8a9fbf66c1f703fe16184d10ca0ee9d23be5b4436400408ba54a95005" + [[package]] name = "egglog" version = "0.4.0" -source = "git+https://github.com/egraphs-good//egglog.git?rev=6f494282442803201b512e9d0828007b52a0b29c#6f494282442803201b512e9d0828007b52a0b29c" +source = "git+https://github.com/egraphs-good/egglog?rev=367a9143be7cb5354a54a9c5660d117440db77a6#367a9143be7cb5354a54a9c5660d117440db77a6" dependencies = [ + "add_primitive", "chrono", "clap", + "core-relations", + "egglog-bridge", "egraph-serialize", "env_logger", "hashbrown 0.15.2", - "im", "im-rc", "indexmap", "instant", @@ -243,28 +362,40 @@ dependencies = [ "log", "num", "ordered-float", - "rustc-hash", + "rustc-hash 1.1.0", "smallvec", "symbol_table", - "thiserror", + "thiserror 1.0.69", ] [[package]] -name = "egglog-experimental" +name = "egglog-bridge" version = "0.1.0" -source = "git+https://github.com/egraphs-good/egglog-experimental?rev=8a1b3d6ad2723a8438f51f05027161e51f37917c#8a1b3d6ad2723a8438f51f05027161e51f37917c" +source = "git+https://github.com/egraphs-good/egglog-backend.git?rev=12e23e1#12e23e1a643543416e6733fe49cc050fb1a08da7" dependencies = [ - "egglog", - "lazy_static", - "num", + "anyhow", + "core-relations", + "dyn-clone", + "hashbrown 0.15.2", + "indexmap", + "log", + "num-rational", + "numeric-id", + "petgraph", + "rayon", + "smallvec", + "thiserror 1.0.69", + "union-find", + "web-time", ] [[package]] name = "egglog_python" -version = "10.0.0" +version = "10.0.1" dependencies = [ + "core-relations", "egglog", - "egglog-experimental", + "egglog-bridge", "egraph-serialize", "lalrpop-util", "log", @@ -289,11 +420,17 @@ dependencies = [ "serde_json", ] +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + [[package]] name = "env_logger" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" dependencies = [ "humantime", "is-terminal", @@ -304,31 +441,43 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys", ] [[package]] name = "fastrand" -version = "2.1.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" [[package]] name = "foldhash" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" [[package]] name = "generic-array" @@ -342,9 +491,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -353,14 +502,14 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" dependencies = [ "cfg-if", "libc", - "wasi 0.13.3+wasi-0.2.2", - "windows-targets 0.52.6", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", ] [[package]] @@ -381,9 +530,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.1" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hashbrown" @@ -396,12 +545,6 @@ dependencies = [ "foldhash", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -410,29 +553,15 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "fbd780fe5cc30f81464441920d82ac8740e2e46b29a6fad543ddd075229ce37e" [[package]] name = "humantime" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] -name = "im" -version = "15.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" -dependencies = [ - "bitmaps", - "rand_core", - "rand_xoshiro", - "sized-chunks", - "typenum", - "version_check", -] +checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f" [[package]] name = "im-rc" @@ -450,26 +579,26 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", - "hashbrown 0.14.1", + "hashbrown 0.15.2", "serde", ] [[package]] name = "indoc" -version = "2.0.4" +version = "2.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" +checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd" [[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", ] @@ -498,13 +627,13 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.9" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" dependencies = [ "hermit-abi", - "rustix", - "windows-sys 0.48.0", + "libc", + "windows-sys", ] [[package]] @@ -515,9 +644,19 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] [[package]] name = "lalrpop-util" @@ -531,21 +670,31 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.169" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "linux-raw-sys" -version = "0.4.15" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + +[[package]] +name = "lock_api" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] [[package]] name = "log" @@ -555,15 +704,15 @@ checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memoffset" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] @@ -641,39 +790,61 @@ dependencies = [ "autocfg", ] +[[package]] +name = "numeric-id" +version = "0.1.0" +source = "git+https://github.com/egraphs-good/egglog-backend.git?rev=12e23e1#12e23e1a643543416e6733fe49cc050fb1a08da7" +dependencies = [ + "lazy_static", + "rayon", +] + [[package]] name = "once_cell" -version = "1.18.0" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "ordered-float" -version = "3.7.0" +version = "3.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fc2dbde8f8a79f2102cc474ceb0ad68e3b80b85289ea62389b60e66777e4213" +checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc" dependencies = [ "num-traits", "rand", "serde", ] +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + [[package]] name = "pest" -version = "2.7.11" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" +checksum = "198db74531d58c70a361c42201efde7e2591e976d518caf7662a47dc5720e7b6" dependencies = [ "memchr", - "thiserror", + "thiserror 2.0.12", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.7.11" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a548d2beca6773b1c244554d36fcf8548a8a58e74156968211567250e48e49a" +checksum = "d725d9cfd79e87dccc9341a2ef39d1b6f6353d68c4b33c177febbe1a402c97c5" dependencies = [ "pest", "pest_generator", @@ -681,48 +852,58 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.11" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c93a82e8d145725dcbaf44e5ea887c8a869efdcc28706df2d08c69e17077183" +checksum = "db7d01726be8ab66ab32f9df467ae8b1148906685bbe75c82d1e65d7f5b3f841" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.100", ] [[package]] name = "pest_meta" -version = "2.7.11" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a941429fea7e08bedec25e4f6785b6ffaacc6b755da98df5ef3e7dcf4a124c4f" +checksum = "7f9f832470494906d1fca5329f8ab5791cc60beb230c74815dff541cbd2b5ca0" dependencies = [ "once_cell", "pest", "sha2", ] +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset 0.4.2", + "indexmap", +] + [[package]] name = "portable-atomic" -version = "1.6.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" [[package]] name = "ppv-lite86" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ "zerocopy", ] [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -785,7 +966,7 @@ dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.60", + "syn 2.0.100", ] [[package]] @@ -794,22 +975,28 @@ version = "0.23.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fca6726ad0f3da9c9de093d6f116a93c1a38e417ed73bf138472cf4064f72028" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.60", + "syn 2.0.100", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + [[package]] name = "rand" version = "0.8.5" @@ -838,7 +1025,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.15", "serde", ] @@ -851,20 +1038,40 @@ dependencies = [ "rand_core", ] +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" dependencies = [ - "bitflags 1.3.2", + "bitflags", ] [[package]] name = "regex" -version = "1.10.4" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -874,9 +1081,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -885,9 +1092,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustc-hash" @@ -895,49 +1102,61 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + [[package]] name = "rustix" -version = "0.38.44" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf" dependencies = [ - "bitflags 2.4.0", + "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys 0.59.0", + "windows-sys", ] [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "scopeguard" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.199" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.199" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.100", ] [[package]] @@ -976,15 +1195,15 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "symbol_table" @@ -1010,9 +1229,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -1027,75 +1246,105 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.8.0" +version = "3.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" dependencies = [ - "cfg-if", "fastrand", - "redox_syscall", + "getrandom 0.3.2", + "once_cell", "rustix", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "termcolor" -version = "1.3.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl 2.0.12", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.100", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", ] [[package]] name = "typenum" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "ucd-trie" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unindent" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" +checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3" + +[[package]] +name = "union-find" +version = "0.1.0" +source = "git+https://github.com/egraphs-good/egglog-backend.git?rev=12e23e1#12e23e1a643543416e6733fe49cc050fb1a08da7" +dependencies = [ + "concurrency", + "crossbeam", + "numeric-id", +] [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" @@ -1103,14 +1352,14 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" dependencies = [ - "getrandom 0.3.1", + "getrandom 0.3.2", ] [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasi" @@ -1120,75 +1369,96 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi" -version = "0.13.3+wasi-0.2.2" +version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" dependencies = [ "wit-bindgen-rt", ] [[package]] -name = "winapi" -version = "0.3.9" +name = "wasm-bindgen" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "cfg-if", + "once_cell", + "wasm-bindgen-macro", ] [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "wasm-bindgen-backend" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn 2.0.100", + "wasm-bindgen-shared", +] [[package]] -name = "winapi-util" -version = "0.1.6" +name = "wasm-bindgen-macro" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ - "winapi", + "quote", + "wasm-bindgen-macro-support", ] [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "wasm-bindgen-macro-support" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] [[package]] -name = "windows-sys" -version = "0.48.0" +name = "wasm-bindgen-shared" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" dependencies = [ - "windows-targets 0.48.1", + "unicode-ident", ] [[package]] -name = "windows-sys" -version = "0.59.0" +name = "web-time" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" dependencies = [ - "windows-targets 0.52.6", + "js-sys", + "wasm-bindgen", ] [[package]] -name = "windows-targets" -version = "0.48.1" +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows-targets", ] [[package]] @@ -1197,46 +1467,28 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -1249,48 +1501,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -1299,30 +1527,29 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "wit-bindgen-rt" -version = "0.33.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.4.0", + "bitflags", ] [[package]] name = "zerocopy" -version = "0.7.35" +version = "0.8.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" dependencies = [ - "byteorder", "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.35" +version = "0.8.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.100", ] diff --git a/Cargo.toml b/Cargo.toml index 4dd360e8..a8753e0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,8 +12,11 @@ crate-type = ["cdylib"] [dependencies] pyo3 = { version = "0.23.0", features = ["extension-module"] } -egglog = { git = "https://github.com/egraphs-good/egglog", rev = "6f494282442803201b512e9d0828007b52a0b29c" } -egglog-experimental = { git = "https://github.com/egraphs-good/egglog-experimental", rev = "8a1b3d6ad2723a8438f51f05027161e51f37917c" } +egglog = { git = "https://github.com/egraphs-good/egglog", rev = "367a9143be7cb5354a54a9c5660d117440db77a6" } +# egglog = { git = "https://github.com/saulshanabrook/egg-smol", rev = "8cd7c0e77a27c271cbaef09ab23514675d646937" } +egglog-bridge = { git = "https://github.com/egraphs-good/egglog-backend.git", rev = "12e23e1" } +core-relations = { git = "https://github.com/egraphs-good/egglog-backend.git", rev = "12e23e1" } +# egglog-experimental = { git = "https://github.com/egraphs-good/egglog-experimental", rev = "8a1b3d6ad2723a8438f51f05027161e51f37917c" } egraph-serialize = { version = "0.2.0", features = ["serde", "graphviz"] } serde_json = "1.0.140" pyo3-log = "0.12.3" @@ -23,9 +26,9 @@ ordered-float = "3.7.0" uuid = { version = "1.16.0", features = ["v4"] } # Use unreleased version of egglog in experimental -[patch.'https://github.com/egraphs-good/egglog'] +# [patch.'https://github.com/egraphs-good/egglog'] # https://github.com/rust-lang/cargo/issues/5478#issuecomment-522719793 -egglog = { git = "https://github.com/egraphs-good//egglog.git", rev = "6f494282442803201b512e9d0828007b52a0b29c" } +# egglog = { git = "https://github.com/egraphs-good//egglog.git", rev = "6f494282442803201b512e9d0828007b52a0b29c" } # [replace] # 'https://github.com/egraphs-good/egglog.git#egglog@0.3.0' = { git = "https://github.com/egraphs-good/egglog.git", rev = "215714e1cbb13ae9e21bed2f2e1bf95804571512" } diff --git a/docs/changelog.md b/docs/changelog.md index 463f872e..30f63027 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -4,6 +4,9 @@ _This project uses semantic versioning_ ## UNRELEASED +- Upgrade egglog which includes new backend. Removes support for egglog experimental including `Rational` since it + is not compatible with new backend yet. + ## 10.0.1 (2025-04-06) - Fix bug on resolving types if not all imported to your module [#286](https://github.com/egraphs-good/egglog-python/pull/286) diff --git a/docs/reference/egglog-translation.md b/docs/reference/egglog-translation.md index 570be5f1..f336a3fa 100644 --- a/docs/reference/egglog-translation.md +++ b/docs/reference/egglog-translation.md @@ -29,8 +29,8 @@ i64(10) + i64(2) ``` ```{code-cell} python -# egg: (+ (rational 1 2) (rational 2 1)) -Rational(i64(1), i64(2)) / Rational(i64(2), i64(1)) +# egg: (+ (bigrat (bigint 1) (bigint 2)) (big-rat (bigint 2) (bigint 1))) +BigRat(1, 2) / BigRat(2, 1) ``` These types are also all checked statically with MyPy, so for example, if you try to add a `String` and a `i64`, you will get a type error. @@ -44,7 +44,7 @@ i64(10) + 2 ``` ```{code-cell} python -Rational(1, 2) / Rational(2, 1) +BigRat(1, 2) / BigRat(2, 1) ``` ### `!=` Operator diff --git a/python/egglog/builtins.py b/python/egglog/builtins.py index 9a9d8a29..4e45469a 100644 --- a/python/egglog/builtins.py +++ b/python/egglog/builtins.py @@ -36,7 +36,6 @@ "MapLike", "MultiSet", "PyObject", - "Rational", "Set", "SetLike", "String", @@ -527,91 +526,92 @@ def __add__(self, other: MultiSet[T]) -> MultiSet[T]: ... def map(self, f: Callable[[T], T]) -> MultiSet[T]: ... -class Rational(BuiltinExpr): - @method(preserve=True) - def eval(self) -> Fraction: - call = _extract_call(self) - if call.callable != InitRef("Rational"): - msg = "Rational can only be initialized with the Rational constructor." - raise BuiltinEvalError(msg) +# Removed until egglog experimental supports new backend +# class Rational(BuiltinExpr): +# @method(preserve=True) +# def eval(self) -> Fraction: +# call = _extract_call(self) +# if call.callable != InitRef("Rational"): +# msg = "Rational can only be initialized with the Rational constructor." +# raise BuiltinEvalError(msg) - def _to_int(e: TypedExprDecl) -> int: - expr = e.expr - if not isinstance(expr, LitDecl): - msg = "Rational can only be initialized with literals" - raise BuiltinEvalError(msg) - assert isinstance(expr.value, int) - return expr.value +# def _to_int(e: TypedExprDecl) -> int: +# expr = e.expr +# if not isinstance(expr, LitDecl): +# msg = "Rational can only be initialized with literals" +# raise BuiltinEvalError(msg) +# assert isinstance(expr.value, int) +# return expr.value - num, den = call.args - return Fraction(_to_int(num), _to_int(den)) +# num, den = call.args +# return Fraction(_to_int(num), _to_int(den)) - @method(preserve=True) - def __float__(self) -> float: - return float(self.eval()) +# @method(preserve=True) +# def __float__(self) -> float: +# return float(self.eval()) - @method(preserve=True) - def __int__(self) -> int: - return int(self.eval()) +# @method(preserve=True) +# def __int__(self) -> int: +# return int(self.eval()) - @method(egg_fn="rational") - def __init__(self, num: i64Like, den: i64Like) -> None: ... +# @method(egg_fn="rational") +# def __init__(self, num: i64Like, den: i64Like) -> None: ... - @method(egg_fn="to-f64") - def to_f64(self) -> f64: ... +# @method(egg_fn="to-f64") +# def to_f64(self) -> f64: ... - @method(egg_fn="+") - def __add__(self, other: Rational) -> Rational: ... +# @method(egg_fn="+") +# def __add__(self, other: Rational) -> Rational: ... - @method(egg_fn="-") - def __sub__(self, other: Rational) -> Rational: ... +# @method(egg_fn="-") +# def __sub__(self, other: Rational) -> Rational: ... - @method(egg_fn="*") - def __mul__(self, other: Rational) -> Rational: ... +# @method(egg_fn="*") +# def __mul__(self, other: Rational) -> Rational: ... - @method(egg_fn="/") - def __truediv__(self, other: Rational) -> Rational: ... +# @method(egg_fn="/") +# def __truediv__(self, other: Rational) -> Rational: ... - @method(egg_fn="min") - def min(self, other: Rational) -> Rational: ... +# @method(egg_fn="min") +# def min(self, other: Rational) -> Rational: ... - @method(egg_fn="max") - def max(self, other: Rational) -> Rational: ... +# @method(egg_fn="max") +# def max(self, other: Rational) -> Rational: ... - @method(egg_fn="neg") - def __neg__(self) -> Rational: ... +# @method(egg_fn="neg") +# def __neg__(self) -> Rational: ... - @method(egg_fn="abs") - def __abs__(self) -> Rational: ... +# @method(egg_fn="abs") +# def __abs__(self) -> Rational: ... - @method(egg_fn="floor") - def floor(self) -> Rational: ... +# @method(egg_fn="floor") +# def floor(self) -> Rational: ... - @method(egg_fn="ceil") - def ceil(self) -> Rational: ... +# @method(egg_fn="ceil") +# def ceil(self) -> Rational: ... - @method(egg_fn="round") - def round(self) -> Rational: ... +# @method(egg_fn="round") +# def round(self) -> Rational: ... - @method(egg_fn="pow") - def __pow__(self, other: Rational) -> Rational: ... +# @method(egg_fn="pow") +# def __pow__(self, other: Rational) -> Rational: ... - @method(egg_fn="log") - def log(self) -> Rational: ... +# @method(egg_fn="log") +# def log(self) -> Rational: ... - @method(egg_fn="sqrt") - def sqrt(self) -> Rational: ... +# @method(egg_fn="sqrt") +# def sqrt(self) -> Rational: ... - @method(egg_fn="cbrt") - def cbrt(self) -> Rational: ... +# @method(egg_fn="cbrt") +# def cbrt(self) -> Rational: ... - @method(egg_fn="numer") # type: ignore[misc] - @property - def numer(self) -> i64: ... +# @method(egg_fn="numer") # type: ignore[misc] +# @property +# def numer(self) -> i64: ... - @method(egg_fn="denom") # type: ignore[misc] - @property - def denom(self) -> i64: ... +# @method(egg_fn="denom") # type: ignore[misc] +# @property +# def denom(self) -> i64: ... class BigInt(BuiltinExpr): diff --git a/python/tests/test_high_level.py b/python/tests/test_high_level.py index ad774a5a..2f3c7281 100644 --- a/python/tests/test_high_level.py +++ b/python/tests/test_high_level.py @@ -511,10 +511,10 @@ def test_set(self): assert i64(1) in s assert i64(3) not in s - def test_rational(self): - assert Rational(1, 2).eval() == Fraction(1, 2) - assert float(Rational(1, 2)) == 0.5 - assert int(Rational(1, 1)) == 1 + # def test_rational(self): + # assert Rational(1, 2).eval() == Fraction(1, 2) + # assert float(Rational(1, 2)) == 0.5 + # assert int(Rational(1, 1)) == 1 def test_vec(self): assert Vec[i64].empty().eval() == () diff --git a/src/egraph.rs b/src/egraph.rs index 54ec19d1..63478abc 100644 --- a/src/egraph.rs +++ b/src/egraph.rs @@ -5,7 +5,7 @@ use crate::error::{EggResult, WrappedError}; use crate::py_object_sort::ArcPyObjectSort; use crate::serialize::SerializedEGraph; -use egglog::{span, SerializeConfig}; +use egglog::{span, EGraph as EgglogEGraph, SerializeConfig}; use log::info; use pyo3::prelude::*; use std::path::PathBuf; @@ -33,7 +33,7 @@ impl EGraph { seminaive: bool, record: bool, ) -> Self { - let mut egraph = egglog_experimental::new_experimental_egraph(); + let mut egraph = EgglogEGraph::default(); egraph.fact_directory = fact_directory; egraph.seminaive = seminaive; if let Some(py_object_sort) = py_object_sort { @@ -61,16 +61,17 @@ impl EGraph { /// Returns a list of strings representing the output. /// An EggSmolError is raised if there is problem parsing or executing. #[pyo3(signature=(*commands))] - fn run_program(&mut self, commands: Vec) -> EggResult> { + fn run_program(&mut self, py: Python<'_>, commands: Vec) -> EggResult> { let commands: Vec = commands.into_iter().map(|x| x.into()).collect(); let mut cmds_str = String::new(); for cmd in &commands { cmds_str = cmds_str + &cmd.to_string() + "\n"; } info!("Running commands:\n{}", cmds_str); - - let res = self.egraph.run_program(commands).map_err(|e| { - WrappedError::Egglog(e, "\nWhen running commands:\n".to_string() + &cmds_str) + let res = py.allow_threads(|| { + self.egraph.run_program(commands).map_err(|e| { + WrappedError::Egglog(e, "\nWhen running commands:\n".to_string() + &cmds_str) + }) }); if res.is_ok() { if let Some(cmds) = &mut self.cmds { @@ -115,22 +116,25 @@ impl EGraph { )] fn serialize( &mut self, + py: Python<'_>, root_eclasses: Vec, max_functions: Option, max_calls_per_function: Option, include_temporary_functions: bool, ) -> SerializedEGraph { - let root_eclasses: Vec<_> = root_eclasses - .into_iter() - .map(|x| self.egraph.eval_expr(&egglog::ast::Expr::from(x)).unwrap()) - .collect(); - SerializedEGraph { - egraph: self.egraph.serialize(SerializeConfig { - max_functions, - max_calls_per_function, - include_temporary_functions, - root_eclasses, - }), - } + py.allow_threads(|| { + let root_eclasses: Vec<_> = root_eclasses + .into_iter() + .map(|x| self.egraph.eval_expr(&egglog::ast::Expr::from(x)).unwrap()) + .collect(); + SerializedEGraph { + egraph: self.egraph.serialize(SerializeConfig { + max_functions, + max_calls_per_function, + include_temporary_functions, + root_eclasses, + }), + } + }) } } diff --git a/src/py_object_sort.rs b/src/py_object_sort.rs index 581582fa..148e2799 100644 --- a/src/py_object_sort.rs +++ b/src/py_object_sort.rs @@ -1,13 +1,14 @@ use crate::error::EggResult; +use egglog::sort::IntoSort; use egglog::{ + add_primitive, ast::{Expr, Literal, Span, Symbol}, call, - constraint::{AllEqualTypeConstraint, SimpleTypeConstraint, TypeConstraint}, extract::{Cost, Extractor}, lit, - sort::{BoolSort, FromSort, I64Sort, IntoSort as _, Sort, StringSort}, + sort::{ColumnTy, FromSort, Sort}, util::IndexMap, - ArcSort, EGraph, PrimitiveLike, Term, TermDag, TypeInfo, Value, + EGraph, Term, TermDag, Value, }; use pyo3::{ ffi, intern, prelude::*, types::PyDict, AsPyPointer, PyAny, PyErr, PyObject, PyResult, @@ -26,6 +27,10 @@ use uuid::Uuid; const NAME: &str = "PyObject"; +// TODO: Use a vec of objects with the index as the identifier instead of the hash or ID +// Then store two mappings: One from object ID to index and one from hash to list of indices +// When retrieving, try checking ID. If missing, try hash if hashable. + fn value(i: usize) -> Value { Value { #[cfg(debug_assertions)] @@ -43,14 +48,11 @@ pub enum PyObjectIdent { } impl PyObjectIdent { - pub fn from_pyobject(obj: &PyObject) -> Self { - Python::with_gil(|py| { - let o = obj.bind(py); - match o.hash() { - Ok(hash) => PyObjectIdent::Hashable(o.get_type().hash().unwrap(), hash), - Err(_) => PyObjectIdent::Unhashable(obj.as_ptr() as usize), - } - }) + pub fn from_pyobject<'py>(o: &Bound<'py, PyAny>) -> Self { + match o.hash() { + Ok(hash) => PyObjectIdent::Hashable(o.get_type().hash().unwrap(), hash), + Err(_) => PyObjectIdent::Unhashable(o.as_ptr() as usize), + } } pub fn from_expr(expr: &Expr) -> Self { @@ -96,19 +98,15 @@ impl PyObjectSort { Self(Mutex::new(IndexMap::default())) } /// Store a Python object with its hash and return its index in the registry. - pub fn insert_full(&self, key: PyObjectIdent, value: PyObject) -> usize { + pub fn insert_full<'py>(&self, key: PyObjectIdent, value: PyObject) -> usize { self.0.lock().unwrap().insert_full(key, value).0 } /// Retrieves the Python object at the given index. - pub fn get_index(&self, py: Python<'_>, index: usize) -> PyObject { - self.0 - .lock() - .unwrap() - .get_index(index) - .unwrap() - .1 - .clone_ref(py) + pub fn get_index<'py>(&self, py: Python<'py>, index: usize) -> Bound<'py, PyAny> { + let binding = self.0.lock().unwrap(); + let res = binding.get_index(index).unwrap().1; + res.bind(py).clone() } /// Retrieves the index of the given key. @@ -116,6 +114,19 @@ impl PyObjectSort { self.0.lock().unwrap().get_index_of(key).unwrap() } + pub fn get_object<'py>(&self, py: Python<'py>, ident: &PyObjectIdent) -> Bound<'py, PyAny> { + let binding = self.0.lock().unwrap(); + binding.get(ident).unwrap().bind(py).clone() + // let index = binding.get_index_of(ident).unwrap(); + // binding.get_index(index).unwrap().1.bind(py).clone() + } + + pub fn store_object<'py>(&self, obj: &Bound<'py, PyAny>) -> PyObjectIdent { + let ident = PyObjectIdent::from_pyobject(obj); + self.insert_full(ident, obj.clone().unbind()); + ident + } + pub fn load_ident(&self, value: &Value) -> PyObjectIdent { let objects = self.0.lock().unwrap(); let i = value.bits as usize; @@ -123,28 +134,31 @@ impl PyObjectSort { ident.clone() } - pub fn store(&self, obj: PyObject) -> Value { + pub fn store<'py>(&self, obj: &Bound<'py, PyAny>) -> Value { // Try hashing the object, if it fails, then it's unhashable, and store with ID - let ident = PyObjectIdent::from_pyobject(&obj); - let i = self.insert_full(ident, obj); + let ident = PyObjectIdent::from_pyobject(obj); + let i = self.insert_full(ident, obj.clone().unbind()); value(i) } - pub fn load(&self, py: Python<'_>, value: Value) -> PyObject { + pub fn load<'py>(&self, py: Python<'py>, value: Value) -> Bound<'py, PyAny> { let i = value.bits as usize; self.get_index(py, i) } } -/// Implement wrapper struct so can implement foreign sort on it -#[derive(IntoPyObject, IntoPyObjectRef)] -pub struct MyPyObject(pub PyObject); +impl IntoSort for PyObjectIdent { + type Sort = PyObjectSort; + fn store(self, sort: &Self::Sort) -> Value { + value(sort.get_index_of(&self)) + } +} -impl FromSort for MyPyObject { +impl FromSort for PyObjectIdent { type Sort = PyObjectSort; fn load(sort: &Self::Sort, value: &Value) -> Self { - let obj = Python::with_gil(|py| sort.load(py, *value)); - MyPyObject(obj) + let binding = sort.0.lock().unwrap(); + binding.get_index(value.bits as usize).unwrap().0.clone() } } @@ -164,19 +178,19 @@ impl ArcPyObjectSort { /// Store a Python object and return an Expr that points to it. #[pyo3(name="store", signature = (obj, /))] - fn store_py(&mut self, obj: PyObject) -> EggResult { - let ident = PyObjectIdent::from_pyobject(&obj); - self.0.insert_full(ident, obj); + fn store_py<'py>(&mut self, obj: &Bound<'py, PyAny>) -> EggResult { + let ident = PyObjectIdent::from_pyobject(obj); + self.0.insert_full(ident, obj.clone().unbind()); Ok(ident.to_expr().into()) } // Retrieve the Python object from an expression #[pyo3(name="load", signature = (expr, /))] - fn load_py(&self, expr: crate::conversions::Expr) -> PyObject { + fn load_py<'py>(&self, py: Python<'py>, expr: crate::conversions::Expr) -> Bound<'py, PyAny> { let expr: Expr = expr.into(); let ident = PyObjectIdent::from_expr(&expr); let index = self.0.get_index_of(&ident); - Python::with_gil(|py| self.0.get_index(py, index)) + self.0.get_index(py, index) } // Integrate with Python garbage collector @@ -205,51 +219,149 @@ impl Sort for PyObjectSort { self } - #[rustfmt::skip] - fn register_primitives(self: Arc, typeinfo: &mut TypeInfo) { - typeinfo.add_primitive(Ctor { - name: "py-object".into(), - py_object: self.clone(), - i64:typeinfo.get_sort_nofail(), - }); - typeinfo.add_primitive(Eval { - name: "py-eval".into(), - py_object: self.clone(), - string: typeinfo.get_sort_nofail(), - }); - typeinfo.add_primitive(Exec { - name: "py-exec".into(), - py_object: self.clone(), - string: typeinfo.get_sort_nofail(), - }); - typeinfo.add_primitive(Dict { - name: "py-dict".into(), - py_object: self.clone(), - }); - typeinfo.add_primitive(DictUpdate { - name: "py-dict-update".into(), - py_object: self.clone(), - }); - typeinfo.add_primitive(ToString { - name: "py-to-string".into(), - py_object: self.clone(), - string: typeinfo.get_sort_nofail(), - }); - typeinfo.add_primitive(ToBool { - name: "py-to-bool".into(), - py_object: self.clone(), - bool_: typeinfo.get_sort_nofail(), - }); - typeinfo.add_primitive(FromString { - name: "py-from-string".into(), - py_object: self.clone(), - string: typeinfo.get_sort_nofail(), + fn column_ty(&self, backend: &egglog_bridge::EGraph) -> ColumnTy { + ColumnTy::Primitive(backend.primitives().get_ty::()) + } + + fn register_type(&self, backend: &mut egglog_bridge::EGraph) { + backend.primitives_mut().register_type::(); + } + + fn register_primitives(self: Arc, eg: &mut EGraph) { + // (py-object | ) + add_primitive!(eg, "py-object" = [xs: i64] -?> PyObjectIdent { + match xs.collect::>().as_slice() { + [id] => Some(PyObjectIdent::Unhashable(*id as usize)), + [type_hash, hash] => Some(PyObjectIdent::Hashable( + *type_hash as isize, + *hash as isize, + )), + _ => None, + } + }); - typeinfo.add_primitive(FromInt { - name: "py-from-int".into(), - py_object: self, - int: typeinfo.get_sort_nofail(), + // Supports calling (py-eval ) + add_primitive!( + eg, + "py-eval" = + |code: Symbol, globals: PyObjectIdent, locals: PyObjectIdent| -> PyObjectIdent { + { + Python::with_gil(|py| { + let globals = self.__y.get_object(py, &globals); + let locals = self.__y.get_object(py, &locals); + let res = py + .eval( + CString::new(code.to_string()).unwrap().as_c_str(), + Some(globals.downcast::().unwrap()), + Some(locals.downcast::().unwrap()), + ) + .unwrap(); + self.__y.store_object(&res) + }) + } + } + ); + // Copies the locals, execs the Python string, then returns the copied version of the locals with any updates + // (py-exec ) + add_primitive!( + eg, + "py-exec" = + |code: Symbol, globals: PyObjectIdent, locals: PyObjectIdent| -> PyObjectIdent { + Python::with_gil(|py| { + let code: &str = code.into(); + let globals = self.__y.get_object(py, &globals); + let locals = self.__y.get_object(py, &locals); + + // Copy the locals so we can mutate them and return them + let locals = locals.downcast::().unwrap().copy().unwrap(); + // Copy code into temporary file + // Keep it around so that if errors occur we can debug them after the program exits + let mut path = temp_dir(); + let file_name = format!("egglog-{}.py", Uuid::new_v4()); + path.push(file_name); + let mut file = File::create(path.clone()).unwrap(); + file.write_all(code.as_bytes()).unwrap(); + let path = path.to_str().unwrap(); + run_code_path( + py, + code, + Some(globals.downcast::().unwrap()), + Some(&locals), + path, + ) + .unwrap(); + self.__y.store_object(&locals) + }) + } + ); + + // (py-dict [ ]*) + add_primitive!(eg, "py-dict" = [xs: PyObjectIdent] -> PyObjectIdent { + Python::with_gil(|py| { + let dict = PyDict::new(py); + for i in xs.map(|x| self.__y.get_object(py, &x)).collect::>().chunks_exact(2) { + dict.set_item(i[0].clone(), i[1].clone()).unwrap(); + } + self.__y.store_object(&dict) + }) }); + // Supports calling (py-dict-update [ ]*) + add_primitive!(eg, "py-dict-update" = [xs: PyObjectIdent] -> PyObjectIdent {{ + Python::with_gil(|py| { + let xs = xs.map(|x| self.__y.get_object(py, &x)).collect::>(); + // Copy the dict so we can mutate it and return it + let dict = xs[0].downcast::().unwrap().copy().unwrap(); + // Update the dict with the key-value pairs + for i in xs[1..].chunks_exact(2) { + dict.set_item(i[0].clone(), i[1].clone()).unwrap(); + } + self.__y.store_object(&dict) + + }) + }}); + // (py-to-string ) + add_primitive!( + eg, + "py-to-string" = |x: PyObjectIdent| -> Symbol { + { + let obj: String = + Python::with_gil(move |py| self.x.get_object(py, &x).extract().unwrap()); + let symbol: Symbol = obj.into(); + symbol + } + } + ); + // (py-to-bool ) + add_primitive!( + eg, + "py-to-bool" = |x: PyObjectIdent| -> bool { + { + let obj: bool = + Python::with_gil(|py| self.x.get_object(py, &x).extract().unwrap()); + obj + } + } + ); + // (py-from-string ) + add_primitive!( + eg, + "py-from-string" = |x: Symbol| -> PyObjectIdent { + Python::with_gil(|py| { + let obj = x.to_string().into_pyobject(py).unwrap(); + self.__y.store_object(&obj) + }) + } + ); + // (py-from-int ) + add_primitive!( + eg, + "py-from-int" = |x: i64| -> PyObjectIdent { + Python::with_gil(|py| { + let obj = x.into_pyobject(py).unwrap(); + self.__y.store_object(&obj) + }) + } + ); } fn extract_term( &self, @@ -275,361 +387,6 @@ impl Sort for PyObjectSort { } } -/// (py-object | ) -struct Ctor { - name: Symbol, - py_object: Arc, - i64: Arc, -} - -impl PrimitiveLike for Ctor { - fn name(&self) -> Symbol { - self.name - } - - fn get_type_constraints(&self, span: &Span) -> Box { - AllEqualTypeConstraint::new(self.name(), span.clone()) - .with_all_arguments_sort(self.i64.clone()) - .with_output_sort(self.py_object.clone()) - .into_box() - } - - fn apply( - &self, - values: &[Value], - _sorts: (&[ArcSort], &ArcSort), - _egraph: Option<&mut EGraph>, - ) -> Option { - let ident = match values { - [id] => PyObjectIdent::Unhashable(i64::load(self.i64.as_ref(), id) as usize), - [type_hash, hash] => PyObjectIdent::Hashable( - i64::load(self.i64.as_ref(), type_hash) as isize, - i64::load(self.i64.as_ref(), hash) as isize, - ), - _ => unreachable!(), - }; - Some(value(self.py_object.get_index_of(&ident))) - } -} - -/// Supports calling (py-eval ) -struct Eval { - name: Symbol, - py_object: Arc, - string: Arc, -} - -impl PrimitiveLike for Eval { - fn name(&self) -> Symbol { - self.name - } - - fn get_type_constraints(&self, span: &Span) -> Box { - return SimpleTypeConstraint::new( - self.name(), - vec![ - self.string.clone(), - self.py_object.clone(), - self.py_object.clone(), - self.py_object.clone(), - ], - span.clone(), - ) - .into_box(); - } - - fn apply( - &self, - values: &[Value], - _sorts: (&[ArcSort], &ArcSort), - _egraph: Option<&mut EGraph>, - ) -> Option { - let code: Symbol = Symbol::load(self.string.as_ref(), &values[0]); - let res_obj: PyObject = Python::with_gil(|py| { - let globals = self.py_object.load(py, values[1]); - let globals = globals.downcast_bound::(py).unwrap(); - let locals = self.py_object.load(py, values[2]); - let locals = locals.downcast_bound::(py).unwrap(); - py.eval( - CString::new(code.to_string()).unwrap().as_c_str(), - Some(globals), - Some(locals), - ) - .unwrap() - .into() - }); - Some(self.py_object.store(res_obj)) - } -} - -/// Copies the locals, execs the Python string, then returns the copied version of the locals with any updates -/// (py-exec ) -struct Exec { - name: Symbol, - py_object: Arc, - string: Arc, -} - -impl PrimitiveLike for Exec { - fn name(&self) -> Symbol { - self.name - } - - fn get_type_constraints(&self, span: &Span) -> Box { - SimpleTypeConstraint::new( - self.name(), - vec![ - self.string.clone(), - self.py_object.clone(), - self.py_object.clone(), - self.py_object.clone(), - ], - span.clone(), - ) - .into_box() - } - - fn apply( - &self, - values: &[Value], - _sorts: (&[ArcSort], &ArcSort), - _egraph: Option<&mut EGraph>, - ) -> Option { - let code: Symbol = Symbol::load(self.string.as_ref(), &values[0]); - let code: &str = code.into(); - let locals: PyObject = Python::with_gil(|py| { - let globals = self.py_object.load(py, values[1]); - let globals = globals.downcast_bound::(py).unwrap(); - let locals = self.py_object.load(py, values[2]); - // Copy the locals so we can mutate them and return them - let locals = locals.downcast_bound::(py).unwrap().copy().unwrap(); - // Copy code into temporary file - // Keep it around so that if errors occur we can debug them after the program exits - let mut path = temp_dir(); - let file_name = format!("egglog-{}.py", Uuid::new_v4()); - path.push(file_name); - let mut file = File::create(path.clone()).unwrap(); - file.write_all(code.as_bytes()).unwrap(); - let path = path.to_str().unwrap(); - run_code_path(py, code, Some(globals), Some(&locals), path).unwrap(); - locals.into() - }); - Some(self.py_object.store(locals)) - } -} - -/// (py-dict [ ]*) -struct Dict { - name: Symbol, - py_object: Arc, -} - -impl PrimitiveLike for Dict { - fn name(&self) -> Symbol { - self.name - } - - fn get_type_constraints(&self, span: &Span) -> Box { - AllEqualTypeConstraint::new(self.name(), span.clone()) - .with_all_arguments_sort(self.py_object.clone()) - .with_output_sort(self.py_object.clone()) - .into_box() - } - - fn apply( - &self, - values: &[Value], - _sorts: (&[ArcSort], &ArcSort), - _egraph: Option<&mut EGraph>, - ) -> Option { - let dict: PyObject = Python::with_gil(|py| { - let dict = PyDict::new(py); - // Update the dict with the key-value pairs - for i in values.chunks_exact(2) { - let key = self.py_object.load(py, i[0]); - let value = self.py_object.load(py, i[1]); - dict.set_item(key, value).unwrap(); - } - dict.into() - }); - Some(self.py_object.store(dict)) - } -} - -/// Supports calling (py-dict-update [ ]*) -struct DictUpdate { - name: Symbol, - py_object: Arc, -} - -impl PrimitiveLike for DictUpdate { - fn name(&self) -> Symbol { - self.name - } - - fn get_type_constraints(&self, span: &Span) -> Box { - AllEqualTypeConstraint::new(self.name(), span.clone()) - .with_all_arguments_sort(self.py_object.clone()) - .with_output_sort(self.py_object.clone()) - .into_box() - } - - fn apply( - &self, - values: &[Value], - _sorts: (&[ArcSort], &ArcSort), - _egraph: Option<&mut EGraph>, - ) -> Option { - let dict: PyObject = Python::with_gil(|py| { - let dict = self.py_object.load(py, values[0]); - // Copy the dict so we can mutate it and return it - let dict = dict.downcast_bound::(py).unwrap().copy().unwrap(); - // Update the dict with the key-value pairs - for i in values[1..].chunks_exact(2) { - let key = self.py_object.load(py, i[0]); - let value = self.py_object.load(py, i[1]); - dict.set_item(key, value).unwrap(); - } - dict.into() - }); - Some(self.py_object.store(dict)) - } -} - -/// (py-to-string ) -struct ToString { - name: Symbol, - py_object: Arc, - string: Arc, -} - -impl PrimitiveLike for ToString { - fn name(&self) -> Symbol { - self.name - } - - fn get_type_constraints(&self, span: &Span) -> Box { - SimpleTypeConstraint::new( - self.name(), - vec![self.py_object.clone(), self.string.clone()], - span.clone(), - ) - .into_box() - } - fn apply( - &self, - values: &[Value], - _sorts: (&[ArcSort], &ArcSort), - _egraph: Option<&mut EGraph>, - ) -> Option { - let obj: String = - Python::with_gil(|py| self.py_object.load(py, values[0]).extract(py).unwrap()); - let symbol: Symbol = obj.into(); - symbol.store(self.string.as_ref()) - } -} - -/// (py-to-bool ) -struct ToBool { - name: Symbol, - py_object: Arc, - bool_: Arc, -} - -impl PrimitiveLike for ToBool { - fn name(&self) -> Symbol { - self.name - } - - fn get_type_constraints(&self, span: &Span) -> Box { - SimpleTypeConstraint::new( - self.name(), - vec![self.py_object.clone(), self.bool_.clone()], - span.clone(), - ) - .into_box() - } - - fn apply( - &self, - values: &[Value], - _sorts: (&[ArcSort], &ArcSort), - _egraph: Option<&mut EGraph>, - ) -> Option { - let obj: bool = - Python::with_gil(|py| self.py_object.load(py, values[0]).extract(py).unwrap()); - obj.store(self.bool_.as_ref()) - } -} - -/// (py-from-string ) -struct FromString { - name: Symbol, - py_object: Arc, - string: Arc, -} - -impl PrimitiveLike for FromString { - fn name(&self) -> Symbol { - self.name - } - - fn get_type_constraints(&self, span: &Span) -> Box { - SimpleTypeConstraint::new( - self.name(), - vec![self.string.clone(), self.py_object.clone()], - span.clone(), - ) - .into_box() - } - - fn apply( - &self, - values: &[Value], - _sorts: (&[ArcSort], &ArcSort), - _egraph: Option<&mut EGraph>, - ) -> Option { - let str = Symbol::load(self.string.as_ref(), &values[0]).to_string(); - let obj: PyObject = - Python::with_gil(|py| str.into_pyobject(py).unwrap().as_any().clone().unbind()); - Some(self.py_object.store(obj)) - } -} - -// (py-from-int ) -struct FromInt { - name: Symbol, - py_object: Arc, - int: Arc, -} - -impl PrimitiveLike for FromInt { - fn name(&self) -> Symbol { - self.name - } - - fn get_type_constraints(&self, span: &Span) -> Box { - return SimpleTypeConstraint::new( - self.name(), - vec![self.int.clone(), self.py_object.clone()], - span.clone(), - ) - .into_box(); - } - - fn apply( - &self, - values: &[Value], - _sorts: (&[ArcSort], &ArcSort), - _egraph: Option<&mut EGraph>, - ) -> Option { - let int = i64::load(self.int.as_ref(), &values[0]); - let obj: PyObject = - Python::with_gil(|py| int.into_pyobject(py).unwrap().as_any().clone().unbind()); - Some(self.py_object.store(obj)) - } -} - /// Runs the code in the given context with a certain path. /// Copied from `run_code`, but allows specifying the path. /// https://github.com/PyO3/pyo3/blob/5d2f5b5702319150d41258de77f589119134ee74/src/marker.rs#L678