pytket.circuit.logic_exp

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

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

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

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

Expresion for operation on two arguments.

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

Expression acting only on Bit or Constant types.

class pytket.circuit.logic_exp.BitNot(arg: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister, int])
class pytket.circuit.logic_exp.BitOr(arg1: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister, int], arg2: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister, int])
eval_vals() Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.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[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister, int], arg2: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister, int])
class pytket.circuit.logic_exp.ConstPredicate(exp: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister], const: int)

A binary predicate where at least one of the arguments is constant.

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

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

all_inputs() Set[Union[pytket.circuit.Bit, pytket.circuit.BitRegister]]
Returns

All variables involved in expression.

Return type

Set[Variable]

eval_vals() Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister, int]

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

classmethod factory(op: Union[pytket.circuit.logic_exp.BitWiseOp, pytket.circuit.logic_exp.RegWiseOp]) Type[pytket.circuit.logic_exp.LogicExp]

Return matching operation class for enum.

classmethod from_dict(dic: Dict[str, Any]) pytket.circuit.logic_exp.LogicExp

Load from JSON serializable nested dictionary.

set_value(var: Union[pytket.circuit.Bit, pytket.circuit.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(exp: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister], const: int)
class pytket.circuit.logic_exp.Or(arg1: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister, int], arg2: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister, int])
class pytket.circuit.logic_exp.RegAnd(arg1: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister, int], arg2: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister, int])
class pytket.circuit.logic_exp.RegEq(exp: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister], const: int)
class pytket.circuit.logic_exp.RegGeq(exp: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister], const: int)
class pytket.circuit.logic_exp.RegGt(exp: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister], const: int)
class pytket.circuit.logic_exp.RegLeq(exp: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister], const: int)
class pytket.circuit.logic_exp.RegLogicExp(op: Union[pytket.circuit.logic_exp.BitWiseOp, pytket.circuit.logic_exp.RegWiseOp], args: List[Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister, int]])

Expression acting only on BitRegister or Constant types.

class pytket.circuit.logic_exp.RegLt(exp: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister], const: int)
class pytket.circuit.logic_exp.RegNeq(exp: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister], const: int)
class pytket.circuit.logic_exp.RegOr(arg1: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister, int], arg2: Union[pytket.circuit.logic_exp.LogicExp, pytket.circuit.Bit, pytket.circuit.BitRegister, int])
class pytket.circuit.logic_exp.RegWiseOp(value)

Enum for operations on BitRegister.

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

Expression for operation on one argument.

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

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

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

Equivalent of if bit:.

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

Equivalent of if not bit:.

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

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[pytket.circuit.logic_exp.RegLogicExp, pytket.circuit.BitRegister], value: int) pytket.circuit.logic_exp.ConstPredicate

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[pytket.circuit.logic_exp.RegLogicExp, pytket.circuit.BitRegister], value: int) pytket.circuit.logic_exp.ConstPredicate

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[pytket.circuit.logic_exp.RegLogicExp, pytket.circuit.BitRegister], value: int) pytket.circuit.logic_exp.ConstPredicate

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[pytket.circuit.logic_exp.RegLogicExp, pytket.circuit.BitRegister], value: int) pytket.circuit.logic_exp.ConstPredicate

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[pytket.circuit.logic_exp.RegLogicExp, pytket.circuit.BitRegister], value: int) pytket.circuit.logic_exp.ConstPredicate

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