From: Thomas Walker Lynch Date: Sat, 4 Jan 2025 05:08:03 +0000 (+0000) Subject: checkpoint this mess X-Git-Url: https://git.reasoningtechnology.com/usr/lib/python2.7/encodings/aliases.py?a=commitdiff_plain;h=fa1d949bf4bde18995750b2f85e3ac3ef0363f50;p=Ariadne checkpoint this mess --- diff --git a/developer/example/CountingNumber.java b/developer/example/CountingNumber.java index c0f7871..0e000ec 100644 --- a/developer/example/CountingNumber.java +++ b/developer/example/CountingNumber.java @@ -15,12 +15,12 @@ public class CountingNumber extends Ariadne_SRM{ private BigInteger i; private BigInteger maximum; - Ariadne_SRM.Status status; + Ariadne_SRM.Location location; protected CountingNumber(BigInteger maximum){ i = BigInteger.ONE; this.maximum = maximum; - this.status = Status.LEFTMOST; + this.location = Location.LEFTMOST; test.print("CountingNumber read() value initialized to: " + i); } @@ -31,8 +31,8 @@ public class CountingNumber extends Ariadne_SRM{ } @Override - public Status status(){ - return status; + public Location location(){ + return location; } @Override @@ -47,9 +47,9 @@ public class CountingNumber extends Ariadne_SRM{ if(topology() == Topology.SEGMENT){ if(i.compareTo(maximum) == 0){ - status = Status.RIGHTMOST; - }else if(status() == Status.LEFTMOST){ - status = Status.INTERIM; + location = Location.RIGHTMOST; + }else if(location() == Location.LEFTMOST){ + location = Location.INTERIM; } } diff --git a/developer/example/Example_CountingNumber.java b/developer/example/Example_CountingNumber.java index a635ac0..3ff0f70 100644 --- a/developer/example/Example_CountingNumber.java +++ b/developer/example/Example_CountingNumber.java @@ -11,12 +11,12 @@ public class Example_CountingNumber{ protected static void print_ten(CountingNumber n){ System.out.println("Iterating through Counting Numbers:"); - if( !n.mounted() ) return; + if( !n.can_read() ) return; if(n.topology() == Ariadne_SRM.Topology.SEGMENT){ do{ System.out.println("Current Number: " + n.read()); - if( n.status() == Ariadne_SRM.Status.RIGHTMOST ) break; + if( n.location() == Ariadne_SRM.Location.RIGHTMOST ) break; n.step(); }while(true); diff --git a/developer/example/Example_IndexTree_0 b/developer/example/Example_IndexTree_0 deleted file mode 100755 index f6eac3c..0000000 --- a/developer/example/Example_IndexTree_0 +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -java Example_IndexTree_0 diff --git a/developer/example/Example_IndexTree_0.class b/developer/example/Example_IndexTree_0.class deleted file mode 100644 index 1aa7f73..0000000 Binary files a/developer/example/Example_IndexTree_0.class and /dev/null differ diff --git a/developer/example/Example_IndexTree_0.java b/developer/example/Example_IndexTree_0.java deleted file mode 100644 index 296b499..0000000 --- a/developer/example/Example_IndexTree_0.java +++ /dev/null @@ -1,53 +0,0 @@ -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(); - } -} diff --git a/developer/example/Example_IndexTree_Diagonal_SRM b/developer/example/Example_IndexTree_Diagonal_SRM deleted file mode 100755 index 5b45c16..0000000 --- a/developer/example/Example_IndexTree_Diagonal_SRM +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -java Example_IndexTree_Diagonal_SRM diff --git a/developer/example/Example_IndexTree_Diagonal_SRM.class b/developer/example/Example_IndexTree_Diagonal_SRM.class deleted file mode 100644 index 7f9b08e..0000000 Binary files a/developer/example/Example_IndexTree_Diagonal_SRM.class and /dev/null differ diff --git a/developer/example/Example_IndexTree_Diagonal_SRM.java b/developer/example/Example_IndexTree_Diagonal_SRM.java deleted file mode 100644 index 746735a..0000000 --- a/developer/example/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/Example_SRMI_Array.java b/developer/example/Example_SRMI_Array.java index b3e9b99..9f1f6cf 100644 --- a/developer/example/Example_SRMI_Array.java +++ b/developer/example/Example_SRMI_Array.java @@ -16,17 +16,17 @@ public class Example_SRMI_Array { // Use the SRMI System.out.println( "Topology: " + srm.topology() ); - System.out.println( "Status: " + srm.status() ); + System.out.println( "Location: " + srm.location() ); // Traverse the list - while( srm.status() != Ariadne_SRM.Status.RIGHTMOST ) { + while( srm.location() != Ariadne_SRM.Location.RIGHTMOST ) { System.out.println( "Reading: " + srm.read() ); srm.step(); } // Final item System.out.println( "Reading: " + srm.read() ); - System.out.println( "Status: " + srm.status() ); + System.out.println( "Location: " + srm.location() ); */ } diff --git a/developer/example/Example_SRM_List.class b/developer/example/Example_SRM_List.class index acee04a..abd61ea 100644 Binary files a/developer/example/Example_SRM_List.class and b/developer/example/Example_SRM_List.class differ diff --git a/developer/example/Example_SRM_List.java b/developer/example/Example_SRM_List.java index dd90028..486db68 100644 --- a/developer/example/Example_SRM_List.java +++ b/developer/example/Example_SRM_List.java @@ -4,32 +4,32 @@ import com.ReasoningTechnology.Ariadne.Ariadne_SRM_List; import java.util.LinkedList; public class Example_SRM_List { - public static void main(String[] args) { + public static void main(String[] args){ // Create a linked list - LinkedList labels = new LinkedList<>(); - labels.add("A"); - labels.add("B"); - labels.add("C"); + LinkedList label_list = new LinkedList<>(); + label_list.add("A"); + label_list.add("B"); + label_list.add("C"); // Attach SRM to the linked list - Ariadne_SRM_List srm = Ariadne_SRM_List.attach(labels); + Ariadne_SRM_List srm = Ariadne_SRM_List.make(label_list); // Use the SRM - System.out.println("Topology: " + srm.topology()); - System.out.println("Initial Status: " + srm.status()); + System.out.println( "Topology: " + srm.topology() ); + System.out.println( "Initial Location: " + srm.location() ); // Traverse the list - while (srm.status() != Ariadne_SRM.Status.RIGHTMOST) { + while( srm.location() != Ariadne_SRM.Location.RIGHTMOST ){ System.out.println("Reading: " + srm.read()); srm.step(); } // Final item - System.out.println("Reading: " + srm.read()); - System.out.println("Final Status: " + srm.status()); + System.out.println(" Reading: " + srm.read() ); + System.out.println(" Final Location: " + srm.location() ); // Reset the SRM and traverse again srm.reset(); - System.out.println("After reset: " + srm.read()); + System.out.println( "After reset: " + srm.read() ); } } diff --git a/developer/example/IndexTree_Diagonal_SRM.java b/developer/example/IndexTree_Diagonal_SRM.java deleted file mode 100644 index 42f44db..0000000 --- a/developer/example/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/example/hold/Example_IndexTree_0 b/developer/example/hold/Example_IndexTree_0 new file mode 100755 index 0000000..f6eac3c --- /dev/null +++ b/developer/example/hold/Example_IndexTree_0 @@ -0,0 +1,2 @@ +#!/bin/bash +java Example_IndexTree_0 diff --git a/developer/example/hold/Example_IndexTree_0.class b/developer/example/hold/Example_IndexTree_0.class new file mode 100644 index 0000000..1aa7f73 Binary files /dev/null and b/developer/example/hold/Example_IndexTree_0.class differ diff --git a/developer/example/hold/Example_IndexTree_0.java b/developer/example/hold/Example_IndexTree_0.java new file mode 100644 index 0000000..296b499 --- /dev/null +++ b/developer/example/hold/Example_IndexTree_0.java @@ -0,0 +1,53 @@ +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(); + } +} diff --git a/developer/example/hold/Example_IndexTree_Diagonal_SRM b/developer/example/hold/Example_IndexTree_Diagonal_SRM new file mode 100755 index 0000000..5b45c16 --- /dev/null +++ b/developer/example/hold/Example_IndexTree_Diagonal_SRM @@ -0,0 +1,2 @@ +#!/bin/bash +java Example_IndexTree_Diagonal_SRM diff --git a/developer/example/hold/Example_IndexTree_Diagonal_SRM.class b/developer/example/hold/Example_IndexTree_Diagonal_SRM.class new file mode 100644 index 0000000..7f9b08e Binary files /dev/null and b/developer/example/hold/Example_IndexTree_Diagonal_SRM.class differ diff --git a/developer/example/hold/Example_IndexTree_Diagonal_SRM.java b/developer/example/hold/Example_IndexTree_Diagonal_SRM.java new file mode 100644 index 0000000..746735a --- /dev/null +++ b/developer/example/hold/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/hold/IndexTree_Diagonal_SRM.java b/developer/example/hold/IndexTree_Diagonal_SRM.java new file mode 100644 index 0000000..42f44db --- /dev/null +++ b/developer/example/hold/IndexTree_Diagonal_SRM.java @@ -0,0 +1,80 @@ +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_SRM.java" "b/developer/javac\360\237\226\211/Ariadne_SRM.java" index 2c34a8e..16fee89 100644 --- "a/developer/javac\360\237\226\211/Ariadne_SRM.java" +++ "b/developer/javac\360\237\226\211/Ariadne_SRM.java" @@ -3,6 +3,9 @@ This is a mostly abstract base class. + This is for single threaded execution. The multiple thread model + uses `mount` and `dismount` to lock the resources being iterated on. + */ package com.ReasoningTechnology.Ariadne; @@ -16,45 +19,67 @@ public class Ariadne_SRM { } public enum Topology{ - NO_CELLS + UNDEFINED + ,NO_CELLS + ,SINGLETON ,SEGMENT + ,SEGMENT_OR_CIRCLE ,CIRCLE + ,CIRCLE_OR_INFINITE_RIGHT ,INFINITE_RIGHT - ,UNKNOWN - ,UNDEFINED ; } - public Topology topology(){ - return Topology.UNDEFINED; - } - - // categorizes the head location - public enum Status{ - TAPE_NOT_MOUNTED + public enum Location{ + OTHER ,LEFTMOST ,INTERIM ,RIGHTMOST ; } - public Status status(){ - throw new UnsupportedOperationException("Ariadne_SRM::status not implemented."); + + public Topology topology(){ + return Topology.UNDEFINED; + } + public Location location(){ + throw new UnsupportedOperationException("Ariadne_SRM::location not implemented."); } - public boolean can_step(){ - return - status() == Status.LEFTMOST - || status() == Status.INTERIM; + public boolean can_step() { + return topology().ordinal() >= Topology.SEGMENT.ordinal() + && location().ordinal() <= Location.INTERIM.ordinal(); } - public boolean mounted(){ - return status() != Status.TAPE_NOT_MOUNTED; + + public boolean can_read() { + return topology().ordinal() >= Topology.SINGLETON.ordinal(); + } + + // returns a reference, cell can then be read or written + public TElement access(){ + throw new UnsupportedOperationException("Ariadne_SRM::read not implemented."); } public TElement read(){ + TElement accessed_cell = access(); + return deep_copy( accessed_cell ); + } + private TElement deep_copy( TElement original ){ + throw new UnsupportedOperationException("Ariadne_SRM::deep_copy not implemented."); + } + + // writes value + public void write(TElement e){ throw new UnsupportedOperationException("Ariadne_SRM::read not implemented."); } public void step(){ - if( !can_step() ) - throw new UnsupportedOperationException("Ariadne_SRM::step can not 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.java" "b/developer/javac\360\237\226\211/Ariadne_SRMI.java" index cdb49a1..c4b3dfe 100644 --- "a/developer/javac\360\237\226\211/Ariadne_SRMI.java" +++ "b/developer/javac\360\237\226\211/Ariadne_SRMI.java" @@ -4,32 +4,28 @@ Ariadne_SRM with index */ package com.ReasoningTechnology.Ariadne; -import java.math.BigInteger; -public class Ariadne_SRMI extends Ariadne_SRM{ +public class Ariadne_SRMI extends Ariadne_SRM{ - protected BigInteger index; - - public static Ariadne_SRMI make(){ - return new Ariadne_SRMI(); + public static Ariadne_SRMI make(){ + return new Ariadne_SRMI(); } protected Ariadne_SRMI(){ - super(); - index = BigInteger.ZERO;; } - @Override - public void step(){ - throw new UnsupportedOperationException("Ariadne_SRMI::can't step unmounted tape."); -// index.add(BigInteger.ONE); + public int index(){ + throw new UnsupportedOperationException("Ariadne_SRMI::index not implemented."); } - BigInteger index(){return index;} - BigInteger leftmost_index(){ - return BigInteger.ZERO; + public int leftmost_index(){ + throw new UnsupportedOperationException("Ariadne_SRMI::leftmost_index not implemented."); + } + public int rightmost_index(){ + throw new UnsupportedOperationException("Ariadne_SRMI::rightmost_index not implemented."); } - BigInteger rightmost_index(){ - throw new UnsupportedOperationException("Ariadne_SRMI:: rightmost_index() of undefined."); + + void seek(int i){ + throw new UnsupportedOperationException("Ariadne_SRMI::seek 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 94fcbb7..5e95b45 100644 --- "a/developer/javac\360\237\226\211/Ariadne_SRMI_Array.java" +++ "b/developer/javac\360\237\226\211/Ariadne_SRMI_Array.java" @@ -1,62 +1,70 @@ package com.ReasoningTechnology.Ariadne; - -import java.math.BigInteger; import java.util.List; -import java.util.concurrent.Semaphore; public class Ariadne_SRMI_Array extends Ariadne_SRMI{ - private List list; - private Semaphore lock; - - public static Ariadne_SRMI_Array make(){ - return new Ariadne_SRMI_Array<>(); + public static Ariadne_SRMI_Array make(List array){ + return new Ariadne_SRMI_Array<>(array); } + private List _array; + private int _index; + private Topology _topology; + private Location _location; + protected Ariadne_SRMI_Array(){ - super(); + _array = array; + + if( _array == null || _array.isEmpty() ) + _topology = Topology.NO_CELLS; + else if( _array.size() == 1 ) + _topology = Topology.SINGLETON; + else + _topology = Topology.SEGMENT; + + if(_topology == Topology.SEGMENT) + _location = Location.LEFTMOST; + else + _location = Location.OTHER; + + _index = 0; } @Override public Topology topology(){ - if(list == null || list.isEmpty()){ - return Topology.NO_CELLS; - } - return Topology.SEGMENT; + return _topology; } @Override - public Status status(){ - return super.status(); + public Location location(){ + return _location; } @Override - public T read(){ - if(!mounted()){ - throw new UnsupportedOperationException("Ariadne_SRMI_Array::read tape not mounted or out of bounds."); - } - return list.get(index().intValue()); + public T access(){ + if( can_read() ) return _array.get( _index() ); + throw new UnsupportedOperationException("Ariadne_SRMI_Array::read can not read tape."); } @Override public void step(){ - if(!can_step()){ - throw new UnsupportedOperationException("Ariadne_SRMI_Array::step, cannot step further."); - } - if(index().compareTo(rightmost_index()) < 0){ - index = index.add(BigInteger.ONE); -// set_status(index().equals(rightmost_index()) ? Status.RIGHTMOST : Status.INTERIM); - } else{ - throw new UnsupportedOperationException("Ariadne_SRMI_Array::step, no more cells."); + if( can_step() ){ + _index++; + if( _index == _array.size() - 1 ) _location = Location.RIGHTMOST; + return; } + throw new UnsupportedOperationException("Ariadne_SRMI_Array::step can not step."); } @Override - public BigInteger rightmost_index(){ - if(list == null){ - throw new UnsupportedOperationException("Ariadne_SRMI_Array::rightmost_index no tape mounted."); - } - return BigInteger.valueOf(list.size() - 1); + public int leftmost_index(){ + return 0; + } + + @Override + public int rightmost_index(){ + if( can_read() ) return _array.size() - 1; + throw new UnsupportedOperationException("Ariadne_SRMI_Array::rightmost_index can not read array."); } } 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 db8fd48..49c20bb 100644 --- "a/developer/javac\360\237\226\211/Ariadne_SRM_List.java" +++ "b/developer/javac\360\237\226\211/Ariadne_SRM_List.java" @@ -1,14 +1,8 @@ /* The Ariadne_SRM_List class provides a Step Right Machine (SRM) for linked lists. - This implementation relies on Java's ListIterator, which lacks a direct method - to read the current element without advancing the iterator. + This implementation uses Java's ListIterator, which lacks a direct method + to read the current element without advancing the iterator. - To address this, the `read` method temporarily moves the iterator back to access - the current element, then restores its position. This approach, referred to as the - "wiggle" method, is safe under the assumption of single-threaded execution. - - In multi-threaded environments, external synchronization would be required to - ensure the list remains consistent during the wiggle operation. */ package com.ReasoningTechnology.Ariadne; @@ -16,74 +10,66 @@ package com.ReasoningTechnology.Ariadne; import java.util.List; import java.util.ListIterator; -public class Ariadne_SRM_List extends Ariadne_SRM { - - private final List list; // The attached linked list - private ListIterator iterator; // Iterator for traversal +public class Ariadne_SRM_List extends Ariadne_SRM { - public static Ariadne_SRM_List mount(List list){ + public static Ariadne_SRM_List make(List list){ return new Ariadne_SRM_List<>(list); } - protected Ariadne_SRM_List(List list){ - if (list == null){ - throw new IllegalArgumentException("Ariadne_SRM_List::list cannot be null"); + private final List _list; // The attached linked list + private ListIterator iterator; // Iterator for traversal + private TElement read_value; // Stores the current cell value + + private Topology _topology; + private Location _location; + + // Protected constructor for controlled instantiation + protected Ariadne_SRM_List(List list){ + _list = list; + + if( _list == null || _list.isEmpty() ) + _topology = Topology.NO_CELLS; + else if( _list.size() == 1 ) + _topology = Topology.SINGLETON; + else + _topology = Topology.SEGMENT; + + if(_topology == Topology.SEGMENT) + _location = Location.LEFTMOST; + else + _location = Location.OTHER; + + if(_topology >= SINGLETON){ + iterator = _list.listIterator(); + read_value = iterator.next(); } - this.list = list; - this.iterator = list.listIterator(); } @Override public Topology topology(){ - return list.isEmpty() ? Topology.NO_CELLS : Topology.SEGMENT; + return _topology; } @Override - public Status status(){ - if (list.isEmpty()){ - return Status.TAPE_NOT_MOUNTED; - } - if (!iterator.hasPrevious() && iterator.hasNext()){ - return Status.LEFTMOST; - } - if (!iterator.hasNext() && iterator.hasPrevious()){ - return Status.RIGHTMOST; - } - if (iterator.hasNext() && iterator.hasPrevious()){ - return Status.INTERIM; - } - return Status.TAPE_NOT_MOUNTED; // Fallback, should not occur + public Location location(){ + return _location; } @Override - public T read(){ - if (status() == Status.TAPE_NOT_MOUNTED){ - throw new UnsupportedOperationException("Ariadne_SRM_List::read, tape not mounted."); - } - if (!iterator.hasPrevious()){ - throw new UnsupportedOperationException("Ariadne_SRM_List::read, no cell to read at the leftmost position."); - } - // Wiggle: Move back to read the current element, then restore position - T previous = iterator.previous(); - iterator.next(); // Restore iterator to the current position - return previous; + public TElement access(){ + if( can_read() ) return read_value; + throw new UnsupportedOperationException("Ariadne_SRM_List::access can not read tape."); } @Override public void step(){ - if (!iterator.hasNext()){ - throw new UnsupportedOperationException("Ariadne_SRM_List::step, no next cell."); + if( can_step() ){ + read_value = iterator.next(); // Move to the next cell and update current value + if( !iterator.has_next() ) _location = Location.RIGHTMOST; + return; } - iterator.next(); + throw new UnsupportedOperationException("Ariadne_SRM_List::step can not step."); } - // Optional: Reset to the beginning of the list - public void reset(){ - this.iterator = list.listIterator(); - } - // Optional: Get the underlying linked list - public List getList(){ - return list; - } }