Test of the CG base handling features



 Thing {* supertype of 1st-order concept types *};
  Thing > (Entity Situation)    /* Filling the knowledge base */;
     Entity > (Description Physical_entity);
        Physical_entity > (Cat Mat Table Person);
        Description > Hypothesis;
     Situation > Process State;
        Process > Believe;
  BinaryRel (Thing, Thing) {supertype of 1st-order concept types}
   > (Near, Object, Agent, Author);
  Near (Entity,Entity) > On;  On (Entity,Entity);
  Object (Process,Entity);   Agent (Process,Entity);
  Author (Description,Person);
  Cat : Tom;
  name #CatOnMat [Cat]->(On)->[Mat]; //assertion and rename
  name #TomOnTable [Cat:Tom]->(On)->[Table];



  set test_projection 1   /* the tests that must be done below */;
  set test_type_definition 1;
  set test_informal_CGs 1;
  set test_pipe 1;     set test_contextualized_CGs 1;
  set test_meta_info 1;      set test_join 1;   set test_control_structures 1;


  if ($test_informal_CGs)         // Test projections
  { Cat : Tom2;  name #CatOnMat2 [Cat:Tom2]->(On)->[Table];
    spec [Cat:?] | nbArguments;
    spec [Table]<-(On)<-[Cat:?];
    proj [Cat] #CatOnMat;
    proj [Cat:Tom] #TomOnTable;
    proj [Cat:?] #TomOnTable;
    proj [Table]<-(On)<-[Cat:?] #TomOnTable;
  }

  if (0)  /* $test_informal_CGs */   /* Test non classic forms of CGs */
  { spec Cat : ?;
    [Tom, on: (a mat, on: a table), Near: a !rat];
    [a !rat, on: a mat];
    spec [an entity, on: a mat];
    spec [Tom];
    no decl;  [UndeclaredType1]->(UndeclaredRel)->[UndeclaredType2];  decl;
    ["Tom is on a table"]->("is a specialisation of")->["A cat is on a table"];
    ["A cat", "is on": "a mat", "looks at": "a mouse";
           ["thing related to a cat" $(its definition)$ ]  ];
    
A cat
is on : a mat.
looks at : a mouse.
thing related to a cat
its definition
spec [Description]->(BinaryRel)->[Description]; /* ["a cat" "is on": "a mat"]; ["a cat"]->("is on")->["a mat"]; */ /* [~ [!okl]->(Subtask)->[Task] ]; */ delCGs; name #CatOnMat [Cat]->(On)->[Mat]; //assertion and rename name #TomOnTable [Cat:Tom]->(On)->[Table]; } if ($test_type_definition) /* Test type definitions */ { NSC for LazzyCat (x) are [Cat:*x]->(On)->[Mat]; TC for Cat (x) are [Cat:*x]->(On)->[Mat]; on lambdas; spec [Cat]; on CGs; } if ($test_contextualized_CGs) /* Test contextualized CGs */ { name #CatOnMat_Rel_TomOnTable [Description:CatOnMat]->(BinaryRel)->[Description:TomOnTable]; spec [Cat]; only context; //display embedding CGs only if contextualising spec [Cat] /* note that a CG never appears twice in the results of a request */; all embeddings; //back to the default mode Person : John; //name #DefLazzyCatForPh [Description:NSC_for_LazzyCat]->(Author)->[Person:John]; name #CatOnMatForPh [Description:CatOnMat]->(Author)->[Person:John]; name #TomOnTableForPh [Description:TomOnTable]<-(Object)<-[Believe]->(Agent)->[Person:John]; spec [Cat]; delCG #CatOnMatForPh #TomOnTableForPh #CatOnMat_Rel_TomOnTable; } if ($test_meta_info) /* Test meta information */ { #CatOnMat in Hypothesis with {* view:Task; user:phmartin; *}; spec #CatOnMat ; spec [%thing] ; spec [Thing] in Hypothesis; spec [Thing] with {* user:phmartin; *} ; #CatOnMat in Description; //no meta; //spec [Thing]; //meta; }; if ($test_join) /* Test joins */ { name #TomOnMatNearTable [Cat:Tom]->(On)->[Mat]->(Near)->[Table]; join on Cat Cat:Tom #CatOnMat #TomOnTable; maxjoin #CatOnMat #TomOnMatNearTable; delCG #Join_of_CatOnMat_and_TomOnTable_on_Cat-__and_Cat-Tom; delCG #Maxjoin_of_CatOnMat_and_TomOnMatNearTable } if ($test_pipe) /* Test pipes */ { spec [Cat]; spec [Cat] | maxjoin; spec [Thing]; spec [Thing] | nbArguments | set nbCGs; spec [Cat] | nbArguments | set nbCGsAboutCat; if ($nbCGs = $nbCGsAboutCat) { echo "All CGs of the base are about cats"; } else { echo "Not all CGs of the base are about cats"; };