+++ /dev/null
-import com.ReasoningTechnology.Ariadne.Ariadne_SRM;
-import java.math.BigInteger;
-
-public class CountingNumber extends Ariadne_SRM<BigInteger>{
-
- public static CountingNumber make(BigInteger maximum){
- return new CountingNumber(maximum);
- }
-
- public static CountingNumber make(){
- return new CountingNumber();
- }
-
- private BigInteger i;
- private BigInteger maximum;
-
- private final TopoIface<BigInteger> state_null = new ASRM_Null();
- private final TopoIface<BigInteger> state_segment = new ASRM_Segment();
- private final TopoIface<BigInteger> state_rightmost = new ASRM_Rightmost();
- private final TopoIface<BigInteger> state_infinite = new ASRM_Infinite();
-
- public CountingNumber(){
- this.i = BigInteger.ONE;
- this.maximum = maximum;
- set_topology(state_infinite);
- }
-
- public CountingNumber(BigInteger maximum){
- this.i = BigInteger.ONE;
- this.maximum = maximum;
-
- if( maximum.compareTo(BigInteger.ZERO) <= 0 ){
- set_topology( state_null );
- return;
- }
-
- if( maximum.equals(BigInteger.ONE) ){
- set_topology(state_rightmost);
- return;
- }
-
- set_topology(state_segment);
- }
-
-
- private class ASRM_Null implements TopoIface<BigInteger>{
- @Override
- public boolean can_read(){
- return false;
- }
- @Override
- public BigInteger read(){
- return i;
- }
- @Override
- public boolean can_step(){
- return false;
- }
- @Override
- public void step(){
- throw new UnsupportedOperationException( "Cannot step from NULL state." );
- }
- @Override
- public Topology topology(){
- return Topology.NULL;
- }
- }
-
- private class ASRM_Segment implements TopoIface<BigInteger>{
- @Override
- public boolean can_read(){
- return true;
- }
- @Override
- public BigInteger read(){
- return i;
- }
- @Override
- public boolean can_step(){
- return true;
- }
- @Override
- public void step(){
- i = i.add( BigInteger.ONE );
- if( i.equals( maximum ) ){
- set_topology( state_rightmost );
- }
- }
- @Override
- public Topology topology(){
- return Topology.SEGMENT;
- }
- }
-
- private class ASRM_Rightmost implements TopoIface<BigInteger>{
- @Override
- public boolean can_read(){
- return true;
- }
- @Override
- public BigInteger read(){
- return i;
- }
- @Override
- public boolean can_step(){
- return false;
- }
- @Override
- public void step(){
- throw new UnsupportedOperationException( "Cannot step from RIGHTMOST." );
- }
- @Override
- public Topology topology(){
- return Topology.RIGHTMOST;
- }
- }
-
- private class ASRM_Infinite implements TopoIface<BigInteger>{
- @Override
- public boolean can_read(){
- return true;
- }
- @Override
- public BigInteger read(){
- return i;
- }
- @Override
- public boolean can_step(){
- return true;
- }
- @Override
- public void step(){
- i = i.add( BigInteger.ONE );
- }
- @Override
- public Topology topology(){
- return Topology.INFINITE;
- }
- }
-}
--- /dev/null
+import com.ReasoningTechnology.Ariadne.Ariadne_SRMT;
+import java.math.BigInteger;
+
+public class CountingNumber extends Ariadne_SRMT<BigInteger>{
+
+ public static CountingNumber make(BigInteger maximum){
+ return new CountingNumber(maximum);
+ }
+
+ public static CountingNumber make(){
+ return new CountingNumber();
+ }
+
+ private BigInteger i;
+ private BigInteger maximum;
+
+ private final TopoIface<BigInteger> state_null = new ASRMT_Null();
+ private final TopoIface<BigInteger> state_segment = new ASRMT_Segment();
+ private final TopoIface<BigInteger> state_rightmost = new ASRMT_Rightmost();
+ private final TopoIface<BigInteger> state_infinite = new ASRMT_Infinite();
+
+ public CountingNumber(){
+ this.i = BigInteger.ONE;
+ this.maximum = maximum;
+ set_topology(state_infinite);
+ }
+
+ public CountingNumber(BigInteger maximum){
+ this.i = BigInteger.ONE;
+ this.maximum = maximum;
+
+ if( maximum.compareTo(BigInteger.ZERO) <= 0 ){
+ set_topology( state_null );
+ return;
+ }
+
+ if( maximum.equals(BigInteger.ONE) ){
+ set_topology(state_rightmost);
+ return;
+ }
+
+ set_topology(state_segment);
+ }
+
+
+ private class ASRMT_Null implements TopoIface<BigInteger>{
+ @Override
+ public boolean can_read(){
+ return false;
+ }
+ @Override
+ public BigInteger read(){
+ return i;
+ }
+ @Override
+ public boolean can_step(){
+ return false;
+ }
+ @Override
+ public void step(){
+ throw new UnsupportedOperationException( "Cannot step from NULL state." );
+ }
+ @Override
+ public Topology topology(){
+ return Topology.NULL;
+ }
+ }
+
+ private class ASRMT_Segment implements TopoIface<BigInteger>{
+ @Override
+ public boolean can_read(){
+ return true;
+ }
+ @Override
+ public BigInteger read(){
+ return i;
+ }
+ @Override
+ public boolean can_step(){
+ return true;
+ }
+ @Override
+ public void step(){
+ i = i.add( BigInteger.ONE );
+ if( i.equals( maximum ) ){
+ set_topology( state_rightmost );
+ }
+ }
+ @Override
+ public Topology topology(){
+ return Topology.SEGMENT;
+ }
+ }
+
+ private class ASRMT_Rightmost implements TopoIface<BigInteger>{
+ @Override
+ public boolean can_read(){
+ return true;
+ }
+ @Override
+ public BigInteger read(){
+ return i;
+ }
+ @Override
+ public boolean can_step(){
+ return false;
+ }
+ @Override
+ public void step(){
+ throw new UnsupportedOperationException( "Cannot step from RIGHTMOST." );
+ }
+ @Override
+ public Topology topology(){
+ return Topology.RIGHTMOST;
+ }
+ }
+
+ private class ASRMT_Infinite implements TopoIface<BigInteger>{
+ @Override
+ public boolean can_read(){
+ return true;
+ }
+ @Override
+ public BigInteger read(){
+ return i;
+ }
+ @Override
+ public boolean can_step(){
+ return true;
+ }
+ @Override
+ public void step(){
+ i = i.add( BigInteger.ONE );
+ }
+ @Override
+ public Topology topology(){
+ return Topology.INFINITE;
+ }
+ }
+}
--- /dev/null
+import com.ReasoningTechnology.Ariadne.Ariadne_SRMT;
+import java.math.BigInteger;
+
+public class Example_CountingNumber_0{
+
+ protected static void print_ten(CountingNumber n){
+ System.out.println("Iterating through Counting Numbers:");
+
+ if( !n.can_read() ) return;
+
+ if( n.topology() == Ariadne_SRMT.Topology.SEGMENT ){
+ do{
+ System.out.println("Current Number: " + n.read());
+ if( !n.can_step() ) break;
+ n.step();
+ }while( true );
+
+ }else if( n.topology() == Ariadne_SRMT.Topology.INFINITE ){
+ int count = 0;
+ do{
+ System.out.println("Current Number: " + n.read());
+ if( count == 9 ) break;
+ n.step();
+ count++;
+ }while( true );
+
+ }else{
+ System.out.println("Unrecognized or invalid tape state.");
+ }
+ }
+
+ public static void main(String[] args){
+ print_ten( CountingNumber.make(BigInteger.TEN) ); // Finite segment up to 10
+ print_ten( CountingNumber.make() ); // Infinite tape, stopping after 10 steps
+ }
+
+}
+++ /dev/null
-import com.ReasoningTechnology.Ariadne.Ariadne_SRM;
-import java.math.BigInteger;
-
-public class Example_CountingNumber_0{
-
- protected static void print_ten(CountingNumber n){
- System.out.println("Iterating through Counting Numbers:");
-
- if( !n.can_read() ) return;
-
- if( n.topology() == Ariadne_SRM.Topology.SEGMENT ){
- do{
- System.out.println("Current Number: " + n.read());
- if( !n.can_step() ) break;
- n.step();
- }while( true );
-
- }else if( n.topology() == Ariadne_SRM.Topology.INFINITE ){
- int count = 0;
- do{
- System.out.println("Current Number: " + n.read());
- if( count == 9 ) break;
- n.step();
- count++;
- }while( true );
-
- }else{
- System.out.println("Unrecognized or invalid tape state.");
- }
- }
-
- public static void main(String[] args){
- print_ten( CountingNumber.make(BigInteger.TEN) ); // Finite segment up to 10
- print_ten( CountingNumber.make() ); // Infinite tape, stopping after 10 steps
- }
-
-}
+++ /dev/null
-import com.ReasoningTechnology.Ariadne.Ariadne_SRM;
-import com.ReasoningTechnology.Ariadne.Ariadne_SRM_List;
-import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Child_SRM;
-import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Graph;
-import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Node;
-
-public class Example_IndexTree_4x4{
-
- public static void main(String[] args){
-
- System.out.println("Example_IndexTree_4x4");
-
- // Initialize graph and start at root
- Ariadne_IndexTree_Graph graph = Ariadne_IndexTree_Graph.make();
- Ariadne_IndexTree_Child_SRM root = graph.start();
-
- System.out.println("root: " + root.read().toString());
-
- // Variables for traversal
- Ariadne_IndexTree_Label label = root.read();
- Ariadne_IndexTree_Node node;
- Ariadne_SRM<Ariadne_IndexTree_Label> child_srm;
-
- // Descend 3 more levels
- int i = 1;
- do{
- node = graph.lookup(label);
- child_srm = node.neighbor();
- label = child_srm.read();
- System.out.println("Descend: " + label.toString());
- if(i == 3) break;
- i++;
- }while(true);
-
- // Move across three more nodes
- i = 1;
- do{
- child_srm.step();
- label = child_srm.read();
- System.out.println("Across: " + label.toString());
- if(i == 3) break;
- i++;
- }while(true);
-
- }
-}
+++ /dev/null
-import java.math.BigInteger;
-import java.util.Queue;
-
-public class Example_IndexTree_Diagonal_SRM {
-
- public static void main(String[] args){
- System.out.println("Starting IndexTree SRM Example");
-
- // Instantiate the IndexTree Diagonal SRM
- IndexTree_Diagonal_SRM srm = IndexTree_Diagonal_SRM.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));
- }
- }
- */
- if(step_count == 3) break; // Mid-loop test for inclusive bounds
- step_count++;
- srm.step();
- }while(true);
- }
-
- 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();
- }
-}
+++ /dev/null
-import com.ReasoningTechnology.Ariadne.Ariadne_SRM;
-import com.ReasoningTechnology.Ariadne.Ariadne_SRMI_Array;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class Example_SRMI_Array {
- public static void main( String[] args ){
- // Create an Array
- List<String> label_array = Arrays.asList( "A", "B", "C", "D" );
-
- // Attach SRMI to the array
- Ariadne_SRMI_Array<String> srm = Ariadne_SRMI_Array.make( label_array );
- if( srm.can_read() ){
- do{
- System.out.println( "Reading: " + srm.read() );
- System.out.println( "Topology: " + srm.topology() );
- if( !srm.can_step() ) break;
- srm.step();
- }while(true);
- }
- }
-}
+++ /dev/null
-import com.ReasoningTechnology.Ariadne.Ariadne_SRM;
-import com.ReasoningTechnology.Ariadne.Ariadne_SRM_List;
-
-import java.util.LinkedList;
-
-public class Example_SRM_List {
- public static void main( String[] args ){
- // Create a linked list
- LinkedList<String> label_list = new LinkedList<>();
- label_list.add( "A" );
- label_list.add( "B" );
- label_list.add( "C" );
-
- // Attach SRM to the linked list and traverse
- Ariadne_SRM_List<String> srm = Ariadne_SRM_List.make(label_list);
- if( srm.can_read() ){
- do{
- System.out.println( "Reading: " + srm.read() );
- System.out.println( "Topology: " + srm.topology() );
- if( !srm.can_step() ) break;
- srm.step();
- }while(true);
- }
- }
-}
--- /dev/null
+import com.ReasoningTechnology.Ariadne.Ariadne_SRMT;
+import com.ReasoningTechnology.Ariadne.Ariadne_SRMT_List;
+import com.ReasoningTechnology.Ariadne.IndexTree_SRMT_Child;
+import com.ReasoningTechnology.Ariadne.IndexTree_Graph;
+import com.ReasoningTechnology.Ariadne.IndexTree_Node;
+
+public class Example_IndexTree_4x4{
+
+ public static void main(String[] args){
+
+ System.out.println("Example_IndexTree_4x4");
+
+ // Initialize graph and start at root
+ IndexTree_Graph graph = IndexTree_Graph.make();
+ IndexTree_SRMT_Child root = graph.start();
+
+ System.out.println("root: " + root.read().toString());
+
+ // Variables for traversal
+ IndexTree_Label label = root.read();
+ IndexTree_Node node;
+ Ariadne_SRMT<IndexTree_Label> child_srm;
+
+ // Descend 3 more levels
+ int i = 1;
+ do{
+ node = graph.lookup(label);
+ child_srm = node.neighbor();
+ label = child_srm.read();
+ System.out.println("Descend: " + label.toString());
+ if(i == 3) break;
+ i++;
+ }while(true);
+
+ // Move across three more nodes
+ i = 1;
+ do{
+ child_srm.step();
+ label = child_srm.read();
+ System.out.println("Across: " + label.toString());
+ if(i == 3) break;
+ i++;
+ }while(true);
+
+ }
+}
--- /dev/null
+import java.math.BigInteger;
+import java.util.Queue;
+
+public class Example_IndexTree_Diagonal_SRMT {
+
+ public static void main(String[] args){
+ System.out.println("Starting IndexTree SRMT Example");
+
+ // Instantiate the IndexTree Diagonal SRMT
+ IndexTree_Diagonal_SRMT srm = IndexTree_Diagonal_SRMT.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));
+ }
+ }
+ */
+ if(step_count == 3) break; // Mid-loop test for inclusive bounds
+ step_count++;
+ srm.step();
+ }while(true);
+ }
+
+ 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();
+ }
+}
--- /dev/null
+package com.ReasoningTechnology.Ariadne;
+
+public class IndexTree_Graph{
+
+ public static IndexTree_Graph make(){
+ return new IndexTree_Graph();
+ }
+ protected IndexTree_Graph(){
+ }
+
+ public IndexTree_SRMT_Child start(){
+ IndexTree_Label root_label = IndexTree_Label.root();
+ return IndexTree_SRMT_Child.make(root_label);
+ }
+
+ IndexTree_Node lookup(IndexTree_Label label){
+ return IndexTree_Node.make(label);
+ }
+
+}
+
--- /dev/null
+/*
+ Implementation of Ariadne_Label for BigInteger array-based labels.
+*/
+
+package com.ReasoningTechnology.Ariadne;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+
+public class IndexTree_Label implements Ariadne_Label{
+
+ // Owned by class
+ //
+
+ public static IndexTree_Label make(BigInteger[] array){
+ return new IndexTree_Label(array);
+ }
+
+ public static IndexTree_Label root(){
+ return new IndexTree_Label(new BigInteger[0]);
+ }
+
+ // Instance data
+ //
+
+ private BigInteger[] value;
+
+ // Constructor
+ //
+
+ private IndexTree_Label(BigInteger[] array){
+ this.value = array.clone();
+ }
+
+ // Instance interface implementation
+ //
+
+ @Override public boolean isEmpty(){
+ return value == null;
+ }
+
+ @Override public String toString(){
+ return Arrays.toString(value);
+ }
+
+ @Override public IndexTree_Label copy(){
+ return new IndexTree_Label(value);
+ }
+
+ // Increment last element by one, modifying in place
+ public void inc_across(){
+ if(value == null || value.length == 0){
+ throw new UnsupportedOperationException("Cannot increment across an empty array.");
+ }
+ value[value.length - 1] = value[value.length - 1].add(BigInteger.ONE);
+ }
+
+ // Append a zero element, modifying in place
+ public void inc_down(){
+ if(value == null){
+ throw new UnsupportedOperationException("Cannot append to a null array.");
+ }
+ BigInteger[] newValue = Arrays.copyOf(value, value.length + 1);
+ newValue[newValue.length - 1] = BigInteger.ZERO;
+ value = newValue;
+ }
+
+ // Good object citizenship
+ //
+
+ @Override public boolean equals(Object o){
+ if(this == o) return true;
+ if( o == null || getClass() != o.getClass() ) return false;
+ IndexTree_Label that = (IndexTree_Label) o;
+ return Arrays.equals(value, that.value);
+ }
+
+ @Override public int hashCode(){
+ return Arrays.hashCode(value);
+ }
+}
--- /dev/null
+package com.ReasoningTechnology.Ariadne;
+import java.util.Arrays;
+
+public class IndexTree_Node extends Ariadne_Node{
+
+ public static IndexTree_Node make(IndexTree_Label label){
+ return new IndexTree_Node(label);
+ }
+
+ private final IndexTree_Label first_child_label;
+
+ public IndexTree_Node(IndexTree_Label label){
+ super(label);
+ first_child_label = label.copy();
+ first_child_label.inc_down();
+ }
+
+ // public IndexTree_SRMT_Child neighbor(){
+ public IndexTree_SRMT_Child neighbor(){
+ return IndexTree_SRMT_Child.make(first_child_label);
+ }
+
+}
--- /dev/null
+package com.ReasoningTechnology.Ariadne;
+
+public class IndexTree_SRMT_Child extends Ariadne_SRMT_Label {
+
+ public static IndexTree_SRMT_Child make( IndexTree_Label first_child_label ){
+ return new IndexTree_SRMT_Child( first_child_label );
+ }
+
+ private final IndexTree_Label label;
+
+ protected IndexTree_SRMT_Child( IndexTree_Label first_child_label ){
+ this.label = first_child_label.copy();
+
+ if( label == null ){
+ set_topology( topo_null );
+ return;
+ }
+
+ if( label.isEmpty() ){
+ set_topology( topo_rightmost );
+ return;
+ }
+
+ set_topology( topo_infinite_right );
+ }
+
+ private final TopoIface topo_null = new TopoIface(){
+ @Override public boolean can_read(){
+ return false;
+ }
+ @Override public Object read(){
+ throw new UnsupportedOperationException( "Cannot read from NULL topology." );
+ }
+ @Override public boolean can_step(){
+ return false;
+ }
+ @Override public void step(){
+ throw new UnsupportedOperationException( "Cannot step from NULL topology." );
+ }
+ @Override public Topology topology(){
+ return Topology.NULL;
+ }
+ };
+
+ private final TopoIface topo_infinite_right = new TopoIface(){
+ @Override public boolean can_read(){
+ return true;
+ }
+ @Override public Object read(){
+ return label;
+ }
+ @Override public boolean can_step(){
+ return true;
+ }
+ @Override public void step(){
+ label.inc_across();
+ }
+ @Override public Topology topology(){
+ return Topology.INFINITE;
+ }
+ };
+
+ private final TopoIface topo_rightmost = new TopoIface(){
+ @Override public boolean can_read(){
+ return true;
+ }
+ @Override public Object read(){
+ return label;
+ }
+ @Override public boolean can_step(){
+ return false;
+ }
+ @Override public void step(){
+ throw new UnsupportedOperationException( "Cannot step from RIGHTMOST topology." );
+ }
+ @Override public Topology topology(){
+ return Topology.RIGHTMOST;
+ }
+ };
+
+}
--- /dev/null
+/*
+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_SRMT;
+import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Node;
+
+public class IndexTree_Diagonal_SRMT extends Ariadne_SRMT_Label>{
+
+ // Static
+ //
+
+ public static IndexTree_Diagonal_SRMT make(){
+ return new IndexTree_Diagonal_SRMT();
+ }
+
+ //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<Ariadne_SRMT> 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_SRMT(){
+ 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_SRMT 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);
+ }
+
+}
+++ /dev/null
-/*
-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);
- }
-
-}
--- /dev/null
+import com.ReasoningTechnology.Ariadne.Ariadne_SRMT;
+import com.ReasoningTechnology.Ariadne.Ariadne_SRMTI_Array;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class Example_SRMTI_Array {
+ public static void main( String[] args ){
+ // Create an Array
+ List<String> label_array = Arrays.asList( "A", "B", "C", "D" );
+
+ // Attach SRMTI to the array
+ Ariadne_SRMTI_Array<String> srm = Ariadne_SRMTI_Array.make( label_array );
+ if( srm.can_read() ){
+ do{
+ System.out.println( "Reading: " + srm.read() );
+ System.out.println( "Topology: " + srm.topology() );
+ if( !srm.can_step() ) break;
+ srm.step();
+ }while(true);
+ }
+ }
+}
--- /dev/null
+import com.ReasoningTechnology.Ariadne.Ariadne_SRMT;
+import com.ReasoningTechnology.Ariadne.Ariadne_SRMT_List;
+
+import java.util.LinkedList;
+
+public class Example_SRMT_List {
+ public static void main( String[] args ){
+ // Create a linked list
+ LinkedList<String> label_list = new LinkedList<>();
+ label_list.add( "A" );
+ label_list.add( "B" );
+ label_list.add( "C" );
+
+ // Attach SRMT to the linked list and traverse
+ Ariadne_SRMT_List<String> srm = Ariadne_SRMT_List.make(label_list);
+ if( srm.can_read() ){
+ do{
+ System.out.println( "Reading: " + srm.read() );
+ System.out.println( "Topology: " + srm.topology() );
+ if( !srm.can_step() ) break;
+ srm.step();
+ }while(true);
+ }
+ }
+}
--- /dev/null
+/*
+ IndexTree_SRMT_Diagonal
+
+ 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_SRMT;
+import com.ReasoningTechnology.Ariadne.IndexTree_Node;
+
+public class IndexTree_SRMT_Diagonal extends Ariadne_SRMT_Label {
+
+ // Static
+
+ public static IndexTree_SRMT_Diagonal make(){
+ return new IndexTree_SRMT_Diagonal();
+ }
+
+ // Instance Data
+
+ private final List<Ariadne_Label> list_of__unopened_node;
+ private final List<List<Ariadne_Label>> list_of__opened_incomplete_child_list;
+ private final List<Ariadne_Label> read_list;
+ private final Ariadne_SRMT_Label breadth_srm;
+
+ // Constructor
+
+ protected IndexTree_SRMT_Diagonal(){
+ list_of__unopened_node = new ArrayList<>();
+ list_of__opened_incomplete_child_list = new ArrayList<>();
+ read_list = new ArrayList<>();
+ breadth_srm = Ariadne_SRMT_Label.make();
+ enqueue_root();
+ }
+
+ // Instance Methods
+
+ private void enqueue_root(){
+ IndexTree_Label root_label = IndexTree_Label.root();
+ read_list.add( root_label );
+
+ IndexTree_Node root_node = lookup( root_label );
+ breadth_srm.mount( root_node.neighbor() );
+
+ if( breadth_srm.can_read() ){
+ list_of__unopened_node.add( root_label );
+ }
+ }
+
+ private IndexTree_Node lookup( Ariadne_Label label ){
+ return IndexTree_Node.make( (IndexTree_Label)label );
+ }
+
+ @Override
+ public List<Ariadne_Label> read(){
+ return read_list;
+ }
+
+ @Override
+ public void step(){
+ read_list.clear();
+
+ // Process unopened nodes
+ while( !list_of__unopened_node.isEmpty() ){
+ Ariadne_Label label = list_of__unopened_node.remove( 0 );
+
+ // Retrieve the node using lookup
+ IndexTree_Node node = lookup( label );
+
+ // Mount a new breadth-first SRMT for children
+ breadth_srm.mount( node.neighbor() );
+
+ if( breadth_srm.can_read() ){
+ do{
+ Ariadne_Label child_label = breadth_srm.read();
+ list_of__unopened_node.add( child_label );
+ list_of__opened_incomplete_child_list.add( new ArrayList<>( List.of( child_label ) ) );
+
+ breadth_srm.step();
+ }while( breadth_srm.can_step() );
+ }
+ }
+
+ // Process incomplete child lists
+ while( !list_of__opened_incomplete_child_list.isEmpty() ){
+ List<Ariadne_Label> child_list = list_of__opened_incomplete_child_list.remove( 0 );
+ if( !child_list.isEmpty() ){
+ Ariadne_Label label = child_list.remove( 0 );
+ read_list.add( label );
+
+ IndexTree_Node node = lookup( label );
+ breadth_srm.mount( node.neighbor() );
+
+ if( breadth_srm.can_read() ){
+ list_of__unopened_node.add( label );
+ }
+ }
+ }
+ }
+}
public interface Ariadne_Graph {
- Ariadne_SRM start();
+ Ariadne_SRMT start();
Ariadne_Node lookup(Ariadne_Label label);
+++ /dev/null
-package com.ReasoningTechnology.Ariadne;
-
-public class Ariadne_IndexTree_Child_SRM extends Ariadne_SRM_Label {
-
- public static Ariadne_IndexTree_Child_SRM make( Ariadne_IndexTree_Label first_child_label ){
- return new Ariadne_IndexTree_Child_SRM( first_child_label );
- }
-
- private final Ariadne_IndexTree_Label label;
-
- protected Ariadne_IndexTree_Child_SRM( Ariadne_IndexTree_Label first_child_label ){
- this.label = first_child_label.copy();
-
- if( label == null ){
- set_topology( topo_null );
- return;
- }
-
- if( label.isEmpty() ){
- set_topology( topo_rightmost );
- return;
- }
-
- set_topology( topo_infinite_right );
- }
-
- private final TopoIface topo_null = new TopoIface(){
- @Override public boolean can_read(){
- return false;
- }
- @Override public Object read(){
- throw new UnsupportedOperationException( "Cannot read from NULL topology." );
- }
- @Override public boolean can_step(){
- return false;
- }
- @Override public void step(){
- throw new UnsupportedOperationException( "Cannot step from NULL topology." );
- }
- @Override public Topology topology(){
- return Topology.NULL;
- }
- };
-
- private final TopoIface topo_infinite_right = new TopoIface(){
- @Override public boolean can_read(){
- return true;
- }
- @Override public Object read(){
- return label;
- }
- @Override public boolean can_step(){
- return true;
- }
- @Override public void step(){
- label.inc_across();
- }
- @Override public Topology topology(){
- return Topology.INFINITE;
- }
- };
-
- private final TopoIface topo_rightmost = new TopoIface(){
- @Override public boolean can_read(){
- return true;
- }
- @Override public Object read(){
- return label;
- }
- @Override public boolean can_step(){
- return false;
- }
- @Override public void step(){
- throw new UnsupportedOperationException( "Cannot step from RIGHTMOST topology." );
- }
- @Override public Topology topology(){
- return Topology.RIGHTMOST;
- }
- };
-
-}
+++ /dev/null
-package com.ReasoningTechnology.Ariadne;
-
-public class Ariadne_IndexTree_Graph{
-
- public static Ariadne_IndexTree_Graph make(){
- return new Ariadne_IndexTree_Graph();
- }
- protected Ariadne_IndexTree_Graph(){
- }
-
- public Ariadne_IndexTree_Child_SRM start(){
- Ariadne_IndexTree_Label root_label = Ariadne_IndexTree_Label.root();
- return Ariadne_IndexTree_Child_SRM.make(root_label);
- }
-
- Ariadne_IndexTree_Node lookup(Ariadne_IndexTree_Label label){
- return Ariadne_IndexTree_Node.make(label);
- }
-
-}
-
+++ /dev/null
-/*
- Implementation of Ariadne_Label for BigInteger array-based labels.
-*/
-
-package com.ReasoningTechnology.Ariadne;
-
-import java.math.BigInteger;
-import java.util.Arrays;
-
-public class Ariadne_IndexTree_Label implements Ariadne_Label{
-
- // Owned by class
- //
-
- public static Ariadne_IndexTree_Label make(BigInteger[] array){
- return new Ariadne_IndexTree_Label(array);
- }
-
- public static Ariadne_IndexTree_Label root(){
- return new Ariadne_IndexTree_Label(new BigInteger[0]);
- }
-
- // Instance data
- //
-
- private BigInteger[] value;
-
- // Constructor
- //
-
- private Ariadne_IndexTree_Label(BigInteger[] array){
- this.value = array.clone();
- }
-
- // Instance interface implementation
- //
-
- @Override public boolean isEmpty(){
- return value == null;
- }
-
- @Override public String toString(){
- return Arrays.toString(value);
- }
-
- @Override public Ariadne_IndexTree_Label copy(){
- return new Ariadne_IndexTree_Label(value);
- }
-
- // Increment last element by one, modifying in place
- public void inc_across(){
- if(value == null || value.length == 0){
- throw new UnsupportedOperationException("Cannot increment across an empty array.");
- }
- value[value.length - 1] = value[value.length - 1].add(BigInteger.ONE);
- }
-
- // Append a zero element, modifying in place
- public void inc_down(){
- if(value == null){
- throw new UnsupportedOperationException("Cannot append to a null array.");
- }
- BigInteger[] newValue = Arrays.copyOf(value, value.length + 1);
- newValue[newValue.length - 1] = BigInteger.ZERO;
- value = newValue;
- }
-
- // Good object citizenship
- //
-
- @Override public boolean equals(Object o){
- if(this == o) return true;
- if( o == null || getClass() != o.getClass() ) return false;
- Ariadne_IndexTree_Label that = (Ariadne_IndexTree_Label) o;
- return Arrays.equals(value, that.value);
- }
-
- @Override public int hashCode(){
- return Arrays.hashCode(value);
- }
-}
+++ /dev/null
-package com.ReasoningTechnology.Ariadne;
-import java.util.Arrays;
-
-public class Ariadne_IndexTree_Node extends Ariadne_Node{
-
- public static Ariadne_IndexTree_Node make(Ariadne_IndexTree_Label label){
- return new Ariadne_IndexTree_Node(label);
- }
-
- private final Ariadne_IndexTree_Label first_child_label;
-
- public Ariadne_IndexTree_Node(Ariadne_IndexTree_Label label){
- super(label);
- first_child_label = label.copy();
- first_child_label.inc_down();
- }
-
- // public Ariadne_IndexTree_Child_SRM neighbor(){
- public Ariadne_IndexTree_Child_SRM neighbor(){
- return Ariadne_IndexTree_Child_SRM.make(first_child_label);
- }
-
-}
return this.label;
}
- public Ariadne_SRM_Label neighbor(){
+ public Ariadne_SRMT_Label neighbor(){
throw new UnsupportedOperationException("Ariadne_Node::neighbor not implemented in the base class.");
}
// Marks representation
if( !mark_set.isEmpty() ){
- Ariadne_SRM_Set srm = Ariadne_SRM_Set.make(mark_set);
+ Ariadne_SRMT_Set srm = Ariadne_SRMT_Set.make(mark_set);
output.append( " Mark(" );
do{
+++ /dev/null
-/*
- Step Right Machine
-
- This is a mostly abstract base class.
-
- This is for single-threaded execution. The multi-threaded model
- uses `mount` and `dismount` to lock the resources being iterated on.
-*/
-package com.ReasoningTechnology.Ariadne;
-
-public class Ariadne_SRM{
-
- // static
- //
-
- public enum Topology{
- NULL
- ,CYCLIC
- ,SEGMENT
- ,RIGHTMOST
- ,INFINITE
- }
-
- public static make(){
- return new Ariadne_SRM
- }
-
- // instance data
- //
-
- protected TopoIface current_topology;
- public final TopoIface not_mounted = new NotMounted();
-
- // constructor(s)
- //
-
- protected Ariadne_SRM(){
- set_topology( not_mounted );
- }
-
- public boolean is_mounted(){
- return
- current_topology != null
- && current_topology != not_mounted;
- }
-
- // Implementation of instance interface.
-
- protected interface TopoIface{
- boolean can_read();
- Object read();
- boolean can_step();
- void step();
- Topology topology();
- }
-
- // Initially, the tape has not been mounted.
- protected class NotMounted implements TopoIface{
- @Override public boolean can_read(){
- return false;
- }
- @Override public Object read(){
- throw new UnsupportedOperationException("Ariadne_SRM::NotMounted::read.");
- }
- @Override public boolean can_step(){
- return false;
- }
- @Override public void step(){
- throw new UnsupportedOperationException("Ariadne_SRM::NotMounted::step.");
- }
- @Override public Topology topology(){
- throw new UnsupportedOperationException("Ariadne_SRM::NotMounted::topology.");
- }
- }
-
- // Sets the tape access methods to be used.
- protected void set_topology(TopoIface new_topology){
- current_topology = new_topology;
- }
-
- public boolean can_read(){
- return current_topology.can_read();
- }
-
- public Object read(){
- return current_topology.read();
- }
-
- public boolean can_step(){
- return current_topology.can_step();
- }
-
- public void step(){
- current_topology.step();
- }
-
- public Topology topology(){
- return current_topology.topology();
- }
-
-}
-
+++ /dev/null
-/*
-Ariadne_SRM with index
-
-*/
-
-package com.ReasoningTechnology.Ariadne;
-import java.math.BigInteger;
-
-public abstract class Ariadne_SRMI extends Ariadne_SRM{
-
- private BigInteger current_index;
-
- public Ariadne_SRMI(){
- this.current_index = BigInteger.ZERO;
- }
-
- public BigInteger index(){
- return current_index;
- }
-
- public void increment(){
- current_index = current_index.add(BigInteger.ONE);
- }
-}
+++ /dev/null
-package com.ReasoningTechnology.Ariadne;
-
-import java.math.BigInteger;
-import java.util.List;
-
-public class Ariadne_SRMI_Array extends Ariadne_SRMI{
-
- // Static methods
- public static Ariadne_SRMI_Array make(List array){
- return new Ariadne_SRMI_Array( array );
- }
-
- // Instance data
- private final List array;
-
- private final TopoIface topo_null = new TopoNull();
- private final TopoIface topo_segment = new TopoSegment();
- private final TopoIface topo_rightmost = new TopoRightmost();
-
- // Constructor
- protected Ariadne_SRMI_Array(List array){
- super();
- this.array = array;
-
- if( array == null || array.isEmpty() ){
- set_topology( topo_null );
- return;
- }
-
- if( array.size() == 1 ){
- set_topology( topo_rightmost );
- return;
- }
-
- set_topology( topo_segment );
- }
-
- // TopoNull
- private class TopoNull implements TopoIface{
- @Override
- public boolean can_read(){
- return false;
- }
- @Override
- public Object read(){
- throw new UnsupportedOperationException( "Cannot read from NULL topo." );
- }
- @Override
- public boolean can_step(){
- return false;
- }
- @Override
- public void step(){
- throw new UnsupportedOperationException( "Cannot step from NULL topo." );
- }
- @Override
- public Topology topology(){
- return Topology.NULL;
- }
- }
-
- // TopoSegment
- private class TopoSegment implements TopoIface{
- @Override
- public boolean can_read(){
- return true;
- }
- @Override
- public Object read(){
- return array.get( index().intValueExact() );
- }
- @Override
- public boolean can_step(){
- return true;
- }
- @Override
- public void step(){
- increment();
- if( index().compareTo(BigInteger.valueOf(array.size() - 1)) == 0 )
- set_topology(topo_rightmost);
- }
- @Override
- public Topology topology(){
- return Topology.SEGMENT;
- }
- }
-
- // TopoRightmost
- private class TopoRightmost implements TopoIface{
- @Override
- public boolean can_read(){
- return true;
- }
- @Override
- public Object read(){
- return array.get( index().intValueExact() );
- }
- @Override
- public boolean can_step(){
- return false;
- }
- @Override
- public void step(){
- throw new UnsupportedOperationException( "Cannot step from RIGHTMOST topo." );
- }
- @Override
- public Topology topology(){
- return Topology.RIGHTMOST;
- }
- }
-}
+++ /dev/null
-package com.ReasoningTechnology.Ariadne;
-
-public class Ariadne_SRM_Label extends Ariadne_SRM {
-
- public static Ariadne_SRM_Label make(){
- return new Ariadne_SRM_Label();
- }
-
- @Override public Ariadne_Label read(){
- return (Ariadne_Label)super.read();
- }
-
-}
+++ /dev/null
-/*
- The Ariadne_SRM_List class provides a Step Right Machine (SRM) for linked lists.
- This implementation uses Java's ListIterator, which lacks a direct method
- to read the current element without advancing the iterator.
-
-*/
-package com.ReasoningTechnology.Ariadne;
-import java.util.List;
-import java.util.ListIterator;
-
-public class Ariadne_SRM_List extends Ariadne_SRM{
-
- // Static methods
- public static Ariadne_SRM_List make(List list){
- return new Ariadne_SRM_List(list);
- }
-
- private List list; // The attached linked list
- private ListIterator iterator; // Iterator for traversal
- private Object 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_SRM_List(List list){
- this.list = list;
-
- if( list == null || list.isEmpty() ){
- this.iterator = null;
- set_topology(topo_null);
- return;
- }
-
- this.iterator = list.listIterator();
- read_value = iterator.next();
-
- if( list.size() == 1 ){
- set_topology(topo_rightmost);
- return;
- }
-
- set_topology(topo_segment);
- }
-
- private class TopoNull implements TopoIface{
- @Override public boolean can_read(){
- return false;
- }
- @Override public Object read(){
- throw new UnsupportedOperationException( "Cannot read from NULL topo." );
- }
- @Override public boolean can_step(){
- return false;
- }
- @Override public void step(){
- throw new UnsupportedOperationException( "Cannot step over NULL topo." );
- }
- @Override public Topology topology(){
- return Topology.NULL;
- }
- }
-
- private class TopoSegment implements TopoIface{
- @Override public boolean can_read(){
- return true;
- }
- @Override public Object read(){
- return read_value;
- }
- @Override public boolean can_step(){
- return true;
- }
- @Override public void step(){
- read_value = iterator.next();
- if( !iterator.hasNext() ) set_topology(topo_rightmost);
- }
- @Override public Topology topology(){
- return Topology.SEGMENT;
- }
- }
-
- private class TopoRightmost implements TopoIface{
- @Override public boolean can_read(){
- return true;
- }
- @Override public Object read(){
- return read_value;
- }
- @Override public boolean can_step(){
- return false;
- }
- @Override public void step(){
- throw new UnsupportedOperationException( "Cannot step from RIGHTMOST topo." );
- }
- @Override public Topology topology(){
- return Topology.RIGHTMOST;
- }
- }
-}
-
-
+++ /dev/null
-package com.ReasoningTechnology.Ariadne;
-
-import java.util.ArrayList;
-import java.util.Set;
-
-public class Ariadne_SRM_Set extends Ariadne_SRMI_Array{
-
- // Static factory method
- public static Ariadne_SRM_Set make(Set set){
- return new Ariadne_SRM_Set( set );
- }
-
- // Constructor
- protected Ariadne_SRM_Set(Set set){
- super( new ArrayList(set) );
- }
-
-}
--- /dev/null
+/*
+ Step Right Machine
+
+ This is a mostly abstract base class.
+
+ This is for single-threaded execution. The multi-threaded model
+ uses `mount` and `dismount` to lock the resources being iterated on.
+*/
+package com.ReasoningTechnology.Ariadne;
+
+public class Ariadne_SRMT{
+
+ // static
+ //
+
+ public enum Topology{
+ NULL
+ ,CYCLIC
+ ,SEGMENT
+ ,RIGHTMOST
+ ,INFINITE
+ }
+
+ public static Ariadne_SRMT make(){
+ return new Ariadne_SRMT();
+ }
+
+ // instance data
+ //
+
+ protected TopoIface current_topology;
+ public final TopoIface not_mounted = new NotMounted();
+
+ // constructor(s)
+ //
+
+ protected Ariadne_SRMT(){
+ set_topology( not_mounted );
+ }
+
+ public boolean is_mounted(){
+ return
+ current_topology != null
+ && current_topology != not_mounted;
+ }
+
+ // Implementation of instance interface.
+
+ protected interface TopoIface{
+ boolean can_read();
+ Object read();
+ boolean can_step();
+ void step();
+ Topology topology();
+ }
+
+ // Initially, the tape has not been mounted.
+ protected class NotMounted implements TopoIface{
+ @Override public boolean can_read(){
+ return false;
+ }
+ @Override public Object read(){
+ throw new UnsupportedOperationException("Ariadne_SRMT::NotMounted::read.");
+ }
+ @Override public boolean can_step(){
+ return false;
+ }
+ @Override public void step(){
+ throw new UnsupportedOperationException("Ariadne_SRMT::NotMounted::step.");
+ }
+ @Override public Topology topology(){
+ throw new UnsupportedOperationException("Ariadne_SRMT::NotMounted::topology.");
+ }
+ }
+
+ // Sets the tape access methods to be used.
+ protected void set_topology(TopoIface new_topology){
+ current_topology = new_topology;
+ }
+
+ public boolean can_read(){
+ return current_topology.can_read();
+ }
+
+ public Object read(){
+ return current_topology.read();
+ }
+
+ public boolean can_step(){
+ return current_topology.can_step();
+ }
+
+ public void step(){
+ current_topology.step();
+ }
+
+ public Topology topology(){
+ return current_topology.topology();
+ }
+
+}
+
--- /dev/null
+/*
+Ariadne_SRMT with index
+
+*/
+
+package com.ReasoningTechnology.Ariadne;
+import java.math.BigInteger;
+
+public abstract class Ariadne_SRMTI extends Ariadne_SRMT{
+
+ private BigInteger current_index;
+
+ public Ariadne_SRMTI(){
+ this.current_index = BigInteger.ZERO;
+ }
+
+ public BigInteger index(){
+ return current_index;
+ }
+
+ public void increment(){
+ current_index = current_index.add(BigInteger.ONE);
+ }
+}
--- /dev/null
+package com.ReasoningTechnology.Ariadne;
+
+import java.math.BigInteger;
+import java.util.List;
+
+public class Ariadne_SRMTI_Array extends Ariadne_SRMTI{
+
+ // Static methods
+ public static Ariadne_SRMTI_Array make(List array){
+ return new Ariadne_SRMTI_Array( array );
+ }
+
+ // Instance data
+ private final List array;
+
+ private final TopoIface topo_null = new TopoNull();
+ private final TopoIface topo_segment = new TopoSegment();
+ private final TopoIface topo_rightmost = new TopoRightmost();
+
+ // Constructor
+ protected Ariadne_SRMTI_Array(List array){
+ super();
+ this.array = array;
+
+ if( array == null || array.isEmpty() ){
+ set_topology( topo_null );
+ return;
+ }
+
+ if( array.size() == 1 ){
+ set_topology( topo_rightmost );
+ return;
+ }
+
+ set_topology( topo_segment );
+ }
+
+ // TopoNull
+ private class TopoNull implements TopoIface{
+ @Override
+ public boolean can_read(){
+ return false;
+ }
+ @Override
+ public Object read(){
+ throw new UnsupportedOperationException( "Cannot read from NULL topo." );
+ }
+ @Override
+ public boolean can_step(){
+ return false;
+ }
+ @Override
+ public void step(){
+ throw new UnsupportedOperationException( "Cannot step from NULL topo." );
+ }
+ @Override
+ public Topology topology(){
+ return Topology.NULL;
+ }
+ }
+
+ // TopoSegment
+ private class TopoSegment implements TopoIface{
+ @Override
+ public boolean can_read(){
+ return true;
+ }
+ @Override
+ public Object read(){
+ return array.get( index().intValueExact() );
+ }
+ @Override
+ public boolean can_step(){
+ return true;
+ }
+ @Override
+ public void step(){
+ increment();
+ if( index().compareTo(BigInteger.valueOf(array.size() - 1)) == 0 )
+ set_topology(topo_rightmost);
+ }
+ @Override
+ public Topology topology(){
+ return Topology.SEGMENT;
+ }
+ }
+
+ // TopoRightmost
+ private class TopoRightmost implements TopoIface{
+ @Override
+ public boolean can_read(){
+ return true;
+ }
+ @Override
+ public Object read(){
+ return array.get( index().intValueExact() );
+ }
+ @Override
+ public boolean can_step(){
+ return false;
+ }
+ @Override
+ public void step(){
+ throw new UnsupportedOperationException( "Cannot step from RIGHTMOST topo." );
+ }
+ @Override
+ public Topology topology(){
+ return Topology.RIGHTMOST;
+ }
+ }
+}
--- /dev/null
+package com.ReasoningTechnology.Ariadne;
+
+public class Ariadne_SRMT_Label extends Ariadne_SRMT {
+
+ public static Ariadne_SRMT_Label make(){
+ return new Ariadne_SRMT_Label();
+ }
+
+ @Override public Ariadne_Label read(){
+ return (Ariadne_Label)super.read();
+ }
+
+}
--- /dev/null
+/*
+ The Ariadne_SRMT_List class provides a Step Right Machine (SRMT) for linked lists.
+ This implementation uses Java's ListIterator, which lacks a direct method
+ to read the current element without advancing the iterator.
+
+*/
+package com.ReasoningTechnology.Ariadne;
+import java.util.List;
+import java.util.ListIterator;
+
+public class Ariadne_SRMT_List extends Ariadne_SRMT{
+
+ // Static methods
+ public static Ariadne_SRMT_List make(List list){
+ return new Ariadne_SRMT_List(list);
+ }
+
+ private List list; // The attached linked list
+ private ListIterator iterator; // Iterator for traversal
+ private Object 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_SRMT_List(List list){
+ this.list = list;
+
+ if( list == null || list.isEmpty() ){
+ this.iterator = null;
+ set_topology(topo_null);
+ return;
+ }
+
+ this.iterator = list.listIterator();
+ read_value = iterator.next();
+
+ if( list.size() == 1 ){
+ set_topology(topo_rightmost);
+ return;
+ }
+
+ set_topology(topo_segment);
+ }
+
+ private class TopoNull implements TopoIface{
+ @Override public boolean can_read(){
+ return false;
+ }
+ @Override public Object read(){
+ throw new UnsupportedOperationException( "Cannot read from NULL topo." );
+ }
+ @Override public boolean can_step(){
+ return false;
+ }
+ @Override public void step(){
+ throw new UnsupportedOperationException( "Cannot step over NULL topo." );
+ }
+ @Override public Topology topology(){
+ return Topology.NULL;
+ }
+ }
+
+ private class TopoSegment implements TopoIface{
+ @Override public boolean can_read(){
+ return true;
+ }
+ @Override public Object read(){
+ return read_value;
+ }
+ @Override public boolean can_step(){
+ return true;
+ }
+ @Override public void step(){
+ read_value = iterator.next();
+ if( !iterator.hasNext() ) set_topology(topo_rightmost);
+ }
+ @Override public Topology topology(){
+ return Topology.SEGMENT;
+ }
+ }
+
+ private class TopoRightmost implements TopoIface{
+ @Override public boolean can_read(){
+ return true;
+ }
+ @Override public Object read(){
+ return read_value;
+ }
+ @Override public boolean can_step(){
+ return false;
+ }
+ @Override public void step(){
+ throw new UnsupportedOperationException( "Cannot step from RIGHTMOST topo." );
+ }
+ @Override public Topology topology(){
+ return Topology.RIGHTMOST;
+ }
+ }
+}
+
+
--- /dev/null
+package com.ReasoningTechnology.Ariadne;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+public class Ariadne_SRMT_Set extends Ariadne_SRMTI_Array{
+
+ // Static factory method
+ public static Ariadne_SRMT_Set make(Set set){
+ return new Ariadne_SRMT_Set( set );
+ }
+
+ protected Ariadne_SRMT_Set(Set set){
+ super( new ArrayList(set) );
+ }
+
+}
cd "$REPO_HOME"/developer || exit 1
source tool🖉/env_script
-# remove example class files
+# Check if the directory $1 exists
+if [ ! -d "example/$1" ]; then
+ echo "Error: Directory 'example/$1' does not exist."
+ exit 1
+fi
- cd example || exit 1
+cd "example/$1" || exit 1
+
+
+# remove wrappers and class files
for file in Example_*.class; do
echo "file: " $file
- rm_na "$file"
wrapper_name=$(basename "$file" .class)
rm_na "$wrapper_name"
done
+ rm_na *.class
+
echo "$(script_fn) done."
cd "$REPO_HOME"/developer || exit 1
source tool🖉/env_script
+# Check if the directory $1 exists
+if [ ! -d "example/$1" ]; then
+ echo "Error: Directory 'example/$1' does not exist."
+ exit 1
+fi
-cd example || exit 1
+cd "example/$1" || exit 1
echo "Compiling example .java files..."
--- /dev/null
+
+
+/*
+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);
+ }
+
+}