#include "putnam.h"

This page has information from files putnam.h and putnam.c.

Contents


Public Routines in File putnam.c

Index

dp_append_clausedp_first_modeldp_next_modelfprint_dp_report
dp_atom_valuedp_get_modeldp_p_modelfprint_putnam_mem
dp_canceldp_initfprint_dp_preprocess_reportp_putnam_mem

Details


DP_rc dp_append_clause(DP_state dp, int clause[], int number_of_literals);
This routine adds a propositional clause to a Davis-Putnam set. The clause is an array of non-zero integers (atoms are positive integers). (If the set of clauses has n atoms, it is most efficient to name them 1, 2, ..., n.)

Clauses cannot be added to the set after dp_first_model() has been called. If you try to do so, a fatal error will occur.

The return codes are


int dp_atom_value(DP_state dp, int atom);
This routine returns the current value of an atom. It assumes you have a model (that is, dp_first_model() or dp_next_model() just returned OK_RETURN). The return is ATOM_TRUE or ATOM_FALSE. If the atom is out of range, ATOM_FALSE is returned.
void dp_cancel(DP_state dp);
This routine deallocates a DP_state. It should be called if This routine should not be called if If the "final_report" flag was given to dp_init(), the report is printed (to stdout).
DP_rc dp_first_model(DP_state dp);
This routine starts the Davis-Putnam search. The return codes are
void dp_get_model(DP_state dp, int **literals, int *num_literals);
This routine can be called to retrieve the current model after dp_first_model() or dp_next_model() returns with OK_RETURN. The form of the model is an array (*literals) of nonzero integers (sorted by absolute value) giving the literals true in the model. The size of the array (*num_literals) is the number of atoms in the set of clauses.
DP_state dp_init(int seconds_limit,
		 int megabyte_limit,
		 BOOL subsume,
		 FILE *report_file);
This routine allocates a DP_state for a Davis-Putnam search.
DP_rc dp_next_model(DP_state dp);
This routine continues the Davis-Putnam search. The return codes are
void dp_p_model(DP_state dp);

void fprint_dp_preprocess_report(FILE *fp, DP_state dp);
This routine prints (to FILE *fp) a report containing all statistics for a Davis-Putnam search.
void fprint_dp_report(FILE *fp, DP_state dp);
This routine prints (to FILE *fp) a report containing all statistics for a Davis-Putnam search.
void fprint_putnam_mem(FILE *fp, BOOL heading);
This routine prints (to FILE *fp) memory usage statistics for data types associated with Davis-Putnam. The Boolean argument heading tells whether to print a heading on the table. (This does not include the vast majority of the DP memory usage, which is managed privately. See fprint_dp_report().)
void p_putnam_mem();
This routine prints (to stdout) memory usage statistics for data types associated with Davis-Putnam. (This does not include the vast majority of the DP memory usage, which is managed privately. See fprint_dp_report().)

Public Definitions in File putnam.h

typedef struct dp_state * DP_state;

/* return codes for first_model(), next_model(), and dp_insert_clause() */

typedef enum { OK_RETURN,
	       NO_MODEL_RETURN,
	       TIME_OUT_RETURN,
	       MEMORY_OUT_RETURN,
             } DP_rc;

/* values of propositional variables */

#define ATOM_FALSE          0
#define ATOM_TRUE           1
#define ATOM_NOT_ASSIGNED   2


Introduction

This package is an implementation of the Davis-Putnam procedure for testing satisfiability of propositional CNF formulas. It uses a straightforward algorithm. The selection function is to use the first literal in the first, shortest positive clause.

The search is incremental, returning models as they are found. How to use the package:

If you go through the complete sequence of models with calls to dp_first_model() and dp_next_model(), you don't necessarily get all of the models. The reason is that if the search gets to a state with no positive clauses, it simply makes all remaining atoms false, and reports a model. For example, with the two clauses (-1 | -2) and (-3), one model (everything false) will be reported, but there are actually 2 more models.

These activities are projects of the Mathematics and Computer Science Division of Argonne National Laboratory.