Question: (Substitution in Prolog) Implement substitution for rst-order logic in Prolog by completing the stub below. You do not have to avoid variable capture. Explain the
(Substitution in Prolog) Implement substitution for rst-order logic in Prolog by completing the stub below. You do not have to avoid variable capture. Explain the problem of variable capture using the three test inputs as examples. % We use a simple fragment of rst=order logic % truth for truth % conj(F,G) for conjunction % univ(x,F) for universal quantication % applyF(p,L) for applications of predicate p (a string) to list L of terms % vr(x) for variables where x is a string % applyT(f,L) for applications of function f (a string) to list L of terms % We represent substitutions as list S=[(x,t),...] where x is a variable and t a term % lookup(S,X,T) hold if S contains (X,T) % subsF(F,S,F2) holds if formula F2 arises from F via substitution S % subsT(T,S,T2) holds if term T2 arises from T via substitution S % subsTs(Ts,S,T2) holds list of terms Ts2 arises from Ts via substitution S % test inputs: % subsF(univ("x",applyF("p",[vr("x")])),[("x",vr("y"))],F) % subsF(univ("y",applyF("p",[vr("x")])),[("x",vr("y"))],F) % subsF(univ("y",applyF("p",[vr("x")])),[("x",vr("z"))],F)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
