-- | generates the axiom for the homomorphism applied to a concrete op
homomorphism_form_op :: Id -> OpType -> Named CASLFORMULA
homomorphism_form_op name (OpType _ args res) = named_form
      where free_args = map mkFreeName args
            vars_lhs = createVars 0 free_args
            ot_lhs = Op_type Total free_args (mkFreeName res) nullRange
            ot_hom = Op_type Partial [mkFreeName res] res nullRange
            name_hom = mkQualOp homId ot_hom
            name_lhs = mkQualOp (mkFreeName name) ot_lhs
            inner_lhs = mkAppl name_lhs vars_lhs
            lhs = mkAppl name_hom [inner_lhs]
            ot_rhs = Op_type Total args res nullRange
            name_rhs = mkQualOp name ot_rhs
            inner_rhs = apply_hom_vars args vars_lhs
            rhs = mkAppl name_rhs inner_rhs
            form = mkStEq lhs rhs
            form' = quantifyUniversally form
            named_form = makeNamed "" form'

-- | generates the variables for the homomorphisms
homomorphism_form_op :: Id -> OpType -> Named CASLFORMULA
homomorphism_form_op name (OpType _ args res) = named_form
      where free_args = map mkFreeName args
            vars_lhs = createVars 0 free_args
            ot_lhs = Op_type Total free_args (mkFreeName res) nullRange
            ot_hom = Op_type Partial [mkFreeName res] res nullRange
            name_hom = mkQualOp homId ot_hom
            name_lhs = mkQualOp (mkFreeName name) ot_lhs
            inner_lhs = mkAppl name_lhs vars_lhs
            lhs = mkAppl name_hom [inner_lhs]
            ot_rhs = Op_type Total args res nullRange
            name_rhs = mkQualOp name ot_rhs
            inner_rhs = apply_hom_vars args vars_lhs
            rhs = mkAppl name_rhs inner_rhs
            form = mkStEq lhs rhs
            form' = quantifyUniversally form
            named_form = makeNamed "" form'

-- | generates the variables for the homomorphisms
homomorphism_form_op name (OpType _ args res) = named_form
      where free_args = map mkFreeName args
            vars_lhs = createVars 0 free_args
            ot_lhs = Op_type Total free_args (mkFreeName res) nullRange
            ot_hom = Op_type Partial [mkFreeName res] res nullRange
            name_hom = mkQualOp homId ot_hom
            name_lhs = mkQualOp (mkFreeName name) ot_lhs
            inner_lhs = mkAppl name_lhs vars_lhs
            lhs = mkAppl name_hom [inner_lhs]
            ot_rhs = Op_type Total args res nullRange
            name_rhs = mkQualOp name ot_rhs
            inner_rhs = apply_hom_vars args vars_lhs
            rhs = mkAppl name_rhs inner_rhs
            form = mkStEq lhs rhs
            form' = quantifyUniversally form
            named_form = makeNamed "" form'

-- | generates the variables for the homomorphisms