def expp_xor_indep(p1, p2):
    """
    Probability of term t1 XOR t2 being 1 if t1 is 1 with p1 and t2 is 1 with p2.
    t1 and t2 has to be independent (no common sub-term).
    Due to associativity can be computed on multiple terms: t1 ^ t2 ^ t3 ^ t4 = (((t1 ^ t2) ^ t3) ^ t4) - zipping.

    XOR:
      a b | r
      ----+---
      1 1 | 0
      1 0 | 1  = p1    * (1-p2)
      0 1 | 1  = (1-p1)* p2
      0 0 | 0

    :param p1:
    :param p2:
    :return:
    """
    return p1*(1-p2)+(1-p1)*p2