EXISTS -> NOT_EMPTY
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Thu, 27 Mar 2025 16:21:53 +0000 (16:21 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Thu, 27 Mar 2025 16:21:53 +0000 (16:21 +0000)
developer/example/cpp_ext_0.c
developer/example/try_1_exists.c
developer/example/try_2_connectors.c
developer/example/try_3_eq.c

index f9fe34c..3ebdf57 100644 (file)
@@ -7,7 +7,7 @@
 
 1. Provides:
 
-  COMMA, SEMICOLON, EXISTS, NOT_EXISTS, ,MATCH_RWR ,NOT_MATCH_RWR, BOOL, NOT, AND, OR, EQ, NOT_EQ, IF_ELSE
+  COMMA, SEMICOLON, NOT_EMPTY, EMPTY, ,MATCH_RWR ,NOT_MATCH_RWR, BOOL, NOT, AND, OR, EQ, NOT_EQ, IF_ELSE
 
 2.
   These are the non-recursive extensions.  See cpp_ext_1 for the recursive extensions.
@@ -101,24 +101,24 @@ Existence
   //----------------------------------------
   // existence
   //
-  // `##` prevents rewrite of _TWION_ in the _EXISTS_ITEM_1 macro, don't
+  // `##` prevents rewrite of _TWION_ in the _NOT_EMPTY_ITEM_1 macro, don't
   // replace that with CAT!
 
-  #define _EXISTS_ITEM_2(x_item) _SECOND(x_item ,1) 
-  #define _EXISTS_ITEM_1(x_item) _EXISTS_ITEM_2(_TWION_0##x_item)
+  #define _NOT_EMPTY_ITEM_2(x_item) _SECOND(x_item ,1) 
+  #define _NOT_EMPTY_ITEM_1(x_item) _NOT_EMPTY_ITEM_2(_TWION_0##x_item)
 
-  #define EXISTS_ITEM(x_item)   _EXISTS_ITEM_1(x_item)
-  #define EXISTS(...) EXISTS_ITEM( _FIRST(__VA_ARGS__) )
+  #define NOT_EMPTY_ITEM(x_item)   _NOT_EMPTY_ITEM_1(x_item)
+  #define NOT_EMPTY(...) NOT_EMPTY_ITEM( _FIRST(__VA_ARGS__) )
 
-  #define _NOT_EXISTS_ITEM_2(x_item) _SECOND(x_item ,0) 
-  #define _NOT_EXISTS_ITEM_1(x_item) _NOT_EXISTS_ITEM_2(_TWION_1##x_item)
+  #define _EMPTY_ITEM_2(x_item) _SECOND(x_item ,0) 
+  #define _EMPTY_ITEM_1(x_item) _EMPTY_ITEM_2(_TWION_1##x_item)
 
-  #define NOT_EXISTS_ITEM(x_item)   _NOT_EXISTS_ITEM_1(x_item)
-  #define NOT_EXISTS(...) NOT_EXISTS_ITEM( _FIRST(__VA_ARGS__) )
+  #define EMPTY_ITEM(x_item)   _EMPTY_ITEM_1(x_item)
+  #define EMPTY(...) EMPTY_ITEM( _FIRST(__VA_ARGS__) )
 
   // useful to use with rewrite rules that substitute to nothing
-  #define MATCH_RWR(x_item) NOT_EXISTS(x_item)
-  #define NOT_MATCH_RWR(x_item) EXISTS(x_item)
+  #define MATCH_RWR(x_item) EMPTY(x_item)
+  #define NOT_MATCH_RWR(x_item) NOT_EMPTY(x_item)
 
 /*===========================================================================
 Logic Connectors
@@ -135,7 +135,7 @@ Logic Connectors
 
   #define _BOOL(x_item) \
     _AND( \
-       EXISTS_ITEM( x_item ) \
+       NOT_EMPTY_ITEM( x_item ) \
       ,NOT_MATCH_RWR( CAT2(_RWR_EQ__0__oo__ ,x_item) )  \
     )
   #define BOOL(x_item) _BOOL(_FIRST(x_item))
@@ -187,28 +187,28 @@ Access
   // _FIRST defined in the logic section
   #define FIRST(pad ,...)\
     IF_ELSE \
-      ( NOT_EXISTS(__VA_ARGS__) ) \
+      ( EMPTY(__VA_ARGS__) ) \
       (pad)                       \
       ( _FIRST(__VA_ARGS__) )  
 
   #define _REST(a ,...) __VA_ARGS__
   #define REST(...)\
     IF_ELSE \
-      ( NOT_EXISTS(__VA_ARGS__) ) \
+      ( EMPTY(__VA_ARGS__) ) \
       ()                          \
       ( _REST(__VA_ARGS__) )  
 
   // _SECOND defined in the logic section
   #define SECOND(pad ,...) \
     IF_ELSE \
-      ( NOT_EXISTS(__VA_ARGS__) ) \
+      ( EMPTY(__VA_ARGS__) ) \
       (pad)                       \
       ( _SECOND(__VA_ARGS__ ,pad) )  
 
   #define _THIRD(a ,b ,c ,...) c
   #define THIRD(pad ,...) \
     IF_ELSE \
-      ( NOT_EXISTS(__VA_ARGS__) ) \
+      ( EMPTY(__VA_ARGS__) ) \
       (pad)                       \
       ( _THIRD(__VA_ARGS__ ,pad, pad) )  
 
index 5b52fb3..9fd18d2 100644 (file)
@@ -9,7 +9,7 @@
 #define D 7
 
 
-// Patch for _EXISTS to succeed on 0
+// Patch for _NOT_EMPTY to succeed on 0
 #define _REWRITE_TWION_0 _REWRITE_TWION
 
 int main(void){
@@ -33,46 +33,46 @@ int main(void){
   printf("\n");
 
   // Existence detection
-  int empty = EXISTS_ITEM();         // → 1 (rewrite hits)
-  int empty_0 = EXISTS_ITEM(0);      // → 1 (rewrite hits)
-  int empty_1 = EXISTS_ITEM(1);      // → 0 (no rewrite)
-  int empty_f = EXISTS_ITEM(hello);  // → 0
-
-  printf("EXISTS_ITEM() = %d\n", empty);
-  printf("EXISTS_ITEM(0) = %d\n", empty_0);
-  printf("EXISTS_ITEM(1) = %d\n", empty_1);
-  printf("EXISTS_ITEM(hello) = %d\n", empty_f);
+  int empty = NOT_EMPTY_ITEM();         // → 1 (rewrite hits)
+  int empty_0 = NOT_EMPTY_ITEM(0);      // → 1 (rewrite hits)
+  int empty_1 = NOT_EMPTY_ITEM(1);      // → 0 (no rewrite)
+  int empty_f = NOT_EMPTY_ITEM(hello);  // → 0
+
+  printf("NOT_EMPTY_ITEM() = %d\n", empty);
+  printf("NOT_EMPTY_ITEM(0) = %d\n", empty_0);
+  printf("NOT_EMPTY_ITEM(1) = %d\n", empty_1);
+  printf("NOT_EMPTY_ITEM(hello) = %d\n", empty_f);
   printf("\n");
 
   // Not Existence detection
-  empty = NOT_EXISTS_ITEM();         // → 1 (rewrite hits)
-  empty_0 = NOT_EXISTS_ITEM(0);      // → 1 (rewrite hits)
-  empty_1 = NOT_EXISTS_ITEM(1);      // → 0 (no rewrite)
-  empty_f = NOT_EXISTS_ITEM(hello);  // → 0
-
-  printf("NOT_EXISTS_ITEM() = %d\n", empty);
-  printf("NOT_EXISTS_ITEM(0) = %d\n", empty_0);
-  printf("NOT_EXISTS_ITEM(1) = %d\n", empty_1);
-  printf("NOT_EXISTS_ITEM(hello) = %d\n", empty_f);
+  empty = EMPTY_ITEM();         // → 1 (rewrite hits)
+  empty_0 = EMPTY_ITEM(0);      // → 1 (rewrite hits)
+  empty_1 = EMPTY_ITEM(1);      // → 0 (no rewrite)
+  empty_f = EMPTY_ITEM(hello);  // → 0
+
+  printf("EMPTY_ITEM() = %d\n", empty);
+  printf("EMPTY_ITEM(0) = %d\n", empty_0);
+  printf("EMPTY_ITEM(1) = %d\n", empty_1);
+  printf("EMPTY_ITEM(hello) = %d\n", empty_f);
   printf("\n");
 
 
-  //  int empty_10 = EXISTS_ITEM(10,11,12); // illegal call, try it anyway ..compilation error
-  int empty_11 = EXISTS(10,11,12); // this is a legal call
-  int empty_12 = EXISTS(); 
+  //  int empty_10 = NOT_EMPTY_ITEM(10,11,12); // illegal call, try it anyway ..compilation error
+  int empty_11 = NOT_EMPTY(10,11,12); // this is a legal call
+  int empty_12 = NOT_EMPTY(); 
 
-  // printf("EXISTS_ITEM(10,11,12) = %d\n", empty_10);
-  printf("EXISTS(10,11,12) = %d\n", empty_11);
-  printf("EXISTS() = %d\n", empty_12);
+  // printf("NOT_EMPTY_ITEM(10,11,12) = %d\n", empty_10);
+  printf("NOT_EMPTY(10,11,12) = %d\n", empty_11);
+  printf("NOT_EMPTY() = %d\n", empty_12);
   printf("\n");
 
-  //  int empty_10 = EXISTS_ITEM(10,11,12); // illegal call, try it anyway ..compilation error
-  empty_11 = NOT_EXISTS(10,11,12); // this is a legal call
-  empty_12 = NOT_EXISTS(); 
+  //  int empty_10 = NOT_EMPTY_ITEM(10,11,12); // illegal call, try it anyway ..compilation error
+  empty_11 = EMPTY(10,11,12); // this is a legal call
+  empty_12 = EMPTY(); 
 
-  // printf("NOT_EXISTS_ITEM(10,11,12) = %d\n", empty_10);
-  printf("NOT_EXISTS(10,11,12) = %d\n", empty_11);
-  printf("NOT_EXISTS() = %d\n", empty_12);
+  // printf("EMPTY_ITEM(10,11,12) = %d\n", empty_10);
+  printf("EMPTY(10,11,12) = %d\n", empty_11);
+  printf("EMPTY() = %d\n", empty_12);
   printf("\n");
 
 
@@ -92,19 +92,19 @@ int main(void){
   _FIRST(11 ,22 ,33) = 11
   _SECOND(11 ,22 ,33) = 22
 
-  EXISTS_ITEM() = 0
-  EXISTS_ITEM(0) = 1
-  EXISTS_ITEM(1) = 1
-  EXISTS_ITEM(hello) = 1
+  NOT_EMPTY_ITEM() = 0
+  NOT_EMPTY_ITEM(0) = 1
+  NOT_EMPTY_ITEM(1) = 1
+  NOT_EMPTY_ITEM(hello) = 1
 
-  NOT_EXISTS_ITEM() = 1
-  NOT_EXISTS_ITEM(0) = 0
-  NOT_EXISTS_ITEM(1) = 0
-  NOT_EXISTS_ITEM(hello) = 0
+  EMPTY_ITEM() = 1
+  EMPTY_ITEM(0) = 0
+  EMPTY_ITEM(1) = 0
+  EMPTY_ITEM(hello) = 0
 
-  EXISTS(10,11,12) = 1
-  EXISTS() = 0
+  NOT_EMPTY(10,11,12) = 1
+  NOT_EMPTY() = 0
 
-  NOT_EXISTS(10,11,12) = 0
-  NOT_EXISTS() = 1
+  EMPTY(10,11,12) = 0
+  EMPTY() = 1
 */
index 1e99ee3..48606e5 100644 (file)
@@ -7,8 +7,8 @@ int main(void){
   //--------------------------------------------------------------------------
 
   #define x0 
-  SHOW(  EXISTS_ITEM(x0) );       // → 0 (assumed undefined)
-  SHOW(  NOT_EXISTS_ITEM(x0) );   // → 1
+  SHOW(  NOT_EMPTY_ITEM(x0) );       // → 0 (assumed undefined)
+  SHOW(  EMPTY_ITEM(x0) );   // → 1
   printf("\n");
 
   SHOW(  MATCH(x0) );
@@ -48,11 +48,11 @@ int main(void){
   SHOW( _BOOL(x0) );       // 0 because it does not exit (see the #define at the top)
   printf("\n");
 
-  SHOW( BOOL(0) );       // _FIRST = 0, EXISTS_ITEM(_FIRST) = 0 → _AND(0 ,1) → 0
-  SHOW( BOOL(1) );       // EXISTS_ITEM(1) = 0 → BOOL = 0
-  SHOW( BOOL(10) );       // EXISTS_ITEM(1) = 0 → BOOL = 0
-  SHOW( BOOL() );       // EXISTS_ITEM(1) = 0 → BOOL = 0
-  SHOW( BOOL(x0) );       // EXISTS_ITEM(1) = 0 → BOOL = 0
+  SHOW( BOOL(0) );       // _FIRST = 0, NOT_EMPTY_ITEM(_FIRST) = 0 → _AND(0 ,1) → 0
+  SHOW( BOOL(1) );       // NOT_EMPTY_ITEM(1) = 0 → BOOL = 0
+  SHOW( BOOL(10) );       // NOT_EMPTY_ITEM(1) = 0 → BOOL = 0
+  SHOW( BOOL() );       // NOT_EMPTY_ITEM(1) = 0 → BOOL = 0
+  SHOW( BOOL(x0) );       // NOT_EMPTY_ITEM(1) = 0 → BOOL = 0
   printf("\n");
 
   SHOW( NOT(0) );        // BOOL = 0 → NOT(0) = _NOT(0) = 1
@@ -119,8 +119,8 @@ int main(void){
   2025-03-27T13:00:11Z[developer]
   Thomas-developer@Stanley§/home/Thomas-masu/developer/N/developer/example§
   > ./a.out
-  EXISTS_ITEM(x0) --> 0
-  NOT_EXISTS_ITEM(x0) --> 1
+  NOT_EMPTY_ITEM(x0) --> 0
+  EMPTY_ITEM(x0) --> 1
 
   MATCH(x0) --> MATCH()
   NOT_MATCH(x0) --> NOT_MATCH()
index 6cb8aaf..6989c56 100644 (file)
@@ -18,7 +18,7 @@ int main(void){
   // NOTEQ Tests — inverse behavior
   //---------------------------------------------------------------------------
 
-  SHOW(NOT_EQ(0 ,0));  // Expected → 0 (because EQ → 1, so EXISTS → 0)
+  SHOW(NOT_EQ(0 ,0));  // Expected → 0 (because EQ → 1, so NOT_EMPTY → 0)
   SHOW(NOT_EQ(1 ,1));  // Expected → 0
   SHOW(NOT_EQ(0 ,1));  // Expected → 1
   SHOW(NOT_EQ(1 ,0));  // Expected → 1