I need to convert the following propositions into prolog code and I have do not understand how the operators work. I usually use java.
"Jeans are only casual, dress pants are only formal, kakis are only semi-formal, belts are not casual, black socks are acceptable anytime. Casual = C, Semi-Formal = SF, Formal = F, Jeans = J, Dress pants = DP, Kakis = K, Belts = B, Black socks = BS. J -> C, DP -> F, K -> SF, B -> !C, BS -> (C v SF v F)"
Here is the code I already have:
casual(jeans).
formal(dress_pants, belt, black_socks).
semiFormal(khakis).
formal(belt).
semiFormal(belt).
casual(black_socks).
formal(black_socks).
semiFormal(black_socks).
Informally, a unary predicate
pcan be viewed as a set P and, consequently, a literalp(X)can be viewed as the set membership test X∈P. Therefore, a goalp(X)will be true or false (i.e., a proposition), depending on whether X belongs to the set P or not.The sentences "Jeans are only casual, dress pants are only formal, kakis are only semi-formal, belts are not casual, black socks are acceptable anytime." can be represented as the sets:
And these sets can be represented in Prolog by the facts:
Here are some Prolog queries about these facts: