Example #1
0
static int
type_max (check_ctx_t *ctx, int idx)
{
    model_t         model = ctx->parent;
    lts_type_t      ltstype = GBgetLTStype (model);
    int             typeno = lts_type_get_state_typeno (ltstype, idx);
    int              c;
    switch (lts_type_get_format (ltstype, typeno))
    {
        case LTStypeDirect:
            GBgetInitialState (model, ctx->src2);
            c = ctx->src2[idx];
            return c == 0 ? 1 : c;
        case LTStypeRange:
            return lts_type_get_min (ltstype, typeno);
        case LTStypeEnum:
            c = pins_chunk_count (model, typeno);
            HREassert (c > 0, "Empty enum table for slot: %d -- %s", idx, str_slot(ctx, NULL, idx));
            return c;
        case LTStypeChunk:
            c = pins_chunk_count (model, typeno);
            return c == 0 ? 1 : c;
        case LTStypeBool:
            return 1;
        case LTStypeTrilean:
            return 2;
        case LTStypeSInt32:
            return (1ULL<<31) - 1;
        default: {
                HREassert(false);
                return -1;
        }
    }
}
Example #2
0
static void
output_types(FILE *tbl_file)
{
    int type_count = lts_type_get_type_count(ltstype);

    for (int i = 0; i < type_count; i++) {
        Warning(info, "dumping type %s", lts_type_get_type(ltstype, i));
        fprintf(tbl_file, "begin sort ");
        fprint_ltsmin_ident(tbl_file, lts_type_get_type(ltstype, i));
        fprintf(tbl_file, "\n");

        int values = pins_chunk_count (model,i);

        for (int j = 0; j < values; j++) {
            chunk c    = pins_chunk_get (model, i, j);
            size_t len = c.len * 2 + 6;
            char str[len];

            chunk2string(c, len, str);
            fprintf(tbl_file, "%s\n", str);
        }

        fprintf(tbl_file,"end sort\n");
    }
}
Example #3
0
static char *
str_group (check_ctx_t *ctx, int group)
{
    model_t         model = ctx->parent;
    lts_type_t      ltstype = GBgetLTStype (model);
    int             label = lts_type_find_edge_label (ltstype, LTSMIN_EDGE_TYPE_STATEMENT);
    if (label) return "NULL";
    int             type = lts_type_get_edge_label_typeno (ltstype, label);
    int             count = pins_chunk_count  (model, type);
    if (count < ctx->K) return "NULL";
    chunk           c = pins_chunk_get (model, type, group);
    return c.data;
}
Example #4
0
static void
save_snapshot_vset(FILE *f)
{
    /* Call hook */
    vset_pre_save(f, domain);

    /* Write domain */
    vdom_save(f, domain);

    /* Write initial state */
    vset_save(f, initial);

    /* Write number of transitions and all transitions */
    fwrite(&nGrps, sizeof(int), 1, f);
    for (int i=0; i<nGrps; i++) vrel_save_proj(f, group_next[i]);
    for (int i=0; i<nGrps; i++) vrel_save(f, group_next[i]);

    /* Write reachable states */
    int save_reachable = 1;
    fwrite(&save_reachable, sizeof(int), 1, f);
    vset_save(f, visited);

    /* Call hook */
    vset_post_save(f, domain);

    /* Now write action labels */
    int action_count = 0;
    if (act_label != -1) action_count = pins_chunk_count(model, action_typeno);
    fwrite(&action_count, sizeof(int), 1, f);
    for (int i=0; i<action_count; i++) {
        chunk ch = pins_chunk_get(model, action_typeno, i);
        uint32_t len = ch.len;
        char *action = ch.data;
        fwrite(&len, sizeof(uint32_t), 1, f);
        fwrite(action, sizeof(char), len, f);
    }
}
Example #5
0
File: pg.c Project: Meijuh/ltsmin
/**
 * \brief Initialises the data structures for generating symbolic parity games.
 */
void
init_spg(model_t model)
{
    lts_type_t type = GBgetLTStype(model);
    var_pos = 0;
    var_type_no = 0;
    for(int i=0; i<N; i++)
    {
        //Printf(infoLong, "%d: %s (%d [%s])\n", i, lts_type_get_state_name(type, i), lts_type_get_state_typeno(type, i), lts_type_get_state_type(type, i));
#ifdef LTSMIN_PBES
        char* str1 = "string"; // for the PBES language module
#else
        char* str1 = "mu"; // for the mu-calculus PINS layer
#endif
        size_t strlen1 = strlen(str1);
        char* str2 = lts_type_get_state_type(type, i);
        size_t strlen2 = strlen(str2);
        if (strlen1==strlen2 && strncmp(str1, str2, strlen1)==0)
        {
            var_pos = i;
            var_type_no = lts_type_get_state_typeno(type, i);
            if (GBhaveMucalc()) {
                true_index = 0; // enforced by mucalc parser (mucalc-grammar.lemon / mucalc-syntax.c)
                false_index = 1;
            } else { // required for the PBES language module.
                true_index = pins_chunk_put (model, var_type_no, chunk_str("true"));
                false_index = pins_chunk_put (model, var_type_no, chunk_str("false"));
            }
        }
    }
    int p_len = 1;
    int proj[1] = {var_pos}; // position 0 encodes the variable
    variable_projection = vproj_create(domain, p_len, proj);

    num_vars = pins_chunk_count (model, var_type_no); // number of propositional variables
    if (GBhaveMucalc()) {
        num_vars = GBgetMucalcNodeCount(); // number of mu-calculus subformulae
    }
    Print(infoLong, "init_spg: var_type_no=%d, num_vars=%zu", var_type_no, num_vars);
    priority = RTmalloc(num_vars * sizeof(int)); // priority of variables
    player = RTmalloc(num_vars * sizeof(int)); // player of variables
    for(size_t i=0; i<num_vars; i++)
    {
        lts_type_t type = GBgetLTStype(model);
        int state_length = lts_type_get_state_length(type);
        // create dummy state with variable i:
        int state[state_length];
        for(int j=0; j < state_length; j++)
        {
            state[j] = 0;
        }
        state[var_pos] = i;
        int label = GBgetStateLabelLong(model, PG_PRIORITY, state); // priority
        priority[i] = label;
        if (label < min_priority) {
            min_priority = label;
        }
        if (label > max_priority) {
            max_priority = label;
        }
        //Print(infoLong, "  label %d (priority): %d", 0, label);
        label = GBgetStateLabelLong(model, PG_PLAYER, state); // player
        player[i] = label;
        //Print(infoLong, "  label %d (player): %d", 1, label);
    }
    true_states = vset_create(domain, -1, NULL);
    false_states = vset_create(domain, -1, NULL);
}