pytket.circuit.logic_exp

Classes and functions for constructing logical expressions over Bit and BitRegister.

class pytket.circuit.logic_exp.And(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
eval_vals() Union[LogicExp, Bit, BitRegister, int]

Attempt to evaluate all sub-expressions; simple constant folding.

class pytket.circuit.logic_exp.BinaryOp(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])

Expresion for operation on two arguments.

class pytket.circuit.logic_exp.BitAnd(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.BitEq(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.BitLogicExp(op: Union[BitWiseOp, RegWiseOp], args: List[Union[LogicExp, Bit, BitRegister, int]])

Expression acting only on Bit or Constant types.

class pytket.circuit.logic_exp.BitNeq(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.BitNot(arg: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.BitOr(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
eval_vals() Union[LogicExp, Bit, BitRegister, int]

Attempt to evaluate all sub-expressions; simple constant folding.

class pytket.circuit.logic_exp.BitWiseOp(value)

Enum for operations on Bit.

class pytket.circuit.logic_exp.BitXor(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
pytket.circuit.logic_exp.ConstPredicate

alias of PredicateExp

class pytket.circuit.logic_exp.Eq(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.LogicExp(op: Union[BitWiseOp, RegWiseOp], args: List[Union[LogicExp, Bit, BitRegister, int]])

Logical expressions over Bit or BitRegister. Encoded as a tree of expressions

all_inputs() Set[Union[Bit, BitRegister]]
Returns

All variables involved in expression.

Return type

Set[Variable]

eval_vals() Union[LogicExp, Bit, BitRegister, int]

Attempt to evaluate all sub-expressions; simple constant folding.

classmethod factory(op: Union[BitWiseOp, RegWiseOp]) Type[LogicExp]

Return matching operation class for enum.

classmethod from_dict(dic: Dict[str, Any]) LogicExp

Load from JSON serializable nested dictionary.

set_value(var: Union[Bit, BitRegister], val: int) None

Set value of var to val recursively.

to_dict() Dict[str, Any]

Output JSON serializable nested dictionary.

class pytket.circuit.logic_exp.Neq(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.Or(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.PredicateExp(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])

A binary predicate where the arguments are either Bits, BitRegisters, or Constants.

class pytket.circuit.logic_exp.RegAdd(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegAnd(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegDiv(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegEq(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegGeq(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegGt(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegLeq(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegLogicExp(op: Union[BitWiseOp, RegWiseOp], args: List[Union[LogicExp, Bit, BitRegister, int]])

Expression acting only on BitRegister or Constant types.

class pytket.circuit.logic_exp.RegLsh(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegLt(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegMul(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegNeg(arg: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegNeq(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegNot(arg: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegOr(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegPow(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegRsh(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegSub(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.RegWiseOp(value)

Enum for operations on BitRegister.

class pytket.circuit.logic_exp.RegXor(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
class pytket.circuit.logic_exp.UnaryOp(arg: Union[LogicExp, Bit, BitRegister, int])

Expression for operation on one argument.

class pytket.circuit.logic_exp.Xor(arg1: Union[LogicExp, Bit, BitRegister, int], arg2: Union[LogicExp, Bit, BitRegister, int])
pytket.circuit.logic_exp.filter_by_type(seq: Iterable, var_type: Type[T]) Iterator[Tuple[int, T]]

Return enumeration of seq, with only elements of type var_type.

pytket.circuit.logic_exp.if_bit(bit: Union[Bit, BitLogicExp]) PredicateExp

Equivalent of if bit:.

pytket.circuit.logic_exp.if_not_bit(bit: Union[Bit, BitLogicExp]) PredicateExp

Equivalent of if not bit:.

pytket.circuit.logic_exp.reg_eq(register: Union[RegLogicExp, BitRegister], value: int) PredicateExp

Function to express a BitRegister equality predicate, i.e. for a register r, (r == 5) is expressed as reg_eq(r, 5)

pytket.circuit.logic_exp.reg_geq(register: Union[RegLogicExp, BitRegister], value: int) PredicateExp

Function to express a BitRegister greater than or equal to predicate, i.e. for a register r, (r >= 5) is expressed as reg_geq(r, 5)

pytket.circuit.logic_exp.reg_gt(register: Union[RegLogicExp, BitRegister], value: int) PredicateExp

Function to express a BitRegister greater than predicate, i.e. for a register r, (r > 5) is expressed as reg_gt(r, 5)

pytket.circuit.logic_exp.reg_leq(register: Union[RegLogicExp, BitRegister], value: int) PredicateExp

Function to express a BitRegister less than or equal to predicate, i.e. for a register r, (r <= 5) is expressed as reg_leq(r, 5)

pytket.circuit.logic_exp.reg_lt(register: Union[RegLogicExp, BitRegister], value: int) PredicateExp

Function to express a BitRegister less than predicate, i.e. for a register r, (r < 5) is expressed as reg_lt(r, 5)

pytket.circuit.logic_exp.reg_neq(register: Union[RegLogicExp, BitRegister], value: int) PredicateExp

Function to express a BitRegister inequality predicate, i.e. for a register r, (r != 5) is expressed as reg_neq(r, 5)