示例#1
0
def const_vector(prefix, length, sort=z3.RealSort()):
    """
    Returns a list of z3 constants of given sort.

    e.g. const_vector("foo", 5, z3.FloatSingle())
    Returns a list of 5 FP
    """
    names = [prefix + "__" + str(i) for i in range(length)]
    return z3.Consts(names, sort)
示例#2
0
def Consts(names, uct_sort, annctx=default_annctx):
    """
    Declare a list of constants.  
    :param names: string containing all the names separated by a space  
    :param uct_sort: naturalproofs.uct.UCTSort  
    :param annctx: naturalproofs.AnnotatedContext.AnnotatedContext  
    :return: list of z3.ExprRef  
    """
    if not isinstance(uct_sort, UCTSort):
        raise TypeError('UCTSort expected.')
    z3consts = z3.Consts(names, uct_sort.z3sort)
    if not isinstance(annctx, AnnotatedContext):
        raise TypeError('AnnotatedContext expected.')
    for z3const in z3consts:
        # Constants must be tracked as a 0-arity function
        declaration = z3const.decl()
        annctx.add_alias_annotation(declaration, tuple([uct_sort]))
        annctx.add_vocabulary_annotation(declaration)
    return z3consts
示例#3
0
文件: read_rules.py 项目: uwplse/taso
    OP_MUL: ('smul', (), 2, 1, {2, 3, 4}
             )  # multiply a tensor (first argument) with a scalar (0-D tensor)
}

for d in operator_data.values():
    for i in range(d[3]):
        name = d[0]
        globals()[name] = z3.Function(name,
                                      *(len(d[1]) * [P] + d[2] * [T] + [T]))

name = "split_0"
globals()[name] = z3.Function(name, *(1 * [T] + [T]))
name = "split_1"
globals()[name] = z3.Function(name, *(1 * [T] + [T]))

x, y, z, w, one = z3.Consts('x y z w one', T)
sx, sy, kx, ky, pad, acti, ax = z3.Consts('sx sy kx ky pad acti ax', P)

N = [
    1, 2, 3, 4
]  # change this to control number of combinations for symbolic validation, e.g., [1,2], [1,3] or [3,4] each provide a reasonable experiment to run and go for coffee (assuming 8 cores)
D = [1, 3]

# list of axioms with list of possible values for verify_axioms.py. possible values are actual values for parameters, and shapes for tensors

#    (ForAll([kx, ky, x, y], enlarge_0(kx, ky, ewadd_0(x, y)) == ewadd_0(enlarge_0(kx, ky, x), enlarge_0(kx, ky, y))),
#     lambda : [(kx, ky, s, s)
#               for kx, ky in product(D, repeat=2)
#               for s in product(N, repeat=4)
#     ]),
#
示例#4
0
文件: data.py 项目: sllam/chrcp
def newChars(quantity):
	cnames = " ".join( map(lambda _: get_new_var(prefix="c") ,range(0,quantity)) )
	return z3.Consts(cnames, Char)
示例#5
0
文件: data.py 项目: sllam/chrcp
def newDests(quantity):
	dnames = " ".join( map(lambda _: get_new_var(prefix="d") ,range(0,quantity)) )
	return z3.Consts(dnames, Dest)
示例#6
0
文件: data.py 项目: sllam/chrcp
def newLocs(quantity):
	lnames = " ".join( map(lambda _: get_new_var(prefix="l") ,range(0,quantity)) )
	return z3.Consts(lnames, Loc)
示例#7
0
文件: data.py 项目: sllam/chrcp
def newUnknowns(quantity):
	unames = " ".join( map(lambda _: get_new_var(prefix="str") ,range(0,quantity)) )
	return z3.Consts(unames, Unknown)
示例#8
0
文件: data.py 项目: sllam/chrcp
def newStrings(quantity):
	snames = " ".join( map(lambda _: get_new_var(prefix="str") ,range(0,quantity)) )
	return z3.Consts(snames, String)
示例#9
0
文件: 1 intro.py 项目: valeporti/imt
import z3

Humain = z3.DeclareSort('Humain')
Socrate = z3.Const('Socrate', Humain)
is_Mortel = z3.Function('is_Mortel', Humain, z3.BoolSort())
is_Humain = z3.Function('is_Humain', Humain, z3.BoolSort())
s = z3.Solver()
x = z3.Const('x', Humain)
s.add(z3.ForAll(x, z3.Implies(is_Humain(x), is_Mortel(x))))
s.add(is_Humain(Socrate))
s.add(z3.Not(is_Mortel(Socrate)))
print(s.check())

print('-----')
z3.set_param(proof=True)
Humain = z3.DeclareSort('Humain')
Socrate = z3.Const('Socrate', Humain)
is_Mortel = z3.Function('is_Mortel', Humain, z3.BoolSort())
is_Humain = z3.Function('is_Humain', Humain, z3.BoolSort())
s = z3.Solver()
x, y, z = z3.Consts('x y z', Humain)
s.add(z3.ForAll(x, z3.Implies(is_Humain(x), is_Mortel(x))))
s.add(is_Humain(Socrate))
s.add(is_Mortel(Socrate))
print(s.check())
print(s.model())