Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are designing a system for managing software packages on a computer. To that end, you will have information about the available software packages, stored

You are designing a system for managing software packages on a computer. To that end, you will have information about the available software packages, stored in the form of Prolog facts. The types of facts are as follows: package(package_name) Package_name is the name of a package which is available on the system. depends(p1,p2) Indicates that package p1 depends on package p2 (meaning that p1 can only be installed if p2 is also installed). Any package may have multiple dependencies. You can and should make up your own facts to test your code, although be sure to keep the same format for the facts, because we can and will replace your facts with our own for testing. You may assume that there are no circular dependencies represented in the facts. Given the facts above, you are to provide predicates which will perform the following 5 tasks: 1. valid_list(L) Returns true when every element in list L is the name of a package which is available on the system. 2. unsatisfied_dependency(P,L) Returns true when P is a dependency of some member of L, but P is not a member of L itself. 3. unsatisfied_dependency(L) Returns true when any member of L has an unsatisfied dependency. 4. dependency_check(L) Returns true when L has no unsatisfied dependencies. 5. ext_depends(P1,P2) Returns true when P1 depends on package P2, either directly or inderectly by some sequence of of dependencies. You may use some of the predicates you've written as part of another predicate, and you may write your own helper predicates to assist you in writing your code (for example, a notmember predicate would make sense). If you've written your rules well, then a calls to valid_list and dependency_check would tell you if a list of packages names could potentially be installed on your system. You may NOT use any Prolog built-in calls (including not(X)), and you may not use the not operator or not equals operator for this project. 

?

valid_list(L) Returns true when every element in list L is the name of a package which is available on the system.

let ...

package(one)

package(two)

package(three)

.......

package(ten) then if

valid_list([one]) --- return true,

valid_list([one,two]) ------ return true

valid_list([zero]) ---- return false

unsatisfied_dependency(P,L) Returns true when P is a dependency of some member of L, but P is not a member of L itself.

let .......

depends(a,b)

........ then

unsatisfied_dependency(a,[a,b,c,d,e,f]) .........return false

unsatisfied_dependency(b,[a,c,d,e,f]) .........return false

unsatisfied_dependency(a,[b,c,d,e,f]) .........return true

unsatisfied_dependency(L) Returns true when any member of L has an unsatisfied dependency.

let .....

depends(a,b)

........ then

unsatisfied_dependency([a,b,c,d,e,f]) ........... return false
unsatisfied_dependency([b,c,d,e,f]) ........... return true
unsatisfied_dependency([c,d,e,f]) ........... return false
dependency_check(L) Returns true when L has no unsatisfied dependencies.

let .....

depends(a,b)

........ then

unsatisfied_dependency([a,b,c,d,e,f]) ........... return true
unsatisfied_dependency([b,c,d,e,f]) ........... return false
unsatisfied_dependency([c,d,e,f]) ........... return true
ext_depends(P1,P2) Returns true when P1 depends on package P2, either directly or inderectly by some sequence of of dependencies.

let ............

depends(a,b). depends(b,d). depends(d,f).?......... then

ext_depends(a,b)....................true.

ext_depends(a,f)....................true.

ext_depends(b,c)....................false......

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

Web Database Development Step By Step

Authors: Jim Buyens

1st Edition

0735609667, 978-0735609662

More Books

Students also viewed these Databases questions

Question

What does the illustration of the Canyon mean to you as a leader?

Answered: 1 week ago

Question

Why could the Robert Bosch approach make sense to the company?

Answered: 1 week ago