Beispiel #1
0
void CAESAR_INIT_GRAPH(void) {
    int argc;
    char **argv;
    char *FILENAME;
    char *OPTIONS;
    char *token;

    ATinitialize(0,NULL);
    ATsetWarningHandler(WarningHandler);
    ATsetErrorHandler(ErrorHandler);

    /* ATwarning ("Executing CAESAR_INIT_GRAPH"); */

    FILENAME = getenv ("OPEN_CAESAR_FILE");
    if (FILENAME == NULL)
        CAESAR_ERROR ("undefined environment variable $OPEN_CAESAR_FILE");

    OPTIONS = getenv ("MCRL_OPTIONS");
    if (OPTIONS == NULL)
        CAESAR_ERROR ("undefined environment variable $MCRL_OPTIONS");

#define MAX_OPTIONS 100

    argv = (char**)calloc(MAX_OPTIONS,sizeof(char*));
    argc = 0;
    argv[argc] = "mcrl_open";
    // ATwarning ("%d -> \"%s\"\n", argc, argv [argc]);
    argc ++;

    /* skip leading white spaces */
    while (*OPTIONS == ' ') OPTIONS++;
    token = strtok (OPTIONS, " ");
    while (1) {
        if (token == NULL) break;
        argv [argc] = token;
        // ATwarning ("%d -> \"%s\"\n", argc, argv [argc]);
        argc ++;
        token = strtok ((char *) NULL, " ");
    }

    argv [argc] = FILENAME;
    // ATwarning ("%d -> \"%s\"\n", argc, argv [argc]);
    argc ++;

    MCRLsetArguments(&argc, &argv);
    RWsetArguments(&argc,&argv);

    if (!MCRLinitialize())
        ATerror("%s cannot be opened\n",FILENAME);
    ATwarning("Opened %s",FILENAME);
    RWinitialize(MCRLgetAdt());
    LTSsetArguments(&argc,&argv);
    LTSinitialize(wrap_call_back);

    Label_set = ATindexedSetCreate(1024,75);
    /* ATwarning ("Leaving CAESAR_INIT_GRAPH"); */
}
CAESAR_TYPE_DOMAIN_LIST CAESAR_CONSTRUCT_DOMAIN_LIST
(
 CAESAR_TYPE_DOMAIN DOMAIN,
 CAESAR_TYPE_DOMAIN_LIST NEXT
 )
{
  CAESAR_TYPE_DOMAIN_LIST CAESAR_CELL;

  CAESAR_CREATE(CAESAR_CELL, sizeof(CAESAR_BODY_DOMAIN_LIST), CAESAR_TYPE_DOMAIN_LIST);
  if (CAESAR_CELL == NULL)
    CAESAR_ERROR("Memory shortage for domain list");

  CAESAR_CELL->DOMAIN = DOMAIN;
  CAESAR_CELL->NEXT = NEXT;

  return CAESAR_CELL;
}
CAESAR_TYPE_VARIABLE_POSITION_LIST CAESAR_CONSTRUCT_VARIABLE_POSITION_LIST
(
     CAESAR_TYPE_VARIABLE_POSITION POSITION,
     CAESAR_TYPE_VARIABLE_POSITION_LIST NEXT
     )
{
     CAESAR_TYPE_VARIABLE_POSITION_LIST CELL;
     
     CAESAR_CREATE(CELL, sizeof(CAESAR_BODY_VARIABLE_POSITION_LIST), CAESAR_TYPE_VARIABLE_POSITION_LIST);
     if (CELL == NULL)
	  CAESAR_ERROR("Memory shortage for domain list");
     
     CELL->POSITION = POSITION;
     CELL->NEXT = NEXT;
     
     return CELL;
}
CAESAR_TYPE_VARIABLE_MAP_LIST CAESAR_CONSTRUCT_VARIABLE_MAP_LIST
(
     CAESAR_TYPE_VARIABLE_MAP MAP,
     CAESAR_TYPE_VARIABLE_MAP_LIST NEXT
     )
{
     CAESAR_TYPE_VARIABLE_MAP_LIST CELL;
     
     CAESAR_CREATE(CELL, sizeof(CAESAR_BODY_VARIABLE_MAP_LIST), CAESAR_TYPE_VARIABLE_MAP_LIST);
     if (CELL == NULL)
	  CAESAR_ERROR("Memory shortage for VARIABLE_MAP_LIST");
     
     CELL->MAP = MAP;
     CELL->NEXT = NEXT;
     
     return CELL;
}
CAESAR_TYPE_VARIABLE_POSITION CAESAR_CREATE_VARIABLE_POSITION
(
     CAESAR_TYPE_NATURAL LITERAL_INDEX,
     CAESAR_TYPE_NATURAL ARGUMENT_INDEX
     )
{
     CAESAR_TYPE_VARIABLE_POSITION POSITION;
     
     CAESAR_CREATE(POSITION, sizeof(CAESAR_BODY_VARIABLE_POSITION), CAESAR_TYPE_VARIABLE_POSITION);
     if (POSITION == NULL)
	  CAESAR_ERROR("Memory shortage for VARIABLE_POSITION");
     
     POSITION->LITERAL_INDEX = LITERAL_INDEX;
     POSITION->ARGUMENT_INDEX = ARGUMENT_INDEX;
     
     return POSITION;
}
CAESAR_TYPE_RULE_LIST CAESAR_CONSTRUCT_RULE_LIST
(
 CAESAR_TYPE_RULE RULE,
 CAESAR_TYPE_RULE_LIST NEXT
 )
{
  CAESAR_TYPE_RULE_LIST CELL;

  CAESAR_CREATE(CELL, sizeof(CAESAR_BODY_RULE_LIST), CAESAR_TYPE_RULE_LIST);
  if (CELL == NULL)
    CAESAR_ERROR("Memory shortage for rule list");

  CELL->RULE = RULE;
  CELL->NEXT = NEXT;

  return CELL;  
}
CAESAR_TYPE_RELATION_LIST CAESAR_CONSTRUCT_RELATION_LIST
(
 CAESAR_TYPE_RELATION RELATION,
 CAESAR_TYPE_RELATION_LIST NEXT
 )
{
  CAESAR_TYPE_RELATION_LIST CELL;

  CAESAR_CREATE(CELL, sizeof(CAESAR_BODY_RELATION_LIST), CAESAR_TYPE_RELATION_LIST);
  if (CELL == NULL)
    CAESAR_ERROR("Memory shortage for relation list");

  CELL->RELATION = RELATION;
  CELL->NEXT = NEXT;

  return CELL;
}
CAESAR_TYPE_RULE CAESAR_CREATE_RULE
(
 CAESAR_TYPE_ATOM HEAD,
 CAESAR_TYPE_LITERAL_LIST TAIL
)
{
  CAESAR_TYPE_RULE RULE;

  CAESAR_CREATE(RULE, sizeof(CAESAR_BODY_RULE), CAESAR_TYPE_RULE);
  if (RULE == NULL)
    CAESAR_ERROR("Memory shortage for literal");

  RULE->HEAD = HEAD;
  RULE->TAIL = TAIL;

  return RULE;
}
CAESAR_TYPE_LITERAL_LIST CAESAR_CONSTRUCT_LITERAL_LIST
(
 CAESAR_TYPE_LITERAL LITERAL,
 CAESAR_TYPE_LITERAL_LIST NEXT
 )
{
  CAESAR_TYPE_LITERAL_LIST CELL;

  CAESAR_CREATE(CELL, sizeof(CAESAR_BODY_LITERAL_LIST), CAESAR_TYPE_LITERAL_LIST);
  if (CELL == NULL)
    CAESAR_ERROR("Memory shortage for literal list");

  CELL->LITERAL = LITERAL;
  CELL->NEXT = NEXT;

  return CELL;  
}
CAESAR_TYPE_LITERAL CAESAR_CREATE_LITERAL
(
 CAESAR_TYPE_RELATION RELATION,
 CAESAR_TYPE_RULE_VARIABLE_LIST RULE_VARIABLE_LIST
)
{
  CAESAR_TYPE_LITERAL LITERAL;

  CAESAR_CREATE(LITERAL, sizeof(CAESAR_BODY_LITERAL), CAESAR_TYPE_LITERAL);
  if (LITERAL == NULL)
    CAESAR_ERROR("Memory shortage for literal");

  LITERAL->RELATION = RELATION;
  LITERAL->RULE_VARIABLE_LIST = RULE_VARIABLE_LIST;

  return LITERAL;
}
CAESAR_TYPE_ATOM CAESAR_CREATE_ATOM
(
 CAESAR_TYPE_RELATION RELATION,
 CAESAR_TYPE_RULE_VARIABLE_LIST RULE_VARIABLE_LIST
)
{
  CAESAR_TYPE_ATOM ATOM;

  CAESAR_CREATE(ATOM, sizeof(CAESAR_BODY_ATOM), CAESAR_TYPE_ATOM);
  if (ATOM == NULL)
    CAESAR_ERROR("Memory shortage for atom");

  ATOM->RELATION = RELATION;
  ATOM->RULE_VARIABLE_LIST = RULE_VARIABLE_LIST;

  return ATOM;
}
CAESAR_TYPE_DOMAIN CAESAR_CREATE_DOMAIN
(
 CAESAR_TYPE_STRING NAME,
 CAESAR_TYPE_NATURAL CARDINAL,
 CAESAR_TYPE_STRING FILENAME
)
{
  CAESAR_TYPE_DOMAIN DOMAIN;

  CAESAR_CREATE(DOMAIN, sizeof(CAESAR_BODY_DOMAIN), CAESAR_TYPE_DOMAIN);
  if (DOMAIN == NULL)
    CAESAR_ERROR("Memory shortage for domain");

  DOMAIN->NAME = NAME;
  DOMAIN->CARDINAL = CARDINAL;
  DOMAIN->FILENAME = FILENAME;

  return DOMAIN;
}
CAESAR_TYPE_RELATION CAESAR_CREATE_RELATION
(
 CAESAR_TYPE_STRING NAME,
 CAESAR_TYPE_NATURAL ARITY,
 CAESAR_TYPE_DOMAIN_LIST DOMAIN_LIST,
 CAESAR_TYPE_IONATURE IONATURE
)
{
  CAESAR_TYPE_RELATION RELATION;

  CAESAR_CREATE(RELATION, sizeof(CAESAR_BODY_RELATION), CAESAR_TYPE_RELATION);
  if (RELATION == NULL)
    CAESAR_ERROR("Memory shortage for relation");

  RELATION->NAME = NAME;
  RELATION->ARITY = ARITY;
  RELATION->DOMAIN_LIST = DOMAIN_LIST;
  RELATION->IONATURE = IONATURE;

  return RELATION;
}
CAESAR_TYPE_VARIABLE_MAP CAESAR_CREATE_VARIABLE_MAP
(
     CAESAR_TYPE_INDEX_TABLE_1 VARIABLE_INDEX,
     CAESAR_TYPE_NATURAL CARDINAL,
     CAESAR_TYPE_VARIABLE_POSITION HEAD_POSITION,
     CAESAR_TYPE_VARIABLE_POSITION_LIST TAIL_POSITION_LIST
     )
{
     CAESAR_TYPE_VARIABLE_MAP MAP;
     
     CAESAR_CREATE(MAP, sizeof(CAESAR_BODY_VARIABLE_MAP), CAESAR_TYPE_VARIABLE_MAP);
     if (MAP == NULL)
	  CAESAR_ERROR("Memory shortage for VARIABLE_MAP");
     
     MAP->VARIABLE_INDEX = VARIABLE_INDEX;
     MAP->CARDINAL = CARDINAL;
     MAP->HEAD_POSITION = HEAD_POSITION;
     MAP->TAIL_POSITION_LIST = TAIL_POSITION_LIST;
     
     return MAP;
}
Beispiel #15
0
void CAESAR_INIT_GRAPH(void) {
	char *opencaesar_args, *opencaesar_prog,*ltsmin_options;
	 int argc;
	 char **argv;

	opencaesar_prog = getenv ("OPEN_CAESAR_PROG");
	if (opencaesar_prog == NULL)
		CAESAR_ERROR ("undefined environment variable $OPEN_CAESAR_PROG");
	opencaesar_args = getenv ("OPEN_CAESAR_FILE");
	if (opencaesar_args == NULL)
		CAESAR_ERROR ("undefined environment variable $OPEN_CAESAR_FILE");
	ltsmin_options = getenv ("LTSMIN_OPTIONS");
	if (ltsmin_options == NULL)
		CAESAR_ERROR ("undefined environment variable $LTSMIN_OPTIONS");
	
	
	int len=strlen(opencaesar_prog)+strlen(ltsmin_options)+strlen(opencaesar_args);
	char cmdline[len+6];
	sprintf(cmdline,"%s %s %s",opencaesar_prog,ltsmin_options,opencaesar_args);

	int res=poptParseArgvString(cmdline,&argc,(void*)(&argv));
	if (res){
		Abort("could not parse %s: %s",opencaesar_args,poptStrerror(res));
	}

 	char *files[2];
    HREinitBegin(argv[0]);
    HREaddOptions(options,"Options");
    HREinitStart(&argc,&argv,1,1,(char**)files,"<model>");

	Warning(info,"loading model from %s",files[0]);
	model=GBcreateBase();
	GBsetChunkMethods(model,new_string_index,NULL,
	                  (int2chunk_t)SIgetC,
	                  (chunk2int_t)SIputC,
	                  (chunkatint_t)SIputCAt,
	                  (get_count_t)SIgetCount);

	GBloadFile(model,files[0],&model);

	ltstype=GBgetLTStype(model);
	N = lts_type_get_state_length(ltstype);
	K = dm_nrows(GBgetDMInfo(model));
	Warning(info,"length is %d, there are %d groups",N,K);
	state_labels=lts_type_get_state_label_count(ltstype);
	edge_labels=lts_type_get_edge_label_count(ltstype);
	Warning(info,"There are %d state labels and %d edge labels",state_labels,edge_labels);
        if (edge_encode){
            edge_size=edge_labels+N+state_labels;
            Warning(info,"encoding state information on edges");
        } else {
            edge_size=edge_labels;
            Warning(info,"state information is hidden");
        } 
	CAESAR_HINT_SIZE_STATE = N*sizeof(int);
	CAESAR_HINT_HASH_SIZE_STATE = CAESAR_HINT_SIZE_STATE;
	CAESAR_HINT_SIZE_LABEL = edge_size*sizeof(int);
	CAESAR_HINT_HASH_SIZE_LABEL = CAESAR_HINT_SIZE_LABEL;
	Warning(info,"CAESAR_HINT_SIZE_STATE=%lu CAESAR_HINT_SIZE_LABEL=%lu",
	        (unsigned long)CAESAR_HINT_SIZE_STATE,(unsigned long)CAESAR_HINT_SIZE_LABEL);
}
Beispiel #16
0
void CAESAR_FORMAT_LABEL(CAESAR_TYPE_NATURAL x) {
	if (x<=CAESAR_MAX_FORMAT_LABEL())
		label_format = x;
	else
		CAESAR_ERROR("pins_open: %d exceeds max label format",x);
}
Beispiel #17
0
void CAESAR_FORMAT_STATE(CAESAR_TYPE_NATURAL x) {
	if (x<=CAESAR_MAX_FORMAT_STATE())
		state_format = x;
	else
		CAESAR_ERROR("pins_open: %d exceeds max state format",x);
}