import com.ReasoningTechnology.Ariadne.Ariadne_SRTM;
import java.math.BigInteger;
-public class CountingNumber extends Ariadne_SRTM<BigInteger>{
+public class CountingNumber extends Ariadne_SRTM{
+
+ // Static
+ //
public static CountingNumber make(BigInteger maximum){
return new CountingNumber(maximum);
return new CountingNumber();
}
+ // Instance data
+ //
+
private BigInteger i;
private BigInteger maximum;
- private final TopoIface<BigInteger> state_null = new ASRTM_Null();
- private final TopoIface<BigInteger> state_segment = new ASRTM_Segment();
- private final TopoIface<BigInteger> state_rightmost = new ASRTM_Rightmost();
- private final TopoIface<BigInteger> state_infinite = new ASRTM_Infinite();
+ private final TopoIface topo_null = new Topo_Null();
+ private final TopoIface topo_segment = new Topo_Segment();
+ private final TopoIface topo_rightmost = new Topo_Rightmost();
+ private final TopoIface topo_infinite = new Topo_Infinite();
+
+ // Constructor(s)
+ //
public CountingNumber(){
this.i = BigInteger.ONE;
this.maximum = maximum;
- set_topology(state_infinite);
+ set_topology(topo_infinite);
}
public CountingNumber(BigInteger maximum){
this.maximum = maximum;
if( maximum.compareTo(BigInteger.ZERO) <= 0 ){
- set_topology( state_null );
+ set_topology( topo_null );
return;
}
if( maximum.equals(BigInteger.ONE) ){
- set_topology(state_rightmost);
+ set_topology(topo_rightmost);
return;
}
- set_topology(state_segment);
+ set_topology(topo_segment);
}
+ // Instance interface implementation
+ //
- private class ASRTM_Null implements TopoIface<BigInteger>{
- @Override
- public boolean can_read(){
+ private class Topo_Null implements TopoIface{
+ @Override public boolean can_read(){
return false;
}
- @Override
- public BigInteger read(){
+ @Override public BigInteger read(){
return i;
}
- @Override
- public boolean can_step(){
+ @Override public boolean can_step(){
return false;
}
- @Override
- public void step(){
- throw new UnsupportedOperationException( "Cannot step from NULL state." );
+ @Override public void step(){
+ throw new UnsupportedOperationException( "Cannot step over NULL topology." );
}
- @Override
- public Topology topology(){
+ @Override public Topology topology(){
return Topology.NULL;
}
}
- private class ASRTM_Segment implements TopoIface<BigInteger>{
- @Override
- public boolean can_read(){
+ private class Topo_Segment implements TopoIface{
+ @Override public boolean can_read(){
return true;
}
- @Override
- public BigInteger read(){
+ @Override public BigInteger read(){
return i;
}
- @Override
- public boolean can_step(){
+ @Override public boolean can_step(){
return true;
}
- @Override
- public void step(){
+ @Override public void step(){
i = i.add( BigInteger.ONE );
if( i.equals( maximum ) ){
- set_topology( state_rightmost );
+ set_topology( topo_rightmost );
}
}
- @Override
- public Topology topology(){
+ @Override public Topology topology(){
return Topology.SEGMENT;
}
}
- private class ASRTM_Rightmost implements TopoIface<BigInteger>{
- @Override
- public boolean can_read(){
+ private class Topo_Rightmost implements TopoIface{
+ @Override public boolean can_read(){
return true;
}
- @Override
- public BigInteger read(){
+ @Override public BigInteger read(){
return i;
}
- @Override
- public boolean can_step(){
+ @Override public boolean can_step(){
return false;
}
- @Override
- public void step(){
+ @Override public void step(){
throw new UnsupportedOperationException( "Cannot step from RIGHTMOST." );
}
- @Override
- public Topology topology(){
+ @Override public Topology topology(){
return Topology.RIGHTMOST;
}
}
- private class ASRTM_Infinite implements TopoIface<BigInteger>{
- @Override
- public boolean can_read(){
+ private class Topo_Infinite implements TopoIface{
+ @Override public boolean can_read(){
return true;
}
- @Override
- public BigInteger read(){
+ @Override public BigInteger read(){
return i;
}
- @Override
- public boolean can_step(){
+ @Override public boolean can_step(){
return true;
}
- @Override
- public void step(){
+ @Override public void step(){
i = i.add( BigInteger.ONE );
}
- @Override
- public Topology topology(){
+ @Override public Topology topology(){
return Topology.INFINITE;
}
}
--- /dev/null
+ // 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);
+ }
--- /dev/null
+#!/bin/bash
+java Example_4x4
--- /dev/null
+import com.ReasoningTechnology.Ariadne.Ariadne_SRTM;
+import com.ReasoningTechnology.Ariadne.Ariadne_SRTM_List;
+
+public class Example_4x4{
+
+ public static void main(String[] args){
+
+ System.out.println("Example_4x4");
+
+ // Initialize graph and start at root
+ Graph graph = Graph.make();
+ SRTM_Child start = graph.start();
+ Label label = start.read();
+ Node node;
+ SRTM_Child child_srm;
+
+ System.out.println("starting at: " + start.read());
+
+ // Descend 3 more levels
+ int i = 1;
+ do{
+ node = graph.lookup(label);
+ child_srm = node.neighbor();
+ label = child_srm.read();
+ System.out.println("Descended to: " + 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 to: " + label.toString());
+ if(i == 3) break;
+ i++;
+ }while(true);
+
+ }
+}
+++ /dev/null
-import com.ReasoningTechnology.Ariadne.Ariadne_SRTM;
-import com.ReasoningTechnology.Ariadne.Ariadne_SRTM_List;
-import com.ReasoningTechnology.Ariadne.IndexTree_SRTM_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_SRTM_Child root = graph.start();
-
- System.out.println("root: " + root.read().toString());
-
- // Variables for traversal
- IndexTree_Label label = root.read();
- IndexTree_Node node;
- Ariadne_SRTM<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_SRTM {
-
- public static void main(String[] args){
- System.out.println("Starting IndexTree SRTM Example");
-
- // Instantiate the IndexTree Diagonal SRTM
- IndexTree_Diagonal_SRTM srm = IndexTree_Diagonal_SRTM.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
+#!/bin/bash
+java Example_SRTM_Diagonal
--- /dev/null
+
+
+import java.math.BigInteger;
+import java.util.Queue;
+
+public class Example_SRTM_Diagonal {
+
+ public static void main(String[] args){
+ System.out.println("Starting IndexTree SRTM Example");
+
+ // Instantiate the IndexTree Diagonal SRTM
+ SRTM_Diagonal srm = 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));
+ }
+ }
+ */
+ 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_Graph;
+
+public class Graph extends Ariadne_Graph{
+
+ public static Graph make(){
+ return new Graph();
+ }
+ protected Graph(){
+ }
+
+ @Override public SRTM_Child start(){
+ Label root_label = Label.root();
+ return SRTM_Child.make(root_label);
+ }
+
+ // no override, this graph does not lookup Ariadne_Label, only Label
+ Node lookup(Label label){
+ return Node.make(label);
+ }
+
+}
+
+++ /dev/null
-package com.ReasoningTechnology.Ariadne;
-
-public class IndexTree_Graph{
-
- public static IndexTree_Graph make(){
- return new IndexTree_Graph();
- }
- protected IndexTree_Graph(){
- }
-
- public IndexTree_SRTM_Child start(){
- IndexTree_Label root_label = IndexTree_Label.root();
- return IndexTree_SRTM_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_SRTM_Child neighbor(){
- public IndexTree_SRTM_Child neighbor(){
- return IndexTree_SRTM_Child.make(first_child_label);
- }
-
-}
+++ /dev/null
-package com.ReasoningTechnology.Ariadne;
-
-public class IndexTree_SRTM_Child extends Ariadne_SRTM_Label {
-
- public static IndexTree_SRTM_Child make( IndexTree_Label first_child_label ){
- return new IndexTree_SRTM_Child( first_child_label );
- }
-
- private final IndexTree_Label label;
-
- protected IndexTree_SRTM_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_SRTM;
-import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Node;
-
-public class IndexTree_Diagonal_SRTM extends Ariadne_SRTM_Label>{
-
- // Static
- //
-
- public static IndexTree_Diagonal_SRTM make(){
- return new IndexTree_Diagonal_SRTM();
- }
-
- //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_SRTM> 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_SRTM(){
- 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_SRTM 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
+/*
+ Implementation of Ariadne_Label for BigInteger array-based labels.
+*/
+import java.math.BigInteger;
+import java.util.Arrays;
+
+import com.ReasoningTechnology.Ariadne.Ariadne_Label;
+
+
+public class Label implements Ariadne_Label{
+
+ // Owned by class
+ //
+
+ public static Label make(BigInteger[] array){
+ return new Label(array);
+ }
+
+ public static Label root(){
+ return new Label(new BigInteger[0]);
+ }
+
+ // Instance data
+ //
+
+ private BigInteger[] value;
+
+ // Constructor
+ //
+
+ private 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 Label copy(){
+ return new 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;
+ Label that = (Label) o;
+ return Arrays.equals(value, that.value);
+ }
+
+ @Override public int hashCode(){
+ return Arrays.hashCode(value);
+ }
+}
--- /dev/null
+import java.util.Arrays;
+import com.ReasoningTechnology.Ariadne.Ariadne_Node;
+
+public class Node extends Ariadne_Node{
+
+ public static Node make(Label label){
+ return new Node(label);
+ }
+
+ private final Label first_child_label;
+
+ public Node(Label label){
+ super(label);
+ first_child_label = label.copy();
+ first_child_label.inc_down();
+ }
+
+ @Override public SRTM_Child neighbor(){
+ return SRTM_Child.make(first_child_label);
+ }
+
+}
--- /dev/null
+import com.ReasoningTechnology.Ariadne.Ariadne_SRTM_Label;
+
+public class SRTM_Child extends Ariadne_SRTM_Label {
+
+ // Static
+ //
+
+ public static SRTM_Child make( Label first_child_label ){
+ return new SRTM_Child( first_child_label );
+ }
+
+ // Instance data
+ //
+
+ // Label is a container of co-ordinates to a node, so the only thing 'final'
+ // is the container, not its contents.
+ private final Label label;
+
+ // Constructor(s)
+ //
+
+ protected SRTM_Child( Label leftmost_child_label ){
+ this.label = leftmost_child_label.copy();
+
+ if( label == null ){
+ set_topology( topo_null );
+ return;
+ }
+
+ if( label.isEmpty() ){
+ set_topology( topo_rightmost );
+ return;
+ }
+
+ set_topology( topo_infinite_right );
+ }
+
+ // Implementation of the instance interface
+ //
+
+ @Override public Label read(){
+ return (Label)super.read();
+ }
+
+ 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 both in depth and breadth. As a tree is a
+graph, and Index Tree is an infinite graph. The label for each node in
+an index tree is an array of integers that explain how to traverse the
+tree to arrive at the node. `[]` is the root node. `[[0] ,[1] ,[2]
+...] is a list of the children to the root node, etc.
+
+ All parts of a node can be computed from its label. Hence
+ the SRM_Diagonal only manipulates labels.
+
+ Label::inc_down turns a given label into the leftmost
+ child lavel.
+
+ Label::inc_across turns a child label into its right neighbor
+ sibling label.
+
+ An infinite child list is represented by an SRM_Child. The
+ SRM_Child is made from the label for the leftmost child in the
+ list. From each child label it is possible to generate the label for
+ the right neighbor child. This is be done by calling `inc_across()`.
+
+Diagonalization can be used to traverse the infinite Index Tree, while
+always enumerating a next layer of nodes nearest the root. This
+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:
+
+ The `diagonal` list is the read value. It is initialized to the
+ label for the root node, '[]'.
+
+ Each time SRTM_Diagonal is stepped
+
+ 1. For each given label on the diagonal, inc_down is called, thus
+ turning the label into the label for the leftmost child of the
+ given node's child list.
+
+ 2.Each given SRTM_Child kept on the incomplete_list is `inc_across`ed.
+ This turns each label into the label for its right neighbor.
+
+ The SRTM_Child.read() value is then appended to the `diagonal`.
+
+*/
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+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_Node;
+import com.ReasoningTechnology.Ariadne.Ariadne_Label;
+
+public class SRTM_Diagonal extends Ariadne_SRTM_Label{
+
+ // Static
+ //
+
+ public static SRTM_Diagonal make(){
+ return new SRTM_Diagonal();
+ }
+
+ // Instance data
+ //
+
+ private final List<Label> unopened_list;
+ private final List<SRTM_Child> incomplete_list;
+ // returned by read()
+ private List<Label> diagonal;
+
+ private final TopoIface topo_infinite = new Topo_Infinite();
+
+ // Constructor(s)
+ //
+
+ // the diagonal will never be null nor empty
+ protected SRTM_Diagonal(){
+ unopened_node_list = new ArrayList<>();
+ incomplete_child_list_srm =
+ diagonal = new ArrayList<>();
+ set_leftmost_diagonal();
+ set_topology(state_infinite);
+ }
+
+ private void set_leftmost_diagonal(){
+ Ariadne_Label root_label = Label.root();
+ diagonal.add(root_label);
+ unopened_node_list.add(root_label);
+ }
+
+ private class Topo_Infinite implements TopoIface{
+ @Override public boolean can_read(){
+ return true;
+ }
+ @Override public BigInteger read(){
+ return diagonal;
+ }
+ @Override public boolean can_step(){
+ return true;
+ }
+ @Override public void step(){
+ diagonal = new ArrayList<>();
+ Ariadne_SRTM_List unopened = Ariadne_SRTM_List.make(list_of
+
+
+ }
+ @Override public Topology topology(){
+ return Topology.INFINITE;
+ }
+ }
+
+}
List<String> label_array = Arrays.asList( "A", "B", "C", "D" );
// Attach SRTMI to the array
- Ariadne_SRTMI_Array<String> srm = Ariadne_SRTMI_Array.make( label_array );
+ Ariadne_SRTMI_Array srm = Ariadne_SRTMI_Array.make( label_array );
if( srm.can_read() ){
do{
System.out.println( "Reading: " + srm.read() );
label_list.add( "C" );
// Attach SRTM to the linked list and traverse
- Ariadne_SRTM_List<String> srm = Ariadne_SRTM_List.make(label_list);
+ Ariadne_SRTM_List srm = Ariadne_SRTM_List.make(label_list);
if( srm.can_read() ){
do{
System.out.println( "Reading: " + srm.read() );
package com.ReasoningTechnology.Ariadne;
-public interface Ariadne_Graph {
+public class Ariadne_Graph{
- Ariadne_SRTM start();
+ public static Ariadne_Graph make(){
+ return new Ariadne_Graph();
+ }
+ protected Ariadne_Graph(){
+ }
- Ariadne_Node lookup(Ariadne_Label label);
+ public Ariadne_SRTM start(){
+ throw new UnsupportedOperationException("Ariadne_Graph::start.");
+ }
+
+ public Ariadne_Node lookup(Ariadne_Label label){
+ throw new UnsupportedOperationException("Ariadne_Graph::lookup.");
+ }
}
/*
Step Right Tape Machine
- This is a mostly abstract base class.
+ Depending how the undefined methods here are defined, the SRTM can
+ equally be a finite iterator, a generator, or an infinite stream.
This is for single-threaded execution. The multi-threaded model
- uses `mount` and `dismount` to lock the resources being iterated on.
+ uses `mount` and `dismount` to lock the resources being iterated over.
*/
package com.ReasoningTechnology.Ariadne;
+/*
+Graph nodes are referenced by their labels.
+
+*/
+
package com.ReasoningTechnology.Ariadne;
public class Ariadne_SRTM_Label extends Ariadne_SRTM {
/*
- The Ariadne_SRTM_List class provides a Step Right Tape Machine (SRTMT) for linked lists.
+ Linked list specific SRTM.
+
This implementation uses Java's ListIterator, which lacks a direct method
to read the current element without advancing the iterator.