#include "dioph.h"

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

Contents


Public Routines in File dioph.c

Index

dionext_combo_bnext_combo_ss
next_combo_anext_combo_cp_ac_basis

Details


int dio(int ab[MAX_COEF],
	int m, int n,
	int constraints[MAX_COEF],
	int basis[MAX_BASIS][MAX_COEF],
	int *num_basis);
This routine generates the basis of solutions to the homogeneous linear diophantine equation given by ab, m, n. It uses Huet's algorithm (Information Processing Letters 7(3) 1978).

The equation has the form a1x1 + ... + amxm = b1y1 + ... + bnyn.

Return value:
int next_combo_a(int length, int basis[MAX_BASIS][MAX_COEF],
		 int num_basis, int constraints[MAX_COEF],
		 int combo[MAX_BASIS], int sum[MAX_COEF],
		 int start_flag);
This routine gets the first or next appropriate subset of the basis of solutions. "Appropriate" means that each variable gets instantiated to something, and there are no top-level rigid symbol clashes. I think of this as a potential unifier, because he caller still has to worry about recursive unification of subterms. We have several algorithms to do this. This implements algorithm A. (For most practical work, the differences in performance are small.)
int next_combo_b(int length, int basis[MAX_BASIS][MAX_COEF],
		 int num_basis, int constraints[MAX_COEF],
		 int combo[MAX_BASIS], int sum[MAX_COEF],
		 int start_flag);
This routine gets the first or next appropriate subset of the basis of solutions. This implements algorithm B. See next_combo_a() for a description.
int next_combo_c(int length, int basis[MAX_BASIS][MAX_COEF],
		 int num_basis, int constraints[MAX_COEF],
		 int combo[MAX_BASIS], int sum[MAX_COEF],
		 int start_flag);
This routine gets the first or next appropriate subset of the basis of solutions. This implements algorithm C. See next_combo_a() for a description.
int next_combo_ss(int length, int basis[MAX_BASIS][MAX_COEF],
		  int num_basis, int constraints[MAX_COEF],
		  int combo[MAX_BASIS], int sum[MAX_COEF],
		  int start_flag,
		  int combos[MAX_COMBOS][MAX_BASIS],
		  int *np,
		  int ss_parm);
This routine gets the first or next appropriate subset of the basis of solutions, subject to the "supserset restriction". It appears to work like the other next_combo routines, but it is not really incremental. To implement the superset restriction, we collect, in combos[] during the first call, up to MAX_COMBOS subsets satisfying the restriction, then give them out in the subsequent calls. The first bunch of parameters are the same as for the other next_combo routines. The rest of the parameters are added for the supserset restriction.
void p_ac_basis(int basis[MAX_BASIS][MAX_COEF],
		int num_basis, int m, int n);
This routine prints (to stdout) a basis of solutions.

Public Definitions in File dioph.h

#define MAX_COEF   250  /* total # of coef. from both sides */
#define MAX_BASIS  100  /* must be <= MAX_VARS, because rows are indexed */
#define MAX_COMBOS 200  /* for superset-restricted AC unif. */


Introduction

This package solves linear homogeneous Diophantine equations, which can be used to compute the set of associative-commutative unifiers for a pair of first-order terms. The way this usually works is that you first call dio() to get a basis of solutions, then call one of the the next_combo routines to (incrementally) get the relevant solutions.

The file dioph.c has a main() program, and it can be compiled and linked by itself for testing. The command for doing so is "gcc -DSOLO dioph.c".