Ejemplo n.º 1
0
class SizeCoqVal(object):
    def __init__(self, concr_ast):
        self.concr_ast = concr_ast
        self.sce = SizeConstr(self.concr_ast)

    def size(self, v):
        if isinstance(v, BaseVal):
            return self.sce.size(v.c)
        elif isinstance(v, EvarVal):
            return 1 + self.sizes(v.vs)
        elif isinstance(v, CastVal):
            return 1 + self.size(v.v_c) + self.size(v.v_ty)
        elif isinstance(v, CloVal):
            return self.sce.size(v.c)
        elif isinstance(v, AppVal):
            return 1 + self.size(v.v_c) + self.sizes(v.v_cs)
        elif isinstance(v, CaseVal):
            return (1 + self.size(v.ret) + self.size(v.match) +
                    self.sizes(v.cases))
        elif isinstance(v, ProjVal):
            return 1 + self.size(v.v)
        else:
            raise NameError("Kind {} not supported".format(v))

    def sizes(self, vs):
        return sum([self.size(v) for v in vs])
Ejemplo n.º 2
0
    def _kern_size(self):
        _, ctx, (concl_kdx, _), _ = self.tacst
        sc = SizeConstr(self.tactr.decoder.decoded)
        concl_size = sc.decode_size(concl_kdx)
        ctx_size = 0
        for _, kdx, _ in ctx:
            ctx_size += sc.decode_size(kdx)

        self.kern_concl_size = concl_size
        self.kern_ctx_size = ctx_size
        self.kern_size = concl_size + ctx_size
Ejemplo n.º 3
0
 def stats(self):
     term_path_lens = [len(path) for path in self.view_term_paths()]
     err_path_lens = [len(path) for path in self.view_err_paths()]
     avg_depth_ctx_items = [(k, np.mean(v))
                            for k, v in self.view_depth_ctx_items().items()]
     avg_depth_ctx_size = [(k, np.mean(v))
                           for k, v in self.view_depth_ctx_size().items()]
     avg_depth_goal_size = [
         (k, np.mean(tysz))
         for k, tysz in self.view_depth_goal_size().items()
     ]
     sce_full = SizeConstr(self.decoder.decoded, f_shared=False)
     sce_sh = SizeConstr(self.decoder.decoded, f_shared=True)
     avg_depth_astctx_size = [
         (k, np.mean(v))
         for k, v in self.view_depth_astctx_size(sce_full).items()
     ]
     avg_depth_astgoal_size = [
         (k, np.mean(tysz))
         for k, tysz in self.view_depth_astgoal_size(sce_full).items()
     ]
     static_full_comp, static_sh_comp, cbname_comp = self.view_comp(
         sce_full, sce_sh)
     info = {
         'hist': self.view_tactic_hist(f_compress=True),
         'num_tacs': len(self.tactics()),
         'num_goals': len(self.goals()),
         'num_term': len(self.term_goals()),
         'num_err': len(self.dead_goals()),
         'term_path_lens': term_path_lens,
         'err_path_lens': err_path_lens,
         'have_info': self.view_have_info(),
         'avg_depth_ctx_items': avg_depth_ctx_items,
         'avg_depth_ctx_size': avg_depth_ctx_size,
         'avg_depth_goal_size': avg_depth_goal_size,
         'avg_depth_astctx_size': avg_depth_astctx_size,
         'avg_depth_astgoal_size': avg_depth_astgoal_size,
         'hist_coqexp': self.hist_coqexp(),
         'hist_gc': self.hist_gc(),
         'static_full_comp': [v for _, v in static_full_comp.items()],
         'static_sh_comp': [v for _, v in static_sh_comp.items()],
         'cbname_comp': [v for _, v in cbname_comp.items()],
         'notok': self.notok
     }
     return info
Ejemplo n.º 4
0
 def __init__(self, concr_ast):
     self.concr_ast = concr_ast
     self.sce = SizeConstr(self.concr_ast)