from sage.all import operator from vu_common import (VLog, pause, is_list, is_empty, vset) from dig_inv import Inv, InvExp, InvEqt, InvMPP, InvIeq logger = VLog('refine') logger.level = VLog.INFO class Refine(object): """ Refine result invariants using several techniques, including 1) filtering 2) inferring 3) ranking """ def __init__(self, ps): if __debug__: assert is_list(ps) and all(isinstance(p,Inv) for p in ps), ps self.ps = vset(ps) Refine.print_diff('vset', len(ps), len(self.ps)) def get_ps(self): return self._ps def set_ps(self, ps): if __debug__: assert all(isinstance(p,Inv) for p in ps), p self._ps = ps
from pprint import pprint import multiprocessing as mp from sage.all import (SR, srange, var, flatten) from sageutil import (get_vars, get_coefs_terms, is_sage_eq) from vu_common import (VLog, vall_uniq, is_empty, is_list, is_dict, merge_dict, vpartition, list_str) from dig_miscs import (Miscs, get_traces, Tree, AEXP, ExtFun, adjust_arr_sizs) from dig import Solver from dig_inv import InvEqt, InvFlatArray, InvNestedArray logger = VLog('dig_arrays') logger.level = VLog.DEBUG class FlatArray(Solver): """ Find Flat Array Invariants of the form c1A[i][j].. + c2B[i1'][i2'].. = 0 using standard equation solving Examples: ig = InvGen("Traces/AES/Flat/paper_multidim.tc",verbose=1) _ = ig.getInvs(inv_typ='flat',seed=1) *** InvGen *** Sun Jun 3 21:44:39 2012 Sage Version 5.0, Release Date: 2012-05-14 Godel.local Darwin 10.8.0 x86_64
from abc import ABCMeta, abstractmethod from sage.all import (flatten, solve, srange, operator, sage_eval, prod, Polyhedron, CartesianProduct, Combinations, SR, RR, QQ, PolynomialRing, operator, oo, is_even) from sageutil import (get_vars, is_sage_symbol, is_sage_int, is_sage_expr, is_sage_rel) from vu_common import (VLog, pause, vset, is_empty, is_list, is_bool, vcmd) from dig_miscs import (Miscs, get_traces, get_sample, gen_terms_fixed_coefs) from dig import Solver from dig_inv import InvEqt, InvIeq, InvMPP logger = VLog('dig_polynomials') logger.level = VLog.INFO class Eqt(Solver): """ Find equality invariants using standard equation solving """ def __init__(self,terms,tcs,xinfo): super(Eqt,self).__init__(terms, tcs, xinfo) def mk_traces(self): """ No need to do too much filtering because most eqts obtained are valid """