本文整理汇总了Python中z3.Implies方法的典型用法代码示例。如果您正苦于以下问题:Python z3.Implies方法的具体用法?Python z3.Implies怎么用?Python z3.Implies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类z3
的用法示例。
在下文中一共展示了z3.Implies方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: construct_axioms
# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import Implies [as 别名]
def construct_axioms(variables): # List[StatVar]
_axioms = []
for var in variables:
# A variable must be continuous or categorical, but not both.
_axioms.append(z3.And(z3.Or(continuous(var).__z3__, categorical(var).__z3__),
z3.Not(z3.And(continuous(var).__z3__, categorical(var).__z3__))))
# If a variable is an explanatory variable and all explanatory variables are categorical,
# then the variable must be categorical.
# It isn't clear how to reason about whether a variable is an explanatory or explained variable.
# _axioms.append(z3.Implies(all_x_variables_categorical(var).__z3__, categorical(var).__z3__))
# Not sure how to reason about test properties like one_x_variable and one_y_variable.
# _axioms.append(z3.Not(z3.And(one_x_variable(var).__z3__, one_y_variable(var).__z3__)))
# If a variable is normal, then it cannot be categorical.
_axioms.append(z3.Implies(normal(var).__z3__, z3.Not(categorical(var).__z3__)))
# If a variable is continuous or ordinal, it must be continuous.
_axioms.append(z3.Implies(continuous_or_ordinal(var).__z3__, continuous(var).__z3__))
# If a variable has two categories, then it must be categorical.
# _axioms.append(z3.Implies(two_x_variable_categories(var).__z3__, categorical(var).__z3__))
return _axioms
示例2: implies
# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import Implies [as 别名]
def implies(self, l, r):
b = to_bool(l)
if b is True: return r
if b is False: return self.true
b = to_bool(r)
if b is True: return self.true
if b is False: return self.neg(l)
return z3.Implies(l, r, self.ctx)
示例3: z3Node
# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import Implies [as 别名]
def z3Node(self):
return z3.Implies(self.left.z3Node(), self.right.z3Node())
示例4: remapLabels
# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import Implies [as 别名]
def remapLabels(self, policy, writer):
return Implies(
self.left.remapLabels(policy, writer)
, self.right.remapLabels(policy, writer))
# Comparison operations
示例5: fidelity_constraints
# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import Implies [as 别名]
def fidelity_constraints(self):
"""
Set gate fidelity based on gate overlap conditions
"""
for gate in self.gate_start_time:
q_0 = gate.qargs[0].index
no_xtalk = False
if gate not in self.xtalk_overlap_set:
no_xtalk = True
elif not self.xtalk_overlap_set[gate]:
no_xtalk = True
if no_xtalk:
if isinstance(gate.op, U1Gate):
fid = math.log(1.0)
elif isinstance(gate.op, U2Gate):
fid = math.log(1.0 - self.bp_u2_err[q_0])
elif isinstance(gate.op, U3Gate):
fid = math.log(1.0 - self.bp_u3_err[q_0])
elif isinstance(gate.op, CXGate):
fid = math.log(1.0 - self.bp_cx_err[self.cx_tuple(gate)])
self.opt.add(self.gate_fidelity[gate] == round(fid, NUM_PREC))
else:
comb = list(self.powerset(self.xtalk_overlap_set[gate]))
xtalk_set = set(self.xtalk_overlap_set[gate])
for item in comb:
on_set = item
off_set = [i for i in xtalk_set if i not in on_set]
clauses = []
for tmpg in on_set:
clauses.append(self.overlap_indicator[gate][tmpg])
for tmpg in off_set:
clauses.append(Not(self.overlap_indicator[gate][tmpg]))
err = 0
if not on_set:
err = self.bp_cx_err[self.cx_tuple(gate)]
elif len(on_set) == 1:
on_gate = on_set[0]
err = self.crosstalk_prop[self.gate_tuple(gate)][self.gate_tuple(on_gate)]
else:
err_list = []
for on_gate in on_set:
tmp_prop = self.crosstalk_prop[self.gate_tuple(gate)]
err_list.append(tmp_prop[self.gate_tuple(on_gate)])
err = max(err_list)
if err == 1.0:
err = 0.999999
val = round(math.log(1.0 - err), NUM_PREC)
self.opt.add(Implies(And(*clauses), self.gate_fidelity[gate] == val))