another checkpoint
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Sat, 5 Apr 2025 09:59:26 +0000 (09:59 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Sat, 5 Apr 2025 09:59:26 +0000 (09:59 +0000)
developer/cc馃枆/TM.lib.c
developer/example/try_TM_1.cli.c

index a383b1d..57e7cbb 100644 (file)
   #endif
 
   typedef enum{
-     TM路Tape路Topo路mu = 0 
-    ,TM路Tape路Topo路empty       = 1
-    ,TM路Tape路Topo路singleton   = 1 << 1
-    ,TM路Tape路Topo路segment     = 1 << 2
-    ,TM路Tape路Topo路circle      = 1 << 3
-    ,TM路Tape路Topo路tail_cyclic = 1 << 4
-    ,TM路Tape路Topo路infinite    = 1 << 5
-  }TM路Tape路Topo;
-  const TM路Tape路Topo TM路Tape路Topo路bounded = 
-    TM路Tape路Topo路singleton 
-    | TM路Tape路Topo路segment
+     TM路Topo路mu = 0 
+    ,TM路Topo路empty       = 1
+    ,TM路Topo路singleton   = 1 << 1
+    ,TM路Topo路segment     = 1 << 2
+    ,TM路Topo路circle      = 1 << 3
+    ,TM路Topo路tail_cyclic = 1 << 4
+    ,TM路Topo路infinite    = 1 << 5
+  }TM路Topo;
+  const TM路Topo TM路Topo路bounded = 
+    TM路Topo路singleton 
+    | TM路Topo路segment
     ;
 
   typedef enum{
-    TM路Head路Status路mu = 0
-    ,TM路Head路Status路dismounted  = 1
-    ,TM路Head路Status路out_of_area = 1 << 1
-    ,TM路Head路Status路leftmost    = 1 << 2
-    ,TM路Head路Status路interim     = 1 << 3
-    ,TM路Head路Status路rightmost   = 1 << 4
-  } TM路Head路Status;
-
-  const TM路Head路Status TM路Head路Status路on_tape = 
-    TM路Head路Status路leftmost
-    | TM路Head路Status路interim
-    | TM路Head路Status路rightmost
+    TM路Status路mu = 0
+    ,TM路Status路dismounted  = 1
+    ,TM路Status路out_of_area = 1 << 1
+    ,TM路Status路leftmost    = 1 << 2
+    ,TM路Status路interim     = 1 << 3
+    ,TM路Status路rightmost   = 1 << 4
+  } TM路Status;
+
+  const TM路Status TM路Status路on_tape = 
+    TM路Status路leftmost
+    | TM路Status路interim
+    | TM路Status路rightmost
     ;
 
 #endif //#ifndef TM路FACE
 
   typedef struct 路(TM,_TM路CVT_,FG){
 
-    TM路Tape路Topo         (*Tape路topo)     ( 路(TM,_TM路CVT_) tm );
-    bool                 (*Tape路bounded)  ( 路(TM,_TM路CVT_) tm );
-    路(extent_t,_TM路CVT_) (*Tape路extent)   ( 路(TM,_TM路CVT_) tm );
+    TM路Topo         (*topo)     ( 路(TM,_TM路CVT_) tm );
+    bool                 (*bounded)  ( 路(TM,_TM路CVT_) tm );
+    路(extent_t,_TM路CVT_) (*extent)   ( 路(TM,_TM路CVT_) tm );
 
-    TM路Head路Status     (*Head路status)     ( 路(TM,_TM路CVT_) tm );
-    bool               (*Head路dismounted) ( 路(TM,_TM路CVT_) tm );
-    bool               (*Head路on_tape)    ( 路(TM,_TM路CVT_) tm );
-    bool               (*Head路on_leftmost)( 路(TM,_TM路CVT_) tm );
-    bool               (*Head路on_rightmost)( 路(TM,_TM路CVT_) tm );
+    TM路Status     (*status)     ( 路(TM,_TM路CVT_) tm );
+    bool               (*dismounted) ( 路(TM,_TM路CVT_) tm );
+    bool               (*on_tape)    ( 路(TM,_TM路CVT_) tm );
+    bool               (*on_leftmost)( 路(TM,_TM路CVT_) tm );
+    bool               (*on_rightmost)( 路(TM,_TM路CVT_) tm );
 
     // tape machine functions
     void               (*mount)           ( 路(TM,_TM路CVT_) tm );
       Array implementation with a segment tape
     */
 
-    Local TM路Tape路Topo 路(TM,_TM路CVT_,Array,Tape路topo)( 路(TM,_TM路CVT_) tm ){
+    Local TM路Topo 路(TM,_TM路CVT_,Array,topo)( 路(TM,_TM路CVT_) tm ){
       路(TM,_TM路CVT_,Array,Tableau) *t = (路(TM,_TM路CVT_,Array,Tableau) *) tm.tableau;
-      if( t->extent == 0 ) return TM路Tape路Topo路singleton;
-      return TM路Tape路Topo路segment;
+      if( t->extent == 0 ) return TM路Topo路singleton;
+      return TM路Topo路segment;
     }
 
-    Local bool 路(TM,_TM路CVT_,Array,Tape路bounded)( 路(TM,_TM路CVT_) tm ){
+    Local bool 路(TM,_TM路CVT_,Array,bounded)( 路(TM,_TM路CVT_) tm ){
       路(TM,_TM路CVT_,Array,Tableau) *t = (路(TM,_TM路CVT_,Array,Tableau) *) tm.tableau;
-      return 路(TM,_TM路CVT_,Array,Tape路topo)( tm ) & TM路Tape路Topo路bounded;
+      return 路(TM,_TM路CVT_,Array,topo)( tm ) & TM路Topo路bounded;
     }
 
-    Local 路(extent_t,_TM路CVT_) 路(TM,_TM路CVT_,Array,Tape路extent)( 路(TM,_TM路CVT_) tm ){
+    Local 路(extent_t,_TM路CVT_) 路(TM,_TM路CVT_,Array,extent)( 路(TM,_TM路CVT_) tm ){
       路(TM,_TM路CVT_,Array,Tableau) *t = (路(TM,_TM路CVT_,Array,Tableau) *) tm.tableau;
       return t->extent;
     }
 
 
-    Local TM路Head路Status 路(TM,_TM路CVT_,Array,Head路status)( 路(TM,_TM路CVT_) tm ){
+    Local TM路Status 路(TM,_TM路CVT_,Array,status)( 路(TM,_TM路CVT_) tm ){
       路(TM,_TM路CVT_,Array,Tableau) *t = (路(TM,_TM路CVT_,Array,Tableau) *) tm.tableau;
-      if( !t->hd ) return TM路Head路Status路dismounted;
-      if( t->hd == t->position ) return TM路Head路Status路leftmost;
+      if( !t->hd ) return TM路Status路dismounted;
+      if( t->hd == t->position ) return TM路Status路leftmost;
 
       _TM路CVT_ *rightmost_pt = t->position + t->extent;
-      if( t->hd == rightmost_pt ) return TM路Head路Status路rightmost;
+      if( t->hd == rightmost_pt ) return TM路Status路rightmost;
       if( t->hd < t->position || t->hd > rightmost_pt )
-        return TM路Head路Status路out_of_area;
+        return TM路Status路out_of_area;
 
-      return TM路Head路Status路interim;
+      return TM路Status路interim;
     }
 
-    Local bool 路(TM,_TM路CVT_,Array,Head路dismounted)( 路(TM,_TM路CVT_) tm ){
+    Local bool 路(TM,_TM路CVT_,Array,dismounted)( 路(TM,_TM路CVT_) tm ){
       路(TM,_TM路CVT_,Array,Tableau) *t = (路(TM,_TM路CVT_,Array,Tableau) *) tm.tableau;
-      return 路(TM,_TM路CVT_,Array,Head路status)( tm ) & TM路Head路Status路dismounted;
+      return 路(TM,_TM路CVT_,Array,status)( tm ) & TM路Status路dismounted;
     }
 
-    Local bool 路(TM,_TM路CVT_,Array,Head路on_tape)( 路(TM,_TM路CVT_) tm ){
+    Local bool 路(TM,_TM路CVT_,Array,on_tape)( 路(TM,_TM路CVT_) tm ){
       路(TM,_TM路CVT_,Array,Tableau) *t = (路(TM,_TM路CVT_,Array,Tableau) *) tm.tableau;
-      return 路(TM,_TM路CVT_,Array,Head路status)( tm ) & TM路Head路Status路on_tape;
+      return 路(TM,_TM路CVT_,Array,status)( tm ) & TM路Status路on_tape;
     }
 
-    Local bool 路(TM,_TM路CVT_,Array,Head路on_leftmost)( 路(TM,_TM路CVT_) tm ){
+    Local bool 路(TM,_TM路CVT_,Array,on_leftmost)( 路(TM,_TM路CVT_) tm ){
       路(TM,_TM路CVT_,Array,Tableau) *t = (路(TM,_TM路CVT_,Array,Tableau) *) tm.tableau;
-      return 路(TM,_TM路CVT_,Array,Head路status)( tm ) & TM路Head路Status路leftmost;
+      return 路(TM,_TM路CVT_,Array,status)( tm ) & TM路Status路leftmost;
     }
 
-    Local bool 路(TM,_TM路CVT_,Array,Head路on_rightmost)( 路(TM,_TM路CVT_) tm ){
+    Local bool 路(TM,_TM路CVT_,Array,on_rightmost)( 路(TM,_TM路CVT_) tm ){
       路(TM,_TM路CVT_,Array,Tableau) *t = (路(TM,_TM路CVT_,Array,Tableau) *) tm.tableau;
-      return 路(TM,_TM路CVT_,Array,Head路status)( tm ) & TM路Head路Status路rightmost;
+      return 路(TM,_TM路CVT_,Array,status)( tm ) & TM路Status路rightmost;
     }
 
     // does nothing if the hd is already mounted
 
     Local void 路(TM,_TM路CVT_,Array,rewind)( 路(TM,_TM路CVT_) tm ){
       路(TM,_TM路CVT_,Array,Tableau) *t = (路(TM,_TM路CVT_,Array,Tableau) *) tm.tableau;
-      if( 路(TM,_TM路CVT_,Array,Head路dismounted)( tm ) ) return;
+      if( 路(TM,_TM路CVT_,Array,dismounted)( tm ) ) return;
       t->hd = t->position;
     }
 
 
     Local 路(TM,_TM路CVT_,FG) 路(TM,_TM路CVT_,Array,fg) = {
 
-      .Tape路topo         = 路(TM,_TM路CVT_,Array,Tape路topo)
-      ,.Tape路bounded     = 路(TM,_TM路CVT_,Array,Tape路bounded)
-      ,.Tape路extent      = 路(TM,_TM路CVT_,Array,Tape路extent)
+      .topo           = 路(TM,_TM路CVT_,Array,topo)
+      ,.bounded       = 路(TM,_TM路CVT_,Array,bounded)
+      ,.extent        = 路(TM,_TM路CVT_,Array,extent)
 
-      ,.Head路status      = 路(TM,_TM路CVT_,Array,Head路status)
-      ,.Head路dismounted  = 路(TM,_TM路CVT_,Array,Head路dismounted)
-      ,.Head路on_tape     = 路(TM,_TM路CVT_,Array,Head路on_tape)
-      ,.Head路on_leftmost = 路(TM,_TM路CVT_,Array,Head路on_leftmost)
-      ,.Head路on_rightmost= 路(TM,_TM路CVT_,Array,Head路on_rightmost)
+      ,.status        = 路(TM,_TM路CVT_,Array,status)
+      ,.dismounted    = 路(TM,_TM路CVT_,Array,dismounted)
+      ,.on_tape       = 路(TM,_TM路CVT_,Array,on_tape)
+      ,.on_leftmost   = 路(TM,_TM路CVT_,Array,on_leftmost)
+      ,.on_rightmost  = 路(TM,_TM路CVT_,Array,on_rightmost)
 
-      ,.mount            = 路(TM,_TM路CVT_,Array,mount)
-      ,.dismount         = 路(TM,_TM路CVT_,Array,dismount)
+      ,.mount         = 路(TM,_TM路CVT_,Array,mount)
+      ,.dismount      = 路(TM,_TM路CVT_,Array,dismount)
 
-      ,.step             = 路(TM,_TM路CVT_,Array,step)
-      ,.step_right       = 路(TM,_TM路CVT_,Array,step)
-      ,.step_left        = 路(TM,_TM路CVT_,Array,step_left)
-      ,.rewind           = 路(TM,_TM路CVT_,Array,rewind)
+      ,.step          = 路(TM,_TM路CVT_,Array,step)
+      ,.step_right    = 路(TM,_TM路CVT_,Array,step)
+      ,.step_left     = 路(TM,_TM路CVT_,Array,step_left)
+      ,.rewind        = 路(TM,_TM路CVT_,Array,rewind)
 
-      ,.read             = 路(TM,_TM路CVT_,Array,read)
-      ,.write            = 路(TM,_TM路CVT_,Array,write)
+      ,.read          = 路(TM,_TM路CVT_,Array,read)
+      ,.write         = 路(TM,_TM路CVT_,Array,write)
 
     };
 
index 50d1cc5..6f15490 100644 (file)
 #define SET__Binding__TM路AU
 
 int main(){
-  printf("running try_TM.cli.c on %s at %s\n", __DATE__, __TIME__);
+  printf("running try_TM_1.cli.c on %s at %s\n", __DATE__, __TIME__);
 
   // Create a tape with 5 AU values
   AU tape[] = {1 ,2 ,3 ,4 ,5};
-  extent_t路AU extent = sizeof(tape) - 1;
+  extent_t路AU extent = sizeof(tape) / sizeof(AU) - 1;
 
   // Init the tableau
   TM路AU路Array路Tableau t;
   TM路AU tm = TM路AU路Array路init_pe(&t ,tape ,extent);
 
-#if 0
-
-  if( Binding路call(tm ,Head路on_tape) ){
+  if( Binding路call(tm ,on_tape) ){
     do{
-      printf( "%x" ,Binding路call(tm ,read) );
-      if( Binding路call(tm ,)
-
-
+      printf( "%02x" , (unsigned int) Binding路call(tm ,read) );
+      if( Binding路call(tm ,on_rightmost) ) break;
+      Binding路call(tm ,step);
+    }
+    printf("\n");
   }
-   
-
-  AU datum = Binding路call(tm ,read);
-  printf("Initial datum: %u\n", datum);
-
-  // Step and read again
-  Binding路call(tm ,step);
-  datum = Binding路call(tm ,read);
-  printf("After step, datum: %u\n", datum);
-
-  // Write a new value
-  AU value = 99;
-  Binding路call(tm ,write ,&value);
-
-  // Rewind and read again
-  Binding路call(tm ,rewind);
-  datum = Binding路call(tm ,read);
-  
-
-
-  printf("After rewind, datum: %u\n", datum);
 
-#endif
   return 0;
 }