close to getting Example_SRTM_Diagonal
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Sun, 12 Jan 2025 10:43:28 +0000 (10:43 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Sun, 12 Jan 2025 10:43:28 +0000 (10:43 +0000)
34 files changed:
developer/document🖉/diagonal_traversal.txt [new file with mode: 0644]
developer/example/CountingNumber/CountingNumber$Topo_Infinite.class [new file with mode: 0644]
developer/example/CountingNumber/CountingNumber$Topo_Null.class [new file with mode: 0644]
developer/example/CountingNumber/CountingNumber$Topo_Rightmost.class [new file with mode: 0644]
developer/example/CountingNumber/CountingNumber$Topo_Segment.class [new file with mode: 0644]
developer/example/CountingNumber/CountingNumber.class [new file with mode: 0644]
developer/example/CountingNumber/Example_CountingNumber_0 [new file with mode: 0755]
developer/example/CountingNumber/Example_CountingNumber_0.class [new file with mode: 0644]
developer/example/CountingNumber/temp.java [deleted file]
developer/example/IndexTree/Example_4x4 [deleted file]
developer/example/IndexTree/Example_4x4.class [deleted file]
developer/example/IndexTree/Example_SRTM_Diagonal [deleted file]
developer/example/IndexTree/Example_SRTM_Diagonal.class [deleted file]
developer/example/IndexTree/Example_SRTM_Diagonal.java
developer/example/IndexTree/Graph.class [deleted file]
developer/example/IndexTree/Label.class [deleted file]
developer/example/IndexTree/Label.java
developer/example/IndexTree/Node.class [deleted file]
developer/example/IndexTree/SRTM_Child$1.class [deleted file]
developer/example/IndexTree/SRTM_Child$2.class [deleted file]
developer/example/IndexTree/SRTM_Child$3.class [deleted file]
developer/example/IndexTree/SRTM_Child.class [deleted file]
developer/example/IndexTree/SRTM_Child.java
developer/example/IndexTree/SRTM_Diagonal.java
developer/example/SRTM/Example_SRTMI_Array [new file with mode: 0755]
developer/example/SRTM/Example_SRTMI_Array.class [new file with mode: 0644]
developer/example/SRTM/Example_SRTM_List [new file with mode: 0755]
developer/example/SRTM/Example_SRTM_List.class [new file with mode: 0644]
developer/example/SRTM/Example_SRTM_List.java
developer/javac🖉/Ariadne_Label.java
developer/javac🖉/Ariadne_Label_String.java
developer/javac🖉/Ariadne_SRTM_List.java
developer/tool🖉/make
developer/tool🖉/make_example

diff --git a/developer/document🖉/diagonal_traversal.txt b/developer/document🖉/diagonal_traversal.txt
new file mode 100644 (file)
index 0000000..b10710f
--- /dev/null
@@ -0,0 +1,53 @@
+Does there exist a node in the tree, such that if that node were marked before the diagonal generating algorithm is run, that that node will never be reached no matter how long the diagonal generating algorithm runs?  Or perhaps you can't tell.
+ChatGPT said:
+ChatGPT
+This is an interesting and profound question that touches on the completeness of the diagonal traversal algorithm in enumerating all nodes in an infinite tree. Let’s analyze it step by step.
+
+Key Observations About the Algorithm
+Breadth and Depth Expansion:
+
+The diagonal algorithm explicitly alternates between "expanding down" to include children of nodes on the current diagonal and "expanding across" to include siblings of nodes already encountered.
+Infinite Iterations:
+
+The algorithm iteratively generates new diagonals, and given infinite time, it will traverse every node that can be reached by a finite number of inc_down and inc_across operations.
+Traversal Guarantee:
+
+The algorithm systematically enumerates every node along both depth and breadth. No node can be skipped permanently unless:
+It cannot be reached via any sequence of inc_down and inc_across operations starting from the root.
+The marking somehow prevents traversal.
+Impact of Marking a Node
+If a node is marked before the algorithm starts:
+
+Does Marking Influence the Algorithm?
+
+In the current implementation, the diagonal algorithm operates solely on labels and their incremental modifications (inc_down and inc_across). The marking state of a node is not factored into the traversal logic. Therefore:
+Marking a node has no direct effect on whether the algorithm traverses it.
+The algorithm will still reach every node, regardless of whether it is marked.
+Can a Marked Node Be Skipped?
+
+No, the diagonal algorithm’s design ensures that every node in the infinite tree will eventually be reached, even if it is marked, because:
+Marking is a separate property and does not alter the traversal mechanics.
+The algorithm is exhaustive in both depth (inc_down) and breadth (inc_across).
+Does Any Node Remain Unreachable?
+To ensure there is no unreachable node:
+
+Structural Guarantees:
+
+The index tree is connected, meaning every node is reachable from the root via a finite sequence of operations.
+Algorithm Completeness:
+
+The diagonal algorithm guarantees eventual traversal of every node by alternating between expanding depth and breadth.
+No Skipped Nodes:
+
+Since the algorithm generates all possible sequences of inc_down and inc_across, there cannot exist a node in the tree that remains permanently unreachable.
+Conclusion
+No, there does not exist a node in the infinite index tree that, if marked beforehand, would never be reached by the diagonal generating algorithm.
+
+The diagonal algorithm traverses every node eventually, regardless of marking.
+Marking only adds an attribute to nodes but does not interfere with the traversal mechanism.
+Let me know if you'd like a deeper mathematical formalism for this or additional edge cases analyzed! ðŸ˜Š
+
+
+
+
+
diff --git a/developer/example/CountingNumber/CountingNumber$Topo_Infinite.class b/developer/example/CountingNumber/CountingNumber$Topo_Infinite.class
new file mode 100644 (file)
index 0000000..24f713f
Binary files /dev/null and b/developer/example/CountingNumber/CountingNumber$Topo_Infinite.class differ
diff --git a/developer/example/CountingNumber/CountingNumber$Topo_Null.class b/developer/example/CountingNumber/CountingNumber$Topo_Null.class
new file mode 100644 (file)
index 0000000..4c8d074
Binary files /dev/null and b/developer/example/CountingNumber/CountingNumber$Topo_Null.class differ
diff --git a/developer/example/CountingNumber/CountingNumber$Topo_Rightmost.class b/developer/example/CountingNumber/CountingNumber$Topo_Rightmost.class
new file mode 100644 (file)
index 0000000..3003cb0
Binary files /dev/null and b/developer/example/CountingNumber/CountingNumber$Topo_Rightmost.class differ
diff --git a/developer/example/CountingNumber/CountingNumber$Topo_Segment.class b/developer/example/CountingNumber/CountingNumber$Topo_Segment.class
new file mode 100644 (file)
index 0000000..09894f9
Binary files /dev/null and b/developer/example/CountingNumber/CountingNumber$Topo_Segment.class differ
diff --git a/developer/example/CountingNumber/CountingNumber.class b/developer/example/CountingNumber/CountingNumber.class
new file mode 100644 (file)
index 0000000..41ce6dc
Binary files /dev/null and b/developer/example/CountingNumber/CountingNumber.class differ
diff --git a/developer/example/CountingNumber/Example_CountingNumber_0 b/developer/example/CountingNumber/Example_CountingNumber_0
new file mode 100755 (executable)
index 0000000..03434e8
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/bash
+java Example_CountingNumber_0
diff --git a/developer/example/CountingNumber/Example_CountingNumber_0.class b/developer/example/CountingNumber/Example_CountingNumber_0.class
new file mode 100644 (file)
index 0000000..8ee76ad
Binary files /dev/null and b/developer/example/CountingNumber/Example_CountingNumber_0.class differ
diff --git a/developer/example/CountingNumber/temp.java b/developer/example/CountingNumber/temp.java
deleted file mode 100644 (file)
index db47630..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-  // Implementation of instance interface.
-  //
-
-  @Override public List<BigInteger[]> read(){
-    return diagonal;
-  }
-
-  @Override public void step(){
-    diagonal.clear();
-
-    // Process unopened nodes
-    while( !list_of__unopened_node.isEmpty() ){
-      BigInteger[] label = list_of__unopened_node.remove(0);
-
-      // Retrieve the node using lookup
-      Ariadne_Node node = lookup(label);
-
-      // Descend by getting neighbors
-      List<BigInteger[]> child_labels = fetch_child_labels(node);
-      if( !child_labels.isEmpty() ){
-        list_of__opened_incomplete_child_list.add(child_labels);
-      }
-    }
-
-    // Process incomplete child lists
-    while( !list_of__opened_incomplete_child_list.isEmpty() ){
-      List<BigInteger[]> child_labels = list_of__opened_incomplete_child_list.remove(0);
-      if( !child_labels.isEmpty() ){
-        BigInteger[] label = child_labels.remove(0);
-        diagonal.add(label);
-
-        // Retrieve node and check its neighbors
-        Ariadne_Node node = lookup(label);
-        if( !fetch_child_labels(node).isEmpty() ){
-          list_of__unopened_node.add(label);
-        }
-      }
-    }
-  }
-
-  private Ariadne_Node lookup(BigInteger[] label){
-    // Perform a lookup to retrieve the node corresponding to the label
-    return Ariadne_Node.make(label);
-  }
diff --git a/developer/example/IndexTree/Example_4x4 b/developer/example/IndexTree/Example_4x4
deleted file mode 100755 (executable)
index 263380a..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-java Example_4x4
diff --git a/developer/example/IndexTree/Example_4x4.class b/developer/example/IndexTree/Example_4x4.class
deleted file mode 100644 (file)
index 0b68688..0000000
Binary files a/developer/example/IndexTree/Example_4x4.class and /dev/null differ
diff --git a/developer/example/IndexTree/Example_SRTM_Diagonal b/developer/example/IndexTree/Example_SRTM_Diagonal
deleted file mode 100755 (executable)
index b170dce..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-java Example_SRTM_Diagonal
diff --git a/developer/example/IndexTree/Example_SRTM_Diagonal.class b/developer/example/IndexTree/Example_SRTM_Diagonal.class
deleted file mode 100644 (file)
index 8eb9033..0000000
Binary files a/developer/example/IndexTree/Example_SRTM_Diagonal.class and /dev/null differ
index f7f15db..6473a04 100644 (file)
@@ -1,7 +1,5 @@
-
-
-import java.math.BigInteger;
-import java.util.Queue;
+import java.util.List;
+import com.ReasoningTechnology.Ariadne.Ariadne_SRTM_List;
 
 public class Example_SRTM_Diagonal {
 
@@ -9,33 +7,34 @@ public class Example_SRTM_Diagonal {
     System.out.println("Starting IndexTree SRTM Example");
 
     // Instantiate the IndexTree Diagonal SRTM
-    SRTM_Diagonal srm = SRTM_Diagonal.make();
+    SRTM_Diagonal srtm = SRTM_Diagonal.make();
 
     int step_count = 0;
     do{
-      System.out.println("Step " + (step_count + 1) + ":");
-      /*
-      Queue<BigInteger[]> read_list = srm.read();
-      if(!read_list.isEmpty()){
-        for(BigInteger[] label : read_list){
-          System.out.println("  Node Label: " + format_label(label));
-        }
+      System.out.println("Diagonal " + step_count + ":");
+
+      // Read and print the current diagonal
+      List<Label> diagonal = srtm.read();
+      Ariadne_SRTM_List<Label> diagonal_srtm = Ariadne_SRTM_List.make(diagonal);
+
+      if( diagonal_srtm.can_read() ){
+        do{
+          Label label = diagonal_srtm.read();
+          System.out.print(label);
+
+          if( !diagonal_srtm.can_step() ) break;
+          System.out.println(" ");
+          diagonal_srtm.step();
+
+        }while(true);
       }
-      */
-      if(step_count == 3) break; // Mid-loop test for inclusive bounds
+
       step_count++;
-      srm.step();
-    }while(true);
-  }
+      if( step_count == 5 ) break; // Stop after 5 diagonals
 
-  private static String format_label(BigInteger[] label){
-    if(label.length == 0) return "[]";
-    StringBuilder formatted = new StringBuilder("[");
-    for(int i = 0; i < label.length; i++){
-      formatted.append(label[i].toString());
-      if(i < label.length - 1) formatted.append(" ,");
-    }
-    formatted.append("]");
-    return formatted.toString();
+      srtm.step();
+    }while( true );
   }
+
 }
+
diff --git a/developer/example/IndexTree/Graph.class b/developer/example/IndexTree/Graph.class
deleted file mode 100644 (file)
index 79b4c84..0000000
Binary files a/developer/example/IndexTree/Graph.class and /dev/null differ
diff --git a/developer/example/IndexTree/Label.class b/developer/example/IndexTree/Label.class
deleted file mode 100644 (file)
index 501d301..0000000
Binary files a/developer/example/IndexTree/Label.class and /dev/null differ
index e94a16f..9f9c673 100644 (file)
@@ -5,6 +5,7 @@ import java.math.BigInteger;
 import java.util.Arrays;
 
 import com.ReasoningTechnology.Ariadne.Ariadne_Label;
+import com.ReasoningTechnology.Ariadne.Ariadne_SRTM_List;
 
 
 public class Label implements Ariadne_Label{
@@ -35,12 +36,11 @@ public class Label implements Ariadne_Label{
   // Instance interface implementation
   //
 
-  @Override public boolean isEmpty(){
+  @Override public boolean is_null(){
     return value == null;
   }
-
-  @Override public String toString(){
-    return Arrays.toString(value);
+  public int length(){
+    return value.length;
   }
 
   @Override public Label copy(){
@@ -68,6 +68,27 @@ public class Label implements Ariadne_Label{
   // Good object citizenship
   //
   
+  @Override public String toString(){
+    if(is_null()) return "Label()";
+    if(length() == 0) return "Label([])";
+
+    StringBuilder formatted = new StringBuilder("Label([");
+
+    // Use precise loop with SRTM_List to iterate
+    Ariadne_SRTM_List<BigInteger> value_srtm = Ariadne_SRTM_List.make(Arrays.asList(value));
+    if(value_srtm.can_read()){
+      do{
+        formatted.append(value_srtm.read().toString());
+        if( !value_srtm.can_step() ) break;
+        value_srtm.step();
+        formatted.append(" ,");
+      }while(true);
+    }
+
+    formatted.append("])");
+    return formatted.toString();
+  }
+
   @Override public boolean equals(Object o){
     if(this == o) return true;
     if( o == null || getClass() != o.getClass() ) return false;
diff --git a/developer/example/IndexTree/Node.class b/developer/example/IndexTree/Node.class
deleted file mode 100644 (file)
index cd5ec53..0000000
Binary files a/developer/example/IndexTree/Node.class and /dev/null differ
diff --git a/developer/example/IndexTree/SRTM_Child$1.class b/developer/example/IndexTree/SRTM_Child$1.class
deleted file mode 100644 (file)
index 1a8f772..0000000
Binary files a/developer/example/IndexTree/SRTM_Child$1.class and /dev/null differ
diff --git a/developer/example/IndexTree/SRTM_Child$2.class b/developer/example/IndexTree/SRTM_Child$2.class
deleted file mode 100644 (file)
index 7f0bdcb..0000000
Binary files a/developer/example/IndexTree/SRTM_Child$2.class and /dev/null differ
diff --git a/developer/example/IndexTree/SRTM_Child$3.class b/developer/example/IndexTree/SRTM_Child$3.class
deleted file mode 100644 (file)
index 115cf24..0000000
Binary files a/developer/example/IndexTree/SRTM_Child$3.class and /dev/null differ
diff --git a/developer/example/IndexTree/SRTM_Child.class b/developer/example/IndexTree/SRTM_Child.class
deleted file mode 100644 (file)
index be56ddb..0000000
Binary files a/developer/example/IndexTree/SRTM_Child.class and /dev/null differ
index 009cf45..2d86c7e 100644 (file)
@@ -1,6 +1,18 @@
+/*
+SRTM_Child represents in the abstract the infinite child list of an
+IndexTree node.  Index tree node labels are paths through the tree, so
+labels can be computed.
+
+SRTM_Child is made from the leftmost child label. Then step() takes
+the current label and computes from it the right neighbor sibling
+node's label.
+
+*/
+
+
 import com.ReasoningTechnology.Ariadne.Ariadne_SRTM_Label;
 
-public class SRTM_Child extends Ariadne_SRTM_Label {
+public class SRTM_Child extends Ariadne_SRTM_Label{
 
   // Static
   //
@@ -23,16 +35,17 @@ public class SRTM_Child extends Ariadne_SRTM_Label {
     this.label = leftmost_child_label.copy();
 
     if( label == null ){
-      set_topology( topo_null );
+      set_topology(topo_null);
       return;
     }
 
-    if( label.isEmpty() ){
-      set_topology( topo_rightmost );
+    // the label for the root node is an empty array, "[]"
+    if( label.length() == 0){
+      set_topology(topo_rightmost);
       return;
     }
 
-    set_topology( topo_infinite_right );
+    set_topology(topo_infinite_right);
   }
 
   // Implementation of the instance interface
index ee5a78b..c0a766c 100644 (file)
@@ -25,56 +25,60 @@ differs from depth first, which would never return to visit the child
 to the right of the leftmost child, and from breadth first, which
 would never descend to the grandchildren level of the tree.
 
+/*
 How diagonalization works:
 
   This is an infinite object, with each node having an infinite number
-  of children, and their being an infinite number of generations,
-  i.e. levels in the tree.
+  of children, and there being an infinite number of generations,
+  i.e., levels in the tree.
 
   Given a label, `inc_across` will turn it into the label for the
   right neighbor sibling, while `inc_down` will turn it into the label
   for the leftmost child.
 
   We compute each next diagonal based on the prior diagonal and a list
-  a 'child_srtm_list'.  We should not modify values in the diagonal,
-  because the calling program might still be using it.  Hence,
-  labels on the diagonal are copies before being modified.
+  called 'child_srtm_list'. We do not modify labels in the diagonal
+  directly because the calling program might still be using it. Instead,
+  labels on the diagonal are copied before being modified.
 
-  Because we want to do two independent modifications of the same base
-  label, we will need to copy it again before at least one of the
-  modifications. 
+  The diagonalization algorithm systematically alternates between
+  expanding depth (via `inc_down`) and breadth (via `inc_across`),
+  ensuring that every node in the infinite tree is eventually included
+  in a diagonal.
 
   Initially:
 
-    diagonal_0 is the root node, '[]'.
-    diagonal_1 is null.
-    child_srtm_list_0 is empty.
-    child_srtm_list_1 is null.
+    diagonal is the root node, '[]'.
+    child_srtm_list is empty.
+
+  Each time SRTM_Diagonal is stepped:
 
-  Each time SRTM_Diagonal is stepped
+    1. Create a new diagonal_1 and expand the child_srtm_list:
 
-    1. make an empty diagonal_1, and an empty child_srtm_list_1.
+       1.1 Bind diagonal (current diagonal) to an SRTM.
+       1.2 For each label in diagonal:
+           1.2.1 Copy the label.
+           1.2.2 Apply `inc_down` to the copy to get the leftmost child.
+           1.2.3 Append this child label to child_srtm_list as a new SRTM_Child.
 
-    2. bind diagonl_0 to an SRTM, then for each cell:
-       2.1 read label_0.
-       2.2 copy label_0 to label_2.
-       2.3 inc_down label_1
-       2.4 copy label_1 to label_2.
-       2.5 append label_1 to diagonal_2.
-       2.6 bind a Child_SRTM to label_2. 
-       2.7 append the Child_SRTM to child_srtm_list_1
+    2. Populate diagonal_1 using child_srtm_list:
 
-    3. Given child_srtm_list_0, for each child_srtm:
+       2.1 Bind child_srtm_list to an SRTM.
+       2.2 For each STRM in the list:
+           2.2.1 Read the label from the SRTM.
+           2.2.2 Append a copy of this label to diagonal_1.
+           2.2.3 if can_step the STRM, the step the head to the next sibling.
+                 else remove SRTM from the child_srtm_list.  (This removal
+                 will never happen on an infinite topology.)
 
-       3.1 read label_0
-       3.3 inc_across label_0, which will modify it in place to become
-           the right neighbor sibling label.
-       3.3 append label_0 to diagonal_1
+    3. Update the state for the next step:
 
-   4, Update state:
-       3.1 Join child_srtm_list_1 to the end of child_srtm_list_0.
-       3.2 Write over the diagonal_0 reference with the diagonal_1 reference.
+       3.1 Replace diagonal with diagonal_1.
 
+  This algorithm ensures that any given node in the infinite index
+  tree is eventually reached in a finite number of step. It traverses
+  the tree a diagonal manner that alternates between depth and breadth
+  expansion.
 */
 
 import java.math.BigInteger;
@@ -84,10 +88,11 @@ import java.util.List;
 import com.ReasoningTechnology.Ariadne.Ariadne_Test;
 import com.ReasoningTechnology.Ariadne.Ariadne_SRTM;
 import com.ReasoningTechnology.Ariadne.Ariadne_SRTM_Label;
+import com.ReasoningTechnology.Ariadne.Ariadne_SRTM_List;
 import com.ReasoningTechnology.Ariadne.Ariadne_Node;
 import com.ReasoningTechnology.Ariadne.Ariadne_Label;
 
-public class SRTM_Diagonal extends Ariadne_SRTM_Label{
+public class SRTM_Diagonal extends Ariadne_SRTM{
 
   // Static
   //
@@ -99,29 +104,36 @@ public class SRTM_Diagonal extends Ariadne_SRTM_Label{
   // Instance data
   //
 
-  private final List<Label> diagonal; // the read value
+  private List<Label> diagonal; // the read value
   private final List<SRTM_Child> child_srtm_list;
 
-  private final TopoIface topo_infinite = new Topo_Infinite();
+  private final TopoIface topo_infinite_right = new Topo_InfiniteRight();
 
   // Constructor(s)
   //
 
   // the diagonal will never be null nor empty
   protected SRTM_Diagonal(){
-
     diagonal = new ArrayList<>();
-    child_srtm_list_0 = new ArrayList<>();
-    child_srtm_list_1 = new ArrayList<>();
-    
-    diagonal.add(List.root());
+    diagonal.add(Label.root());
+    child_srtm_list = new ArrayList<>();
+    set_topology(topo_infinite_right);
+  }
+
+  // Implementation of instance interface
+  //
+
+  @Override
+  @SuppressWarnings("unchecked")
+  public List<Label> read() {
+    return (List<Label>)super.read(); // Cast to ensure type consistency
   }
 
-  private class Topo_Infinite implements TopoIface{
+  private class Topo_InfiniteRight implements TopoIface{
     @Override public boolean can_read(){
       return true;
     }
-    @Override public BigInteger read(){
+    @Override public List read(){
       return diagonal;
     }
     @Override public boolean can_step(){
@@ -130,65 +142,44 @@ public class SRTM_Diagonal extends Ariadne_SRTM_Label{
 
     @Override public void step(){
 
-      // Step 1: Create a new diagonal_1 and child_srtm_list_1
+      // Create a new diagonal and child_srtm_list_1
       List<Label> diagonal_1 = new ArrayList<>();
-      List<SRTM_Child> child_srtm_list_1 = new ArrayList<>();
 
-      // Step 2: Process diagonal_0 using an SRTM
-      SRTM_Label diagonal_srtm = SRTM_Label.make(diagonal);
+      // Step 2: add child list for each node on the current diagonal
+      Ariadne_SRTM_List<Label> diagonal_srtm = Ariadne_SRTM_List.make(diagonal);
       if( diagonal_srtm.can_read() ){
         do{
           // 2.1 Read label_0 from diagonal_0
-          Label label_0 = diagonal_srtm.read();
-
-          // 2.2 Copy label_0 to label_1 and inc_down it
-          Label label_1 = label_0.copy();
-          label_1.inc_down();
-
-          // 2.3 Append label_1 to diagonal_1
-          diagonal_1.add(label_1);
-
-          // 2.4 Copy label_1 to label_2 and bind it to a Child_SRTM
-          Label label_2 = label_1.copy();
-          SRTM_Child child_srtm = SRTM_Child.make(label_2);
-
-          // 2.5 Append the Child_SRTM to child_srtm_list_1
-          child_srtm_list_1.add(child_srtm);
-
+          Label label = diagonal_srtm.read().copy();
+          label.inc_down();
+          child_srtm_list.add(SRTM_Child.make(label));
           if( !diagonal_srtm.can_step() ) break;
           diagonal_srtm.step();
-        }while( true );
+        }while(true);
       }
 
-      // Step 3: Process child_srtm_list_0 using an SRTM
-      SRTM_Child child_srtm = SRTM_Child.make(child_srtm_list);
-      if( child_srtm.can_read() ){
+      // Add the current node from each child list to the new diagonal
+      Ariadne_SRTM_List<SRTM_Child> child_srtm_srtm = Ariadne_SRTM_List.make(child_srtm_list);
+      if( child_srtm_srtm.can_read() ){
         do{
-          // 3.1 Read the label from the SRTM and inc_across it in place
-          Label sibling_label = child_srtm.read().read();
-          sibling_label.inc_across();
-
-          // 3.2 Append sibling_label to diagonal_1
-          diagonal_1.add(sibling_label);
-
-          if( !child_srtm.can_step() ) break;
+          // 3.1 Read child_srtm and get its current label
+          SRTM_Child child_srtm = child_srtm_srtm.read();
+          Label label = child_srtm.read();
+          diagonal_1.add(label.copy());
           child_srtm.step();
-        }while( true );
+          if( !child_srtm_srtm.can_step() ) break;
+          child_srtm_srtm.step();
+        }while(true);
       }
 
-      // Step 4: Replace diagonal_0 with diagonal_1
+      // Update the state for the next step
       diagonal = diagonal_1;
+    }
 
-      // Step 5: Update the state for the next step
-      SRTM_Label child_srtm_1 = SRTM_Label.make(child_srtm_list_1);
-      if( child_srtm_1.can_read() ){
-        do{
-          child_srtm_list_0.add(child_srtm_1.read());
-          if( !child_srtm_1.can_step() ) break;
-          child_srtm_1.step();
-        }while( true );
-      }
-
+    @Override public Topology topology(){
+      return Topology.INFINITE;
     }
 
+  }
 }
+
diff --git a/developer/example/SRTM/Example_SRTMI_Array b/developer/example/SRTM/Example_SRTMI_Array
new file mode 100755 (executable)
index 0000000..e3d7c56
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/bash
+java Example_SRTMI_Array
diff --git a/developer/example/SRTM/Example_SRTMI_Array.class b/developer/example/SRTM/Example_SRTMI_Array.class
new file mode 100644 (file)
index 0000000..22438d9
Binary files /dev/null and b/developer/example/SRTM/Example_SRTMI_Array.class differ
diff --git a/developer/example/SRTM/Example_SRTM_List b/developer/example/SRTM/Example_SRTM_List
new file mode 100755 (executable)
index 0000000..2f1dd2a
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/bash
+java Example_SRTM_List
diff --git a/developer/example/SRTM/Example_SRTM_List.class b/developer/example/SRTM/Example_SRTM_List.class
new file mode 100644 (file)
index 0000000..44bf679
Binary files /dev/null and b/developer/example/SRTM/Example_SRTM_List.class differ
index f9e7678..489e5fe 100644 (file)
@@ -12,7 +12,7 @@ public class Example_SRTM_List {
     label_list.add( "C" );
 
     // Attach SRTM to the linked list and traverse
-    Ariadne_SRTM_List srm = Ariadne_SRTM_List.make(label_list);
+    Ariadne_SRTM_List<String> srm = Ariadne_SRTM_List.make(label_list);
     if( srm.can_read() ){
       do{
         System.out.println( "Reading: " + srm.read() );  
index a4bb823..138e5e5 100644 (file)
@@ -3,8 +3,8 @@
   Base interface for labels used in the Ariadne library.
 */
 package com.ReasoningTechnology.Ariadne;
-public interface Ariadne_Label {
-  boolean isEmpty();
+public interface Ariadne_Label{
+  boolean is_null();
   Ariadne_Label copy();
   @Override String toString();
 }
index 2212b94..9d5d258 100644 (file)
@@ -3,10 +3,10 @@
 */
 package com.ReasoningTechnology.Ariadne;
 
-public class Ariadne_Label_String implements Ariadne_Label {
+public class Ariadne_Label_String implements Ariadne_Label{
 
   // Owned by class
-  public static Ariadne_Label_String make(String s) {
+  public static Ariadne_Label_String make(String s){
     return new Ariadne_Label_String(s);
   }
 
@@ -14,32 +14,37 @@ public class Ariadne_Label_String implements Ariadne_Label {
   private final String value;
 
   // Constructor
-  private Ariadne_Label_String(String s) {
+  private Ariadne_Label_String(String s){
     this.value = s;
   }
 
   // Instance interface implementation
-  @Override public boolean isEmpty() {
-    return value.isEmpty();
+  @Override public boolean is_null(){
+    return value == null;
   }
 
-  @Override public String toString() {
-    return value;
+  public int length(){
+    return value.length();
   }
 
-  @Override public Ariadne_Label copy() {
+  @Override public String toString(){
+    if (is_null()) return "Label()";
+    return "Ariadne_Label(\"" + value + "\")";
+  }
+
+  @Override public Ariadne_Label copy(){
     return new Ariadne_Label_String(value);
   }
 
   // Good object citizenship
-  @Override public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
+  @Override public boolean equals(Object o){
+    if(this == o) return true;
+    if( o == null || getClass() != o.getClass() ) return false;
     Ariadne_Label_String that = (Ariadne_Label_String) o;
     return value.equals(that.value);
   }
 
-  @Override public int hashCode() {
+  @Override public int hashCode(){
     return value.hashCode();
   }
 }
index 379fc5f..6853749 100644 (file)
@@ -1,30 +1,40 @@
 /*
-  Linked list specific SRTM.
-
-  This implementation uses Java's ListIterator, which lacks a direct method
-  to read the current element without advancing the iterator.
+  By convention an SRTM is named after the type of values found in the tape cells.
+  However, in this case the name reflects the type that that SRTM is made from.
+  The type of values found in the SRTM cells is abstracted as "T".
 
+  This implementation uses Java's ListIterator, which lacks a direct
+  method to read the current cell value, rather it yields the next
+  cell value upon advancing the iterator.
 */
 package com.ReasoningTechnology.Ariadne;
 import java.util.List;
 import java.util.ListIterator;
 
-public class Ariadne_SRTM_List extends Ariadne_SRTM{
+public class Ariadne_SRTM_List<T> extends Ariadne_SRTM{
 
   // Static methods
-  public static  Ariadne_SRTM_List make(List list){
-    return new Ariadne_SRTM_List(list);
+  //
+
+  public static <T> Ariadne_SRTM_List<T> make(List<T> list) {
+    return new Ariadne_SRTM_List<>(list);
   }
 
-  private List list;  // The attached linked list
-  private ListIterator iterator;  // Iterator for traversal
-  private Object read_value;  // Stores the current cell value
+  // instance data
+  //
+
+  private List<T> list;  // The attached linked list
+  private ListIterator<T> iterator;  // Iterator for traversal
+  private T read_value;  // Stores the current cell value
 
   private final TopoIface topo_null = new TopoNull();
   private final TopoIface topo_segment = new TopoSegment();
   private final TopoIface topo_rightmost = new TopoRightmost();
 
-  protected Ariadne_SRTM_List(List list){
+  // constructor(s)
+  //
+
+  protected Ariadne_SRTM_List(List<T> list){
     this.list = list;
 
     if( list == null || list.isEmpty() ){
@@ -44,11 +54,20 @@ public class Ariadne_SRTM_List extends Ariadne_SRTM{
     set_topology(topo_segment);
   }
 
+  // instance interface implementation
+  //
+
+  @Override 
+  @SuppressWarnings("unchecked")
+  public T read(){
+    return (T) current_topology.read(); // Cast to ensure T is returned
+  }
+
   private class TopoNull implements TopoIface{
     @Override public boolean can_read(){
       return false;
     }
-    @Override public Object read(){
+    @Override public T read(){
       throw new UnsupportedOperationException( "Cannot read from NULL topo." );
     }
     @Override public boolean can_step(){
@@ -66,8 +85,8 @@ public class Ariadne_SRTM_List extends Ariadne_SRTM{
     @Override public boolean can_read(){
       return true;
     }
-    @Override public Object read(){
-      return read_value;
+    @Override public T read(){
+      return (T)read_value;
     }
     @Override public boolean can_step(){
       return true;
@@ -85,7 +104,7 @@ public class Ariadne_SRTM_List extends Ariadne_SRTM{
     @Override public boolean can_read(){
       return true;
     }
-    @Override public Object read(){
+    @Override public T read(){
       return read_value;
     }
     @Override public boolean can_step(){
index fcd38a7..652b15a 100755 (executable)
@@ -6,7 +6,7 @@ source tool🖉/env_script
 
 echo "Compiling files..."
   set -x
-  javac -g -d scratchpad javac🖉/*.java
+  javac -Xlint:unchecked -g -d scratchpad javac🖉/*.java
   set +x
   if [ $? -ne 0 ]; then
     echo "Compilation failed."
index 1abd031..c8b8c04 100755 (executable)
@@ -15,7 +15,7 @@ cd "example/$1" || exit 1
 echo "Compiling example .java files..."
 
   set -x
-  javac -g -sourcepath . *.java
+  javac -Xlint:unchecked -g -sourcepath . *.java
   set +x
 
   if [ $? -ne 0 ]; then