I am quite new to prolog, and I have some basic questions...
I don't know if "vocabulary" is the right world in English, but I need to create one to describe an electronic circuit.
My problem is, how do I create these functions and how I use the "=" statement since prolog doesn't seems do accept it?
I'm using SWI Prolog.
That's what I have to put in prolog:
Decide the vocabulary (Predicates, functions, constants):
Ports are represented by constants (X1, X2, ...) –
Gate(X1)
Type(X1) = Xor – types: AND, OR, XOR or NOT
Circuits(C1)
Terminals(x) – returns inputs and outputs of x
In(1, X1) – function that returns first input of X1
Out – function that returns output
Arity(c, i, j) – function, circuit c has i inputs and j outputs
Connected(Out(1, X1), In(1, X2)) - which ports are connected
Signal(t) – signal value for terminal t.
That's what I tried until now. I don't think my approach to the "=" is right...
gate(x1).
gate(x2).
gate(a1).
gate(a2).
gate(o1).
type(x1, xor).
type(x2, xor).
type(a1, and).
type(a2, and).
type(o1, or).
circuit(c1).
Should i use an predicate named Equal(X, Y) ?, like "equal (type(x1), xor).
How should I implement these?
Gate(X1) , Type(X1) = XOR
Gate(X2) , Type(X2) = XOR
Gate(A1) , Type(A1) = AND
Gate(A2) , Type(A2) = AND
Gate(O1) , Type(O1) = OR
I don't know how to continue from here. All my approaches trying to implement the functions seems to be wrong (can't consult).