free_formula (Equation t1 e t2 r) = let
     t1' = free_term t1
     t2' = free_term t2
     sort = getSort t1
     in case sort of
        Nothing -> Equation t1' e t2' r
        Just s -> let
            ps = freePredSymb s
            pred1 = mkPredication ps [t1', t2']
            pred2 = mkNeg $ mkPredication ps [t1', t1']
            pred3 = mkNeg $ mkPredication ps [t2', t2']
            pred4 = conjunct [pred2, pred3]
            pred5 = disjunct [pred1, pred4]
            in if e == Existl then pred1 else pred5
free_formula (Equation t1 e t2 r) = let
     t1' = free_term t1
     t2' = free_term t2
     sort = getSort t1
     in case sort of
        Nothing -> Equation t1' e t2' r
        Just s -> let
            ps = freePredSymb s
            pred1 = mkPredication ps [t1', t2']
            pred2 = mkNeg $ mkPredication ps [t1', t1']
            pred3 = mkNeg $ mkPredication ps [t2', t2']
            pred4 = conjunct [pred2, pred3]
            pred5 = disjunct [pred1, pred4]
            in if e == Existl then pred1 else pred5
free_formula (Equation t1 e t2 r) = let
     t1' = free_term t1
     t2' = free_term t2
     sort = getSort t1
     in case sort of
        Nothing -> Equation t1' e t2' r
        Just s -> let
            ps = freePredSymb s
            pred1 = mkPredication ps [t1', t2']
            pred2 = mkNeg $ mkPredication ps [t1', t1']
            pred3 = mkNeg $ mkPredication ps [t2', t2']
            pred4 = conjunct [pred2, pred3]
            pred5 = disjunct [pred1, pred4]
            in if e == Existl then pred1 else pred5