Write a Prolog program to implement parts of the DRC Interpreter.
The well-formed formulas of DRC will be represented as function terms in
Prolog. Here are some examples.
Here is Prolog code for storing relations db.pl.
Here are the predicates that you will code in SWI-Prolog:
1. wff(F): returns true if F is a wff, false otherwise. 2. freeVariables(F,L): Given a wff F, returns all the free variables of F in L. 3. orSafetyCheck(or(F,G)): returns true if or(F,G) is safe, false otherwise. 4. limitedVariables(F,L): Given a wff F, returns all limited variables amongst the free variables of F in L. You may assume that the wffs do not have the "chain" of eq predicates (e.g. eq(X,Y), eq(Y,Z),..) 5. maxSC(F,M): Given a wff F, returns a list of maximal sub-conjuncts in M. Each subconjunct is a sub-formula of F. 6. safe(F): returns true if wff F is safe. 7. schemaCheck(F) : returns true if predicate names are proper and predicate arities are proper and type checks out properly for constants and repeated variables. we will assume that the database schema and instances are available in Prolog predicates as follows: ?-dynamic(relation/4). relation(c1,[city],[string],[["Atlanta"],["Duluth"],["Wichita"],["Dodge City"]]). relation(c2,[city],[string],[["Carson City"],["Duluth"],["Chennai"]]). relation( suppliers, [sno,sname,city], [string,string,string], [["S1","Jones","Atlanta"], ["S2","Smith","Duluth"], ["S3","Blake","Marietta"]] ). relation( parts, [pno,pname,color,city], [string,string,string,string], [["P1","Nut","Red","Duluth"], ["P2","Bolt","Blue","Marietta"], ["P3","Screw","Red","Dunwoody"], ["P4","Axle","Green","Marietta"]] ). relation( projects, [jno,jname,city], [string,string,string], [["J1","Bicycles","Duluth"], ["J2","Motorcycles","Dunwoody"]] ). relation( spj, [sno,pno,jno,qty], [string,string,string,number], [["S1","P1","J1",100], ["S1","P2","J2",100], ["S1","P1","J2",100], ["S2","P1","J1",100], ["S2","P3","J1",100], ["S2","P3","J2",100], ["S3","P1","J1",100], ["S3","P2","J2",100]] ). Note: For string(X) built-in to work, you must include the following in the beginning of your program: ?-set_prolog_flag(double_quotes,string).