Briefly explain these main programming paradigm

Assignment Help Programming Languages
Reference no: EM131251876

PRINCIPLES OF PROGRAMMING LANGUAGES ASSIGNMENT-

Question 1: Briefly explain these main programming paradigm (Logic, Functional, Object Oriented, Procedural, Imperative and Aspect-oriented), and for each of these paradigms name at least one language that can be used for programming in that paradigm. 

Question 2:  Which of the following pairs of terms can be unified (matched) together? Where relevant, give the variable instantiations that lead to successful unification.  (Note = shows unification)

healtyFood(X) = healtyFood(bread)

healtyFood(bread,X) = healtyFood(Y,salad)

healtyFood(bread,X,milk) = healtyFood(Y,salad,X)

healtyFood(X) = Y

meal(healtyFood(bread),drink(milk)) = meal(X,Y)

meal(healtyFood(bread),drink(milk)) = meal(X, drink(Water))

meal(healtyFood(bread), Y) = meal(X, drink(water))

breakfast(healtyFood(bread),egg,milk)= breakfast(healtyFood(Y),Y, Z)

Question 3: The Purpose of this question is to write a Prolog Program which describes a directed graph (G), with the following structure (shown below) and allows us to ask some questions about this graph.

1153_Figure.png

A) Write all possible node and edge facts that describes the structure of this graph G such as below:

node( a ).  %  "a" is a node of this graph.

edge( a, b ).  % There is an edge (directed) from node "a" to "b".

B) Complete the definition all these rules.

node(X) :-  %  X is a node in graph G

edge( X, Y) :- % There is an directed edge from X to Y.   

parent( X, Y) :- %  There is a directed edge from X to Y.

child(X, Y) :- %  Y is parent of X.

path( X, Y) :- % find a directed path from node X to node Y.

length_of_path( X, Y):- % Length of a path (directed) from X to Y.

connected(  X, Y):- % There is a directed path from X to Y, or from Y to X

undirected_edge( X, Y) :-  /* There is  an edge (ignoring the directions) from X to Y or from Y to X     */

undirected_path( X, Y):- /* find a path  (ignoring the directions) from node X to node Y.  */

C) Create a knowledge base (KB) based on all the facts and rules you have written in parts (A), and (B), and save it in a prolog program file called "my_grapghG.pl", and show a printout of your file here.

D) Run this Prolog program, and write 4 queries about each of those rules that you have created in part B in order to test those rules, and show your queries and their results, and test the correctness of your results.

(Note: you should write and test two ground quires (one with positive and one with negative answer) and two non-ground quires for each of the rules that you have created in Part B.)

E) Add the following rule to your program, and test it and describe its function?

Question 4: Assume we have the following knowledge base in a Prolog program:

man(jack).

man(peter).

woman(rebeca).

woman(julia).

woman(maria).

hasWand(rebeca).

hasWand(maria).

hasWand(jack).

quidditchPlayer(jack).

quidditchPlayer(rebeca).

quidditchPlayer(maria).

quidditchPlayer(peter).

playsAirGuitar(julia).

playsAirGuitar(adam).

playsAirGuitar(rebeca).

playsAirGuitar(mary).

playsAirGuitar(jack).

wizard (jack).

hasBroom(X) :- quidditchPlayer(X).

warlock(X) :- man(X), hasBroom(X), hasWand(X).

witch(X) :- woman(X), hasBroom(X), hasWand(X).

wizard(X):- warlock(X) ; witch(X).   % note: semicolon was used here

A) Determine type of each of the following queries (ground/non-ground), and explain what will Prolog respond for each of these queries (write all the steps of unifications and resolutions for each query)? 

?  -wizard(jack).

? -witch(jack).

? -warlock(jack).

? -witch(maria).

? -warlock(Y).

? -witch(Y).

? -wizard(X).

? -hasBroom(X).

? -playsAirGuitar(Y), witch(Y).

B) Implement your facts & rules as a Prolog program and test all quires in part B. 

Question 5: Write the following rules for lists in a Prolog program and try corresponding queries for each case.

A) my_length(List, Nr).  % find the length of a given list.

?- my_length([a,b,[c,d], e, [f, g]],R).

?- my_length( [ [ ], [ ] ], R).

?- my_length( [ [ [ ] ] ], R).

?- my_length([a,b,[c,d],e],4).

B) my_append(L1,L2,New_list).  % append two given lists L1, L2, and return a new list.

?- myappend([a,b],[c],R).

?- myappend( _ ,[e,s],[f,o,x,e,s]).    

?- myappend(X,[e,s],[f,o,x,e,s]).  

?- myappend(X,Y,[a,b,c]).

C) mymember(X, L).    % test if X is a member of list L. 

?- mymember( a, [ [ ], a, b, c, f]).

?- mymember( X, [ [ ], a, b, c, f]).

?- mymember( [m k], [ [m k], a, b, c, f]).

?- mymember( X, [ [ ], [ [ ] ] , a, b, c, f]).

Attachment:- Assignment.rar

Reference no: EM131251876

Questions Cloud

Rational and emotional aspects of leadership : Explain and illustrate the rational and emotional aspects of leadership. Compare and contrast leadership and management.
Calculate the average daily water demand : Draw a mass diagram, and determine the storage required to supply a community of 6000 persons, if the water demand is 450 UpersoNday - Calculate the average daily water demand for the town in 15 years time, assuming that the average domestic consum..
How candidates may address incumbency beyond method identify : Discuss the incumbency advantage and how candidates may address it beyond methods identified in the text. Particularly, targeting specific demographics. Your response should be approximately three to five paragraphs in length.
Find the reaction components : The figure shows a T-frame with a simple sixed support in A and a simple roller bearing at B, permitting motion at 45?. A vertical force P is acting at the tip in D.
Briefly explain these main programming paradigm : COMP348 PRINCIPLES OF PROGRAMMING LANGUAGES ASSIGNMENT. Briefly explain these main programming paradigm (Logic, Functional, Object Oriented, Procedural, Imperative and Aspect-oriented), and for each of these paradigms name at least one language tha..
Company historical resident trends : Your manager has decided it would be beneficial to expand into this town by opening a satellite office. She is eager to be the first home health company to open a physical office in this new territory and has tasked you with developing a marketing..
What do you think are john major problems as a salesperson : What first-meeting approach might John use to win over "gatekeepers" such as receptionists and administrative secretaries? What kind of training program do you think EBCC has for new salespeople? What would you suggest that the program include?
Determine the distribution of the internal forces n q and m : Determine the reactions. Note that the reaction in B is conveniently represented by its horizontal and vertical components R B = RB.
Disruptive innovation in healthcare : Identify a disruptive innovation in healthcare (i.e. one that completely changed the market). Why was t revolutionary? How did it change healthcare? How can you be prepared for change?

Reviews

len1251876

10/22/2016 1:10:31 AM

Your submission must include a README.txt file that includes the following information: Students Full Name, Students ID, Difficulties (outlining difficulties will help the TA’s/Markers focus on repairing weaknesses), Additional comments (anything deemed important for marking purposes). Please give meaningful names to each program file, folder to make the feedback or correction process easier. All files relating to each Question must be placed in its own folder named Q-# where # is the number corresponding to the exercise. All the exercise folders must then be placed into a single assignment folder named: studentID-assignment-1. The assignment folder must be compressed into a zip file and submitted through EAS on the correct folder (Programming Assignment_1). For example, for the first assignment, student 123456 would submit a zip file containing all the files and folders related to this assignment named a1_123456.zip, and will upload it to EAS.

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd