+++ /dev/null
-#!/bin/bash
-java Example_CountingNumber_0
+++ /dev/null
-#!/bin/bash
-java Example_IndexTree_4x4
-
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;
-import java.math.BigInteger;
-
public class Example_IndexTree_4x4{
public static void main(String[] args){
- Ariadne_IndexTree_Graph graph = new Ariadne_IndexTree_Graph();
- Ariadne_SRM<BigInteger[]> root = graph.start();
+ 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();
- BigInteger label[];
+ System.out.println("root: " + root.read().toString());
+
+ // Variables for traversal
+ Ariadne_IndexTree_Label label = root.read();
Ariadne_IndexTree_Node node;
- Ariadne_SRM<BigInteger[]> child_srm;
+ Ariadne_SRM<Ariadne_IndexTree_Label> child_srm;
- // descend 3 more levels
- label = root.read();
- System.out.println(label);
+ // Descend 3 more levels
int i = 1;
do{
node = graph.lookup(label);
child_srm = node.neighbor();
label = child_srm.read();
- System.out.println(label);
+ System.out.println("Descend: " + label.toString());
if(i == 3) break;
i++;
}while(true);
-
- // move across three more nodes
+
+ // Move across three more nodes
i = 1;
do{
child_srm.step();
label = child_srm.read();
- System.out.println(label);
+ System.out.println("Across: " + label.toString());
if(i == 3) break;
i++;
}while(true);
}
}
-
+++ /dev/null
-#!/bin/bash
-java Example_IndexTree_Diagonal_SRM
+++ /dev/null
-#!/bin/bash
-java Example_SRMI_Array
+++ /dev/null
-#!/bin/bash
-java Example_SRM_List
+/*
+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_SRM;
import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Node;
-public class IndexTree_Diagonal_SRM extends Ariadne_SRM<List<BigInteger[]>>{
+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<BigInteger[]> list_of__unopened_node;
- private final List<List<BigInteger[]>> list_of__opened_incomplete_child_list;
- private final List<BigInteger[]> read_list;
+ //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)
+ //
- // Constructor
protected IndexTree_Diagonal_SRM(){
- this.list_of__unopened_node = new ArrayList<>();
- this.list_of__opened_incomplete_child_list = new ArrayList<>();
- this.read_list = new ArrayList<>();
+ list_of__unopened_node = new ArrayList<>();
+ list_of__opened_incomplete_child_list = new ArrayList<>();
+ read_list = new ArrayList<>();
enqueue_root();
}
- // Static factory method
- public static IndexTree_Diagonal_SRM make(){
- return new IndexTree_Diagonal_SRM();
+ // 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);
+ }
}
- @Override
- public List<BigInteger[]> read(){
+ // 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(){
+ @Override public void step(){
read_list.clear();
// Process unopened nodes
}
}
- private void enqueue_root(){
- BigInteger[] root_label = new BigInteger[0];
- 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);
- }
- }
-
private Ariadne_IndexTree_Node lookup(BigInteger[] label){
// Perform a lookup to retrieve the node corresponding to the label
return Ariadne_IndexTree_Node.make(label);
}
- private List<BigInteger[]> fetch_child_labels(Ariadne_IndexTree_Node node){
- List<BigInteger[]> child_labels = new ArrayList<>();
-
- if(node != null){
- Ariadne_SRM<BigInteger[]> neighbor_srm = node.neighbor();
- while( neighbor_srm.can_step() ){
- child_labels.add(neighbor_srm.read());
- neighbor_srm.step();
- }
- }
-
- return child_labels;
- }
}
+++ /dev/null
-import com.ReasoningTechnology.Ariadne.Ariadne_SRM;
-import com.ReasoningTechnology.Ariadne.Ariadne_Test;
-import java.math.BigInteger;
-
-public class CountingNumber extends Ariadne_SRM<BigInteger> {
-
- private static final Ariadne_Test test = Ariadne_Test.make( "Ariadne_SRM<BigInteger>::" );
-
- public static CountingNumber make(){
- return new CountingNumber( null );
- }
-
- public static CountingNumber make( BigInteger maximum ){
- return new CountingNumber( maximum );
- }
-
- private final Topology _topology;
- private BigInteger i;
- private BigInteger maximum;
- private Location location;
- private Runnable step_behavior;
-
- protected CountingNumber( BigInteger maximum ){
- this.maximum = maximum;
- this.i = BigInteger.ONE;
- this.location = Location.LEFTMOST;
-
- if( maximum == null ){
- _topology = Topology.INFINITE_RIGHT;
- step_behavior = this::step_infinite_right;
- } else {
- _topology = Topology.SEGMENT;
- step_behavior = this::step_segment;
- }
-
- test.print( "CountingNumber initialized with topology: " + _topology + ", initial value: " + i );
- }
-
- @Override
- public Topology topology(){
- return _topology;
- }
-
- @Override
- public Location location(){
- return location;
- }
-
- @Override
- public BigInteger read(){
- return i;
- }
-
- @Override
- public void step(){
- step_behavior.run();
- }
-
- private void step_segment(){
- i = i.add( BigInteger.ONE );
- if( i.equals( maximum ) ){
- location = Location.RIGHTMOST;
- step_behavior = this::step_from_rightmost;
- }else if( location == Location.LEFTMOST ){
- location = Location.INTERIM;
- }
- test.print( " after step_segment, new read() value: " + i );
- }
-
- private void step_infinite_right(){
- i = i.add( BigInteger.ONE );
- test.print( " after step_infinite_right, new read() value: " + i );
- }
-
- private void step_from_rightmost(){
- throw new UnsupportedOperationException( "CountingNumber::step can not step from RIGHTMOST." );
- }
-
-}
+++ /dev/null
-#!/bin/bash
-java Example_IndexTree_0
+++ /dev/null
-import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Child_SRM;
-import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Node;
-import java.math.BigInteger;
-
-public class Example_IndexTree_0{
-
- public static void traverse_index_tree(){
- System.out.println("Starting Index Tree Traversal:");
-
- Ariadne_IndexTree_Node root_node = Ariadne_IndexTree_Node.make(new BigInteger[0]);
- System.out.println("Root Node: " + format_label(root_node.label()));
-
- Ariadne_IndexTree_Node current_node = root_node;
- int depth_count = 0;
- do{
- Ariadne_IndexTree_Child_SRM depth_srm = current_node.neighbor();
- BigInteger[] depth_label = depth_srm.read();
- System.out.println("Step " + (depth_count + 1) + " Down: " + format_label(depth_label));
- current_node = Ariadne_IndexTree_Node.make(depth_label);
-
- // precise loop termination
- if(depth_count == 3) break;
- depth_count++;
- }while(true);
-
- Ariadne_IndexTree_Child_SRM child_srm = current_node.neighbor();
- int child_count = 0;
- do{
- BigInteger[] child_label = child_srm.read();
- System.out.println("Step " + (child_count + 1) + " Across: " + format_label(child_label));
-
- // precise loop termination
- if(child_count == 3) break; // Mid-loop test for inclusive bound
- child_count++;
- child_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();
- }
-
- public static void main(String[] args){
- traverse_index_tree();
- }
-}
+++ /dev/null
-#!/bin/bash
-java Example_IndexTree_Diagonal_SRM
/*
- User defines a graph by implementing this interface. For the build tool, the defined
+ User defines a graph by implementing this interface. For the build tool, the defined
graph is dynamically loaded.
Generally labels are returned and passed around. Only `lookup` returns a Node.
package com.ReasoningTechnology.Ariadne;
-public interface Ariadne_Graph<TLabel> {
+public interface Ariadne_Graph {
- // returns list of TLabel
- Ariadne_SRM<TLabel> start();
+ Ariadne_SRM start();
- // lookup a Node by label
- Ariadne_Node<TLabel> lookup(TLabel label);
+ Ariadne_Node lookup(Ariadne_Label label);
}
package com.ReasoningTechnology.Ariadne;
-import java.math.BigInteger;
+public class Ariadne_IndexTree_Child_SRM extends Ariadne_SRM_Label {
-public class Ariadne_IndexTree_Child_SRM extends Ariadne_SRMI<BigInteger[]>{
-
- // Static
- public static Ariadne_IndexTree_Child_SRM make(BigInteger[] initial_label){
- return new Ariadne_IndexTree_Child_SRM( initial_label );
+ public static Ariadne_IndexTree_Child_SRM make( Ariadne_IndexTree_Label first_child_label ){
+ return new Ariadne_IndexTree_Child_SRM( first_child_label );
}
- // Instance data
- private BigInteger[] label;
+ private final Ariadne_IndexTree_Label label;
+
+ protected Ariadne_IndexTree_Child_SRM( Ariadne_IndexTree_Label first_child_label ){
+ this.label = first_child_label.copy();
- // Constructor
- protected Ariadne_IndexTree_Child_SRM(BigInteger[] initial_label){
- super();
+ if( label == null ){
+ set_topology( topo_null );
+ return;
+ }
- if( initial_label == null || initial_label.length == 0 ){
- throw new IllegalArgumentException( "Initial label must not be null or empty." );
+ if( label.isEmpty() ){
+ set_topology( topo_rightmost );
+ return;
}
- this.label = initial_label;
set_topology( topo_infinite_right );
}
- // Infinite right topology
- private final TopoIface<BigInteger[]> topo_infinite_right = new TopoIface<BigInteger[]>(){
+ 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 BigInteger[] read(){
+ @Override public Object read(){
return label;
}
@Override public boolean can_step(){
return true;
}
@Override public void step(){
- increment();
- label[label.length - 1] = index();
+ 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;
+ }
+ };
+
+}
package com.ReasoningTechnology.Ariadne;
-import java.math.BigInteger;
+public class Ariadne_IndexTree_Graph{
-public class Ariadne_IndexTree_Graph implements Ariadne_Graph<BigInteger[]>{
+ public static Ariadne_IndexTree_Graph make(){
+ return new Ariadne_IndexTree_Graph();
+ }
+ protected Ariadne_IndexTree_Graph(){
+ }
- @Override
public Ariadne_IndexTree_Child_SRM start(){
- return Ariadne_IndexTree_Child_SRM.make(new BigInteger[0]);
+ Ariadne_IndexTree_Label root_label = Ariadne_IndexTree_Label.root();
+ return Ariadne_IndexTree_Child_SRM.make(root_label);
}
- @Override
- public Ariadne_IndexTree_Node lookup(BigInteger[] 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);
+ }
+}
package com.ReasoningTechnology.Ariadne;
-
-import java.math.BigInteger;
import java.util.Arrays;
-public class Ariadne_IndexTree_Node extends Ariadne_Node<BigInteger[]>{
+public class Ariadne_IndexTree_Node extends Ariadne_Node{
- public static Ariadne_IndexTree_Node make(BigInteger[] label){
+ public static Ariadne_IndexTree_Node make(Ariadne_IndexTree_Label label){
return new Ariadne_IndexTree_Node(label);
}
- private final BigInteger[] first_child_label;
+ private final Ariadne_IndexTree_Label first_child_label;
- public Ariadne_IndexTree_Node(BigInteger[] label){
+ public Ariadne_IndexTree_Node(Ariadne_IndexTree_Label label){
super(label);
- this.first_child_label = new BigInteger[label.length + 1];
- System.arraycopy(label, 0, this.first_child_label, 0, label.length);
- this.first_child_label[label.length] = BigInteger.ZERO;
+ first_child_label = label.copy();
+ first_child_label.inc_down();
}
- @Override
+ // public Ariadne_IndexTree_Child_SRM neighbor(){
public Ariadne_IndexTree_Child_SRM neighbor(){
return Ariadne_IndexTree_Child_SRM.make(first_child_label);
}
- @Override
- public String toString(){
- return
- "<"
- + String.join("," ,Arrays.stream(label()).map(BigInteger::toString).toArray(String[]::new))
- + ">";
- }
}
-package com.ReasoningTechnology.Ariadne;
-
-
/*
- A value for the node.label property.
-
- This is a wrapper for a String. We can't instead use an alias by extending
- String, because String is a JavaScript 'final' type.
-
+ Base interface for labels used in the Ariadne library.
*/
-public class Ariadne_Label{
-
- // owned by class
-
-
- // data owned by instance
-
- private final String value;
-
- // constructors
-
-
- private Ariadne_Label(String s){
- this.value = s;
- }
-
- Ariadne_Label make(String s){
- return new Ariadne_Label(s);
- }
-
- public boolean isEmpty(){
- return value.isEmpty();
- }
-
- @Override
- public String toString(){
- return value;
- }
-
- @Override
- public boolean equals(Object o){
- if(this == o) return true;
- if( o == null || getClass() != o.getClass() ) return false;
- Ariadne_Label label = (Ariadne_Label)o;
- return value.equals( label.value );
- }
-
- @Override
- public int hashCode(){
- return value.hashCode();
- }
-
+package com.ReasoningTechnology.Ariadne;
+public interface Ariadne_Label {
+ boolean isEmpty();
+ Ariadne_Label copy();
+ @Override String toString();
}
--- /dev/null
+/*
+ Implementation of Ariadne_Label for string-based labels.
+*/
+package com.ReasoningTechnology.Ariadne;
+
+public class Ariadne_Label_String implements Ariadne_Label {
+
+ // Owned by class
+ public static Ariadne_Label_String make(String s) {
+ return new Ariadne_Label_String(s);
+ }
+
+ // Instance data
+ private final String value;
+
+ // Constructor
+ private Ariadne_Label_String(String s) {
+ this.value = s;
+ }
+
+ // Instance interface implementation
+ @Override public boolean isEmpty() {
+ return value.isEmpty();
+ }
+
+ @Override public String toString() {
+ return 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;
+ Ariadne_Label_String that = (Ariadne_Label_String) o;
+ return value.equals(that.value);
+ }
+
+ @Override public int hashCode() {
+ return value.hashCode();
+ }
+}
import java.util.HashMap;
import java.util.HashSet;
-public class Ariadne_Node<TLabel> extends HashMap<String, Object>{
+public class Ariadne_Node extends HashMap<String, Object>{
// Owned by the class
- public static <TLabel> Ariadne_Node<TLabel> make(TLabel label){
- return new Ariadne_Node<>(label);
+ public static Ariadne_Node make(Ariadne_Label label){
+ return new Ariadne_Node(label);
}
// Data owned by the instance
- private final TLabel label;
- private final HashSet<Ariadne_Token> markSet;
+ private final Ariadne_Label label;
+ private final HashSet<Ariadne_Token> mark_set;
private static final String NEIGHBOR_PROPERTY_NAME = "neighbor_property";
// Constructors
- protected Ariadne_Node(TLabel label){
- super();
+ protected Ariadne_Node(Ariadne_Label label){
this.label = label;
- this.markSet = new HashSet<>();
+ this.mark_set = new HashSet<>();
}
// Instance interface
- public TLabel label(){
+ public Ariadne_Label label(){
return this.label;
}
- public Ariadne_SRM<TLabel> neighbor(){
- throw new UnsupportedOperationException("Neighbor is not implemented in the base class.");
+ public Ariadne_SRM_Label neighbor(){
+ throw new UnsupportedOperationException("Ariadne_Node::neighbor not implemented in the base class.");
}
public void mark(Ariadne_Token token){
- markSet.add(token);
+ mark_set.add(token);
}
public boolean hasMark(Ariadne_Token token){
- return markSet.contains(token);
+ return mark_set.contains(token);
}
public void removeMark(Ariadne_Token token){
- markSet.remove(token);
+ mark_set.remove(token);
}
+
// Object interface
- @Override
- public String toString(){
- return "Ariadne_Node{"
- + "label=" + label
- + " ,markSet=" + markSet
- + "}";
+ @Override public String toString(){
+ StringBuilder output = new StringBuilder();
+
+ // Node representation
+ if( label == null ){
+ output.append( "Node()" );
+ }else{
+ output
+ .append( "Node(" )
+ .append( label.toString() )
+ .append( ")" )
+ ;
+ }
+
+ // Marks representation
+ if( !mark_set.isEmpty() ){
+ Ariadne_SRM_Set srm = Ariadne_SRM_Set.make(mark_set);
+ output.append( " Mark(" );
+
+ do{
+ output.append( srm.read().toString() );
+ if( !srm.can_step() ) break;
+ output.append( ", " );
+ srm.step();
+ }while(true);
+
+ output.append( ")" );
+ }
+
+ return output.toString();
}
+
}
*/
package com.ReasoningTechnology.Ariadne;
-public class Ariadne_SRM<T>{
+public class Ariadne_SRM{
+
+ // static
+ //
public enum Topology{
NULL
,SEGMENT
,RIGHTMOST
,INFINITE
- ;
}
- public static <TElement> Ariadne_SRM<TElement> make(){
- return new Ariadne_SRM<>();
+ public static make(){
+ return new Ariadne_SRM
}
- protected TopoIface<T> current_topology;
- public final TopoIface<T> not_mounted = new NotMounted();
+ // instance data
+ //
+
+ protected TopoIface current_topology;
+ public final TopoIface not_mounted = new NotMounted();
+
+ // constructor(s)
+ //
protected Ariadne_SRM(){
- set_topology(not_mounted);
+ set_topology( not_mounted );
}
public boolean is_mounted(){
&& current_topology != not_mounted;
}
- // Interface for interacting with a tape.
- protected interface TopoIface<T>{
+ // Implementation of instance interface.
+
+ protected interface TopoIface{
boolean can_read();
- T read();
+ Object read();
boolean can_step();
void step();
Topology topology();
}
- // Initially the tape has not been mounted so it can not be interacted with.
- protected class NotMounted implements TopoIface<T>{
- public boolean can_read(){
+ // Initially, the tape has not been mounted.
+ protected class NotMounted implements TopoIface{
+ @Override public boolean can_read(){
return false;
}
- public T read(){
+ @Override public Object read(){
throw new UnsupportedOperationException("Ariadne_SRM::NotMounted::read.");
}
- public boolean can_step(){
+ @Override public boolean can_step(){
return false;
}
- public void step(){
+ @Override public void step(){
throw new UnsupportedOperationException("Ariadne_SRM::NotMounted::step.");
}
- public Topology topology(){
+ @Override public Topology topology(){
throw new UnsupportedOperationException("Ariadne_SRM::NotMounted::topology.");
}
}
- // sets the tape access methods to be used
- protected void set_topology(TopoIface<T> new_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 T 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();
}
}
-
+
package com.ReasoningTechnology.Ariadne;
import java.math.BigInteger;
-public abstract class Ariadne_SRMI<T> extends Ariadne_SRM<T>{
+public abstract class Ariadne_SRMI extends Ariadne_SRM{
private BigInteger current_index;
import java.math.BigInteger;
import java.util.List;
-public class Ariadne_SRMI_Array<T> extends Ariadne_SRMI<T>{
+public class Ariadne_SRMI_Array extends Ariadne_SRMI{
// Static methods
- public static <T> Ariadne_SRMI_Array<T> make(List<T> array){
- return new Ariadne_SRMI_Array<>( array );
+ public static Ariadne_SRMI_Array make(List array){
+ return new Ariadne_SRMI_Array( array );
}
// Instance data
- private final List<T> array;
+ private final List array;
- private final TopoIface<T> topo_null = new TopoNull();
- private final TopoIface<T> topo_segment = new TopoSegment();
- private final TopoIface<T> topo_rightmost = new TopoRightmost();
+ 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<T> array){
+ protected Ariadne_SRMI_Array(List array){
super();
this.array = array;
}
// TopoNull
- private class TopoNull implements TopoIface<T>{
+ private class TopoNull implements TopoIface{
@Override
public boolean can_read(){
return false;
}
@Override
- public T read(){
+ public Object read(){
throw new UnsupportedOperationException( "Cannot read from NULL topo." );
}
@Override
}
// TopoSegment
- private class TopoSegment implements TopoIface<T>{
+ private class TopoSegment implements TopoIface{
@Override
public boolean can_read(){
return true;
}
@Override
- public T read(){
+ public Object read(){
return array.get( index().intValueExact() );
}
@Override
}
// TopoRightmost
- private class TopoRightmost implements TopoIface<T>{
+ private class TopoRightmost implements TopoIface{
@Override
public boolean can_read(){
return true;
}
@Override
- public T read(){
+ public Object read(){
return array.get( index().intValueExact() );
}
@Override
--- /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();
+ }
+
+}
import java.util.List;
import java.util.ListIterator;
-public class Ariadne_SRM_List<T> extends Ariadne_SRM<T>{
+public class Ariadne_SRM_List extends Ariadne_SRM{
// Static methods
- public static <T> Ariadne_SRM_List<T> make(List<T> list){
- return new Ariadne_SRM_List<>(list);
+ public static Ariadne_SRM_List make(List list){
+ return new Ariadne_SRM_List(list);
}
- 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 List list; // The attached linked list
+ private ListIterator iterator; // Iterator for traversal
+ private Object read_value; // Stores the current cell value
- private final TopoIface<T> topo_null = new TopoNull();
- private final TopoIface<T> topo_segment = new TopoSegment();
- private final TopoIface<T> topo_rightmost = new TopoRightmost();
+ 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<T> list){
+ protected Ariadne_SRM_List(List list){
this.list = list;
if( list == null || list.isEmpty() ){
set_topology(topo_segment);
}
- private class TopoNull implements TopoIface<T>{
+ private class TopoNull implements TopoIface{
@Override public boolean can_read(){
return false;
}
- @Override public T read(){
+ @Override public Object read(){
throw new UnsupportedOperationException( "Cannot read from NULL topo." );
}
@Override public boolean can_step(){
}
}
- private class TopoSegment implements TopoIface<T>{
+ private class TopoSegment implements TopoIface{
@Override public boolean can_read(){
return true;
}
- @Override public T read(){
+ @Override public Object read(){
return read_value;
}
@Override public boolean can_step(){
}
}
- private class TopoRightmost implements TopoIface<T>{
+ private class TopoRightmost implements TopoIface{
@Override public boolean can_read(){
return true;
}
- @Override public T read(){
+ @Override public Object read(){
return read_value;
}
@Override public boolean can_step(){
--- /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) );
+ }
+
+}