melded TM with TMI compiles
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Wed, 15 Jan 2025 07:11:47 +0000 (07:11 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Wed, 15 Jan 2025 07:11:47 +0000 (07:11 +0000)
developer/javacđź–‰/Ariadne_TM_SR_ND.java
developer/javacđź–‰/Ariadne_TM_SR_ND_Array.java
temp.java [deleted file]

index d72a57f..a53a211 100644 (file)
@@ -12,7 +12,7 @@ to file system objects.
 package com.ReasoningTechnology.Ariadne;
 import java.math.BigInteger;
 
-public abstract class Ariadne_TM_SR_ND extends Ariadne_TM_SR_ND{
+public class Ariadne_TM_SR_ND{
 
   // static
   //
@@ -34,7 +34,7 @@ public abstract class Ariadne_TM_SR_ND extends Ariadne_TM_SR_ND{
 
   protected TopoIface current_topology;
   public final TopoIface not_mounted = new NotMounted();
-  private BigInteger index;
+  protected BigInteger index;
 
   // constructor(s)
   //
@@ -51,22 +51,25 @@ public abstract class Ariadne_TM_SR_ND extends Ariadne_TM_SR_ND{
     return index;
   }
 
+  protected void increment(){
+    index = index.add(BigInteger.ONE);
+  }
+
+  public boolean head_on_same_cell(Ariadne_TM_SR_ND tm){
+    return this.index.equals(tm.index);
+  }
+
   public Ariadne_TM_SR_ND entangle(){
-    try{
-      Ariadne_TM_SR_ND copy = (Ariadne_TM_SR_ND) this.clone();
+    Ariadne_TM_SR_ND copy = make();
 
-      // entangled copy shares the same tape
-      copy.tape_list = this.tape_list; // Shares the same reference
-      copy.current_topology = this.current_topology; // Shares the same reference
+    // entangled copy shares the same tape
+    copy.current_topology = this.current_topology; // Shares the same reference
 
-      // nuance here, BigInteger is immutable, so any operation on the original
-      // index, and the copy index will be independent without having to do a deep copy.
-      copy.index = this.index; 
+    // Nuance here, BigInteger is immutable, so operation on the original
+    // index, and the copy index, will be independent, which is what we want.
+    copy.index = this.index; 
 
-      return copy;
-    }catch(CloneNotSupportedException e){
-      throw new AssertionError( "Clone not supported: " + e.getMessage() );
-    }
+    return copy;
   }
 
   public boolean is_mounted(){
@@ -89,6 +92,7 @@ public abstract class Ariadne_TM_SR_ND extends Ariadne_TM_SR_ND{
 
   public void step(){
     current_topology.step();
+    increment();
   }
 
   public Topology topology(){
@@ -135,37 +139,61 @@ public abstract class Ariadne_TM_SR_ND extends Ariadne_TM_SR_ND{
     if(!is_mounted()) return "TM_SR_ND(NotMounted)";
     if(!can_read()) return "TM_SR_ND(Null)";
 
-    StringBuilder sb = new StringBuilder();
-    sb.append("TM_SR_ND(").append(topology().name()).append("(");
-
-    try{
-      // Clone for traversal
-      Ariadne_TM_SR_ND copy = (Ariadne_TM_SR_ND) this.clone();
-
-      Object o = null;
-      do{
-        o = copy.read();
-        if(o == null){
-          sb.append("null");
-        }else if(!copy.can_step()){
-          sb.append("[");
-          sb.append(o.toString());
-          sb.append("]");
+    StringBuilder data_channel = new StringBuilder(" ");
+    StringBuilder control_channel = new StringBuilder("|");
+    
+    data_channel.append( "TM_SR_ND(" ).append( topology().name()).append("( " );
+    control_channel.append( " ".repeat(data_channel.length()) );
+
+    String element = null;
+    Ariadne_TM_SR_ND copy = (Ariadne_TM_SR_ND) this.entangle();
+    Object o = null;
+    do{
+      o = copy.read();
+
+      if(o == null){
+        data_channel.append( " ".repeat(3) );
+        if(head_on_same_cell(copy)){
+          control_channel.append("<->");
         }else{
-          sb.append(o.toString());
+          control_channel.append("|-|");
         }
+      }else if(o.toString().isEmpty()){
+        data_channel.append( " ".repeat(3) );
+        if(head_on_same_cell(copy)){
+          control_channel.append("<e>");
+        }else{
+          control_channel.append("|e|");
+        }
+      }else{
+        element = o.toString();
+        data_channel.append(" ").append(element).append(" ");
+        if(head_on_same_cell(copy)){
+          control_channel
+            .append("<")
+            .append("d".repeat(element.length()))
+            .append(">");
+        }else{
+          control_channel
+            .append("|")
+            .append("d".repeat(element.length()))
+            .append("|");
+        }
+      }
 
-        if(!copy.can_step()) break;
-        sb.append(" ,");
-        copy.step();
-      }while(true);
+      if(!copy.can_step()) break;
+      copy.step();
+    }while(true);
 
-    }catch(CloneNotSupportedException e){
-      throw new AssertionError("Clone not supported: " + e.getMessage());
-    }
+    data_channel.append(" )");
+    control_channel.append("  ");
 
-    sb.append("))");
-    return sb.toString();
+    return 
+      data_channel
+      .append("\n")
+      .append(control_channel)
+      .append("\n")
+      .toString();
   }
 
 }
index 3eee722..32c5da2 100644 (file)
@@ -70,7 +70,6 @@ public class Ariadne_TM_SR_ND_Array<T> extends Ariadne_TM_SR_ND{
       return true;
     }
     @Override public void step(){
-      increment();
       if( head_address().compareTo(BigInteger.valueOf(array.size() - 1)) == 0 )
         set_topology(topo_rightmost);
     }
diff --git a/temp.java b/temp.java
deleted file mode 100644 (file)
index 460b5b4..0000000
--- a/temp.java
+++ /dev/null
@@ -1,121 +0,0 @@
-
-
-/*
-An index Tree is infinite.
-
-A tree diagonal consists of
-a) a node descending from each child discovered thus far
-b> a node extending each child list discovered thus far.
-
-Hence, each diagonal extends the tree down one, and over one.
-
-*/
-
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import com.ReasoningTechnology.Ariadne.Ariadne_Test;
-import com.ReasoningTechnology.Ariadne.Ariadne_SRM;
-import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Node;
-
-public class IndexTree_Diagonal_SRM extends Ariadne_SRM_Label>{
-
-  // Static
-  //
-
-  public static IndexTree_Diagonal_SRM make(){
-    return new IndexTree_Diagonal_SRM();
-  }
-
-  //Instance data
-  //
-
-  private final List<Ariadne_Label> list_of__unopened_node;
-  // each node has a child list,  this is a list of child lists
-  private final List<List<Ariadne_IndexTree_Label>> list_of__opened_incomplete_child_list;
-  // Each diagonal is a list of nodes, referenced by their label
-  private final List<Ariadne_Label> read_list;
-
-  // Constructor(s)
-  //
-
-  protected IndexTree_Diagonal_SRM(){
-    list_of__unopened_node = new ArrayList<>();
-    list_of__opened_incomplete_child_list = new ArrayList<>();
-    read_list = new ArrayList<>();
-    enqueue_root();
-  }
-
-  // Implementation of instance interface.
-  //
-
-  private void enqueue_root(){
-    Ariadne_IndexTree_Label root_label = Ariadne_IndexTree_Label.root();
-    read_list.add(root_label);
-
-    Ariadne_IndexTree_Node root_node = lookup(root_label);
-    if( !fetch_child_labels(root_node).isEmpty() ){
-      list_of__unopened_node.add(root_label);
-    }
-  }
-
-  // lol! This can not be done on an infinite list!
-  private List<BigInteger[]> fetch_child_labels(Ariadne_IndexTree_Node node){
-    List<BigInteger[]> child_labels = new ArrayList<>();
-    if(node != null){
-      IndexTree_Diagonal_SRM child_srm = node.neighbor();
-      if( child_srm.can_read() ){
-        do{
-          child_labels.add(child_srm.read());
-          if( !srm.can_step ) break;
-          child_srm.step();
-        }while(true);
-      }
-    }
-    return child_labels;
-  }
-
-  @Override public List<BigInteger[]> read(){
-    return read_list;
-  }
-
-  @Override public void step(){
-    read_list.clear();
-
-    // Process unopened nodes
-    while( !list_of__unopened_node.isEmpty() ){
-      BigInteger[] label = list_of__unopened_node.remove(0);
-
-      // Retrieve the node using lookup
-      Ariadne_IndexTree_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);
-        read_list.add(label);
-
-        // Retrieve node and check its neighbors
-        Ariadne_IndexTree_Node node = lookup(label);
-        if( !fetch_child_labels(node).isEmpty() ){
-          list_of__unopened_node.add(label);
-        }
-      }
-    }
-  }
-
-  private Ariadne_IndexTree_Node lookup(BigInteger[] label){
-    // Perform a lookup to retrieve the node corresponding to the label
-    return Ariadne_IndexTree_Node.make(label);
-  }
-
-}