diff options
author | JSDurand <mmemmew@gmail.com> | 2023-08-09 11:42:03 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2023-08-09 11:42:03 +0800 |
commit | f14c8a2aeab18a9bfa380df28f94736580e08f48 (patch) | |
tree | 352cdff6872c9c48575c7dfcfd02a5924a8d2ad9 /chain/src/default.rs | |
parent | f4f8b84a3a95bea42c118d14697076c2de52c8bb (diff) |
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.
Diffstat (limited to 'chain/src/default.rs')
-rw-r--r-- | chain/src/default.rs | 19 |
1 files changed, 17 insertions, 2 deletions
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)?; |