Skip to content

Commit

Permalink
Merge pull request #6 from dewert99/plat-egg
Browse files Browse the repository at this point in the history
Rename to plat-egg
  • Loading branch information
dewert99 authored May 26, 2024
2 parents 788095a + 722868f commit b97e663
Show file tree
Hide file tree
Showing 27 changed files with 110 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ target
Cargo.lock

dots/
egg/data/
plat_egg/data/

# nix stuff
.envrc
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "An implementation of egraphs"
edition = "2021"
keywords = ["e-graphs"]
license = "MIT"
name = "egg"
name = "plat-egg"
readme = "README.md"
repository = "https://github.com/egraphs-good/egg"
version = "0.9.5"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is a fork of [egg](https://github.com/egraphs-good/egg) primarily designed for
[bat_egg_smt](https://github.com/dewert99/bat_egg_smt) (a toy QF_UF smt solver). It is still
[plat-smt](https://github.com/dewert99/plat-smt) (a toy QF_UF smt solver). It is still
mostly compatible with the original version of egg when using the "egg_compat" feature
(enabled by default).

4 changes: 2 additions & 2 deletions src/dot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The [`EGraphResidual::dot`] method creates `Dot`s.
# Example
```no_run
use egg::{*, rewrite as rw};
use plat_egg::{*, rewrite as rw};
let rules = &[
rw!("mul-commutes"; "(* ?x ?y)" => "(* ?y ?x)"),
Expand Down Expand Up @@ -141,7 +141,7 @@ mod std_only {
///
/// Can be used to run a different binary than `dot`:
/// ```no_run
/// # use egg::*;
/// # use plat_egg::*;
/// # let mut egraph: EGraph<SymbolLang, ()> = Default::default();
/// egraph.dot().run(
/// "/path/to/my/dot",
Expand Down
16 changes: 8 additions & 8 deletions src/egraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {
/// Actually returns the size of the hashcons index.
/// # Example
/// ```
/// use egg::{*, SymbolLang as S};
/// use plat_egg::{*, SymbolLang as S};
/// let mut egraph = EGraph::<S, ()>::default();
/// let x = egraph.add(S::leaf("x"));
/// let y = egraph.add(S::leaf("y"));
Expand Down Expand Up @@ -189,7 +189,7 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {
self
}

/// By default, egg runs a greedy algorithm to reduce the size of resulting explanations (without complexity overhead).
/// By default, plat_egg runs a greedy algorithm to reduce the size of resulting explanations (without complexity overhead).
/// Use this function to turn this algorithm off.
pub fn without_explanation_length_optimization(mut self) -> Self {
if let Some(explain) = &mut self.explain {
Expand All @@ -200,7 +200,7 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {
}
}

/// By default, egg runs a greedy algorithm to reduce the size of resulting explanations (without complexity overhead).
/// By default, plat_egg runs a greedy algorithm to reduce the size of resulting explanations (without complexity overhead).
/// Use this function to turn this algorithm on again if you have turned it off.
pub fn with_explanation_length_optimization(mut self) -> Self {
if let Some(explain) = &mut self.explain {
Expand Down Expand Up @@ -552,7 +552,7 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {
///
/// # Example
/// ```
/// use egg::{*, SymbolLang as S};
/// use plat_egg::{*, SymbolLang as S};
/// let mut egraph = EGraph::<S, ()>::default();
/// let x = egraph.add(S::leaf("x"));
/// let y = egraph.add(S::leaf("y"));
Expand Down Expand Up @@ -668,7 +668,7 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {
///
/// ## Example
/// ```
/// # use egg::*;
/// # use plat_egg::*;
/// let mut egraph: EGraph<SymbolLang, ()> = EGraph::default().with_explanations_enabled();
/// let a = egraph.add_uncanonical(SymbolLang::leaf("a"));
/// let b = egraph.add_uncanonical(SymbolLang::leaf("b"));
Expand All @@ -687,7 +687,7 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {
///
/// # Example
/// ```
/// # use egg::*;
/// # use plat_egg::*;
/// let mut egraph: EGraph<SymbolLang, ()> = EGraph::default().with_explanations_disabled();
/// let a = egraph.add_uncanonical(SymbolLang::leaf("a"));
/// let b = egraph.add_uncanonical(SymbolLang::leaf("b"));
Expand Down Expand Up @@ -1075,7 +1075,7 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {
///
/// # Example
/// ```
/// use egg::{*, SymbolLang as S};
/// use plat_egg::{*, SymbolLang as S};
/// let mut egraph = EGraph::<S, ()>::default();
/// let x = egraph.add(S::leaf("x"));
/// let y = egraph.add(S::leaf("y"));
Expand Down Expand Up @@ -1179,7 +1179,7 @@ where
/// it with the previously [`push`](EGraph::push)ed egraph
///
/// ```
/// use egg::{EGraph, SymbolLang};
/// use plat_egg::{EGraph, SymbolLang};
/// let mut egraph = EGraph::new(()).with_push_pop_enabled();
/// let a = egraph.add_uncanonical(SymbolLang::leaf("a"));
/// let b = egraph.add_uncanonical(SymbolLang::leaf("b"));
Expand Down
2 changes: 1 addition & 1 deletion src/explain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub struct Explain<L: Language> {
))
)]
pub uncanon_memo: HashMap<L, Id>,
/// By default, egg uses a greedy algorithm to find shorter explanations when they are extracted.
/// By default, plat_egg uses a greedy algorithm to find shorter explanations when they are extracted.
pub optimize_explanation_lengths: bool,
// For a given pair of enodes in the same eclass,
// stores the length of the shortest found explanation
Expand Down
10 changes: 5 additions & 5 deletions src/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{Analysis, EClass, EGraph, Id, Language, RecExpr};
/** Extracting a single [`RecExpr`] from an [`EGraph`].
```
use egg::*;
use plat_egg::*;
define_language! {
enum SimpleLanguage {
Expand Down Expand Up @@ -55,7 +55,7 @@ The example below illustrates a silly but realistic example of
implementing a cost function that is essentially AST size weighted by
the operator:
```
# use egg::*;
# use plat_egg::*;
struct SillyCostFn;
impl CostFunction<SymbolLang> for SillyCostFn {
type Cost = f64;
Expand All @@ -82,7 +82,7 @@ If you'd like to access the [`Analysis`] data or anything else in the e-graph,
you can put a reference to the e-graph in your [`CostFunction`]:
```
# use egg::*;
# use plat_egg::*;
# type MyAnalysis = ();
struct EGraphCostFn<'a> {
egraph: &'a EGraph<SymbolLang, MyAnalysis>,
Expand Down Expand Up @@ -148,7 +148,7 @@ pub trait CostFunction<L: Language> {
/** A simple [`CostFunction`] that counts total AST size.
```
# use egg::*;
# use plat_egg::*;
let e: RecExpr<SymbolLang> = "(do_it foo bar baz)".parse().unwrap();
assert_eq!(AstSize.cost_rec(&e), 4);
```
Expand All @@ -169,7 +169,7 @@ impl<L: Language> CostFunction<L> for AstSize {
/** A simple [`CostFunction`] that counts maximum AST depth.
```
# use egg::*;
# use plat_egg::*;
let e: RecExpr<SymbolLang> = "(do_it foo bar baz)".parse().unwrap();
assert_eq!(AstDepth.cost_rec(&e), 2);
```
Expand Down
10 changes: 5 additions & 5 deletions src/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use thiserror::Error;
/// [`from_op`]:
///
/// ```
/// # use egg::*;
/// # use plat_egg::*;
/// # use std::fmt::Display;
/// fn from_op_display_compatible<T: FromOp + Display>(node: T) {
/// let op = node.to_string();
Expand All @@ -37,7 +37,7 @@ use thiserror::Error;
/// # Examples
/// `define_language!` implements [`FromOp`] and [`Display`] automatically:
/// ```
/// # use egg::*;
/// # use plat_egg::*;
///
/// define_language! {
/// enum Calc {
Expand Down Expand Up @@ -233,7 +233,7 @@ impl<L: Language + Display> RecExpr<L> {
///
/// # Example
/// ```
/// # use egg::*;
/// # use plat_egg::*;
/// let e: RecExpr<SymbolLang> = "(* (+ 2 2) (+ x y))".parse().unwrap();
/// assert_eq!(e.pretty(10), "
/// (*
Expand Down Expand Up @@ -355,7 +355,7 @@ just use that.
# Example
```
use egg::{*, rewrite as rw};
use plat_egg::{*, rewrite as rw};
define_language! {
enum SimpleMath {
Expand All @@ -374,7 +374,7 @@ impl Analysis<SimpleMath> for ConstantFolding {
type Data = Option<i32>;
fn merge(&mut self, to: &mut Self::Data, from: Self::Data) -> DidMerge {
egg::merge_max(to, from)
plat_egg::merge_max(to, from)
}
fn make(egraph: &mut EGraph<SimpleMath, Self>, enode: &SimpleMath) -> Self::Data {
Expand Down
2 changes: 1 addition & 1 deletion src/lp_extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<L: Language, N: Analysis<L>> LpCostFunction<L, N> for AstSize {
///
/// # Example
/// ```
/// use egg::*;
/// use plat_egg::*;
/// let mut egraph = EGraph::<SymbolLang, ()>::default();
///
/// let f = egraph.add_expr(&"(f x x x)".parse().unwrap());
Expand Down
6 changes: 3 additions & 3 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ be added later.
The following macro invocation shows the the accepted forms of variants:
```
# use egg::*;
# use plat_egg::*;
define_language! {
enum SimpleLanguage {
// string variant with no children
Expand Down Expand Up @@ -234,7 +234,7 @@ the outermost, and the last condition being the innermost.
# Example
```
# use egg::*;
# use plat_egg::*;
use std::borrow::Cow;
use std::sync::Arc;
define_language! {
Expand All @@ -247,7 +247,7 @@ define_language! {
}
}
type EGraph = egg::EGraph<SimpleLanguage, ()>;
type EGraph = plat_egg::EGraph<SimpleLanguage, ()>;
let mut rules: Vec<Rewrite<SimpleLanguage, ()>> = vec![
rewrite!("commute-add"; "(+ ?a ?b)" => "(+ ?b ?a)"),
Expand Down
2 changes: 1 addition & 1 deletion src/multipattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl<L: Language> MultiPattern<L> {
/// Creates a new multipattern, binding the given patterns to the corresponding variables.
///
/// ```
/// use egg::*;
/// use plat_egg::*;
///
/// let mut egraph = EGraph::<SymbolLang, ()>::default();
/// egraph.add_expr(&"(f a a)".parse().unwrap());
Expand Down
2 changes: 1 addition & 1 deletion src/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::*;
/// This is probably how you'll create most [`Pattern`]s.
///
/// ```
/// use egg::*;
/// use plat_egg::*;
/// define_language! {
/// enum Math {
/// Num(i32),
Expand Down
12 changes: 6 additions & 6 deletions src/raw/egraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl<L: Language> EGraphResidual<L> {
///
/// # Example
/// ```
/// use egg::{raw::*, SymbolLang as S};
/// use plat_egg::{raw::*, SymbolLang as S};
/// let mut egraph = RawEGraph::<S, ()>::default();
/// let x = egraph.add_uncanonical(S::leaf("x"));
/// let y = egraph.add_uncanonical(S::leaf("y"));
Expand All @@ -110,7 +110,7 @@ impl<L: Language> EGraphResidual<L> {
/// Returns `true` if the egraph is empty
/// # Example
/// ```
/// use egg::{raw::*, SymbolLang as S};
/// use plat_egg::{raw::*, SymbolLang as S};
/// let mut egraph = RawEGraph::<S, ()>::default();
/// assert!(egraph.is_empty());
/// egraph.add_uncanonical(S::leaf("foo"));
Expand All @@ -124,7 +124,7 @@ impl<L: Language> EGraphResidual<L> {
///
/// # Example
/// ```
/// use egg::{raw::*, SymbolLang as S};
/// use plat_egg::{raw::*, SymbolLang as S};
/// let mut egraph = RawEGraph::<S, ()>::default();
/// let x = egraph.add_uncanonical(S::leaf("x"));
/// let y = egraph.add_uncanonical(S::leaf("y"));
Expand Down Expand Up @@ -164,7 +164,7 @@ impl<L: Language> EGraphResidual<L> {
/// Actually returns the size of the hashcons index.
/// # Example
/// ```
/// use egg::{raw::*, SymbolLang as S};
/// use plat_egg::{raw::*, SymbolLang as S};
/// let mut egraph = RawEGraph::<S, ()>::default();
/// let x = egraph.add_uncanonical(S::leaf("x"));
/// let y = egraph.add_uncanonical(S::leaf("y"));
Expand All @@ -186,7 +186,7 @@ impl<L: Language> EGraphResidual<L> {
///
/// # Example
/// ```
/// # use egg::{SymbolLang, raw::*};
/// # use plat_egg::{SymbolLang, raw::*};
/// let mut egraph: RawEGraph<SymbolLang, ()> = Default::default();
/// let a = egraph.add_uncanonical(SymbolLang::leaf("a"));
/// let b = egraph.add_uncanonical(SymbolLang::leaf("b"));
Expand Down Expand Up @@ -217,7 +217,7 @@ impl<L: Language> EGraphResidual<L> {
///
/// # Example
/// ```
/// # use egg::{SymbolLang, raw::*};
/// # use plat_egg::{SymbolLang, raw::*};
/// let mut egraph: RawEGraph<SymbolLang, ()> = Default::default();
/// let a = egraph.add_uncanonical(SymbolLang::leaf("a"));
/// let b = egraph.add_uncanonical(SymbolLang::leaf("b"));
Expand Down
4 changes: 2 additions & 2 deletions src/raw/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub trait Language: Debug + Clone + Eq + Ord + Hash {
///
/// # Example
/// ```
/// # use egg::*;
/// # use plat_egg::*;
/// let a_plus_2: RecExpr<SymbolLang> = "(+ a 2)".parse().unwrap();
/// // here's an enode with some meaningless child ids
/// let enode = SymbolLang::new("*", vec![Id::from(0), Id::from(0)]);
Expand Down Expand Up @@ -234,7 +234,7 @@ pub trait Language: Debug + Clone + Eq + Ord + Hash {
/// You could use this method to perform an "ad-hoc" extraction from the e-graph,
/// where you already know which node you want pick for each class:
/// ```
/// # use egg::*;
/// # use plat_egg::*;
/// let mut egraph = EGraph::<SymbolLang, ()>::default();
/// let expr = "(foo (bar1 (bar2 (bar3 baz))))".parse().unwrap();
/// let root = egraph.add_expr(&expr);
Expand Down
4 changes: 2 additions & 2 deletions src/raw/semi_persistent1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ impl<L: Language, D, U: AsUnwrap<UndoLog>> RawEGraph<L, D, U> {
///
/// # Example
/// ```
/// use egg::{raw::*, SymbolLang as S};
/// use egg::raw::semi_persistent1::UndoLog;
/// use plat_egg::{raw::*, SymbolLang as S};
/// use plat_egg::raw::semi_persistent1::UndoLog;
/// let mut egraph = RawEGraph::<S, (), UndoLog>::default();
/// let a = egraph.add_uncanonical(S::leaf("a"));
/// let fa = egraph.add_uncanonical(S::new("f", vec![a]));
Expand Down
4 changes: 2 additions & 2 deletions src/raw/semi_persistent2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ impl<L: Language, D, U: AsUnwrap<UndoLog>> RawEGraph<L, D, U> {
///
/// # Example
/// ```
/// use egg::{raw::*, SymbolLang as S};
/// use egg::raw::semi_persistent2::UndoLog;
/// use plat_egg::{raw::*, SymbolLang as S};
/// use plat_egg::raw::semi_persistent2::UndoLog;
/// let mut egraph = RawEGraph::<S, (), UndoLog>::default();
/// let a = egraph.add_uncanonical(S::leaf("a"));
/// let fa = egraph.add_uncanonical(S::new("f", vec![a]));
Expand Down
4 changes: 2 additions & 2 deletions src/rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ where
///
/// # Example
/// ```
/// use egg::{rewrite as rw, *};
/// use plat_egg::{rewrite as rw, *};
/// use std::sync::Arc;
///
/// define_language! {
Expand All @@ -245,7 +245,7 @@ where
/// }
/// }
///
/// type EGraph = egg::EGraph<Math, MinSize>;
/// type EGraph = plat_egg::EGraph<Math, MinSize>;
///
/// // Our metadata in this case will be size of the smallest
/// // represented expression in the eclass.
Expand Down
Loading

0 comments on commit b97e663

Please sign in to comment.