Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello. I am posting this question for the 5th time now. The previous answers are wrong or incomplete. Please dont waste my question by copy

Hello. I am posting this question for the 5th time now. The previous answers are wrong or incomplete. Please dont waste my question by copy pasting those again here. Please show the output for your code with the sample examples given to show me how to use your code. The previous ones were giving wrong output with the sample inputs given in the question. Please dont copy paste from previous one. Please.

image text in transcribedimage text in transcribedimage text in transcribed

CS 421, Assignment 1 Write a program in C++ that implements the following unification algorithm. Unify(E1,E2) If ( both E1 and E2 are constant or empty ) \{ If ( E1=E2 ), then return \{\} Else return FAIL \} If ( E1 is a variable) \{ If E1 occurs in E2, then return FAIL Else return \{E2/E1\} \} If ( E2 is variable) \{ If E2 occurs in E1, then return FAIL Else return {E1/E2} \} If ( E1 or E2 is empty), then return FAIL HE1 = first element of E1 HE2 = first element of E2 SUBS1 = unify (HE1, HE2) If (SUBS1 = FAIL) then return FAIL TE1 = apply SUBS1 to rest of E1 TE2 = apply SUBS1 to rest of E2 SUBS2 = unify ( TE1,TE2) If (SUBS2 = FAIL) then return FAIL Else return composition(SUBS1, SUBS2) E1 and E2 are two terms where variables start with upper case letters and function/constant symbols start with lower case letters. You need to consider "Occur Check". Example This is an implementation of the unification algorithm. Please enter the first term: a Please enter the second term: X The unifier is: X=a Please enter the first term: X Please enter the second term: Y The unifier is: Y=X Please enter the first term: X Please enter the second term: f(Y) The unifier is: X=f(Y) Please enter the first term: X Please enter the second term: h(a,Y) The unifier is: X=h(a,Y) Example Please enter the first term: f(f(X,Y),X) Please enter the second term: f(f(V,U),g(U,Y)) The unifier is: X=V,Y=U,V=g(U,U) Please enter the first term: f(f(X,Y),X$) Please enter the second term: f(f(V,U),g(U,Y)) The unifier is: Invalid Please enter the first term: X Please enter the second term: f(X) The unifier is: there is no unifier

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions