From 81854107bcf0b4480cfb11e8af7fec6894240c0c Mon Sep 17 00:00:00 2001 From: JSDurand Date: Tue, 1 Aug 2023 11:47:44 +0800 Subject: Fix some bugs Some bugs are fixed: 1. If a non-terminal expansion can be reduced immediately, previously an extra node would be created that had no parents. Now this strange behaviour is corrected. 2. When performing reductions, a leaf non-terminal node would previously be regarded as completed. Now we will first try to complete that node, and then determine if the completion is successful, and finally determine the completedness according to the result. Of course some more tests are still pending, before I can confirm that no more bugs lurk around. --- chain/src/item/reduction.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'chain/src/item/reduction.rs') diff --git a/chain/src/item/reduction.rs b/chain/src/item/reduction.rs index 3c76c1e..512862a 100644 --- a/chain/src/item/reduction.rs +++ b/chain/src/item/reduction.rs @@ -139,6 +139,10 @@ impl DefaultForest> { ) -> Result { let mut result = node; + // if node == 15 && pos == 2 { + // let _ = self.print_viz("pos really before splone.gv"); + // } + // step 1: Determine if this needs reductions. if !accept_root && self.root() == Some(node) { @@ -346,10 +350,14 @@ impl DefaultForest> { panic!("a terminal node {top} has no ending position?"); } Some(TNT::Non(nt)) => { - correct_ends.insert(top, Correct); - self.close_pavi(atom.borrow(), PaVi::Virtual(nt, ter, top), pos)?; + // dbg!(top, nt, ter, pos, self.degree(top)?, degree); + + let correctness = self.degree(top)? > 0; + + correct_ends.insert(top, correctness.into()); + continue 'stack_loop; } None => { @@ -404,6 +412,11 @@ impl DefaultForest> { // NOTE: We must fix the order from top to bottom: this is the // reverse order of `order_of_correct_ends` . + // if node == 15 && pos == 2 { + // dbg!(&order_of_correct_ends); + // let _ = self.print_viz("pos before splone.gv"); + // } + for node in order_of_correct_ends.into_iter().rev() { let label = self.vertex_label(node)?.ok_or(Error::NodeNoLabel(node))?; let degree = self.degree(node)?; @@ -421,6 +434,10 @@ impl DefaultForest> { let last_index = degree - 1; + // if node == 15 && pos == 2 { + // let _ = self.print_viz("before splone.gv"); + // } + self.splone(node, Some(pos), last_index, false)?; } -- cgit v1.2.3-18-g5258