pub fn rebuild(&mut self) -> usize {
        let old_hc_size = self.memo.len();
        let old_n_eclasses = self.number_of_classes();

        let start = Instant::now();

        let n_unions = self.process_unions();
        let trimmed_nodes = self.rebuild_classes();

        let elapsed = start.elapsed();
        info!(
            concat!(
                "REBUILT! in {}.{:03}s\n",
                "  Old: hc size {}, eclasses: {}\n",
                "  New: hc size {}, eclasses: {}\n",
                "  unions: {}, trimmed nodes: {}"
            ),
            elapsed.as_secs(),
            elapsed.subsec_millis(),
            old_hc_size,
            old_n_eclasses,
            self.memo.len(),
            self.number_of_classes(),
            n_unions,
            trimmed_nodes,
        );

        debug_assert!(self.check_memo());
        n_unions
    }
/// Restores the egraph invariants of congruence and enode uniqueness.
///
/// As mentioned
/// [in the tutorial](tutorials/_01_background/index.html#invariants-and-rebuilding),
/// `egg` takes a lazy approach to maintaining the egraph invariants.
/// The `rebuild` method allows the user to manually restore those
/// invariants at a time of their choosing. It's a reasonably
/// fast, linear-ish traversal through the egraph.
///
/// # Example
/// ```
/// use egg::{*, SymbolLang as S};
/// let mut egraph = EGraph::<S, ()>::default();
/// let x = egraph.add(S::leaf("x"));
/// let y = egraph.add(S::leaf("y"));
/// let ax = egraph.add_expr(&"(+ a x)".parse().unwrap());
/// let ay = egraph.add_expr(&"(+ a y)".parse().unwrap());
///
/// // The effects of this union aren't yet visible; ax and ay
/// // should be equivalent by congruence since x = y.
/// egraph.union(x, y);
/// // Classes: [x y] [ax] [ay] [a]
/// assert_eq!(egraph.number_of_classes(), 4);
/// assert_ne!(egraph.find(ax), egraph.find(ay));
///
/// // Rebuilding restores the invariants, finding the "missing" equivalence
/// egraph.rebuild();
/// // Classes: [x y] [ax ay] [a]
/// assert_eq!(egraph.number_of_classes(), 3);
/// assert_eq!(egraph.find(ax), egraph.find(ay));
/// ```
Restores the egraph invariants of congruence and enode uniqueness.
As mentioned
[in the tutorial](tutorials/_01_background/index.html#invariants-and-rebuilding),
`egg` takes a lazy approach to maintaining the egraph invariants.
The `rebuild` method allows the user to manually restore those
invariants at a time of their choosing. It's a reasonably
fast, linear-ish traversal through the egraph.
Restores the egraph invariants of congruence and enode uniqueness . As mentioned [ in the tutorial ] ( tutorials / _01_background / index . html#invariants - and - rebuilding ) ` egg ` takes a lazy approach to maintaining the egraph invariants . The ` rebuild ` method allows the user to manually restore those invariants at a time of their choosing . It ' s a reasonably fast linear - ish traversal through the egraph .
pub fn rebuild(&mut self) -> usize {
        let old_hc_size = self.memo.len();
        let old_n_eclasses = self.number_of_classes();
        let start = Instant::now();
        let n_unions = self.process_unions();
        let trimmed_nodes = self.rebuild_classes();
        let elapsed = start.elapsed();
        info!(
            concat!(
                "REBUILT! in {}.{:03}s\n",
                "  Old: hc size {}, eclasses: {}\n",
                "  New: hc size {}, eclasses: {}\n",
                "  unions: {}, trimmed nodes: {}"
            ),
            elapsed.as_secs(),
            elapsed.subsec_millis(),
            old_hc_size,
            old_n_eclasses,
            self.memo.len(),
            self.number_of_classes(),
            n_unions,
            trimmed_nodes,
        );
        debug_assert!(self.check_memo());
        n_unions
    }
pub fn rebuild ( & mut self ) -> usize { let old_hc_size = self . memo . len ( ) ; let old_n_eclasses = self . number_of_classes ( ) ; let start = Instant :: now ( ) ; let n_unions = self . process_unions ( ) ; let trimmed_nodes = self . rebuild_classes ( ) ; let elapsed = start . elapsed ( ) ; info ! ( concat ( " \n " " \n " " \n " " " ) elapsed as_secs ( ) elapsed subsec_millis ( ) old_hc_size old_n_eclasses self memo len ( ) self number_of_classes ( ) n_unions trimmed_nodes ) ; debug_assert ! ( self check_memo ( ) ) ; n_unions }
Restores the egraph invariants of congruence and enode uniqueness.
Restores the egraph invariants of congruence and enode uniqueness .
&mut self
&mut self
example
```
use egg::{*, SymbolLang as S};
let mut egraph = EGraph::::default();
let x = egraph.add(S::leaf("x"));
let y = egraph.add(S::leaf("y"));
let ax = egraph.add_expr(&"(+ a x)".parse().unwrap());
let ay = egraph.add_expr(&"(+ a y)".parse().unwrap()).

The effects of this union aren't yet visible; ax and ay
should be equivalent by congruence since x = y.
egraph.union(x, y);
Classes: [x y] [ax] [ay] [a]
assert_eq!, 4);
assert_ne!, egraph.find(ay)).

Rebuilding restores the invariants, finding the "missing" equivalence
egraph.rebuild();
Classes: [x y] [ax ay] [a]
assert_eq!, 3);
assert_eq!, egraph.find(ay));
```
` ` ` use egg :: { * SymbolLang as S } ; let mut egraph = EGraph :::: default () ; let x = egraph . add ( S :: leaf ( " x " )) ; let y = egraph . add ( S :: leaf ( " y " )) ; let ax = egraph . add_expr ( & " ( + a x ) " . parse () . unwrap () ) ; let ay = egraph . add_expr ( & " ( + a y ) " . parse () . unwrap () ) . The effects of this union aren ' t yet visible ; ax and ay should be equivalent by congruence since x = y . egraph . union ( x y ) ; Classes : [ x y ] [ ax ] [ ay ] [ a ] assert_eq! 4 ) ; assert_ne! egraph . find ( ay )) . Rebuilding restores the invariants finding the " missing " equivalence egraph . rebuild () ; Classes : [ x y ] [ ax ay ] [ a ] assert_eq! 3 ) ; assert_eq! egraph . find ( ay )) ; ` ` `