sort_surj :: SORT -> Named CASLFORMULA
sort_surj s = form'
      where v1 = newVarIndex 0 $ mkFreeName s
            id_v1 = mkSimpleId "V0"
            vd1 = mkVarDecl id_v1 (mkFreeName s)
            v2 = newVarIndex 1 s
            id_v2 = mkSimpleId "V1"
            vd2 = mkVarDecl id_v2 s
            ot_hom = Op_type Partial [mkFreeName s] s nullRange
            name_hom = mkQualOp homId ot_hom
            lhs = mkAppl name_hom [v1]
            inner_form = mkExEq lhs v2
            inner_form' = mkExist [vd1] inner_form
            form = mkForall [vd2] inner_form'
            form' = makeNamed ("ga_hom_surj_" ++ show s) form

-- | generates the axioms for the homomorphisms applied to the predicates
sort_surj :: SORT -> Named CASLFORMULA
sort_surj s = form'
      where v1 = newVarIndex 0 $ mkFreeName s
            id_v1 = mkSimpleId "V0"
            vd1 = mkVarDecl id_v1 (mkFreeName s)
            v2 = newVarIndex 1 s
            id_v2 = mkSimpleId "V1"
            vd2 = mkVarDecl id_v2 s
            ot_hom = Op_type Partial [mkFreeName s] s nullRange
            name_hom = mkQualOp homId ot_hom
            lhs = mkAppl name_hom [v1]
            inner_form = mkExEq lhs v2
            inner_form' = mkExist [vd1] inner_form
            form = mkForall [vd2] inner_form'
            form' = makeNamed ("ga_hom_surj_" ++ show s) form

-- | generates the axioms for the homomorphisms applied to the predicates
sort_surj s = form'
      where v1 = newVarIndex 0 $ mkFreeName s
            id_v1 = mkSimpleId "V0"
            vd1 = mkVarDecl id_v1 (mkFreeName s)
            v2 = newVarIndex 1 s
            id_v2 = mkSimpleId "V1"
            vd2 = mkVarDecl id_v2 s
            ot_hom = Op_type Partial [mkFreeName s] s nullRange
            name_hom = mkQualOp homId ot_hom
            lhs = mkAppl name_hom [v1]
            inner_form = mkExEq lhs v2
            inner_form' = mkExist [vd1] inner_form
            form = mkForall [vd2] inner_form'
            form' = makeNamed ("ga_hom_surj_" ++ show s) form

-- | generates the axioms for the homomorphisms applied to the predicates