From f14c8a2aeab18a9bfa380df28f94736580e08f48 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Wed, 9 Aug 2023 11:42:03 +0800 Subject: Fix a bug of using incorrect forest nodes to plant. Previously some incorrect forest nodes will be used for planting new nodes. I cannot fix the root cause of their presence in the chain-rule machine. But I can ignore them when they are encountered. Of course I would like to really prevent them from existing, but still cannot figure out how. --- chain/src/default.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'chain/src/default.rs') diff --git a/chain/src/default.rs b/chain/src/default.rs index 1e0eba2..11f0c93 100644 --- a/chain/src/default.rs +++ b/chain/src/default.rs @@ -633,6 +633,7 @@ impl Chain for DefaultChain { let mut new_label = *child_label; new_label.set_true_source(true_pavi); + // new_label.set_forest_source(pavi); output.extend( std::iter::repeat(new_label.into()) @@ -723,6 +724,20 @@ impl Chain for DefaultChain { continue; } + #[allow(clippy::single_match)] + match label.forest_source() { + PaVi::Parent(node, _, _) => match self.forest.vertex_label(node) { + Ok(Some(label)) => match label.label().end() { + Some(end) if end != pos => { + continue; + } + _ => {} + }, + _ => {} + }, + _ => {} + } + let virtual_node = self .atom .atom(non, t) @@ -911,7 +926,7 @@ impl Chain for DefaultChain { // First perform reduction. - let _ = self.forest.print_viz("forest before reduction.gv"); + // let _ = self.forest.print_viz("forest before reduction.gv"); // self.forest.reduction(root, pos, ter, &self.atom, true)?; @@ -1070,7 +1085,7 @@ impl Chain for DefaultChain { self.atom.print_virtual(); let _ = item::default::print_labels(&self.atom, &self.forest); - let _ = self.forest.print_viz("forest before extraction.gv"); + // let _ = self.forest.print_viz("forest before extraction.gv"); result = self.forest.extract(pos)?; -- cgit v1.2.3-18-g5258