Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started