toTseitinEncode' gs (And e1 e2) =
    let gl = gs ++ [1]
        gr = gs ++ [2]
        w  = newRef gs
        w1 = newRef gl
        w2 = newRef gr
        in [And (Or (Not w) w1) (And (Or (Not w) w2) (Or w (Or (Not w1) (Not w2))))] ++
            (toTseitinEncode' gl e1) ++
                (toTseitinEncode' gr e2)
toTseitinEncode' gs (And e1 e2) =
    let gl = gs ++ [1]
        gr = gs ++ [2]
        w  = newRef gs
        w1 = newRef gl
        w2 = newRef gr
        in [And (Or (Not w) w1) (And (Or (Not w) w2) (Or w (Or (Not w1) (Not w2))))] ++
            (toTseitinEncode' gl e1) ++
                (toTseitinEncode' gr e2)
toTseitinEncode' gs (And e1 e2) =
    let gl = gs ++ [1]
        gr = gs ++ [2]
        w  = newRef gs
        w1 = newRef gl
        w2 = newRef gr
        in [And (Or (Not w) w1) (And (Or (Not w) w2) (Or w (Or (Not w1) (Not w2))))] ++
            (toTseitinEncode' gl e1) ++
                (toTseitinEncode' gr e2)