In a method for using a digital computer to generate, responsive to graphical input, a computer program constituting an executable model of a system represented by a plurality of Petri nets which in turn are represented to the computer as one or more data bases of known structure, each Petri net being assembled from places, transitions, arcs, arc-expressions which are related in terms of variables, arc inscriptions, tokens and other constituent elements, each such constituent element being represented in the data bases by appropriate computer program code, said model being executable to allow both analysis and simulation of said system, the steps of operating the computer to:
- a. determine whether there are any unbound variables in the nets and, if not, proceeding with step j, but otherwise proceeding with step b;
- b. determine whether there are any unprocessed input arcs and, if not, skipping to step g;
- c. select an unprocessed input arc;
- d. substitute for all bound variables occurring in an input arc-expression corresponding to the selected input arc the values to which those variables are bound;
- e. perform any function applications that may now be carried out;
- f. pattern-match said input arc-expression against each of the tokens in a current marking of a selected input place associated with the corresponding selected input arc, and
- (i) if any constants and/or already bound variables in the arc-expression are incompatible with the current marking, to return a failure message, and continue processing with step b but treating a previously bound variable as now unbound,
- (ii) if the arc-expression contains function applications (including infix operators) which cannot yet be evaluated due to the presence of unbound variables, to mark and ignore the arc-expression, and continue processing with step b,
- (iii) if the pattern match succeeds, to add newly bound variables to a proposed binding, recursively calling steps b-f for each matchable value and for each match found, to return a success message and continuing with step g, but otherwise to return a failure message and return to step a;
- g. check each marked arc-expression to determine if it is now evaluable and, if so, to branch to step a and repeating steps a-f until there are no more unbound variables or no more evaluable arc expressions;
- h. determine, if there are no evaluable marked arc-expressions, for each still-unbound variable, whether the variable (a) only occurs in output arc expressions or (b) occurs in input arc expressions that are marked and remain unevaluable;
- i. generate for the latter, if the variable is of a color set (i.e. type) with only a small number of values, a possible binding as if there had been a match, and if the variable is of a large color set, to generate a possible value by a random selection;
- and
- j. evaluate arc functions.