Dies ist ein Prolog-Programm, das die Syntax der Aussagenlogik definiertAussagenlogik Teilformel in Prolog
So versuche ich bin fest zu finden, wo X eine Unterformel von Y. ist Ich habe die folgenden Prädikate gemacht, aber ich bin Probleme mit diesem haben. Ich bin mir nicht sicher, was ich danach machen soll. Ich weiß, dass ich überprüfen muss, ob X und Y Formeln sind, aber ich verstehe den nächsten Schritt nicht.
at(a). % Our first atom.
at(b). % Our second atom.
%fmla shows if it is a formula or not
fmla(X):- at(X). % an atom is a formula
fmla(neg(X)) :- fmla(X). % neg(F) is a formula if F is a formula
fmla(or(X,Y)) :- fmla(X), fmla(Y). % or(F,G) is a formula if F and G are formulas
fmla(and(X,Y)) :- fmla(X), fmla(Y). % and(F,G) is a formula if F and G are formulas
fmla(imp(X,Y)) :- fmla(neg(X)), fmla(Y). %imp is a formula when not F and G are formulas
fmla(iff(X,Y)) :- fmla(imp(X,Y)), fmla(imp(Y,X)). %Double implication
sub(X,Y) :- fmla(X), fmla(Y).
Ich möchte einige Ideen, wie Sie die Subformel Teil lösen.
Hey, das sieht gut aus. Jetzt verstehe ich es tatsächlich. Es ist ein wenig langweilig, aber es ist nicht so schlecht zu programmieren. Aber was bedeuten die Unterstriche? Wie ich sie entfernt habe und es sagte, es war ein Singleton variabler Fehler, aber ich bin mir nicht sicher, was das bedeutet. –
[Hier] (http://stackoverflow.com/questions/14238492/prolog-anonymous-variable) ist eine sehr gute Erklärung dafür. ;-) – tas