2
こんにちはstackoverflowのコミュニティ、 iは、真理値表のための部分式を作成し、プロローグコードを持っているし、その後 がうまくその表現の多くの罰金働いたが、この文を使用して、この使用する方法の部分式
をたまたま偽/彼らは真の値与えます1 ?- phrase(subexprs(bicond(and(impl(A,B),impl(B,A)),bicond(A,B))),Subexprs), bindList([A,B]), maplist(expr_value, Subexprs, Values).
A = B, B = true,
Subexprs = [true impl true, true impl true, (true impl true)and(true impl true), true bicond true, **(true impl true)and(true impl true)bicond(true bicond true)**],
Values = [true, true, true, true, false] .
最後の値が式全体が bicondである代わりに印刷された((真のimpl真)と(真のimpl真)、bicond真)する必要があり、印刷すべきか ない
ここでは私のコード
ですand(A,B) :- A, B.
or(A,_) :- A.
or(_,B) :- B.
equ(A,B) :- or(and(A,B), and(not(A),not(B))).
xor(A,B) :- not(equ(A,B)).
nor(A,B) :- not(or(A,B)).
nand(A,B) :- not(and(A,B)).
impl(A,B) :- or(not(A),B).
bicond(true,true):-true.
bicond(true,false):-false.
bicond(false,true):-false.
bicond(false,false):-true.
:- op(900, fy,not).
:- op(910, yfx, and).
:- op(910, yfx, nand).
:- op(920, yfx, or).
:- op(920, yfx, nor).
:- op(930, yfx, impl).
:- op(930, yfx, equ).
:- op(930, yfx, xor).
:- op(910, yfx, bicond).
subexprs(V) -->
{ var(V), ! },
[].
subexprs(and(L, R)) -->
subexprs(L),
subexprs(R),
[and(L, R)].
subexprs(or(L, R)) -->
subexprs(L),
subexprs(R),
[or(L, R)].
subexprs(impl(L, R)) -->
subexprs(L),
subexprs(R),
[impl(L, R)].
subexprs(nand(L, R)) -->
subexprs(L),
subexprs(R),
[nand(L, R)].
subexprs(nor(L, R)) -->
subexprs(L),
subexprs(R),
[nor(L, R)].
subexprs(xor(L, R)) -->
subexprs(L),
subexprs(R),
[xor(L, R)].
subexprs(bicond(L, R)) -->
subexprs(L),
subexprs(R),
[bicond(L, R)].
expr_value(Expr, true) :-
call(Expr),
!.
expr_value(_Expr, false).
bind(true).
bind(false).
bindList([]).
bindList([V|Vs]) :- bind(V),bindList(Vs).
私が間違っている部分がOP だと思いますが、私はbicond/2
のあなたの現在の定義では、それを
bico ditionalの厳密な定義を教えてもらえますか? –