def _to_expr(l: Label, sig_by_name: dict): expr = sympy.true for sig, val in l.items(): sig_by_name[sig.name] = sig s = sympy.Symbol(str(sig)) expr = (expr & s) if val else (expr & ~s) return expr
def __getitem__(self, key:Label): if not isinstance(key, Label): raise TypeError(key) indices = [v for (l, v) in self._value_by_label if set(l.items()).issubset(set(key.items()))] if len(indices) == 0: raise KeyError(key) assert len(indices) == 1, 'return value is not unique: %s: %s' % (str(key), str(indices)) return indices[0]
def smt_out(smt_m: str, i_o: Label, inputs: Iterable[Signal], descr_by_output: Dict[Signal, FuncDesc]) -> str: args_dict = build_tau_args_dict(inputs, smt_m, i_o) conjuncts = [] for sig, val in i_o.items(): out_desc = descr_by_output.get(sig) if out_desc is None: continue condition_on_out = call_func(out_desc, args_dict) if val is False: condition_on_out = op_not(condition_on_out) conjuncts.append(condition_on_out) return op_and(conjuncts)