def to_dimacs(cnf):
    """
    An alternative to `pynusmv.bmc.ltlspec:dump_dimacs_filename` which generates
    less verbose dimacs files and permits to have them all loaded in memory.
    
    :param cnf: a `BeCnf` expression to encode in dimacs format
    :return: a string representation of the `cnf` formula in DIMACS CNF format
    """
    heading = 'p cnf {} {}'.format(cnf.vars_number, cnf.clauses_number)
    d_clauses = [heading]
    for clause in cnf.clauses_list:
        text_form = ' '.join(map(str, clause)) + ' 0'
        d_clauses.append(text_form)
    return '\n'.join(d_clauses)
