Question: Write a context-free grammar for Datalog Rules. A Datalog rule is of the form: p :- q1, ..., qn. where n>0 and p, q1, ...,
Write a context-free grammar for "Datalog Rules". A Datalog rule is of the form:
p :- q1, ..., qn.
where n>0 and p, q1, ..., and qn are atomic formulas of the form:
r(x1, ..., xm)
where m>0 and r is a relation name and x1 , ..., xm are either numbers or variables. Relation names and variables are made up of lower-case alphabetic letters or digits and start with a lower-case alphabetic letter. Numbers are positive integers or zero. Some examples of Datalog rules are:
ancestor(x1,y1) :- parent(x1,y1). teaches(tno,cno) :- faculty(tno), course(cno), assigned(tno,cno). p(x,y) :- q(2,x), r(y,45,z), s(a,b,22).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
