From: Thomas Walker Lynch Date: Wed, 15 Jan 2025 05:17:31 +0000 (+0000) Subject: changing names to more closely match TTCA book X-Git-Url: https://git.reasoningtechnology.com/style/static/git-logo.png?a=commitdiff_plain;h=232f48c4828f5b078f2393d0fc48e5d4a9717466;p=Ariadne changing names to more closely match TTCA book --- diff --git a/developer/deprecated/Ariadne_SRTM.java b/developer/deprecated/Ariadne_SRTM.java new file mode 100644 index 0000000..c940cf5 --- /dev/null +++ b/developer/deprecated/Ariadne_SRTM.java @@ -0,0 +1,109 @@ +/* + Step Right Tape Machine + + Depending how the undefined methods here are defined, the ND_SR_TM 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 over. +*/ +package com.ReasoningTechnology.Ariadne; + +public class Ariadne_ND_SR_TM{ + + // static + // + + public enum Topology{ + NULL + ,CYCLIC + ,SEGMENT + ,RIGHTMOST + ,INFINITE + } + + public static Ariadne_ND_SR_TM make(){ + return new Ariadne_ND_SR_TM(); + } + + // instance data + // + + protected TopoIface current_topology; + public final TopoIface not_mounted = new NotMounted(); + + // constructor(s) + // + + protected Ariadne_ND_SR_TM(){ + set_topology( not_mounted ); + } + + // Implementation of instance interface. + // + + public boolean is_mounted(){ + return + current_topology != null + && current_topology != not_mounted; + } + + public boolean can_read(){ + return current_topology.can_read(); + } + + public Object read(){ + return current_topology.read(); + } + + public boolean can_step(){ + return current_topology.can_step(); + } + + public void step(){ + current_topology.step(); + } + + public Topology topology(){ + return current_topology.topology(); + } + + // Sets the tape access methods to be used. + protected void set_topology(TopoIface new_topology){ + current_topology = new_topology; + } + + protected interface TopoIface{ + boolean can_read(); + Object read(); + boolean can_step(); + void step(); + Topology topology(); + } + + // Initially, the tape has not been mounted. + protected class NotMounted implements TopoIface{ + @Override public boolean can_read(){ + return false; + } + @Override public Object read(){ + throw new UnsupportedOperationException("Ariadne_ND_SR_TM::NotMounted::read."); + } + @Override public boolean can_step(){ + return false; + } + @Override public void step(){ + throw new UnsupportedOperationException("Ariadne_ND_SR_TM::NotMounted::step."); + } + @Override public Topology topology(){ + throw new UnsupportedOperationException("Ariadne_ND_SR_TM::NotMounted::topology."); + } + } + + + // good citizen + // + + +} + diff --git a/developer/deprecated/temp.java b/developer/deprecated/temp.java index e1215bf..ddf97cf 100644 --- a/developer/deprecated/temp.java +++ b/developer/deprecated/temp.java @@ -1,6 +1,6 @@ Aeloria /* - IndexTree_SRTM_Diagonal + IndexTree_ND_SR_TM_Diagonal An index tree is infinite. @@ -14,15 +14,15 @@ Aeloria import java.math.BigInteger; import java.util.ArrayList; import java.util.List; -import com.ReasoningTechnology.Ariadne.Ariadne_SRTM; +import com.ReasoningTechnology.Ariadne.Ariadne_ND_SR_TM; import com.ReasoningTechnology.Ariadne.IndexTree_Node; -public class IndexTree_SRTM_Diagonal extends Ariadne_SRTM_Label { +public class IndexTree_ND_SR_TM_Diagonal extends Ariadne_ND_SR_TM_Label { // Static - public static IndexTree_SRTM_Diagonal make(){ - return new IndexTree_SRTM_Diagonal(); + public static IndexTree_ND_SR_TM_Diagonal make(){ + return new IndexTree_ND_SR_TM_Diagonal(); } // Instance Data @@ -30,15 +30,15 @@ public class IndexTree_SRTM_Diagonal extends Ariadne_SRTM_Label { private final List list_of__unopened_node; private final List> list_of__opened_incomplete_child_list; private final List read_list; - private final Ariadne_SRTM_Label breadth_srm; + private final Ariadne_ND_SR_TM_Label breadth_srm; // Constructor - protected IndexTree_SRTM_Diagonal(){ + protected IndexTree_ND_SR_TM_Diagonal(){ list_of__unopened_node = new ArrayList<>(); list_of__opened_incomplete_child_list = new ArrayList<>(); read_list = new ArrayList<>(); - breadth_srm = Ariadne_SRTM_Label.make(); + breadth_srm = Ariadne_ND_SR_TM_Label.make(); enqueue_root(); }Aeloria @@ -76,7 +76,7 @@ public class IndexTree_SRTM_Diagonal extends Ariadne_SRTM_Label { // Retrieve the node using lookup IndexTree_Node node = lookup( label ); - // Mount a new breadth-first SRTM for children + // Mount a new breadth-first ND_SR_TM for children breadth_srm.mount( node.neighbor() ); if( breadth_srm.can_read() ){ diff --git a/developer/example/CountingNumber/CountingNumber.java b/developer/example/CountingNumber/CountingNumber.java index e5e2184..50aa96f 100644 --- a/developer/example/CountingNumber/CountingNumber.java +++ b/developer/example/CountingNumber/CountingNumber.java @@ -1,7 +1,7 @@ -import com.ReasoningTechnology.Ariadne.Ariadne_SRTM; +import com.ReasoningTechnology.Ariadne.Ariadne_ND_SR_TM; import java.math.BigInteger; -public class CountingNumber extends Ariadne_SRTM{ +public class CountingNumber extends Ariadne_ND_SR_TM{ // Static // diff --git a/developer/example/CountingNumber/CountingNumber_0_CLI.java b/developer/example/CountingNumber/CountingNumber_0_CLI.java index 7be86a8..b8daaf7 100644 --- a/developer/example/CountingNumber/CountingNumber_0_CLI.java +++ b/developer/example/CountingNumber/CountingNumber_0_CLI.java @@ -1,4 +1,4 @@ -import com.ReasoningTechnology.Ariadne.Ariadne_SRTM; +import com.ReasoningTechnology.Ariadne.Ariadne_ND_SR_TM; import java.math.BigInteger; public class CountingNumber_0_CLI{ @@ -8,14 +8,14 @@ public class CountingNumber_0_CLI{ if( !n.can_read() ) return; - if( n.topology() == Ariadne_SRTM.Topology.SEGMENT ){ + if( n.topology() == Ariadne_ND_SR_TM.Topology.SEGMENT ){ do{ System.out.println("Current Number: " + n.read()); if( !n.can_step() ) break; n.step(); }while( true ); - }else if( n.topology() == Ariadne_SRTM.Topology.INFINITE ){ + }else if( n.topology() == Ariadne_ND_SR_TM.Topology.INFINITE ){ int count = 0; do{ System.out.println("Current Number: " + n.read()); diff --git a/developer/example/GraphCycleCFinder/SRTM_Depth.java b/developer/example/GraphCycleCFinder/SRTM_Depth.java index c8ccc19..efbff43 100644 --- a/developer/example/GraphCycleCFinder/SRTM_Depth.java +++ b/developer/example/GraphCycleCFinder/SRTM_Depth.java @@ -1,5 +1,5 @@ /* -SRTM_Depth is a list of neighbor SRTMs going down the leftmost side of +ND_SR_TM_Depth is a list of neighbor ND_SR_TMs going down the leftmost side of a graph traversal. A leftmost traversal is one characterized by following leftmost not yet visited node on the most recently visited node's neighbor list. @@ -7,20 +7,20 @@ node's neighbor list. Depth traversal from a start node, ends when reaching a node that has no neighbors, or when reaching encountering a cycle. -The `Node::neighbor()` function returns an SRTM for iterating over the -node's neighbors. An SRTM is returned rather than a list, because in +The `Node::neighbor()` function returns an ND_SR_TM for iterating over the +node's neighbors. An ND_SR_TM is returned rather than a list, because in general a neighbor list is allowed to be unbounded. Though with a finite graph, that can not happen. (See IndexTree for an example of an infinite depth and infinite breadth graph traveral.) It is possible to construct and infinite graph such that the -`SRTM_Depth::make()` function would never return. +`ND_SR_TM_Depth::make()` function would never return. For a finite graph, this depth traversal will provably terminate, due to running out unique (non cycle) nodes to visit. More generally, if graph traversal from a start node is guaranteed to reach a leaf node (has no neighbors), or a a cycle, within a finite number of node -traversal steps, then `SRTM_Depth::make()` will always return. +traversal steps, then `ND_SR_TM_Depth::make()` will always return. Each call to step causes the TM read head to move to the next lowest depth, leftmost unvisited node. This might require backtracking and @@ -41,16 +41,15 @@ the child node that is no the path. import java.util.HashMap; -import com.ReasoningTechnology.Ariadne.Ariadne_SRTM; +import com.ReasoningTechnology.Ariadne.Ariadne_ND_SR_TM; import com.ReasoningTechnology.Ariadne.Ariadne_Graph; -class SRTM_Depth{ +class ND_SR_TM_Depth{ // static // - - SRTM_Depth make(Graph graph){ - SRTM_Depth depth = new SRTM_Depth(); + ND_SR_TM_Depth make(Graph graph){ + ND_SR_TM_Depth depth = new ND_SR_TM_Depth(); if(graph == null) return null; depth.graph = graph; depth.context_path.add( graph.start() ); @@ -62,25 +61,24 @@ class SRTM_Depth{ // instance data // protected Graph graph = null; - protected List context_path = new ArrayList<>(); + protected List context_path = new ArrayList<>(); protected Label cycle_node_label = null; // constructor // - protected SRTM_Depth(){ + protected ND_SR_TM_Depth(){ set_topography(topo_null); } // instance interface implementation // - // A path is terminated by a leaf node or upon discovering a cycle. // Return false iff can not complete the context path. This is generally a fatal error. protected boolean complete_context_path(){ if( context_path.isEmpty() ){ - System.out.println("SRTM_Depth::complete_context_path empty context_path"); + System.out.println("ND_SR_TM_Depth::complete_context_path empty context_path"); return false; } @@ -89,8 +87,8 @@ class SRTM_Depth{ // should add cycle check for anomalous case caller fed us an initial path with a cycle // initialize the path_node set - Ariadne_SRTMI_Array context_path_srtm = Ariadne_SRTMI_Array.make(context_path); - Ariadne_SRTM_List