def certificate_size(rf, mode):
    """returns the certificate dimension w.r.t. a given mode and RF

    :param rf: the RF
    :type rf: model.ReachabilityForm
    :param mode: either 'min' or 'max'
    :type mode: str
    :return: certificate dimension
    :rtype: int
    """
    assert mode in ["min", "max"]
    C, N = rf.system.P.shape
    if mode == "min":
        return N-2
    else:
        return C-2