From: Thomas Walker Lynch Date: Sat, 4 Jan 2025 10:20:09 +0000 (+0000) Subject: moving to a SRM implementation more faithful to the C model X-Git-Url: https://git.reasoningtechnology.com/usr/lib/python2.7/encodings/cp850.py?a=commitdiff_plain;h=de8b53d1bd69e74b85ee2afc7043594590f967c8;p=Ariadne moving to a SRM implementation more faithful to the C model --- diff --git "a/developer/document\360\237\226\211/Step_Right_Machine.txt" "b/developer/document\360\237\226\211/Step_Right_Machine.txt" index cee6bef..d602f9b 100644 --- "a/developer/document\360\237\226\211/Step_Right_Machine.txt" +++ "b/developer/document\360\237\226\211/Step_Right_Machine.txt" @@ -48,3 +48,9 @@ The SRM methods (mount, dismount, lenient_mount, lenient_dismount) simply delega Relinquishing Locks Last: By ensuring that relinquish is the last step in dismount and other relevant methods, we prevent premature lock release before operations are complete. + +---- + +a SRM with a function implementation represents an evolving system, it is common that information is lost for reversing a forward step in an evolving system, so it is natural in function based programming to have a tape machine that only steps right. + +Still a Turing Machine can step left, and there are computation complexity implications. Some of these can be mitigated by having a context window, and thus tentative forward evolution of the system. diff --git a/developer/example/CountingNumber$State.class b/developer/example/CountingNumber$State.class new file mode 100644 index 0000000..a34a9fc Binary files /dev/null and b/developer/example/CountingNumber$State.class differ diff --git a/developer/example/CountingNumber$State_InfiniteRight.class b/developer/example/CountingNumber$State_InfiniteRight.class new file mode 100644 index 0000000..8e706ff Binary files /dev/null and b/developer/example/CountingNumber$State_InfiniteRight.class differ diff --git a/developer/example/CountingNumber$State_InterimSegment.class b/developer/example/CountingNumber$State_InterimSegment.class new file mode 100644 index 0000000..13e4d7e Binary files /dev/null and b/developer/example/CountingNumber$State_InterimSegment.class differ diff --git a/developer/example/CountingNumber$State_Leftmost.class b/developer/example/CountingNumber$State_Leftmost.class new file mode 100644 index 0000000..e2283d6 Binary files /dev/null and b/developer/example/CountingNumber$State_Leftmost.class differ diff --git a/developer/example/CountingNumber$State_Rightmost.class b/developer/example/CountingNumber$State_Rightmost.class new file mode 100644 index 0000000..ae86555 Binary files /dev/null and b/developer/example/CountingNumber$State_Rightmost.class differ diff --git a/developer/example/CountingNumber.class b/developer/example/CountingNumber.class index 2df2a30..9cc87ce 100644 Binary files a/developer/example/CountingNumber.class and b/developer/example/CountingNumber.class differ diff --git a/developer/example/CountingNumber.java b/developer/example/CountingNumber.java index 0e000ec..adedfc5 100644 --- a/developer/example/CountingNumber.java +++ b/developer/example/CountingNumber.java @@ -1,60 +1,129 @@ -import com.ReasoningTechnology.Ariadne.Ariadne_SRM; -import com.ReasoningTechnology.Ariadne.Ariadne_Test; import java.math.BigInteger; -public class CountingNumber extends Ariadne_SRM{ +public class CountingNumber { - private static final Ariadne_Test test = Ariadne_Test.make("Ariadne_SRM::"); + private BigInteger i; + private BigInteger maximum; + private State current_state; + + public static CountingNumber make( BigInteger maximum ){ + return new CountingNumber( maximum ); + } public static CountingNumber make(){ - return new CountingNumber(null); + return new CountingNumber( null ); } - public static CountingNumber make(BigInteger maximum){ - return new CountingNumber(maximum); + + private CountingNumber( BigInteger maximum ){ + this.i = BigInteger.ONE; + this.maximum = maximum; + this.current_state = ( maximum == null ) ? new State_InfiniteRight() : new State_Leftmost(); } - private BigInteger i; - private BigInteger maximum; - Ariadne_SRM.Location location; + private void set_state( State new_state ){ + this.current_state = new_state; + } - protected CountingNumber(BigInteger maximum){ - i = BigInteger.ONE; - this.maximum = maximum; - this.location = Location.LEFTMOST; - test.print("CountingNumber read() value initialized to: " + i); + public boolean can_read(){ + return current_state.can_read(); } - @Override - public Topology topology(){ - if(maximum == null) return Topology.INFINITE_RIGHT; - return Topology.SEGMENT; + public boolean can_step(){ + return current_state.can_step(); } - @Override - public Location location(){ - return location; + public void step(){ + current_state.step(); } - - @Override + public BigInteger read(){ - return i; // note that BigInteger is immutable + return i; } - @Override - public void step(){ - super.step(); - i = i.add(BigInteger.ONE); - - if(topology() == Topology.SEGMENT){ - if(i.compareTo(maximum) == 0){ - location = Location.RIGHTMOST; - }else if(location() == Location.LEFTMOST){ - location = Location.INTERIM; + // --- State Interface --- + private abstract class State { + abstract boolean can_read(); + abstract boolean can_step(); + abstract void step(); + } + + // --- State_Leftmost --- + private class State_Leftmost extends State { + @Override + boolean can_read(){ + return true; + } + + @Override + boolean can_step(){ + return true; + } + + @Override + void step(){ + i = i.add( BigInteger.ONE ); + if( i.equals( maximum ) ){ + set_state( new State_Rightmost() ); + }else{ + set_state( new State_InterimSegment() ); } } - - test.print(" after step, new read() value: " + i); } -} + // --- State_InterimSegment --- + private class State_InterimSegment extends State { + @Override + boolean can_read(){ + return true; + } + @Override + boolean can_step(){ + return true; + } + + @Override + void step(){ + i = i.add( BigInteger.ONE ); + if( i.equals( maximum ) ){ + set_state( new State_Rightmost() ); + } + } + } + + // --- State_InfiniteRight --- + private class State_InfiniteRight extends State { + @Override + boolean can_read(){ + return true; + } + + @Override + boolean can_step(){ + return true; + } + + @Override + void step(){ + i = i.add( BigInteger.ONE ); + } + } + + // --- State_Rightmost --- + private class State_Rightmost extends State { + @Override + boolean can_read(){ + return true; + } + + @Override + boolean can_step(){ + return false; + } + + @Override + void step(){ + throw new UnsupportedOperationException( "Cannot step from RIGHTMOST." ); + } + } +} diff --git a/developer/example/Example_* b/developer/example/Example_* new file mode 100755 index 0000000..3c6f542 --- /dev/null +++ b/developer/example/Example_* @@ -0,0 +1,2 @@ +#!/bin/bash +java Example_* diff --git a/developer/example/Example_CountingNumber b/developer/example/Example_CountingNumber deleted file mode 100755 index 624ad06..0000000 --- a/developer/example/Example_CountingNumber +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -java Example_CountingNumber diff --git a/developer/example/Example_CountingNumber.class b/developer/example/Example_CountingNumber.class deleted file mode 100644 index aee2ee4..0000000 Binary files a/developer/example/Example_CountingNumber.class and /dev/null differ diff --git a/developer/example/Example_CountingNumber.java b/developer/example/Example_CountingNumber.java deleted file mode 100644 index 3ff0f70..0000000 --- a/developer/example/Example_CountingNumber.java +++ /dev/null @@ -1,43 +0,0 @@ -/* -Donald Knuth pointed out in the Art of Computer Programming, that there -is a mid-test loop missing from most languages. The mid-test loop works -well with inclusive bound loops, as is needed with the SRM. - -*/ -import com.ReasoningTechnology.Ariadne.Ariadne_SRM; -import java.math.BigInteger; - -public class Example_CountingNumber{ - - 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.location() == Ariadne_SRM.Location.RIGHTMOST ) break; - n.step(); - }while(true); - - }else if(n.topology() == Ariadne_SRM.Topology.INFINITE_RIGHT){ - - int i = 1; - do{ - System.out.println("Current Number: " + n.read()); - if( i == 10 ) break; - n.step(); - i++; - }while(true); - - } else { - System.out.println("Unrecognized tape topology."); - } - } - - public static void main(String[] args){ - print_ten(CountingNumber.make(BigInteger.TEN)); - print_ten(CountingNumber.make()); - - } -} diff --git a/developer/example/Example_CountingNumber_0.java b/developer/example/Example_CountingNumber_0.java new file mode 100644 index 0000000..95a1fd7 --- /dev/null +++ b/developer/example/Example_CountingNumber_0.java @@ -0,0 +1,37 @@ +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) { + if (n.can_read()) { + 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_RIGHT) { + int i = 1; + if (n.can_read()) { + do { + System.out.println("Current Number: " + n.read()); + if (i == 10) break; + n.step(); + i++; + } while (true); + } + } else { + System.out.println("Unrecognized tape topology."); + } + } + + public static void main(String[] args) { + print_ten(CountingNumber.make(BigInteger.TEN)); + print_ten(CountingNumber.make()); + } +} diff --git a/developer/example/Example_IndexTree_Diagonal_SRM.java b/developer/example/Example_IndexTree_Diagonal_SRM.java new file mode 100644 index 0000000..746735a --- /dev/null +++ b/developer/example/Example_IndexTree_Diagonal_SRM.java @@ -0,0 +1,39 @@ +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 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(); + } +} diff --git a/developer/example/Example_SRMI_Array b/developer/example/Example_SRMI_Array deleted file mode 100755 index 80c5dbd..0000000 --- a/developer/example/Example_SRMI_Array +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -java Example_SRMI_Array diff --git a/developer/example/Example_SRMI_Array.class b/developer/example/Example_SRMI_Array.class deleted file mode 100644 index 4917a44..0000000 Binary files a/developer/example/Example_SRMI_Array.class and /dev/null differ diff --git a/developer/example/Example_SRMI_Array.java b/developer/example/Example_SRMI_Array.java index 9f1f6cf..818a72f 100644 --- a/developer/example/Example_SRMI_Array.java +++ b/developer/example/Example_SRMI_Array.java @@ -5,9 +5,7 @@ import java.util.Arrays; import java.util.List; public class Example_SRMI_Array { - public static void main( String[] args ) { - /* - + public static void main( String[] args ){ // Create a list List label_list = Arrays.asList( "A" ,"B" ,"C" ,"D" ); @@ -19,15 +17,13 @@ public class Example_SRMI_Array { System.out.println( "Location: " + srm.location() ); // Traverse the list - while( srm.location() != Ariadne_SRM.Location.RIGHTMOST ) { - System.out.println( "Reading: " + srm.read() ); + while( srm.location() != Ariadne_SRM.Location.RIGHTMOST ){ + System.out.println( "Reading: " + srm.access() ); srm.step(); } // Final item - System.out.println( "Reading: " + srm.read() ); + System.out.println( "Reading: " + srm.access() ); System.out.println( "Location: " + srm.location() ); - - */ } } diff --git a/developer/example/Example_SRM_List b/developer/example/Example_SRM_List deleted file mode 100755 index e0d48dd..0000000 --- a/developer/example/Example_SRM_List +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -java Example_SRM_List diff --git a/developer/example/Example_SRM_List.class b/developer/example/Example_SRM_List.class deleted file mode 100644 index abd61ea..0000000 Binary files a/developer/example/Example_SRM_List.class and /dev/null differ diff --git a/developer/example/Example_SRM_List.java b/developer/example/Example_SRM_List.java index 486db68..4aa315a 100644 --- a/developer/example/Example_SRM_List.java +++ b/developer/example/Example_SRM_List.java @@ -20,16 +20,16 @@ public class Example_SRM_List { // Traverse the list while( srm.location() != Ariadne_SRM.Location.RIGHTMOST ){ - System.out.println("Reading: " + srm.read()); + System.out.println("Reading: " + srm.access()); srm.step(); } // Final item - System.out.println(" Reading: " + srm.read() ); + System.out.println(" Reading: " + srm.access() ); System.out.println(" Final Location: " + srm.location() ); - // Reset the SRM and traverse again - srm.reset(); - System.out.println( "After reset: " + srm.read() ); + // Rewind the SRM and traverse again + srm.rewind(); + System.out.println( "After rewind: " + srm.access() ); } } diff --git a/developer/example/IndexTree_Diagonal_SRM.java b/developer/example/IndexTree_Diagonal_SRM.java new file mode 100644 index 0000000..b3fb2b7 --- /dev/null +++ b/developer/example/IndexTree_Diagonal_SRM.java @@ -0,0 +1,106 @@ +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> { + + private final List list_of__unopened_node; + private final List> list_of__opened_incomplete_child_list; + private final List read_list; + private final Ariadne_Test tester; + + public static IndexTree_Diagonal_SRM make() { + return new IndexTree_Diagonal_SRM(); + } + + 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<>(); + this.tester = Ariadne_Test.make("IndexTree_Diagonal_SRM: "); + enqueue_root(); + } + + @Override + public List access() { + return read_list; + } + + @Override + public void step() { + read_list.clear(); + + 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 child_labels = fetch_child_labels(node); + if (!child_labels.isEmpty()) { + list_of__opened_incomplete_child_list.add(child_labels); + } + } + + while (!list_of__opened_incomplete_child_list.isEmpty()) { + List child_labels = list_of__opened_incomplete_child_list.remove(0); + if (!child_labels.isEmpty()) { + BigInteger[] label = child_labels.remove(0); + read_list.add(label); + + tester.print("Queued label: " + format_label(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 void enqueue_root() { + BigInteger[] root_label = new BigInteger[0]; + read_list.add(root_label); + + tester.print("Queued root label: " + format_label(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 fetch_child_labels(Ariadne_IndexTree_Node node) { + List child_labels = new ArrayList<>(); + + if (node != null) { + Ariadne_SRM neighbor_srm = node.neighbor(); + while (neighbor_srm.can_step()) { + child_labels.add(neighbor_srm.read()); + neighbor_srm.step(); + } + } + + return child_labels; + } + + private String format_label(BigInteger[] label) { + 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(); + } +} diff --git a/developer/example/hold/CountingNumber.java b/developer/example/hold/CountingNumber.java new file mode 100644 index 0000000..f4f41cf --- /dev/null +++ b/developer/example/hold/CountingNumber.java @@ -0,0 +1,79 @@ +import com.ReasoningTechnology.Ariadne.Ariadne_SRM; +import com.ReasoningTechnology.Ariadne.Ariadne_Test; +import java.math.BigInteger; + +public class CountingNumber extends Ariadne_SRM { + + private static final Ariadne_Test test = Ariadne_Test.make( "Ariadne_SRM::" ); + + 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." ); + } + +} diff --git a/developer/example/hold/Example_IndexTree_0.class b/developer/example/hold/Example_IndexTree_0.class deleted file mode 100644 index 1aa7f73..0000000 Binary files a/developer/example/hold/Example_IndexTree_0.class and /dev/null differ diff --git a/developer/example/hold/Example_IndexTree_Diagonal_SRM.class b/developer/example/hold/Example_IndexTree_Diagonal_SRM.class deleted file mode 100644 index 7f9b08e..0000000 Binary files a/developer/example/hold/Example_IndexTree_Diagonal_SRM.class and /dev/null differ diff --git a/developer/example/hold/Example_IndexTree_Diagonal_SRM.java b/developer/example/hold/Example_IndexTree_Diagonal_SRM.java deleted file mode 100644 index 746735a..0000000 --- a/developer/example/hold/Example_IndexTree_Diagonal_SRM.java +++ /dev/null @@ -1,39 +0,0 @@ -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 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(); - } -} diff --git a/developer/example/hold/IndexTree_Diagonal_SRM.java b/developer/example/hold/IndexTree_Diagonal_SRM.java deleted file mode 100644 index 42f44db..0000000 --- a/developer/example/hold/IndexTree_Diagonal_SRM.java +++ /dev/null @@ -1,80 +0,0 @@ -import java.math.BigInteger; -import com.ReasoningTechnology.Ariadne.Ariadne_Test; -import com.ReasoningTechnology.Ariadne.Ariadne_SRM; -import com.ReasoningTechnology.Ariadne.Ariadne_SRM_List; -import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Node; - -public class IndexTree_Diagonal_SRM extends Ariadne_SRM { - - private final Ariadne_SRM_List list_of__unopened_node; - private final Ariadne_SRM_List> list_of__opened_incomplete_child_list; - private final Ariadne_SRM_List read_list; - private final Ariadne_Test tester; - - public static IndexTree_Diagonal_SRM make(){ - return new IndexTree_Diagonal_SRM(); - } - - protected IndexTree_Diagonal_SRM(){ - this.list_of__unopened_node = new Ariadne_SRM_List<>(); - this.list_of__opened_incomplete_child_list = new Ariadne_SRM_List<>(); - this.read_list = new Ariadne_SRM_List<>(); - this.tester = Ariadne_Test.make("IndexTree_Diagonal_SRM: "); - enqueue_root(); - } - - @Override - public void step(){ - super.step(); - - read_list.clear(); // Clear the current read list for the new diagonal - - // Process unopened nodes - while(!list_of__unopened_node.is_empty()){ - Ariadne_IndexTree_Node node = list_of__unopened_node.read(); - list_of__unopened_node.step(); // Remove node from unopened list - Ariadne_SRM_List child_list = node.open(); - if(child_list != null){ - list_of__opened_incomplete_child_list.add(child_list); - } - } - - // Process incomplete child lists - while(!list_of__opened_incomplete_child_list.is_empty()){ - Ariadne_SRM_List child_list = list_of__opened_incomplete_child_list.read(); - if(!child_list.is_empty()){ - Ariadne_IndexTree_Node node = child_list.read(); - child_list.step(); // Step to the next node in the child list - BigInteger[] label = node.label(); - read_list.add(label); // Queue the label on the read list - tester.print("Queued label: " + format_label(label)); - if(node.has_children()){ - list_of__unopened_node.add(node); // Add node to unopened list if it has children - } - if(child_list.is_empty()){ - list_of__opened_incomplete_child_list.step(); // Remove empty child lists - } - } - } - } - - private void enqueue_root(){ - Ariadne_IndexTree_Node root = Ariadne_IndexTree_Node.make(new BigInteger[0]); - read_list.add(root.label()); - tester.print("Queued root label: " + format_label(root.label())); - if(root.has_children()){ - list_of__unopened_node.add(root); - } - } - - private 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(); - } -} diff --git "a/developer/javac\360\237\226\211/#Ariadne_LockManager.java#" "b/developer/javac\360\237\226\211/#Ariadne_LockManager.java#" deleted file mode 100644 index 06773c8..0000000 --- "a/developer/javac\360\237\226\211/#Ariadne_LockManager.java#" +++ /dev/null @@ -1,12 +0,0 @@ -/* - - -*/ - - -package com.ReasoningTechnology.Ariadne; - -public interface Ariadne_OwnershipServer{ - Ariadne_LockManagerDelegate single_thread(Object resource); - Ariadne_LockManagerDelegate multiple_thread(Object resource); -} diff --git "a/developer/javac\360\237\226\211/#Ariadne_Node.xjava#" "b/developer/javac\360\237\226\211/#Ariadne_Node.xjava#" deleted file mode 100644 index d2d55b4..0000000 --- "a/developer/javac\360\237\226\211/#Ariadne_Node.xjava#" +++ /dev/null @@ -1,50 +0,0 @@ -package com.ReasoningTechnology.Ariadne; -import java.util.HashMap; -import java.util.HashSet; - -public class Ariadne_Node extends HashMap{ - - // owned by the class - // - public static Ariadne_Node make(Ariadne_Label label){ - return new Ariadne_Node(label); - } - - // data owned by the instance - // - private Ariadne_Label label; - private HashSet mark_set; - - // constructors - // - public Ariadne_Node(Ariadne_Label label){ - super(); - this.label = label; - this.market_set = new HashSet; - } - - // instance interface - // - public Ariadne_Label label(){ - return this.label; - } - - public Ariadne_StepRightMachine neighbor_set(); - - public void mark(Ariadne_Token token){ - mark_set.add(token); - } - - public boolean has_mark(Ariadne_Token token){ - return mark_set.contains(token); - } - - public Ariadne_LabelList neighbor(){ - return(Ariadne_LabelList) this.get(neighbor_property_name); - } - - // Object interface - // - - -} diff --git "a/developer/javac\360\237\226\211/Ariadne_IndexTree_Child_SRM.java" "b/developer/javac\360\237\226\211/Ariadne_IndexTree_Child_SRM.java" index ee9cec5..2226a0f 100644 --- "a/developer/javac\360\237\226\211/Ariadne_IndexTree_Child_SRM.java" +++ "b/developer/javac\360\237\226\211/Ariadne_IndexTree_Child_SRM.java" @@ -24,7 +24,7 @@ public class Ariadne_IndexTree_Child_SRM extends Ariadne_SRM { } @Override - public BigInteger[] read(){ + public BigInteger[] access(){ // Return a reference to the current label return label; } diff --git "a/developer/javac\360\237\226\211/Ariadne_SRM.java" "b/developer/javac\360\237\226\211/Ariadne_SRM.java" index 16fee89..1ef9317 100644 --- "a/developer/javac\360\237\226\211/Ariadne_SRM.java" +++ "b/developer/javac\360\237\226\211/Ariadne_SRM.java" @@ -18,6 +18,9 @@ public class Ariadne_SRM { protected Ariadne_SRM(){ } + // machine and tape status/properties + // + public enum Topology{ UNDEFINED ,NO_CELLS @@ -47,13 +50,30 @@ public class Ariadne_SRM { return topology().ordinal() >= Topology.SEGMENT.ordinal() && location().ordinal() <= Location.INTERIM.ordinal(); } - public boolean can_read() { return topology().ordinal() >= Topology.SINGLETON.ordinal(); } - // returns a reference, cell can then be read or written - public TElement access(){ + // moving the head + // + + public void step(){ + throw new UnsupportedOperationException("Ariadne_SRM::step not implemented."); + } + + public void rewind(){ + throw new UnsupportedOperationException("Ariadne_SRM::rewind not implemented."); + } + + public void fast_forward(){ + throw new UnsupportedOperationException("Ariadne_SRM::fast_forward not implemented."); + } + + // access + // + + public TElement access(){ + // returns a reference, cell can then be read or written throw new UnsupportedOperationException("Ariadne_SRM::read not implemented."); } @@ -70,16 +90,4 @@ public class Ariadne_SRM { throw new UnsupportedOperationException("Ariadne_SRM::read not implemented."); } - public void step(){ - throw new UnsupportedOperationException("Ariadne_SRM::step not implemented."); - } - - public void rewind(){ - throw new UnsupportedOperationException("Ariadne_SRM::rewind not implemented."); - } - - public void fast_forward(){ - throw new UnsupportedOperationException("Ariadne_SRM::fast_forward not implemented."); - } - } diff --git "a/developer/javac\360\237\226\211/Ariadne_SRMI_Array.java" "b/developer/javac\360\237\226\211/Ariadne_SRMI_Array.java" index 5e95b45..f5b5c92 100644 --- "a/developer/javac\360\237\226\211/Ariadne_SRMI_Array.java" +++ "b/developer/javac\360\237\226\211/Ariadne_SRMI_Array.java" @@ -1,18 +1,18 @@ package com.ReasoningTechnology.Ariadne; import java.util.List; -public class Ariadne_SRMI_Array extends Ariadne_SRMI{ +public class Ariadne_SRMI_Array extends Ariadne_SRMI{ public static Ariadne_SRMI_Array make(List array){ return new Ariadne_SRMI_Array<>(array); } - private List _array; + private List _array; private int _index; private Topology _topology; private Location _location; - protected Ariadne_SRMI_Array(){ + protected Ariadne_SRMI_Array(List array) { _array = array; if( _array == null || _array.isEmpty() ) @@ -41,8 +41,8 @@ public class Ariadne_SRMI_Array extends Ariadne_SRMI{ } @Override - public T access(){ - if( can_read() ) return _array.get( _index() ); + public TElement access(){ + if( can_read() ) return _array.get( _index ); throw new UnsupportedOperationException("Ariadne_SRMI_Array::read can not read tape."); } diff --git "a/developer/javac\360\237\226\211/Ariadne_SRM_List.java" "b/developer/javac\360\237\226\211/Ariadne_SRM_List.java" index 49c20bb..45a11c3 100644 --- "a/developer/javac\360\237\226\211/Ariadne_SRM_List.java" +++ "b/developer/javac\360\237\226\211/Ariadne_SRM_List.java" @@ -16,7 +16,7 @@ public class Ariadne_SRM_List extends Ariadne_SRM { return new Ariadne_SRM_List<>(list); } - private final List _list; // The attached linked list + private List _list; // The attached linked list private ListIterator iterator; // Iterator for traversal private TElement read_value; // Stores the current cell value @@ -25,6 +25,9 @@ public class Ariadne_SRM_List extends Ariadne_SRM { // Protected constructor for controlled instantiation protected Ariadne_SRM_List(List list){ + init(list); + } + private void init(List list){ _list = list; if( _list == null || _list.isEmpty() ) @@ -39,7 +42,7 @@ public class Ariadne_SRM_List extends Ariadne_SRM { else _location = Location.OTHER; - if(_topology >= SINGLETON){ + if(_topology.ordinal() >= Topology.SINGLETON.ordinal()){ iterator = _list.listIterator(); read_value = iterator.next(); } @@ -65,11 +68,15 @@ public class Ariadne_SRM_List extends Ariadne_SRM { public void step(){ if( can_step() ){ read_value = iterator.next(); // Move to the next cell and update current value - if( !iterator.has_next() ) _location = Location.RIGHTMOST; + if( !iterator.hasNext() ) _location = Location.RIGHTMOST; return; } throw new UnsupportedOperationException("Ariadne_SRM_List::step can not step."); } + @Override + public void rewind(){ + init(_list); + } }