/*-------------------------------------------------------------------------*/ /* Benchmark (Boolean) */ /* */ /* Name : bdiag.pl */ /* Title : N adder diagnostic */ /* Original Source: Greg Sidebottom - University of Vancouver Canada */ /* Adapted by : Daniel Diaz for GNU Prolog */ /* Date : September 1993 */ /* */ /* The circuit diagnosis problem is as follows: */ /* */ /*Given: */ /* 1. a description of a digital circuit with a set of components C */ /* 2. a function f computed by the circuit */ /* 3. a symptom consisting of an input output pair (i,o) such that */ /* f(i) <> o */ /* Find: */ /* a diagnosis D. D is a subset of C which, if not working correctly, */ /* could result in the circuit computing o given i. */ /* */ /* The specific circuit used for this benchmark is an N bit adder with */ /* forward carry propagation. However, any combinatorial circuit diagnosis*/ /* problem could easily formulated from it's network description. */ /* This example was constructed based on an example from an article about */ /* Prolog III in CACM July 1990. */ /* The problem consists in finding the minimum number of broken components */ /* in a N bit adder that thinks 0+0=2^N-1 (the answer is always N). */ /* Each adder consists of 5 gates (2 'and', 2 'xor' and 1 'or'). */ /* A boolean (Di) is associated to each gate and it is true (1) if the */ /* gate is broken. The solution is a list of Di. F is the number of broken */ /* components. To minimize F we label it (indomain) first (since there is */ /* no choice point it is correct). */ /* */ /* Solution: */ /* N=1 [0,0,0,0,1] */ /* N=2 [0,0,0,0,1,0,0,0,0,1] */ /* N=3 [0,0,0,0,1,0,0,0,0,1,0,0,0,0,1] */ /*-------------------------------------------------------------------------*/ go:- statistics(runtime,_), top, statistics(runtime,[_,Y]), write('time : '), write(Y), nl. top:- N=3, Z is 1< (U1 #<=> X #/\ Y), #\ D1 #=> (U2 #<=> U3 #/\ C1), #\ D2 #=> (C #<=> U1 #\/ U2), % #\ D3 #=> (U3 #<=> X ## Y), #\ D3 #=> (U3 #<=> X #\ Y), #\ D4 #=> (Z #<=> U3 ## C1), #\ D4 #=> (Z #<=> U3 #\ C1).