From f90d1c7aa3bfb45b1c41fa4513ca20dbb569743e Mon Sep 17 00:00:00 2001 From: Thomas Walker Lynch Date: Fri, 3 Jan 2025 10:25:48 +0000 Subject: [PATCH] chkpt this mess --- .../deprecated/Ariadne_IdentityManager.java | 0 .../deprecated/Ariadne_LockManager.java | 0 .../Ariadne_LockManagerDelegate.java | 0 .../deprecated/Ariadne_SRM_with_locks.java | 108 ++++++++++++++++++ .../hold/Ariadne_DirectedGraph.java | 0 .../deprecated/hold/Ariadne_NodeList.xjava | 0 .../graph_print.html" | 2 +- developer/example/CountingNumber.class | Bin 2610 -> 2962 bytes developer/example/CountingNumber.java | 35 ++++-- developer/example/Example_CountingNumber | 2 + .../example/Example_CountingNumber.class | Bin 0 -> 2352 bytes developer/example/Example_CountingNumber.java | 43 +++++++ .../example/Example_IdentityManager_0.java | 50 -------- developer/example/Example_IndexTree_0 | 2 + developer/example/Example_IndexTree_0.class | Bin 0 -> 2787 bytes developer/example/Example_IndexTree_0.java | 73 +++++++----- .../example/Example_IndexTree_Diagonal_SRM | 2 + .../Example_IndexTree_Diagonal_SRM.class | Bin 0 -> 1852 bytes .../Example_IndexTree_Diagonal_SRM.java | 39 +++++++ developer/example/Example_SRMI_Array | 2 + developer/example/Example_SRMI_Array.class | Bin 0 -> 397 bytes developer/example/Example_SRMI_Array.java | 8 +- developer/example/Example_SRM_0.java | 23 ---- developer/example/Example_SRM_1.java | 55 --------- developer/example/Example_SRM_List | 2 + developer/example/Example_SRM_List.class | Bin 0 -> 391 bytes developer/example/Example_SRM_List.java | 32 +++--- developer/example/IndexTree_Diagonal_SRM.java | 80 +++++++++++++ .../javac\360\237\226\211/Ariadne_Graph.java" | 12 +- .../Ariadne_IndexTree_Child_SRM.java" | 38 ++++++ .../Ariadne_IndexTree_Graph.java" | 5 +- .../Ariadne_IndexTree_Node.java" | 11 +- .../Ariadne_IndexTree_SRM.java" | 40 ------- .../javac\360\237\226\211/Ariadne_Node.java" | 36 +++--- .../javac\360\237\226\211/Ariadne_SRM.java" | 93 ++++----------- .../javac\360\237\226\211/Ariadne_SRMI.java" | 4 +- .../Ariadne_SRMI_Array.java" | 36 +----- "developer/tool\360\237\226\211/make_example" | 29 +++-- 38 files changed, 491 insertions(+), 371 deletions(-) rename "developer/javac\360\237\226\211/Ariadne_IdentityManager.java" => developer/deprecated/Ariadne_IdentityManager.java (100%) rename "developer/javac\360\237\226\211/Ariadne_LockManager.java" => developer/deprecated/Ariadne_LockManager.java (100%) rename "developer/javac\360\237\226\211/Ariadne_LockManagerDelegate.java" => developer/deprecated/Ariadne_LockManagerDelegate.java (100%) create mode 100644 developer/deprecated/Ariadne_SRM_with_locks.java rename "developer/javac\360\237\226\211/hold/Ariadne_DirectedGraph.java" => developer/deprecated/hold/Ariadne_DirectedGraph.java (100%) rename "developer/javac\360\237\226\211/hold/Ariadne_NodeList.xjava" => developer/deprecated/hold/Ariadne_NodeList.xjava (100%) create mode 100755 developer/example/Example_CountingNumber create mode 100644 developer/example/Example_CountingNumber.class create mode 100644 developer/example/Example_CountingNumber.java delete mode 100644 developer/example/Example_IdentityManager_0.java create mode 100755 developer/example/Example_IndexTree_0 create mode 100644 developer/example/Example_IndexTree_0.class create mode 100755 developer/example/Example_IndexTree_Diagonal_SRM create mode 100644 developer/example/Example_IndexTree_Diagonal_SRM.class create mode 100644 developer/example/Example_IndexTree_Diagonal_SRM.java create mode 100755 developer/example/Example_SRMI_Array create mode 100644 developer/example/Example_SRMI_Array.class delete mode 100644 developer/example/Example_SRM_0.java delete mode 100644 developer/example/Example_SRM_1.java create mode 100755 developer/example/Example_SRM_List create mode 100644 developer/example/Example_SRM_List.class create mode 100644 developer/example/IndexTree_Diagonal_SRM.java create mode 100644 "developer/javac\360\237\226\211/Ariadne_IndexTree_Child_SRM.java" delete mode 100644 "developer/javac\360\237\226\211/Ariadne_IndexTree_SRM.java" diff --git "a/developer/javac\360\237\226\211/Ariadne_IdentityManager.java" b/developer/deprecated/Ariadne_IdentityManager.java similarity index 100% rename from "developer/javac\360\237\226\211/Ariadne_IdentityManager.java" rename to developer/deprecated/Ariadne_IdentityManager.java diff --git "a/developer/javac\360\237\226\211/Ariadne_LockManager.java" b/developer/deprecated/Ariadne_LockManager.java similarity index 100% rename from "developer/javac\360\237\226\211/Ariadne_LockManager.java" rename to developer/deprecated/Ariadne_LockManager.java diff --git "a/developer/javac\360\237\226\211/Ariadne_LockManagerDelegate.java" b/developer/deprecated/Ariadne_LockManagerDelegate.java similarity index 100% rename from "developer/javac\360\237\226\211/Ariadne_LockManagerDelegate.java" rename to developer/deprecated/Ariadne_LockManagerDelegate.java diff --git a/developer/deprecated/Ariadne_SRM_with_locks.java b/developer/deprecated/Ariadne_SRM_with_locks.java new file mode 100644 index 0000000..14cf1fa --- /dev/null +++ b/developer/deprecated/Ariadne_SRM_with_locks.java @@ -0,0 +1,108 @@ +/* +Step Right Machine + +This is a mostly abstract base class. + +The SRM is for a single traversal through a bound resources. + +In Java it is possible to declare a variable of the SRM type long before it is used +for traversal. This complicates managing ownwership of the resource being traversed. + +The SRM model is that of 'mount' and 'dismount'. When the resource is mounted, +the SRM requests ownership of it. When it is dismounted, the SRM relinquishes +ownership. + + + +mount and unmount are used for handling shared memory scenarios. See +the Ariadne_Access class. For single threaded execution pass in an +Ariadne_Access_Single instance. + +*/ + +package com.ReasoningTechnology.Ariadne; + +public class Ariadne_SRM{ + + public enum Topology{ + NO_CELLS + ,SEGMENT + ,CIRCLE + ,INFINITE_RIGHT + ,INFINITE_LEFT + ,INFINITE + ,UNKNOWN + ,UNDEFINED + ; + } + + public Topology topology(){ + return Topology.UNDEFINED; + } + + public enum Status{ + TAPE_NOT_MOUNTED + ,LEFTMOST + ,INTERIM + ,RIGHTMOST + ; + } + + public Status status(){ + throw new UnsupportedOperationException("Ariadne_SRM::status not implemented."); + } + + public boolean can_step(){ + return + status() == Status.LEFTMOST + || status() == Status.INTERIM; + } + + public boolean can_read(){ + return status() != Status.TAPE_NOT_MOUNTED; + } + + public static Ariadne_SRM make(LockManagerDelegate delegate){ + if(delegate == null){ + throw new IllegalArgumentException("Ariadne_SRM::make delegate cannot be null."); + } + return new Ariadne_SRM<>(delegate); + } + + private Ariadne_SRM(LockManagerDelegate delegate){ + this.delegate = delegate; + } + + public void mount(){ + if(status() != Status.TAPE_NOT_MOUNTED){ + throw new IllegalStateException("Ariadne_SRM::mount already mounted."); + } + delegate.request(this); + } + public void mount_lenient() { + if(status() != Status.TAPE_NOT_MOUNTED) { + dismount(); // Ensure the current tape is dismounted first + } + mount(); // Proceed to mount the new tape + } + + public void dismount(){ + if(status() == Status.TAPE_NOT_MOUNTED){ + throw new IllegalStateException("Ariadne_SRM::dismount not mounted."); + } + delegate.relinquish(this); + } + public void dismount_lenient() { + if(status() != Status.TAPE_NOT_MOUNTED) { + dismount(); // Only dismount if a tape is currently mounted + } + } + + public T read(){ + throw new UnsupportedOperationException("Ariadne_SRM::read not implemented."); + } + + public void step(){ + throw new UnsupportedOperationException("Ariadne_SRM::step not implemented."); + } +} diff --git "a/developer/javac\360\237\226\211/hold/Ariadne_DirectedGraph.java" b/developer/deprecated/hold/Ariadne_DirectedGraph.java similarity index 100% rename from "developer/javac\360\237\226\211/hold/Ariadne_DirectedGraph.java" rename to developer/deprecated/hold/Ariadne_DirectedGraph.java diff --git "a/developer/javac\360\237\226\211/hold/Ariadne_NodeList.xjava" b/developer/deprecated/hold/Ariadne_NodeList.xjava similarity index 100% rename from "developer/javac\360\237\226\211/hold/Ariadne_NodeList.xjava" rename to developer/deprecated/hold/Ariadne_NodeList.xjava diff --git "a/developer/document\360\237\226\211/graph_print.html" "b/developer/document\360\237\226\211/graph_print.html" index 039ebc8..2945154 100644 --- "a/developer/document\360\237\226\211/graph_print.html" +++ "b/developer/document\360\237\226\211/graph_print.html" @@ -309,7 +309,7 @@ This algorithm avoids forward referencing by ensuring that nodes are processed a
  • Yield a node from the list (one at a time).
  • If the list becomes empty, remove it from list_of__opened_incomplete_child_list.
  • -
  • Print the node.
  • +
  • queue the node as the read value.
  • If the node has its own child list, add it to list_of__unopened_node.
diff --git a/developer/example/CountingNumber.class b/developer/example/CountingNumber.class index cce86a0204662058bad342ec42ca45cc4063f0bb..2df2a3097a457c9643836373247f2271f2621b10 100644 GIT binary patch literal 2962 zcmbVOZBrXn6n-uQHc6L)DbNO643=U@DX}fqN)QVe+GrA#MA}*vmt-5ZB)f65p)bDs zD;$47{o;p;7CUvuug>_R9G|;c%2Lt}HJRDFd-t5@ob#NQyZ`+A_%8qp_(4I3z~Kd} zX*z~k$v10jx*diLN5PEP}L9dEFyd==y z&JHD)@@av=_FjbO@(~sNQePPIX;8&c`J~jeJ4UTp3n7Xj1uv^OjuQgsUck%If}=Uj zhCnczUM%L83Ppjb?27}Wq+hS7h)D;!8!o8adR4_qjFNLlZ#V*z2Zk1J!U{k9$^`)BvV_p*7*Gp@+^pcYrZ!zlANJUs16DrPNQs8J! z+t3#*v!pp!4QHKqblh~v#vZVit#)8xypFR9&Z#($DS?TD@+N~5=&CaYt^9?mHCv0?T9rHTXXbn#MkH&MwCak+ z=}A>jKj5qzY{9<$CVR+bX(OlAJ<0wZp8P$}%9$xuy~!Rb7!{KP&Zb}K1BWe%ZJ&Ty z1|BY0O}nHo8Zy`;dt;iEX`}D+mgO`YTdU`EXWc3{g7`w<%wE};Om=)c=1#DfblA|U z#y!0pbFAr@2!bTUV%kkdw_~!qCSs<3dyf*Odb`mKV-vR(+>ul5uE6N-lr+puYeV;j zWoytaY9+_ADfXkkGCaYSw^uZ?T-6(+SHdusBdSFV)1TWZzF!gC*Ni;dk_m+ zwOTM7oeZlP)70&Ss@7=eB%!<2LQL$=TvPCkz^Q$4wsT*>cLKxD7o~|-tQcW426;jR zFeJ|{-gU@>*Ijw!a)mtNcn$Ht3XSq>d>TQge1*`T5ZA>Y=zPEjffBFXT!FAFUiQS# zQ(W%4;t5Z@!zbPYov+oFkUZ@96p&vn9)L~1I=GjhvXa<>`Vf)C>4zBL{jrA_-oi-Y zcSIiH)MK0mwvqgm(k%-^L;<4;U;u|O$PbgF{2${H8+EM?wvcfX70S_uYoFg9axQ!J z7rDv+dTC|gZzx-M#m$QL=4VU4>Rdub`f(}BKZk9 z=|k!AP=p+sZImNVE63X^^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 delta 1166 zcmZWoNmCP15dL0fl1au#62c}ZafqUsfJ6aVT|kWrvM5AUTn8N1$d*CNDywqxtnw~; z_efb96)mjtY+UyeRrzxL%g@bE08U}$scwdpxH+c7 z4^=~ep+VFs4dDQGfNLn>2qMH#E}kgmI)gf%8X0D&6pxk4SO5&A91)qoX631zqXLzb z=Ga+>p-C8u8A(&ztz##uHPmqI!fx@6_4}e6dteCDlM2SLSHnJzdhBOtB>uQ~;n^RI z!_<)AXh0)FD_yq=uJm{4B&~@fi9-xNdwJE$WEm>r19R3rE19ttrjx@HbM~auZH@=f zj1~>897oW$#vU{_ql2RpZ46r9P&zfzHz*tJ<~S;wP=<$668$*G3G|3ZN_!|mT}5>= zr#Ma{B{tQ4?5y~%M*T7LarEQ7@OmGLb#GF9R!-CSd|AhGR z+M3ANG?=VoFA-7P92Y;lFPSBt`I@^X8R`vd%CT1r`Mh;+OC1PJeoFX)&`n{eakskJvRV5Tt0(>U|oBFG^ulwD==A z4{GF!X!#zwIP!i3sEq+?aga_1-OHc&7xWP1*7`ns^T_ zk%#^c;XKL`ZxQ~0s!h}a8>o9t86FoSlB04UOtzHf9HE3V4ATuSz~BNd(urXNqhuvT z6M0FY=5auZDF7A3R29{#+qG$2+NvGcl2;)Gk-81!4nBvL$Kh9bv`aL_m8DZ2u$wg1 z79mz_A&$9utdv0M1#Cel$xB&Y3H`6GSP_bMTi0b=L9WnLnuuj}EKyL_wSi;*jIP%m zow`n0g_eU<10105F%AP}5k;&(5$+{@SO3$ufs=prUh7{ private static final Ariadne_Test test = Ariadne_Test.make("Ariadne_SRM::"); public static CountingNumber make(){ - return new CountingNumber(); + return new CountingNumber(null); + } + public static CountingNumber make(BigInteger maximum){ + return new CountingNumber(maximum); } private BigInteger i; + private BigInteger maximum; + Ariadne_SRM.Status status; - protected CountingNumber(){ - super(); - i = BigInteger.ZERO; + protected CountingNumber(BigInteger maximum){ + i = BigInteger.ONE; + this.maximum = maximum; + this.status = Status.LEFTMOST; test.print("CountingNumber read() value initialized to: " + i); } @Override public Topology topology(){ - return Topology.INFINITE_RIGHT; // leftmost, no rightmost + if(maximum == null) return Topology.INFINITE_RIGHT; + return Topology.SEGMENT; } @Override public Status status(){ - if( i.equals(BigInteger.ZERO) ) return Status.LEFTMOST; - else return Status.INTERIM; + return status; } @Override @@ -35,10 +41,19 @@ public class CountingNumber extends Ariadne_SRM{ } @Override - public boolean step(){ + public void step(){ + super.step(); i = i.add(BigInteger.ONE); - test.print(" after step right new read() value: " + i); - return true; + + if(topology() == Topology.SEGMENT){ + if(i.compareTo(maximum) == 0){ + status = Status.RIGHTMOST; + }else if(status() == Status.LEFTMOST){ + status = Status.INTERIM; + } + } + + test.print(" after step, new read() value: " + i); } } diff --git a/developer/example/Example_CountingNumber b/developer/example/Example_CountingNumber new file mode 100755 index 0000000..624ad06 --- /dev/null +++ b/developer/example/Example_CountingNumber @@ -0,0 +1,2 @@ +#!/bin/bash +java Example_CountingNumber diff --git a/developer/example/Example_CountingNumber.class b/developer/example/Example_CountingNumber.class new file mode 100644 index 0000000000000000000000000000000000000000..aee2ee4f583c981cabcc4d853f30604fe75eb9b3 GIT binary patch literal 2352 zcmbVNUsoGN6#orL*(59w!hfhVZJ{Q#C0Y?%LMtUEkeWaxDb-fRA(h*%dj-(7mMTn!Ll{3Wc}4@W89Ur=kaHi+JXsDn*&3j2bBo zr))!-5xH+_y39yZ@N(3HK8DLlDNHUky%3Z|)2J1S!I)9g?Tz(Xc}JMlMIZbaP!Lct zh#`i-4#pUiie^&9l;|9ZMneU01q35`K zsL3MzRVCMD^^~y&f9;f7vCOOZ5DQe5q$_KryKqK=GPWMka}&1|EUJiNiQ&ds=y6Oi zcsG-)YuWThhUl3;6FqehRzP=Dd~9`|o7$&h70q20D^|tyCD#+l^<*}_ZM*T{6NbqL zx+!u-LD!y%d{FX=2sTP}&Wi+A6|AX9;vU0LCyJ@mv+;F?k^d@y5u{Y4K_YI8Erw8? z=hL+kPPMiZ70-QqreIS=29%GH_)}i4l*D$c7$wc_+HEPQZwEuCtvFq~Wnp;85Fl<_ z^`itVX5=W=y#&um z!=$V2MRN<+1sz{&T+f$8bvk7jd$mfmJKPi8F7U=ROc#aIYYM(&m}yH)r+5`ma;E-Ylk()c;8A~Z9a&&~b<_L6?O@CA+5G2p`^8dXOCkMX6wqQ;>eQf3NCTSlKBLkaZ0 zLjUY54F3f8OPVK-ap4eQI-$kP3Bs?*7aW-nj`7hUx{r{cv)e~+es|=T4{_bS)UGk< z_x)^1_gd0FGIsRlk0bP0K4WCh0`0OvCon+&z4Z3?(Zk%22?TJBp5|K^!fgy=8KbyI zuWSmF_!{R?pl5UsQ_yh%-%^GoF5w4E+d+>|U@6StE0VNQ@f_RuhGtHmA6~zAs{1eW zu!%q6?NZ>y4suRX=vH(x>OV&O1fQN@;{*?A{5QFMgctPIc@ZL%vrS3%BM(7mE manager = new IdentityManager<>( "ResourceNamespace" ); - - // Create resources and register them - String name1 = manager.generate_name(); - ExampleResource resource1 = new ExampleResource( name1 ); - manager.register( name1 ,resource1 ); - - String name2 = manager.generate_name(); - ExampleResource resource2 = new ExampleResource( name2 ); - manager.register( name2 ,resource2 ); - - // Access resources - System.out.println( "Resource 1: " + manager.get_resource( name1 ) ); - System.out.println( "Resource 2: " + manager.get_resource( name2 ) ); - - // Print all registered resources - System.out.println( manager ); - - // Unregister a resource - manager.unregister( name1 ); - System.out.println( "After unregistration: " + manager ); - } - -} diff --git a/developer/example/Example_IndexTree_0 b/developer/example/Example_IndexTree_0 new file mode 100755 index 0000000..f6eac3c --- /dev/null +++ b/developer/example/Example_IndexTree_0 @@ -0,0 +1,2 @@ +#!/bin/bash +java Example_IndexTree_0 diff --git a/developer/example/Example_IndexTree_0.class b/developer/example/Example_IndexTree_0.class new file mode 100644 index 0000000000000000000000000000000000000000..1aa7f737816dd5b836f10941688f0acbd9f13308 GIT binary patch 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$*$ literal 0 HcmV?d00001 diff --git a/developer/example/Example_IndexTree_0.java b/developer/example/Example_IndexTree_0.java index 306e475..296b499 100644 --- a/developer/example/Example_IndexTree_0.java +++ b/developer/example/Example_IndexTree_0.java @@ -1,36 +1,53 @@ -import java.math.BigInteger; -import java.util.List; -import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Graph; +import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Child_SRM; import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Node; -import com.ReasoningTechnology.Ariadne.Ariadne_SRM; +import java.math.BigInteger; -public class Example_IndexTree_0 { +public class Example_IndexTree_0{ - public static void main(String[] args){ - // Create the IndexTree graph - Ariadne_IndexTree_Graph graph = new Ariadne_IndexTree_Graph(); - Ariadne_SRM srm = graph.start(); - - System.out.println("Starting Depth-First Traversal:"); - // Depth-First Traversal: Visit the leftmost child at each level - for (int i = 0; i < 4; i++){ - System.out.println("Step " + i + ": " + srm.read()); - srm = srm.neighbor(); // Move to the leftmost child - } + public static void traverse_index_tree(){ + System.out.println("Starting Index Tree Traversal:"); - System.out.println("\nStarting Breadth-First Traversal:"); - // Breadth-First Traversal: Visit all siblings before descending - for (int i = 0; i < 4; i++){ - System.out.println("Step " + i + ": " + srm.read()); - srm.step_right(); // Move to the next sibling - } + 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); - System.out.println("\nStarting Diagonal Walk:"); - // Diagonal Walk: Alternate between descending and stepping right - for (int i = 0; i < 4; i++){ - System.out.println("Step " + i + ": " + srm.read()); - srm = srm.neighbor(); // Move to the first child - srm.step_right(); // Step to the sibling + 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 new file mode 100755 index 0000000..5b45c16 --- /dev/null +++ b/developer/example/Example_IndexTree_Diagonal_SRM @@ -0,0 +1,2 @@ +#!/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 new file mode 100644 index 0000000000000000000000000000000000000000..7f9b08e0649ece48dbe8210813346b0f3c1b17b4 GIT binary patch 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 literal 0 HcmV?d00001 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 new file mode 100755 index 0000000..80c5dbd --- /dev/null +++ b/developer/example/Example_SRMI_Array @@ -0,0 +1,2 @@ +#!/bin/bash +java Example_SRMI_Array diff --git a/developer/example/Example_SRMI_Array.class b/developer/example/Example_SRMI_Array.class new file mode 100644 index 0000000000000000000000000000000000000000..4917a44ce73d911ebe6d0b8f757fd1d1f1baf5c2 GIT binary patch literal 397 zcmZut!AiqG5Pg%Tjg8f6TJ);7R>6EgMUbK(LQPfJP98B06$8c zt%5>a*f-3)d2e?1D>s z4=aS=pS&8 z7)DL2344`7X~Nd%Ci;C(TpOkH$v9zNn4Hyve`taqR|}KLQ)P#5H~kN+C3fNQ=Jq%s zyE|i-vydZkZ125-UY4}aXlbxym9h8Tz;TVUF4ocKiWTqkwS5iY&L1IvGB%fu0i%P# E7fwx0^#A|> literal 0 HcmV?d00001 diff --git a/developer/example/Example_SRMI_Array.java b/developer/example/Example_SRMI_Array.java index 93a96c4..b3e9b99 100644 --- a/developer/example/Example_SRMI_Array.java +++ b/developer/example/Example_SRMI_Array.java @@ -6,11 +6,13 @@ import java.util.List; public class Example_SRMI_Array { public static void main( String[] args ) { + /* + // Create a list - List labels = Arrays.asList( "A" ,"B" ,"C" ,"D" ); + List label_list = Arrays.asList( "A" ,"B" ,"C" ,"D" ); // Attach SRMI to the list - Ariadne_SRMI_Array srm = Ariadne_SRMI_Array.attach( labels ); + Ariadne_SRMI_Array srm = Ariadne_SRMI_Array.make( label_list ); // Use the SRMI System.out.println( "Topology: " + srm.topology() ); @@ -25,5 +27,7 @@ public class Example_SRMI_Array { // Final item System.out.println( "Reading: " + srm.read() ); System.out.println( "Status: " + srm.status() ); + + */ } } diff --git a/developer/example/Example_SRM_0.java b/developer/example/Example_SRM_0.java deleted file mode 100644 index bd8a9b3..0000000 --- a/developer/example/Example_SRM_0.java +++ /dev/null @@ -1,23 +0,0 @@ -import com.ReasoningTechnology.Ariadne.Ariadne_SRM; - -import java.math.BigInteger; - -public class Example_SRM_0{ - - public static void main(String[] args){ - CountingNumber counting_number = CountingNumber.make(); - - System.out.println("Initial Status: " + counting_number.status()); - System.out.println("Initial Read Value: " + counting_number.read()); - - for( int step_index = 0 ;step_index < 10 ;step_index++ ){ - counting_number.step(); - System.out.println( - "Step: " + step_index - +", Status: " + counting_number.status() - +", Read Value: " + counting_number.read() - ); - } - } -} - diff --git a/developer/example/Example_SRM_1.java b/developer/example/Example_SRM_1.java deleted file mode 100644 index 213b567..0000000 --- a/developer/example/Example_SRM_1.java +++ /dev/null @@ -1,55 +0,0 @@ -import com.ReasoningTechnology.Ariadne.Ariadne_SRM; - -import java.util.Arrays; -import java.util.List; - -public class Example_Ariadne_SRM_1{ - - public static class SimpleLockManagerDelegate implements Ariadne_LockManagerDelegate{ - - @Override - public void request(Object srm){ - System.out.println("LockManagerDelegate: Lock acquired for " + srm); - } - - @Override - public void relinquish(Object srm){ - System.out.println("LockManagerDelegate: Lock released for " + srm); - } - } - - public static void main(String[] args){ - // Create a LockManagerDelegate - Ariadne_LockManagerDelegate delegate = new SimpleLockManagerDelegate(); - - // Create an SRM instance with the delegate - Ariadne_SRM srm = Ariadne_SRM.make(delegate); - - // Define a list to iterate over - List list = Arrays.asList(10 ,20 ,30 ,40 ,50); - - // Mount the list on the SRM - try{ - srm.mount(); - System.out.println("Mounted SRM. Status: " + srm.status()); - - // Iterate through the list - for(Integer value : list){ - System.out.println("Read value: " + value); - } - - // Dismount the SRM - srm.dismount(); - System.out.println("Dismounted SRM. Status: " + srm.status()); - }catch(IllegalStateException e){ - System.err.println("Error: " + e.getMessage()); - } - - // Demonstrate lenient methods - System.out.println("\nUsing lenient methods:"); - srm.lenient_mount(); - System.out.println("Lenient mount complete. Status: " + srm.status()); - srm.lenient_dismount(); - System.out.println("Lenient dismount complete. Status: " + srm.status()); - } -} diff --git a/developer/example/Example_SRM_List b/developer/example/Example_SRM_List new file mode 100755 index 0000000..e0d48dd --- /dev/null +++ b/developer/example/Example_SRM_List @@ -0,0 +1,2 @@ +#!/bin/bash +java Example_SRM_List diff --git a/developer/example/Example_SRM_List.class b/developer/example/Example_SRM_List.class new file mode 100644 index 0000000000000000000000000000000000000000..acee04abde09f4a936352cc32873d4d25f41e75e GIT binary patch literal 391 zcmZut%TB^T6g^W4m5PF(?oC{PCiVj`ZV0ZbB-C`{f=uhA4r!-mD8}D%W#YmQ@S_a( zqKO8XWX{dK=P{4ZulElCBOLm0Q1jrnP)9?cGndaY$fe1GNitVyCD6FkMpst?wf-RX zutTEpi!7dUHH)S labels = new List<>(); - labels.add( "A" ); - labels.add( "B" ); - labels.add( "C" ); + LinkedList labels = new LinkedList<>(); + labels.add("A"); + labels.add("B"); + labels.add("C"); - // Attach SRMI to the linked list - Ariadne_SRMI_List srm = Ariadne_SRMI_List.attach( labels ); + // Attach SRM to the linked list + Ariadne_SRM_List srm = Ariadne_SRM_List.attach(labels); - // Use the SRMI - System.out.println( "Topology: " + srm.topology() ); - System.out.println( "Status: " + srm.status() ); + // Use the SRM + System.out.println("Topology: " + srm.topology()); + System.out.println("Initial Status: " + srm.status()); // Traverse the list - while( srm.status() != Ariadne_SRM.Status.RIGHTMOST ) { - System.out.println( "Reading: " + srm.read() ); + while (srm.status() != Ariadne_SRM.Status.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("Reading: " + srm.read()); + System.out.println("Final Status: " + srm.status()); // 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 new file mode 100644 index 0000000..42f44db --- /dev/null +++ b/developer/example/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_Graph.java" "b/developer/javac\360\237\226\211/Ariadne_Graph.java" index 5c95392..51cbfd2 100644 --- "a/developer/javac\360\237\226\211/Ariadne_Graph.java" +++ "b/developer/javac\360\237\226\211/Ariadne_Graph.java" @@ -2,18 +2,20 @@ User defines a graph by implementing this interface. For the build tool, the defined graph is dynamically loaded. + Generally labels are returned and passed around. Only `lookup` returns a Node. + In a wellformed graph, the labels returned by `start()` will be in the graph. This can be checked by calling `lookup`. */ package com.ReasoningTechnology.Ariadne; -public interface Ariadne_Graph { +public interface Ariadne_Graph { - // One or more nodes for starting graph traversals - Ariadne_SRM start(); + // returns list of TLabel + Ariadne_SRM start(); - // Method to look up a node by label - Ariadne_Node lookup(T label); + // lookup a Node by label + Ariadne_Node lookup(TLabel label); } 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" new file mode 100644 index 0000000..ee9cec5 --- /dev/null +++ "b/developer/javac\360\237\226\211/Ariadne_IndexTree_Child_SRM.java" @@ -0,0 +1,38 @@ +package com.ReasoningTechnology.Ariadne; + +import java.math.BigInteger; + +public class Ariadne_IndexTree_Child_SRM extends Ariadne_SRM { + + private BigInteger[] label; + + public static Ariadne_IndexTree_Child_SRM make(BigInteger[] initial_label){ + return new Ariadne_IndexTree_Child_SRM(initial_label); + } + + protected Ariadne_IndexTree_Child_SRM(BigInteger[] initial_label){ + super(); + if (initial_label == null || initial_label.length == 0) { + throw new IllegalArgumentException("Initial label must not be null or empty."); + } + this.label = initial_label; + } + + @Override + public Topology topology(){ + return Topology.INFINITE_RIGHT; + } + + @Override + public BigInteger[] read(){ + // Return a reference to the current label + return label; + } + + @Override + public void step(){ + int max_index = label.length - 1; + label[max_index] = label[max_index].add(BigInteger.ONE); + } + +} diff --git "a/developer/javac\360\237\226\211/Ariadne_IndexTree_Graph.java" "b/developer/javac\360\237\226\211/Ariadne_IndexTree_Graph.java" index 9dbcf60..5924bb4 100644 --- "a/developer/javac\360\237\226\211/Ariadne_IndexTree_Graph.java" +++ "b/developer/javac\360\237\226\211/Ariadne_IndexTree_Graph.java" @@ -5,8 +5,8 @@ import java.math.BigInteger; public class Ariadne_IndexTree_Graph implements Ariadne_Graph{ @Override - public Ariadne_IndexTree_SRM start(){ - return Ariadne_IndexTree_SRM.make(new BigInteger[0]); + public Ariadne_IndexTree_Child_SRM start(){ + return Ariadne_IndexTree_Child_SRM.make(new BigInteger[0]); } @Override @@ -15,3 +15,4 @@ public class Ariadne_IndexTree_Graph implements Ariadne_Graph{ } } + diff --git "a/developer/javac\360\237\226\211/Ariadne_IndexTree_Node.java" "b/developer/javac\360\237\226\211/Ariadne_IndexTree_Node.java" index 405ca2a..44a4eb5 100644 --- "a/developer/javac\360\237\226\211/Ariadne_IndexTree_Node.java" +++ "b/developer/javac\360\237\226\211/Ariadne_IndexTree_Node.java" @@ -14,8 +14,15 @@ public class Ariadne_IndexTree_Node extends Ariadne_Node { } @Override - public Ariadne_IndexTree_SRM neighbor(){ - return new Ariadne_IndexTree_SRM(label()); + public Ariadne_IndexTree_Child_SRM neighbor(){ + // Copy the current label + BigInteger[] parentLabel = this.label(); + BigInteger[] childLabel = new BigInteger[parentLabel.length + 1]; + System.arraycopy(parentLabel, 0, childLabel, 0, parentLabel.length); + + childLabel[parentLabel.length] = BigInteger.ZERO; + + return Ariadne_IndexTree_Child_SRM.make(childLabel); } @Override diff --git "a/developer/javac\360\237\226\211/Ariadne_IndexTree_SRM.java" "b/developer/javac\360\237\226\211/Ariadne_IndexTree_SRM.java" deleted file mode 100644 index b70c8a5..0000000 --- "a/developer/javac\360\237\226\211/Ariadne_IndexTree_SRM.java" +++ /dev/null @@ -1,40 +0,0 @@ -package com.ReasoningTechnology.Ariadne; - -import java.math.BigInteger; - -public class Ariadne_IndexTree_SRM extends Ariadne_SRM { - - private final BigInteger[] current_label; - - public static Ariadne_IndexTree_SRM make(BigInteger[] initial_label){ - return new Ariadne_IndexTree_SRM(initial_label); - } - - protected Ariadne_IndexTree_SRM(BigInteger[] initial_label){ - super(); - if (initial_label == null || initial_label.length == 0) { - throw new IllegalArgumentException("Initial label must not be null or empty."); - } - this.current_label = initial_label; - } - - @Override - public Topology topology(){ - return Topology.INFINITE_RIGHT; - } - - @Override - public BigInteger[] read(){ - // Return a reference to the current label - return current_label; - } - - @Override - public boolean step(){ - // Increment the last element of the label (child counter) - int lastIndex = current_label.length - 1; - current_label[lastIndex] = current_label[lastIndex].add(BigInteger.ONE); - return true; - } - -} diff --git "a/developer/javac\360\237\226\211/Ariadne_Node.java" "b/developer/javac\360\237\226\211/Ariadne_Node.java" index e23e1a4..2aa34d1 100644 --- "a/developer/javac\360\237\226\211/Ariadne_Node.java" +++ "b/developer/javac\360\237\226\211/Ariadne_Node.java" @@ -31,44 +31,44 @@ package com.ReasoningTechnology.Ariadne; import java.util.HashMap; import java.util.HashSet; -public class Ariadne_Node extends HashMap { +public class Ariadne_Node extends HashMap { // Owned by the class - public static Ariadne_Node make(T label) { - return new Ariadne_Node<>(label) ; + public static Ariadne_Node make(TLabel label) { + return new Ariadne_Node<>(label); } // Data owned by the instance - private final T label ; - private final HashSet markSet ; - private static final String NEIGHBOR_PROPERTY_NAME = "neighbor_property" ; + private final TLabel label; + private final HashSet markSet; + private static final String NEIGHBOR_PROPERTY_NAME = "neighbor_property"; // Constructors - public Ariadne_Node(T label) { - super() ; - this.label = label ; - this.markSet = new HashSet<>() ; + public Ariadne_Node(TLabel label) { + super(); + this.label = label; + this.markSet = new HashSet<>(); } // Instance interface - public T label() { - return this.label ; + public TLabel label() { + return this.label; } - public Ariadne_SRM neighbor() { - return Ariadne_SRM.make() ; + public Ariadne_SRM neighbor() { + return Ariadne_SRM.make(); } public void mark(Ariadne_Token token) { - markSet.add(token) ; + markSet.add(token); } public boolean hasMark(Ariadne_Token token) { - return markSet.contains(token) ; + return markSet.contains(token); } public void removeMark(Ariadne_Token token) { - markSet.remove(token) ; + markSet.remove(token); } // Object interface @@ -77,6 +77,6 @@ public class Ariadne_Node extends HashMap { return "Ariadne_Node{" + "label=" + label + " ,markSet=" + markSet - + "}" ; + + "}"; } } diff --git "a/developer/javac\360\237\226\211/Ariadne_SRM.java" "b/developer/javac\360\237\226\211/Ariadne_SRM.java" index 422718f..2c34a8e 100644 --- "a/developer/javac\360\237\226\211/Ariadne_SRM.java" +++ "b/developer/javac\360\237\226\211/Ariadne_SRM.java" @@ -1,41 +1,34 @@ /* -Step Right Machine + Step Right Machine -This is a mostly abstract base class. - -The SRM is for a single traversal through a bound resources. - -In Java it is possible to declare a variable of the SRM type long before it is used -for traversal. This complicates managing ownwership of the resource being traversed. - -The SRM model is that of 'mount' and 'dismount'. When the resource is mounted, -the SRM requests ownership of it. When it is dismounted, the SRM relinquishes -ownership. - - - -mount and unmount are used for handling shared memory scenarios. See -the Ariadne_Access class. For single threaded execution pass in an -Ariadne_Access_Single instance. + This is a mostly abstract base class. */ package com.ReasoningTechnology.Ariadne; -public class Ariadne_SRM{ +public class Ariadne_SRM { + + public static Ariadne_SRM make(){ + return new Ariadne_SRM<>(); + } + protected Ariadne_SRM(){ + } public enum Topology{ NO_CELLS ,SEGMENT ,CIRCLE ,INFINITE_RIGHT - ,INFINITE_LEFT - ,INFINITE ,UNKNOWN ,UNDEFINED ; } + public Topology topology(){ + return Topology.UNDEFINED; + } + // categorizes the head location public enum Status{ TAPE_NOT_MOUNTED ,LEFTMOST @@ -43,69 +36,25 @@ public class Ariadne_SRM{ ,RIGHTMOST ; } - - private final LockManagerDelegate delegate; - - public static Ariadne_SRM make(LockManagerDelegate delegate){ - if(delegate == null){ - throw new IllegalArgumentException("Ariadne_SRM::make delegate cannot be null."); - } - return new Ariadne_SRM<>(delegate); - } - - private Ariadne_SRM(LockManagerDelegate delegate){ - this.delegate = delegate; - } - - public synchronized void mount(){ - if(status() != Status.TAPE_NOT_MOUNTED){ - throw new IllegalStateException("Ariadne_SRM::mount already mounted."); - } - delegate.request(this); - } - public void mount_lenient() { - if(status() != Status.TAPE_NOT_MOUNTED) { - dismount(); // Ensure the current tape is dismounted first - } - mount(); // Proceed to mount the new tape - } - - - public synchronized void dismount(){ - if(status() == Status.TAPE_NOT_MOUNTED){ - throw new IllegalStateException("Ariadne_SRM::dismount not mounted."); - } - delegate.relinquish(this); - } - public void dismount_lenient() { - if(status() != Status.TAPE_NOT_MOUNTED) { - dismount(); // Only dismount if a tape is currently mounted - } - } - - public synchronized Topology topology(){ - return Topology.UNDEFINED; - } - - public synchronized Status status(){ + public Status status(){ throw new UnsupportedOperationException("Ariadne_SRM::status not implemented."); } - - public synchronized boolean can_step(){ + public boolean can_step(){ return status() == Status.LEFTMOST || status() == Status.INTERIM; } - - public synchronized boolean can_read(){ + public boolean mounted(){ return status() != Status.TAPE_NOT_MOUNTED; } - public synchronized T read(){ + public TElement read(){ throw new UnsupportedOperationException("Ariadne_SRM::read not implemented."); } - public synchronized void step(){ - throw new UnsupportedOperationException("Ariadne_SRM::step not implemented."); + public void step(){ + if( !can_step() ) + throw new UnsupportedOperationException("Ariadne_SRM::step can not step."); } + } diff --git "a/developer/javac\360\237\226\211/Ariadne_SRMI.java" "b/developer/javac\360\237\226\211/Ariadne_SRMI.java" index 3ec1b76..cdb49a1 100644 --- "a/developer/javac\360\237\226\211/Ariadne_SRMI.java" +++ "b/developer/javac\360\237\226\211/Ariadne_SRMI.java" @@ -19,9 +19,9 @@ public class Ariadne_SRMI extends Ariadne_SRM{ } @Override - public boolean step(){ + public void step(){ throw new UnsupportedOperationException("Ariadne_SRMI::can't step unmounted tape."); - // index.add(BigInteger.ONE); +// index.add(BigInteger.ONE); } BigInteger index(){return index;} 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 2dcefba..94fcbb7 100644 --- "a/developer/javac\360\237\226\211/Ariadne_SRMI_Array.java" +++ "b/developer/javac\360\237\226\211/Ariadne_SRMI_Array.java" @@ -17,38 +17,6 @@ public class Ariadne_SRMI_Array extends Ariadne_SRMI{ super(); } - public void mount(List list ,Semaphore semaphore){ - if(this.list != null){ - throw new IllegalStateException("Ariadne_SRMI_Array::mount tape already mounted."); - } - if(list == null){ - throw new IllegalArgumentException("Ariadne_SRMI_Array::mount list cannot be null."); - } - this.list = list; - this.lock = semaphore; - if(lock != null){ - try{ - lock.acquire(); - } catch(InterruptedException e){ - Thread.currentThread().interrupt(); - throw new IllegalStateException("Ariadne_SRMI_Array::mount interrupted while acquiring lock."); - } - } - set_status(list.isEmpty() ? Status.TAPE_NOT_MOUNTED : Status.LEFTMOST); - } - - public void unmount(){ - if(this.list == null){ - throw new IllegalStateException("Ariadne_SRMI_Array::unmount no tape mounted."); - } - this.list = null; - set_status(Status.TAPE_NOT_MOUNTED); - if(lock != null){ - lock.release(); - lock = null; - } - } - @Override public Topology topology(){ if(list == null || list.isEmpty()){ @@ -64,7 +32,7 @@ public class Ariadne_SRMI_Array extends Ariadne_SRMI{ @Override public T read(){ - if(!can_read()){ + if(!mounted()){ throw new UnsupportedOperationException("Ariadne_SRMI_Array::read tape not mounted or out of bounds."); } return list.get(index().intValue()); @@ -77,7 +45,7 @@ public class Ariadne_SRMI_Array extends Ariadne_SRMI{ } if(index().compareTo(rightmost_index()) < 0){ index = index.add(BigInteger.ONE); - set_status(index().equals(rightmost_index()) ? Status.RIGHTMOST : Status.INTERIM); +// set_status(index().equals(rightmost_index()) ? Status.RIGHTMOST : Status.INTERIM); } else{ throw new UnsupportedOperationException("Ariadne_SRMI_Array::step, no more cells."); } diff --git "a/developer/tool\360\237\226\211/make_example" "b/developer/tool\360\237\226\211/make_example" index b766bd5..3cd18be 100755 --- "a/developer/tool\360\237\226\211/make_example" +++ "b/developer/tool\360\237\226\211/make_example" @@ -9,30 +9,37 @@ script_afp=$(realpath "${BASH_SOURCE[0]}") exit 1 fi - cd "$REPO_HOME"/developer - + cd "$REPO_HOME"/developer/example echo "Compiling example .java files..." set -x - cd example - javac -verbose -g -sourcepath . *.java + javac -g -sourcepath . *.java set +x + if [ $? -ne 0 ]; then echo "Compilation failed." exit 1 fi echo "Creating bash wrappers..." - # wrapper is a space separated list - wrapper=Example_*.class - for file in $wrapper;do - cat > $file << EOL + +set -x + +wrapper=(Example_*.class) + +for file in "${wrapper[@]}"; do + wrapper_name=$(basename "$file" .class) + cat > "$wrapper_name" << EOL #!/bin/bash -java $file +java $wrapper_name EOL - chmod +x $file - done + + # Make the wrapper executable + chmod +x "$wrapper_name" +done + +set +x echo "$(script_fp) done." -- 2.20.1