Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
411 changes: 86 additions & 325 deletions Cargo.lock

Large diffs are not rendered by default.

25 changes: 11 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "egglog_python"
version = "8.0.1"
edition = "2021"


# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "egglog"
Expand All @@ -11,27 +12,23 @@ crate-type = ["cdylib"]
[dependencies]
pyo3 = { version = "0.22.5", features = ["extension-module"] }

# https://github.com/egraphs-good/egglog/compare/ceed816e9369570ffed9feeba157b19471dda70d...main
egglog = { git = "https://github.com/egraphs-good/egglog", rev = "b0db06832264c9b22694bd3de2bdacd55bbe9e32" }
# egglog = { path = "../egg-smol" }
# egglog = { git = "https://github.com/oflatt/egg-smol", branch = "oflatt-fast-terms" }
# egglog = { git = "https://github.com/saulshanabrook/egg-smol", rev = "a555b2f5e82c684442775cc1a5da94b71930113c" }
egglog = { git = "https://github.com/saulshanabrook/egg-smol", rev = "889ca7635368d7e382e16a93b2883aba82f1078f" }
egglog-experimental = { git = "https://github.com/egraphs-good/egglog-experimental", rev = "8a1b3d6ad2723a8438f51f05027161e51f37917c" }
egraph-serialize = { version = "0.2.0", features = ["serde", "graphviz"] }
# egraph-serialize = { path = "../egraph-serialize", features = [
# "serde",
# "graphviz",
# ] }
serde_json = "1.0.132"
pyo3-log = "0.11.0"
log = "0.4.22"
lalrpop-util = { version = "0.22", features = ["lexer"] }
ordered-float = "3.7"
ordered-float = "3.7.0"
uuid = { version = "1.11.0", features = ["v4"] }

# Use unreleased version of egraph-serialize in egglog as well
# [patch.crates-io]
# egraph-serialize = { git = "https://github.com/egraphs-good/egraph-serialize", rev = "5838c036623e91540831745b1574539e01c8cb23" }
# egraph-serialize = { path = "../egraph-serialize" }
# Use unreleased version of egglog in experimental
[patch.'https://github.com/egraphs-good/egglog']
# https://github.com/rust-lang/cargo/issues/5478#issuecomment-522719793
egglog = { git = "https://github.com/saulshanabrook/egg-smol.git", rev = "889ca7635368d7e382e16a93b2883aba82f1078f" }

# [replace]
# 'https://github.com/egraphs-good/egglog.git#[email protected]' = { git = "https://github.com/egraphs-good/egglog.git", rev = "215714e1cbb13ae9e21bed2f2e1bf95804571512" }

# enable debug symbols for easier profiling
# [profile.release]
Expand Down
10 changes: 10 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ _This project uses semantic versioning_
- Use `add_note` for exception to add more context, instead of raising a new exception, to make it easier to debug.
- Add conversions from generic types to be supported at runtime and typing level (so can go from `(1, 2, 3)` to `TupleInt`)
- Open files with webbrowser instead of internal graphviz util for better support
- Add support for not visualizing when using `.saturate()` method [#254](https://github.com/egraphs-good/egglog-python/pull/254)
- Upgrade [egglog](https://github.com/egraphs-good/egglog/compare/b0db06832264c9b22694bd3de2bdacd55bbe9e32...saulshanabrook:egg-smol:889ca7635368d7e382e16a93b2883aba82f1078f)
- This includes a few big changes to the underlying bindings, which I won't go over in full detail here. See the [pyi diff](https://github.com/egraphs-good/egglog-python/pull/258/files#diff-f34a5dd5d6568cd258ed9f786e5abce03df5ee95d356ea9e1b1b39e3505e5d62) for all public changes.
- Creates seperate parent classes for `BuiltinExpr` vs `Expr` (aka eqsort aka user defined expressions). This is to
allow us statically to differentiate between the two, to be more precise about what behavior is allowed. For example,
`union` can only take `Expr` and not `BuiltinExpr`.
- Removes deprecated support for modules and building functions off of the e-egraph.
- Updates function constructor to remove `default` and `on_merge`. You also can't set a `cost` when you use a `merge`
function or return a primitive.
- `eq` now only takes two args, instead of being able to compare any number of values.

## 8.0.1 (2024-10-24)

Expand Down
6 changes: 3 additions & 3 deletions docs/how-to-guides.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ file_format: mystnb

## Parsing and running program strings

You can provide your program in a special DSL language. You can parse this with {meth}`egglog.bindings.parse_program` and then run the result with You can parse this with {meth}`egglog.bindings.EGraph.run_program`::
You can provide your program in a special DSL language. You can parse this with {meth}`egglog.bindings.EGraph.parse_program` and then run the result with You can parse this with {meth}`egglog.bindings.EGraph.run_program`::

```{code-cell}
from egglog.bindings import EGraph, parse_program
from egglog.bindings import EGraph

egraph = EGraph()
commands = parse_program("(check (= (+ 1 2) 3))")
commands = egraph.parse_program("(check (= (+ 1 2) 3))")
commands
```

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ eqsat_basic = """(datatype Math
(check (= expr1 expr2))"""

egraph = EGraph()
commands = parse_program(eqsat_basic)
commands = egraph.parse_program(eqsat_basic)
egraph.run_program(*commands)
```

Expand Down
13 changes: 10 additions & 3 deletions docs/reference/egglog-translation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ Any EGraph can also be converted to egglog with the `egraph.as_egglog_string` pr

The currently unsupported features are:

- Proof mode: Not currently tested, but could add support if needed.
- Naive mode: Not currently exposed, but could add support
- `(output ...)`: No examples in the tests, so not sure how this works.
- `(calc ...)`: Could be implemented, but haven't yet.

## Builtin Types

Expand Down Expand Up @@ -124,6 +121,16 @@ def my_foo() -> i64:

The static types on the decorator preserve the type of the underlying function, so that they can all be checked statically.

### Functions vs Constructors

Egglog has changed how it handles functions, seperating them into two seperate commands:

- `function` which can include a `merge` expression.
- `constructor` which can include a cost and requires the result to be an "eqsort" aka a non builtin type.

Since this was added after the Python API was first created, we added support to automatically choose between the two based on the return type of the function and whether a merge function is provided. If the return type is a builtin type, it will be a `function`, otherwise it will be a `constructor`, unless it has a merge function
provided then it will always be a `function`.

### Datatype functions

In egglog, the `(datatype ...)` command can also be used to declare functions. All of the functions declared in this block return the type of the declared datatype. Similarly, in Python, any methods of an `Expr` will be registered automatically. These
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ strict_equality = true
warn_unused_configs = true
allow_redefinition = true
exclude = ["__snapshots__", "_build", "^conftest.py$"]
# mypy_path = "python"
# explicit_package_bases = true
# namespace_packages = true

[tool.maturin]
python-source = "python"
Expand Down
Loading
Loading