From de8b53d1bd69e74b85ee2afc7043594590f967c8 Mon Sep 17 00:00:00 2001 From: Thomas Walker Lynch Date: Sat, 4 Jan 2025 10:20:09 +0000 Subject: [PATCH] moving to a SRM implementation more faithful to the C model --- .../Step_Right_Machine.txt" | 6 + developer/example/CountingNumber$State.class | Bin 0 -> 468 bytes .../CountingNumber$State_InfiniteRight.class | Bin 0 -> 901 bytes .../CountingNumber$State_InterimSegment.class | Bin 0 -> 1155 bytes .../CountingNumber$State_Leftmost.class | Bin 0 -> 1240 bytes .../CountingNumber$State_Rightmost.class | Bin 0 -> 789 bytes developer/example/CountingNumber.class | Bin 2962 -> 1670 bytes developer/example/CountingNumber.java | 145 +++++++++++++----- developer/example/Example_* | 2 + developer/example/Example_CountingNumber | 2 - .../example/Example_CountingNumber.class | Bin 2352 -> 0 bytes developer/example/Example_CountingNumber.java | 43 ------ .../example/Example_CountingNumber_0.java | 37 +++++ .../Example_IndexTree_Diagonal_SRM.java | 0 developer/example/Example_SRMI_Array | 2 - developer/example/Example_SRMI_Array.class | Bin 397 -> 0 bytes developer/example/Example_SRMI_Array.java | 12 +- developer/example/Example_SRM_List | 2 - developer/example/Example_SRM_List.class | Bin 2497 -> 0 bytes developer/example/Example_SRM_List.java | 10 +- developer/example/IndexTree_Diagonal_SRM.java | 106 +++++++++++++ developer/example/hold/CountingNumber.java | 79 ++++++++++ .../example/hold/Example_IndexTree_0.class | Bin 2787 -> 0 bytes .../hold/Example_IndexTree_Diagonal_SRM.class | Bin 1852 -> 0 bytes .../example/hold/IndexTree_Diagonal_SRM.java | 80 ---------- .../#Ariadne_LockManager.java#" | 12 -- .../#Ariadne_Node.xjava#" | 50 ------ .../Ariadne_IndexTree_Child_SRM.java" | 2 +- .../javac\360\237\226\211/Ariadne_SRM.java" | 38 +++-- .../Ariadne_SRMI_Array.java" | 10 +- .../Ariadne_SRM_List.java" | 13 +- 31 files changed, 385 insertions(+), 266 deletions(-) create mode 100644 developer/example/CountingNumber$State.class create mode 100644 developer/example/CountingNumber$State_InfiniteRight.class create mode 100644 developer/example/CountingNumber$State_InterimSegment.class create mode 100644 developer/example/CountingNumber$State_Leftmost.class create mode 100644 developer/example/CountingNumber$State_Rightmost.class create mode 100755 developer/example/Example_* delete mode 100755 developer/example/Example_CountingNumber delete mode 100644 developer/example/Example_CountingNumber.class delete mode 100644 developer/example/Example_CountingNumber.java create mode 100644 developer/example/Example_CountingNumber_0.java rename developer/example/{hold => }/Example_IndexTree_Diagonal_SRM.java (100%) delete mode 100755 developer/example/Example_SRMI_Array delete mode 100644 developer/example/Example_SRMI_Array.class delete mode 100755 developer/example/Example_SRM_List delete mode 100644 developer/example/Example_SRM_List.class create mode 100644 developer/example/IndexTree_Diagonal_SRM.java create mode 100644 developer/example/hold/CountingNumber.java delete mode 100644 developer/example/hold/Example_IndexTree_0.class delete mode 100644 developer/example/hold/Example_IndexTree_Diagonal_SRM.class delete mode 100644 developer/example/hold/IndexTree_Diagonal_SRM.java delete mode 100644 "developer/javac\360\237\226\211/#Ariadne_LockManager.java#" delete mode 100644 "developer/javac\360\237\226\211/#Ariadne_Node.xjava#" 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 0000000000000000000000000000000000000000..a34a9fc69db8df732e52b4cc74a4aa9b0364b3e3 GIT binary patch literal 468 zcmZ8d%TB^T6g^X>6l;YF2tGD0T!1n10T?$;j3$UC7#42KP$n>>Ov!Zczg(HP@B{oP z<85Jslgv4D&wbC&@7Fhg2xmSVlsxbNF3JqyLcEJ!BJ`~HG+D^lGL&zWR`!;m)ai~r zR2Z63y4F_d*>Js_NOLi=!b*llXRzz&cgGAoN~h$k4V0Ff_!lurNU0CfSR`X%RBmrY zZs#gvX#K0SY0;2;&G>`IrwE^-dEf-Ef9I!w{3ZbGX2QJYjS)4_QjqDA-iVLU( zi32}?ABC88ERj?`aM+ohZ}z3rc;PBgGVq71q7bUn1_3h)e8u6cMwPy^q)@6bA zsE9IlZB$(Bp~_I+mSA9#VSn(Ef95AkuI4AtrQZ*f@I}-sqK<}*eHT|WwVri}!F)4( z;n2-%F0SJS#e6nnIBsQYwzFXd%L`|MVRs+{v2NBoK3Nb_9fVW981YEzI0Y@;GKS`* zdb9f5qrSctY97u`dBm4OiHMkmDG$bx;FPM_YQIl`Scy-R%Gwb=VsOsFRWubZrOu_c z-MwSo5uy%7tX_pNeWlwE0ugx&9>;=Ssb&6mE(cg$8bs&4ZC0<2G40*_UvKB!PRha&$+leuM)?g(e9EhkUz4FzZrD1hX4Qo literal 0 HcmV?d00001 diff --git a/developer/example/CountingNumber$State_InterimSegment.class b/developer/example/CountingNumber$State_InterimSegment.class new file mode 100644 index 0000000000000000000000000000000000000000..13e4d7ecb3a3f41cc63b560b61326cbb380f2928 GIT binary patch literal 1155 zcma)4+fEZv6kTUpn6?b1LP5bB3TRu9;sq}Z`e36GQ^0^h!3T0^PujuG6lbQ!_$U5@ zFB&e1CVqe)Wn8D77)tu!!`b`nea>F{wtoNl@e4o+kCQMEGZDAYhkk*nQnTfSj#pc2 zxqHf=-V9}^c2~Sm`Hs7(YOeA^f&Q@W1k(!wnR54kJB0+2CQ=p#U5(xDc?>ai%}C}7S8L? zY_CrOvGuiQDgGR{FoBD-Wwk0WpX-g8@9oxAUbb*W=P_OR$#Gk*2A#BU4cFPC`p}Y% zKwvb&ZAhuCFAg7|Z2%B1aIa1J=?}^s}%*(y8)(RUSmCQ=83}Us2B;UEE0b zH0Jg42(_ky@CBzKV6Awb@=FaF1d3U+y}8-fcC-7=^S^0gl1xvK^dghdT<0xL4{1tS zptVSCP!AMlk01)OCosR!G%!oq4?+17bCg#5K7d=8r&Z+X<0Dal1>EMNMw_G7Ax8YG zmZv~gPk|T_2yo{=A~$+Q-o?Er=Vx}LbJ~SNHo$X;!S5J3#)TscMs`PCI>yy67}ds4 zOl@m@f|+C7&>hFx#SRk;ctc9RCHuCqgmSgv&YbU@`Tgg|F93OL7|;;Y5x3BVZib0`z2QpR zt?V|OW8uvmNG`=uLA;et-IomAvTFNtOAN_E>&cvn9vC`I3%#%yhFiBoB8p$JU0bd( z45iu$(nSLa^y^4k7{DMyqLqSy*$ktF6aIl`9WJZcO}nz~N>LGB&cHB6bc|ZKqC$r| z9b$;>?Y=PS4PQ9K&R5X_3sY>`FDz*~Bailk(iQkV2Zl@P$0`RWBIE+m#EW zbLpavd4}1J)JiAMb`C_v5w0|mfx!^Z*ULoMU$9*f_WLzIt`Ra=sF!%H$UR&65g1pk zXP9d1Tib}_Xf$?&tk%o>+~ba*v=r1+;_i_rIH?^=r4J*(m*SLe5gNja41F|krFT30 zG)ih7)Eiz&Y}x8sL#?GPswNZFuJGl{U^=aB*A-sA#(iH<)eXz{OVy+pEniA0M?RQCTz<~l|$<586J6IG;g?q|-Z z0Q%0*_Z>q`jGdz|@BZqSf>ZF zL9@JxRXoQYwl3XkKdR_4og;l$2PpCh{cCuNTwoJeAv+VOpCAU+l?2w}8oiSQo{^s+ HyAJIyt)mOZ literal 0 HcmV?d00001 diff --git a/developer/example/CountingNumber$State_Rightmost.class b/developer/example/CountingNumber$State_Rightmost.class new file mode 100644 index 0000000000000000000000000000000000000000..ae86555b5e85c3e66d579ed03960df1e56956778 GIT binary patch literal 789 zcmZuuO>fgc5PfSqaWJ7tla{YSFfCG3KrIJuMO-YPmC_b9X(YH*+hj?Ml3lajAbRO9 z;=-vCNO0#zA!Z#*O#+rYUpsH+z1`n`zW)ReVIzP8*N0a|0Y!$DNKK@P<=}8KJ`?&; z+i)WoiZ5aro0kmrW^2A#IXG%}wgdPmTQ)ZsR-3J>v2CM?SGKRh(3qz&C3<=s z4~Ax}Qp4ays!z--tyqewm<~T1QKi;WJwEDk9osxFdS)1>4B>*h#j(2#)dOLMs{fX2 zJ{Cr3LX~=4o@&AS3~qDleO|EQh{n`Wy~_}^)kOEi>)7(B&nwurN(p)>QnN=2d^})S zn(tvK?@K9kG~#J0XmcTdpGxMhZ|lX!PcFf}QRHCR=3rz$ zp+>fx#YNPyLfI<)1v;!+_)XlRLmNFMZy}EN)!LaMW@d8>$->gnQzeLfcor3H1N=K=&Bl6hw~S!Vx3X| literal 0 HcmV?d00001 diff --git a/developer/example/CountingNumber.class b/developer/example/CountingNumber.class index 2df2a3097a457c9643836373247f2271f2621b10..9cc87cea5cc4a9bc2b98d029164c155630d1896e 100644 GIT binary patch literal 1670 zcmZ`(T~8BH5IwgoU0N1IKrAWa50lxU4 zMl_McR}+7fc<$XTX>sjC=g#cRnVECv&hI}zegY`tiGhSbPr2T31KX`FHJo+nWg(C< z(Sfu;`j+k5!K}bgq4LstW0f2$*ecE0wFNhjHR;Vvu4d7RjDf6*=o0AFZrheyD=n|T zl+{2WS(seSpc_2~4w>l1VS#}-FnTU8JrEd-PnBU^{U!!fys(uvXyT~S499wBI}OLc zkie<-ZYEX&E0Ajo?xyNQKDBFGK^8e2SM{DCVxiI=z?KY*2n@HIBbixIYQyuS8?5;%pK2m5ekO}NP8&F5qJT;A5a%S&S+(3XPg)zAyca5H%EVa} zp+EV7e65VrCQ6F*lrm5_)+?qi{O_&~lr+PLa(#mlhbp!!!`pvmt#8xPSE*O6?N!UO zmEJTKCSxFiE!*e4|NEtz)K_0ETCbzn}bHC1R@Ri{fx=n}HpnqwhDEosyHY15b?&D=Zc*+y6wwNC1bUorX(6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63X^^W5^3fAP|Bjcm>)BynVP8*`G>ZKN64eN4!08SOSQKcR;_ z=g9NV=%>U7B>g_Z+$%iA{mK*WTeOU^48S%GU=k5d>*F{}e$Qcw9}u&=rg0HhdEoD6 z|C*1o06M1n`sNt6u`ldxTzxw1E+5PeXF=S061FUM`3psEJi@2HVMNx5zi1Wuxxu{- rR8ezR6BgIQ+;J#bcds_?ac_tmM%g=GUW)QlA&9TIevNPOJ)-{s?vvGX 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 aee2ee4f583c981cabcc4d853f30604fe75eb9b3..0000000000000000000000000000000000000000 GIT binary patch literal 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Xlbxym9h8Tz;TVUF4ocKiWTqkwS5iY&L1IvGB%fu0i%P# E7fwx0^#A|> 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 abd61ea8e132bb8fb10cef035bea27bf586f2611..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2497 zcmb7GO;;OL7=A7UCWL8e0|cqGrU(e6HWjhf2C+a(L6cHR1ly{3Nv2`QWG2o`5Ug5t z@4}r6cj|F%7qkb@@woO^_(%MBW+thDpyy;3_s)I4?)yIP$IS149sCMl0bfSYhIR!Z z6&>glIJGTzWYUmkF}bq2t>s;T&Kcd*-C2S5@rgABVSzqhsOsuQGOe2>t&r9oHv$Fi zVRQ?KIq&_1ij(M}mMjzm`p45pEvF{#hH;wW^I`OITZo_^F$DuEp248NrMy*6u4>Y; zOx-NzwEUK78CG#GIcMv#U~2V!BfFZ}@H`L*m1Rj2xL&)g=Aq-JCep1MOLgH{3@JFP z;vAkk1Wb0%akVldv#PwaKL|{>lDBQ$bhECl$#Tkz<-CevJTDM-t%~otz?JcqJQ>N= zG-+=XV+vkSF^-AD-nhKBD4^^}qpGdk7Z^JZ>jwDgA~jM`7C=J91-vLQ-~qQ_nR)51 z>+Tlc99NpIbHrFpbE4T;1W8;{@REutye!b`C;Koabg|+gWSB?Fp>B1}1ML+Rm+>mA zjt;n0I&ir~$g;j3qZ3GU;VM!JW>mZm7VuOHMKBWB5$IZ7zPXgktYmWn)2)?1UFPHdc7E8nN^}_MDMT!78v9df1`bt!jBwvvYFOASIf%^3qt7>>{3P#E`qC6YOaEsG*eK zRXTGP8^71!^wXq~FYO|AdyioYL=3s985@S*pRvHek;%a;+8vt>HPs5de#=ueb~v29 zNV=tR&j$xKo7F)jhKMb8<-Q-IdS*ZaV$y!xAuPy2x^!-QCz35c|(>HHfuH)LW zlF{5PtKfveD(S9w|JAq%gN=Q9nS)rDMm(rZpS(qgIV210X#c!Ty?7(Rp!xWsZXQ-+ zK2OfwcQrfiR}xiwI#G$>BiITYZz^!Kjr?1qy18SOv}BO=U{EZ|yldHe0^c^yo0?z{ z$C5M)hUSck5xUq(Hp2GMJ@8S+o8OB$*i+jZ7J> { + + 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 1aa7f737816dd5b836f10941688f0acbd9f13308..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2787 zcmbtWTT>Hf7=Avout``v1Q4*O5kW&xQjuCqJaABy8c=~^Ewyn;R7Zk$POp2{o8I+@)T!F%+bkLdJFU*_eES{V)APLV`|bYr@a{bT zBltXw8U$1*8fsA|u;G%vs3-EeHJ>;&cge`O0(A#X%XAM51Y+GYAp{Xp5!O%-?J4o8 zrIKqDC}o$a)SU7RnReo|V_NQ%>lk_=8N@n)ty8YY}W7!+6DG!>_TGF&`Y*O&1oZ(v+TS*zmynqOg(EEEAO-ys|+Dm&l!0liFH?@tRyC>qC=qNIqt*gM3;)48g?N@ z7LQ%g3&p%q1>;o#?V{~4?zHcv=lNKkRE1A*gw+$*(1YEKK~gbdTN&LwYq~kkO0I6X zC4rr5C8r9BZ%jh&)sO&V3R;FapPRECfg?oy|4AIlnfYvbYI2-R_F1lIYqM56_m)W5NesrtCO|wPMNln6b+i?@Pg~g(_Y>JbncJX#=m!%)+={ z^obEBr7O+r8nP-^RohCMyo<`@J-KP6xu3o$d9FM2B)QQq>*`~H@RVJ4GRCMWbJV&< z8hT}U@;fk0ib_m*aoliocD57*8(5p9QxbKMl{J1U|_?aP+8w@6)oZz$u~ zr4o17*WpSSOZY&=hq9qQ66k!=1*WxVFBpkRC0A~pQ9a|@&XT~l)g|l;RsuSqTiLu( z>P*@8Lb;e+#aH#tQ;O3|MWg!A@1Sb7{QJ1NzkL%UdOkm8x?c9jEX#04@_MOclvG?5 z=vswotx#25<0tdqMcKp^T-eSItl`xRD7=pNMdvufRf2E9cWwMO#1EX*;4DXZ%uT$_ zQS;~L@D5iY*~Q$Uvbc%>=fF2VLX9*mV}0NkG~YqXNv`9|*zzm3-@%T%=mvNgPX!M3 zEMw2ao@MMEP$<)`Txe4~iPt>|xoAnX*L{z=n+RR65jP+G?r8+}E1pssF`QE0fX2udYyKKerf33xzec=>_9CPB#GhkA6Ofgiqg3~2*;u@U`<;5dIM#<7XO zS_rrmv)GIa{0qon3ruXq$7Jsdbl^+uz*pq)Yg&=SOwwvE;*@`v-uiiRo>B^RI`JN7 zwe)cfY1#sPUV_eAhtb(a0r6~VH ufqk^zUsa9@@+fdW0E=S{Y!vx!;`%aeyzh-AZ!9x^AX5UL;8T2twtoN`XU$*$ 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 7f9b08e0649ece48dbe8210813346b0f3c1b17b4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1852 zcmaJ?T~kv>7=D(7oDdFR1M+1GkuQO$X|4StYAYx;ZBT0{)KVIkWE+m0oRc{@apb-~ zqSK2`#~W|8)4`6N;Rp0T^s4`&GuA$v6BS5GGTGht-FKh&c|UgZ=fBVQ0W3kr(1DPF zu!&AY1Ww$S4`kYwPC0#R>%J=b0+CCWWBFGELbG#gU5KK~K+Hrp%tPk+-I}i|v~ue_ zbTZcfvfT7-&vN{{?Z56`_yk#J6 zq8|eS{cUgrjH*Vp9Xgr~JT)lO4RJGbYcULB$iT3P5sV59zV=kOX34VaNV`Cn0^y3> zQ39j0bGh~=nK;vwF!46V1ctQrlIs+uzi#>4T-AK(_%+QUJJ-rXvq+jatrHt&cB)ZK z3Uq928ki>9n^Xt97weW?QeG5i1jI%RQ<&3L8Hgc;vj)zYIFGczK;v9R`rGM6tDJRw zRaTxr)OQ0IS}>fW;2Dkgu89kHk0q7Ws&YyK=h|hjLYiH`ed(2n)Zb>Com%tQufzXWd4ZU&S)u6G9d@+H3iPmbi#sc_+9Yaz?|Ljm z!IoRf7D&CKailnzHsv6oCD7SCIn*S0^q@dj;KEm|)<{c`uPQ^XdAIHr)v~3tI(dBJ z&g6VzUN7rA8nAnP4H#>0e>Qd-l-xJ0IE5 zWlD+gz2`UuP?w1Og2-d^{Lmp%dl-NG@^9@X)NnIHIKbco9-|u*z5FIH#7jJkGkhmg z8071Axo_>9DFP~VNv3-lTo6eqg~n#Jc$uD><8F3<1( zgh+hi$sd@y8=rZGSu#${??1w1YCdsc5A%C?XPt_0=@DY7_(d&}`{S2?rQ#oGfl++) z8cC7nf0e*iQ1qCpj;oWlzBaa!KQEwa?~dl8Pl mK(~P@G5!zB6vAz4JMbm$aE{XIEB^A>pcLckTYQIm82JwtRn6c4 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); + } } -- 2.20.1