Explain AI problem 2 3 4 5 6 7 1B
PAGE NO 01
What is depth first search? Explain algorithm and advantages 03 06 07 12 14 54 solved in 2007 old syllabus 15 17 18 19 21 22 iv. Cons  25
2A what is representation and reasoning 2B explain the term iteration and recursion related to AI 3A explain water jug problem 3B solve the problem by decomposable method sin2xcos2dx 4A explain any four built in functions of lisp
8 9 10 11 12 13
4B what is predicates in lisp explain any two 5A write a lisp program to fib Fibonacci series 5B write a lisp program to find a factorial of a given number 6A briefly explain the structure of a prolog program 6B write the step procedure to compile and execute a program 7 explain the following with example i. null 22 ii. setf  23 iii. Format  24
14 15
8A write a lisp program to find frequency of a number in a sinen list 8B What is recursion? Write a program using recursive concept to find sun of natural number
27 28
SN 16 17 18 19 20 21 22 23 24
QUESTION it is useful to structure AI. Production system provide such structure? discuss in detail Explain various characteristics of problem explain state space representation for water jug problem differentiate between depth first versus breadth first search method what is heuristics? Explain any heuristic search method define matching. Explain any one matching technique how do you represent the knowledge using predicate logic discuss unification algorithm define predicate an objects in prolog. Discuss various types of objects used in prolog
P. NO 30 32 36 39 40 42 43 47 49
25 R 26
write a prolog program to generate Fibonacci series explain various list processing functions of LISP write a program in LISP to find the factorial of a given number N i. without recursion  57 ii. with recursion  60 write a prolog program to verify username and password list the similarities and differences between prolog and conventional programming languages write a short notes on a. b. c. d. forward versus backward reasoning structure of prolog program repeated in 2007 characteristics of knowledge  66 syntax and semantics of propositional logic  66
52 54 57
27 28
7.A 7.B
61 62
29
64
SN 30 31
QUESTION What is AI? Explain different AI techniques explain application area of AI explain production system in detail discuss traveling salesmans problem discuss state space representation for water jug problem Explain any heuristic research method
P. NO 72 73
REPEATED IN
32
4.A 4.B
explain various characteristics of problem list the various differences between depth first and breadth first search method explain structures of a prolog program write a prolog program to generate Fibonacci numbers write a prolog program to find sun of n natural numbers write the similarities and differences between prolog and conventional programming languages write various list processing function of LISP write a program in LISP to find the largest of three numbers write short notes on any two of the following i. ii. iii. forward verses backward reasoning characteristics of knowledge syntax and semantics of propositional logic 79 78
7.A 34 7.B 8
2007
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! Artificial intelligence 1. 1.A WHAT IS AI? EXPLAIN AI PROBLEM AI is The branch of computer science concerned with making computers behave like humans. The term was coined in 1956 by John McCarthy at the Massachusetts Institute of Technology. includes Artificial intelligence includes: games playing: programming computers to play games such as chess and checkers expert systems : programming computers to make decisions in reallife situations (for example, some expert systems help doctors diagnose diseases based on symptoms) natural language : programming computers to understand natural human languages neural networks : Systems that simulate intelligence by attempting to reproduce the types of physical connections that occur in animal brains robotics : programming computers to see and hear and react to other sensory stimuli Currently, no computers exhibit full artificial intelligence (that is, are able to simulate human behavior). The greatest advances have occurred in the field of games playing. The best computer chess programs are now capable of beating humans. In May, 1997, an IBM supercomputer called Deep Blue defeated world chess champion Gary Kasparov in a chess match. In the area of robotics, computers are now widely used in assembly plants, but they are capable only of very limited tasks. Robots have great difficulty identifying objects based on appearance or feel, and they still move and handle objects clumsily.
Naturallanguage processing offers the greatest potential rewards because it would allow people to interact with computers without needing any specialized knowledge. You could simply walk up to a computer and talk to it. Unfortunately, programming computers to understand natural languages has proved to be more difficult than originally thought. Some rudimentary translation systems that translate from one human language to another are in existence, but they are not nearly as good as human translators. There are also voice recognition systems that can convert spoken sounds into written words, but they do not understand what they are writing; they simply take dictation. Even these systems are quite limited  you must speak slowly and distinctly.
2007
In the early 1980s, expert systems were believed to represent the future of artificial intelligence and of computers in general. To date, however, they have not lived up to expectations. Many expert systems help human experts in such fields as medicine and engineering, but they are very expensive to produce and are helpful only in special situations. Today, the hottest area of artificial intelligence is neural networks, which are proving successful in a number of disciplines such as voice recognition and naturallanguage processing. There are several programming languages that are known as AI languages because they are used almost exclusively for AI applications. The two most common are LISP and Prolog. Challenges
It is true that AI does not yet achieve its ultimate goal. Still AI systems could not defeat even a three year old child on many counts: ability to recognize and remember different objects, adapt to new situations, understand and generate human languages, and so on. The main problem is that we, still could not understand how human mind works, how we learn new things, especially how we learn languages and reproduce them properly.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 1
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! Applications
There are many AI applications that we witness: Robotics, Machine translators, chatbots, voice recognizers to name a few. AI tehniques are used to solve many real life problems. Some kind of robots are helping to find landmines, searching humans trapped in rubbles due to natural calamities.
Future of AI
AI is the best field for dreamers to play around. It must be evolved from the thought that making a humanmachine is possible. Though many conclude that this is not possible, there is still a lot of research going on in this field to attain the final objective. There are inherent advantages of using computers as they do not get tired or loosing temper and are becoming faster and faster. Only time will say what will be the future of AI: will it attain humanlevel or above humanlevel intelligence or not.
AI Problem Whenever we have problems we try by all means to solve it. There would be more than one way to solve the problem. So it is required search for better solution from the available solutions. Making the system systematic will solve the problem efficiently. For systematic search knowledge and intelligence are the must. We always try to use machines solve our day to day problems: calculators for calculation, washing machines for washing clothes and so on. But whenever we hear knowledge and intelligence the word computer comes into our mind. Yes, computers can be fed knowledge and intelligence by means of artificial intelligence techniques. There are several search techniques available in the field of artificial intelligence. This article explains some of them. Types of AI search techniques There are two types: uninformed search and uninformed search. This classification is based on the amount of information required for a technique. Uninformed Search We cannot always have sufficient information to solve a problem. When we have less information we have to search blindly and so is the name blind search. The search is like traversing a tree of nodes where each node represents a state. one way is to explore all the nodes in each level and if the solution is not found go on exploring the nodes in the next level. This cycle should repeat till we reach a solution state or we found that there is no solution at all. This technique is known as breadth first search (BFS) because the search is breadthwise. The problem with breadth first search is that it takes a lot of time if the solution is far away from the root node in the tree. If there is a solution then BFS is guaranteed to find it. The exploration can be done depthwise instead of breadthwise. That is, exploring one branch completely till solution is found or it is found that there is no solution. If no solution is found in one branch, backtracking should be done to go back to the previous node and explore in another branch. This technique is called depth first search (DFS). If the goal state exists in an early node in one of the first few branches then depth first search will find it easily, otherwise DFS is no better than BFS. Searching can also be done on both directions: one from the initial state to the goal state and another from the goal state towards the initial state. This approach is called bidirectional search.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 2
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! Informed Search Some we luckily have sufficient information. The information may be a clue or some other information. In this case we can solve the problem in an efficient manner. The information that helps finding the solution is called heuristic information. Heuristic search techniques provide solution to the problems for which we have sufficient information. While traversing the tree, heuristic search decides whether to proceed in the particular direction or not based on the information in hand. So it always selects the most promising successor. Some of the heuristic search techniques are pure heuristic Search, A* algorithm, iterativedeepening A*, depthfirst branchandbound and recursive bestFirst search.
1.B WHAT IS DEPTH FIRST SEARCH? EXPLAIN ALGORITHM AND ADVANTAGES ANSWER 1:
2. 3.
2. 3.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 3
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! ANSWER 2: Formally, DFS is an uninformed search that progresses by expanding the first child node of the search tree that appears and thus going deeper and deeper until a goal node is found, or until it hits a node that has no children. Then the search backtracks, returning to the most recent node it hasn't finished exploring. In a nonrecursive implementation, all freshly expanded nodes are added to a stack for exploration. The depthfirst search explores each possible path to its conclusion before another path is tried. To understand exactly how this works, consider the tree that follows. F is the goal.
A depthfirst search traverses the graph in the following order: ABDBEBACF. If you are familiar with trees, you recognize this type of search as an inorder tree traversal. That is, the path goes left until a terminal node is reached or the goal is found. If a terminal node is reached, the path backs up one level, goes right, and then left until either the goal or a terminal node is encountered. This procedure is repeated until the goal is found or the last node in the search space has been examined. EXAMPLE: For the following graph:
a depthfirst search starting at A, assuming that the left edges in the shown graph are chosen before right edges, and assuming the search remembers previouslyvisited nodes and will not repeat them (since this is a small graph), will visit the nodes in the following order: A, B, D, F, E, C, G. The edges traversed in this search form a Trmaux tree, a structure with important applications in graph theory.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 4
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! Performing the same search without remembering previously visited nodes results in visiting nodes in the order A, B, D, F, E, A, B, D, F, E, etc. forever, caught in the A, B, D, F, E cycle and never reaching C or G. Iterative deepening is one technique to avoid this infinite loop and would reach all nodes.
DFS ALGORITHM
A DFS algorithm, as the name implies, is used to search deeper in the graph, whenever possible. The edges are explored, out of the most recently discovered vertex v that still has unexplored edges leaving it. When all of v's edges have been explored, the search backtracks to explore edges leaving the vertex from which v was discovered. This process continues until we have discovered all the vertices that are reachable from the source vertex. DFS uses stack structure to maintain the order in which the vertices are to be processed. Algorithm: Step 1: Initialize all nodes to ready state (status = 1) Step 2: Push the starting node in stack and change its status to the waiting state (status = 2) Step 3: Repeat step 4 and 5 until stack is empty Step 4: pop the top node n of stack. Process n and change the status of n to the processed state (status = 3) Step 5: Push on to the stack, all the neighbor of n that are in ready state (status = 1), and change their status to the waiting state (status = 2) [End of the step 3 loop] Step 6: exit APPLICATIONS OF DFS ALGORITHM
Finding connected components. Topological sorting. Finding 2(edge or vertex)connected components. Finding 3(edge or vertex)connected components. Finding the bridges of a graph. Finding strongly connected components. Planarity Testing[1][2] Solving puzzles with only one solution, such as mazes. (DFS can be adapted to find all solutions to a maze by only including nodes on the current path in the visited set.) Maze generation may use a randomized depthfirst search. Finding biconnectivity in graphs.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 5
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! 2. 2.A WHAT IS REPRESENTATION AND REASONING is an area of artificial intelligence research aimed at representing knowledge in symbols to facilitate inferencing from those knowledge elements, creating new elements of knowledge. The KR can be made to be independent of the underlying knowledge model or knowledge base system (KBS) such as a semantic network.[1]
A knowledge representation (KR) is most fundamentally a surrogate, a substitute for the thing itself, used to enable an entity to determine consequences by thinking rather than acting, i.e., by reasoning about the world rather than taking action in it. It is a set of ontological commitments, i.e., an answer to the question: In what terms should I think about the world? It is a fragmentary theory of intelligent reasoning, expressed in terms of three components: (i) the representation's fundamental conception of intelligent reasoning; (ii) the set of inferences the representation sanctions; and (iii) the set of inferences it recommends. It is a medium for pragmatically efficient computation, i.e., the computational environment in which thinking is accomplished. One contribution to this pragmatic efficiency is supplied by the guidance a representation provides for organizing information so as to facilitate making the recommended inferences. It is a medium of human expression, i.e., a language in which we say things about the world."
How do people represent knowledge? What is the nature of knowledge? Should a representation scheme deal with a particular domain or should it be general purpose? How expressive is a representation scheme or formal language? Should the scheme be declarative or procedural?
Characteristics
A good knowledge representation covers six basic characteristics:
Coverage, which means the KR covers a breath and depth of information. Without a wide coverage, the KR cannot determine anything or resolve ambiguities. Understandable by humans. KR is viewed as a natural language, so the logic should flow freely. It should support modularity and hierarchies of classes (Polar bears are bears, which are animals). It should also have simple primitives that combine in complex forms. Consistency. If John closed the door, it can also be interpreted as the door was closed by John. By being consistent, the KR can eliminate redundant or conflicting knowledge. Efficient Easiness for modifying and updating. Supports the intelligent activity which uses the knowledge base
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 6
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! this program has a long history of work in the following areas:
Generative planning Reactive planning/control Fuzzy control Evidential reasoning Structured argumentation Automated deduction Knowledge management Agent architectures Distributed reasoning
Applications
Many of the technological innovations that are attributable to the Representation and Reasoning Program were motivated by attempts to address the specific problems of various realworld domains of application. These domains include:
Military planning and scheduling Intelligence analysis Autonomous vehicle control Program composition/synthesis Data fusion and situation assessment Diagnosis and decision support Process control Emergency response planning and action Scientific knowledgebase management
2.B EXPLAIN THE TERM ITERATION AND RECURSION RELATED TO AI Recursion and iteration are two very commonly used, powerful methods of solving complex problems, directly harnessing the power of the computer to calculate things very quickly. Both methods rely on breaking up the complex problems into smaller, simpler steps that can be solved easily, but the two methods are subtlety different. Iteration, perhaps, is the simpler of the two. In iteration, a problem is converted into a train of steps that are finished one at a time, one after another. For instance, if you want to add up all the whole numbers less than 5, you would start with 1 (in the 1st step), then (in step 2) add 2, then (step 3) add 3, and so on. In each step, you add another number (which is the same number as the number of the step you are on). This is called "iterating through the problem." The only part that really changes from step to step is the number of the step, since you can figure out all the other information (like the number you need to add) from that step number. This is the key to iteration: using the step number to find all of your other information. The classic example of iteration in languages like BASIC or C++, of course, is the for loop. If iteration is a bunch of steps leading to a solution, recursion is like piling all of those steps on top of each other and then squashing them all into the solution. Recursion is like holding a mirror up to another mirror: in each image, there is another, smaller image that's basically the same. Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal pg. no: 7
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! This is best explained with an example. How would you tell a computer to see if someone is a descendant of Ghengis Khan? Perhaps the algorithm to define who is and isn't a descendant of Ghengis Khan would look like this: The person is an heir to Ghengis Khan if his/her father is named Ghengis Khan, or his/her father or mother is an heir to Ghengis Khan. Wait, haven't we violated a basic rule that we learned in elementary school  not to use word (in this case, phrase) in its own definition? Well, we aren't exactly using circular logic here, since we aren't saying "an heir to Ghengis Khan is an heir to Ghengis Khan." Let's trace this definition out a bit: Take Jim. He doesn't know it, but he's the direct greatgrandson of Ghengis Khan, through a series of male heirs. Since Jim's father isn't named Ghengis Khan, we have to see if his father is an heir...so, we just try the definition again on his father, just like we did with Jim. Jim's father's father (his grandfather) isn't named Ghengis Khan, so we have to look at Jim's father's father's father (his greatgrandfather). But wait! His greatgrandfather is named Ghengis Khan. So, this means that Jim's grandfather is an heir, which means that his father is an heir, which means that Jim is an heir. If you notice, we went deeper and deeper into the problem, using the same method over and over until we reached something that was new, an "endpoint". After this, we sort of "unwound" the problem until we arrived where we began, except with the problem solved. This kind of "selfcloning" technique of recursion leads to a famous programmer's joke: Recursion /reeker'zhon/: See Recursion So, the difference between iteration and recursion is that with iteration, each step clearly leads onto the next, like stepping stones across a river, while in recursion, each step replicates itself at a smaller scale, so that all of them combined together eventually solve the problem. These two basic methods are very important to understand fully, since they appear in almost every computer algorithm ever made.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 8
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! A Sierpinski triangle dividing the sides of each triangle forms a confined recursion of triangles.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 9
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! Answer 2:
Recursive functions is a function that partially defined by itself and consists of some simple case with a known answer. Example: Fibonacci number sequence, factorial function, quick sort and more. Some of the algorithms/functions can be represented in iterative way and some may not.
Iterative functions are loop based imperative repetition of a process (in contrast to recursion which has more declarative approach).
Comparison between Iterative and Recursive approaches from performance considerations Factorial:
//recursive function calculates n! static int FactorialRecursive(int n) { if (n <= 1) return 1; return n * FactorialRecursive(n  1); } //iterative function calculates n! static int FactorialIterative(int n) { int sum = 1; if (n <= 1) return sum; while (n > 1) { sum *= n; n; } return sum; }
Remark: in this test I don't look at the results because int isn't capable of holding such big numbers. N Recursive Iterative 10 334 ticks 11 ticks 100 846 ticks 23 ticks 1000 3368 ticks 110 ticks 10000 9990 ticks 975 ticks stackoverflow 100000 9767 ticks As we can clearly see the recursive is a lot slower than the iterative (considerably) and limiting (stackoverflow). The reason for the poor performance is heavy pushpop of the registers in the IL level of each recursive call. Fibonacci: Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal pg. no: 10
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
// iterative version static int FibonacciIterative(int n) { if (n == 0) return 0; if (n == 1) return 1; int prevPrev = 0; int prev = 1; int result = 0; for (int i = 2; i <= n; i++) { result = prev + prevPrev; prevPrev = prev; prev = result; } return result; } // naive recursive version static int FibonacciRecursive(int n) { if (n == 0) return 0; if (n == 1) return 1; return FibonacciRecursive(n  1) + FibonacciRecursive(n  2); } // optimized recursive version static Dictionary resultHistory = new Dictionary(); static { if if if return int FibonacciRecursiveOpt(int n) (n == 0) return 0; (n == 1) return 1; (resultHistory.ContainsKey(n)) resultHistory[n];
int result = FibonacciRecursiveOpt(n  1) + FibonacciRecursiveOpt(n  2); resultHistory[n] = result; return result; } Remark: in this test I don't look at the results because int isn't capable of holding such big numbers.
N Recursive Recursive opt. Iterative 5 5 ticks 22 ticks 9 ticks 10 36 ticks 49 ticks 10 ticks 20 2315 ticks 65 ticks 10 ticks 30 180254 ticks 61 ticks 9 ticks 100 Too long/overflow 158 ticks 11 ticks 1000 Too long/overflow 1470 ticks 27 ticks 10000 Too long/overflow 13873 ticks 190 ticks 100000 Too long/overflow Too long/overflow 3952 ticks Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 11
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! As before the recursive approach is worse than iterative however, we could apply memoization pattern (saving previous results in dictionary for quick key based access), although this pattern isn't match for iterative approach (but definitely improvement over the simple recursion). Summery 1. 2. 3. 3. 3.A EXPLAIN WATER JUG PROBLEM This program implements an "environmentally responsible" solution to the water jugs problem. Rather than filling and spilling from an infinite water resource, we conserve a finite initial charge with a third jug: (reservoir). This approach is simpler than the traditional method, because there are only two actions; it is more flexible than the traditional method, because it can solve problems that are constrained by a limited supply from the reservoir. To simulate the infinite version, we use a filled reservoir with a capacity greater than the combined capacities of the jugs, so that the reservoir can never be emptied. "Perfection is achieved not when there is nothing more to add, but when there is nothing more to take away."
We are given two water jugs having no measuring marks on these. The capacities of jugs are 3 liter and 4 liter and 4 liter. It is required to till the bigger jug with exactly 2 liter of water. The water can be filled in a jug from a tap. In this problem, the start state is that both jugs are empty and the final state is that 4 liter jugs has exactly 2 liters of water. The production rules involve filling a jug with some amount of water, filling the water from one jug to other or empting the jug. The search will be finding the sequence of production rules which transform the initial state to final state
Try not to use recursion in system critical locations Elegant solutions not always the best performing when used in "recursive situations". If you required to use recursion at least try to optimize it with dynamic programming approaches (such as memoization)
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 12
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 13
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
3.B solve the problem by decomposable method sin2xcos2dx Didnt get the exact answer, but below one was the only answer which at least matching the equation with different coefficients for our question sin2xcos2dx  suresh.
(5x2+sin2x cos2x) dx Can be decomposed into smaller and simpler problems viz., sin2x cos2x dxx2 dx and 5 I) Analysing a problem: It is useful in determining the characteristics of the problem under consideration, which may help in solving the problem. Some of the characteristics are discussed below: (i) Whether the problem is decomposable into independent smaller or easier sub problems, so that programming facilities like procedure and recursion etc may be used for designing a solution of the problem. (ii) Whether steps in a proposed solution or solution strategy of the problem, may or may not be ignorable, recoverable or inherently irrecoverable, i.e., irrecoverable by the nature of the problem. Depending upon the nature of the problem, the solution strategy has to be decided or modified. For example, a) While proving a theorem, if an unrequired lemma is proved, we may ignore it. The only loss is the loss of efforts in proving the lemma. Such a problem is called ignorablestep problem. b) Suppose we are interested in solving 8puzzle problem of reaching from some initial state say 287 135 64 To some final state say 123 84 765 By sliding, any one of the digits from a cell adjacent to the blank cell, to the blank cell. Then a wrong step cannot be ignored but has to be recovered. By recoverable we mean that we are allowed to move back to the earlier state from which we came to the current state, if current state seems to be less desirable than the earlier state. The 8puzzle problem has recoverable steps, or, we may say the problem is a recoverable problem. c) However if we are playing chess, then a wrong step may not be even recoverable. In other words, we may not be in a position, because of the adversarys move, to move back to earlier state. Such a problem is called an irrecoverable problem. Depending on the nature of the problem as ignorablestep, recoverablestep or irrecoverable step problem, we have to choose our tools, techniques and strategies for solving the problem. <![if !supportLineBreakNewLine]><![endif]> There are many other characteristics of a problem viz., Whether the problem has certain outcome or uncertain outcome
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 14
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
Whether a good solution is absolute or relative Whether the solution is a state or a path Whether the problem essentially requires interaction with the user etc. Which can be known through analyzing the problem under consideration, and the knowledge of which, in turn, may help us in determining or guessing a correct sequence of actions for solving the problem under consideration.
Analysing an algorithm: It is used to determine the requirement of computer resources for each algorithm. And then, if there are more than one algorithms that solve a problem, the analysis is also concerned with choosing the better one on the basis of comparison of requirement of resources for different available algorithms. The lesser the requirement better the algorithm. The resources that are taken into consideration for analysing algorithms, include (i) Time expected to be taken in executing the instances of the problem generally as a function for the size of the instance. (ii) Memory space expected to be required by the computer system, in executing the instances of the problem, generally as a function of the size of the instances. (iii) Also sometimes, the manhour or manmonth taken by the team developing the program is also taken as a resource for the purpose.
4. 4.A EXPLAIN ANY FOUR BUILT IN FUNCTIONS OF LISP? >>> REPEATED IN 2007 OLD SYLLABUS, PLEASE REFER PAGE NO 54 4.B WHAT IS PREDICATES IN LISP EXPLAIN ANY TWO A predicate is a function used to test for some condition involving its arguments and returns nil if the condition is false, or some nonnil value if the condition is true. Name of the predicates in CL usually ends with p. Ex: numberp, standardcharp etc. overview Logical values Data Type predicates General Type Predicates Specific data type predicates Equality predicates Logical operators Logical values The names nil and t are constants in Lisp This object represents logical false value and also the empty list. It can also be written as () The values of nil and t are not permitted to be changed. Data type predicates: using data type predicates one can determine whether or not it belongs to a given type, or one can compare two type specifies. General Type predicates Syntax: typep object type Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal pg. no: 15
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! Typep is the predicate that is true if the object is of type type false otherwise. Subtypep type1 type2
returns TEx: (subtypep t t) Subtypep are supposed to return a second value of nil unless one or both of its arguments involves satisfies and, or, not or member. Subtypep should signal an error when one or both of its arguments involves values or the list form of the function type specifier Subtypep must always return the two values t and t in the case where its arguments, after expansion of specifies defined by deftype are equal. (subtypep (array A) (array B)) is true if and only if (upgradedarrayelementtype A) is the same type as (upgradedarrayelementtype b) (subtypep (complex A) (complex B)) is true if and only if (upgradedcomplexparttype A) and (upgradedcomplexparttype B) is of same type. Specific data type predicates The following data types test for specific individual data types. returns true if the argument is () or false otherwise.null object returns true if the argument is a symbol else returns falsesymbolp object is true if the argument is not cons otherwise its false.atom object is true if the argument is a cons, false otherwiseconsp object is true if the argument is a cons or an empty list (), false otherwiselistp object is T if the argument is any kind of numberNumberp object is T if the argument is a rational number false otherwiseRationalp object Similarly we have floatp, charaterp, vectorp, stringp, complexp, simplebitvectorp, simplestringvectorp, arrayp etc. is T if its argument is a package and otherwise is falsepackagep object functionp is T if its arguments are suitable for applying to arguments,object using for ex the funccall or apply function and otherwise is false is T if its argument is any compiled code object and otherwise is falseCompiledfunctionp object is T if its argument is any standard CL data type, and otherwise is falseCommonp object Equality predicates Cl provides these predicates to test for the equality of the two objects: eq, eql, equal, equalp is true if and only if x and y are the same identical objects.eq x y falseEx: (eq g h) true(eq 3 3) false(eq hi HI) Eql is true if the arguments are eq, or of there are numbers of thex y same type with the same value, or if there are character objects that represent the same character is true if the arguments are structurally similar objects. (isomorphic objects)equal x y trueEx: (equal #B #B) true(equal FOO FOO) is true if the two objects are equal, and if and only if they are eq that is, the same identical object.equalp x y two hash tables are considered the same by equalp if and only if they satisfy the following four conditions:
They must be of the same kind ( equivalent :test arguments must be given to make hashtable when the two hashtables are created. pg. no: 16
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! They must have the same number of entries. For every entry(key1, value1) in one hash table there must be the corresponding entry(key2, value2) in the other hash table. For every entry(key1, value1) in one hash table and its corresponding entry(key2, value2) in the other , such that key1 and key2 are the same, equalp must be true of value1 and value2. Logical operators CL provides three operators as Boolean value: and, or, and not Ex: not y
And returns t if the condition is true else NIL. Ex: (and form1, form2,)
Evaluates each form one at the time from left to right. If at least one form returns a nil, the evaluation is stopped by returning a nil.
Ex: (and (< 1 2) (< 3 4) (princ true)) true true Or operator returns NIL for false conditions and true conditions return nonnil characters (or form1,form2,..)
Performs or operation the forms one by one from left to right. It is true if at least one of the forms are true
Ex; (or (< 3 1) (> 2 1)) T 5. 5.A WRITE A LISP PROGRAM TO FIND FIBONACCI SERIES The Fibonacci numbers are the integer sequence 0, 1, 1, 2, 3, 5, 8, 13, 21, ..., in which each item is formed by adding the previous two. The sequence can be defined recursively by
Fibonacci number programs that implement this definition directly are often used as introductory examples of recursion. However, many other algorithms for calculating (or making use of) Fibonacci numbers also exist. Program:
;; Return the n'th Fibonacci number
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 17
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
(defun fib_n (n) (if (integerp n) (if (or (= n 1) (< n 1)) 1 (+ (fib_n (+ n 1)) (fib_n (+ n 2)) ) ) nil)) ;; Return the a list of the first i Fibonacci numbers (defun fib (i) (if (and (integerp i) (> i 0)) (append (fib (+ i 1)) (list (fib_n i)) ))) ;; Run the FIB function to display a list of the first 10 Fibonacci numbers (fib 10) ;; This should be the returned result: ; (1 2 3 5 8 13 21 34 55 89)
Use the below given logic and try to build a program Factorial (iterative) Common Lisp Marco Baringer
(defun fact (n) (loop for i from 2 to n for fact = 1 then (* fact i) finally (return fact))) (format t "Factorial of 6 is: ~A~%" (fact 6))
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 18
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
Prolog, which stands for PROgramming in LOGic, is the most widely available language in the logic programming paradigm. Logic and therefore Prolog is based the mathematical notions of relations and logical inference. Prolog is a declarative language meaning that rather than describing how to compute a solution, a program consists of a data base of facts and logical relationships (rules) which describe the relationships which hold for the given application. Rather then running a program to obtain a solution, the user asks a question. When asked a question, the run time system searches through the data base of facts and rules to determine (by logical deduction) the answer. Among the features of Prolog are `logical variables' meaning that they behave like mathematical variables, a powerful patternmatching facility (unification), a backtracking strategy to search for proofs, uniform data structures, and input and output are interchangeable. Often there will be more than one way to deduce the answer or there will be more than one solution, in such cases the run time system may be asked find other solutions. backtracking to generate alternative solutions. Prolog is a weakly typed language with dynamic type checking and static scope rules. Prolog is used in artificial intelligence applications such as natural language interfaces, automated reasoning systems and expert systems. Expert systems usually consist of a data base of facts and rules and an inference engine, the run time system of Prolog provides much of the services of an inference engine.
A Prolog program consists of a database of facts and rules, and queries (questions). o Fact: ... . o Rule: ... : ... . o Query: ? ... . o Variables: must begin with an upper case letter. o Constants: numbers, begin with lowercase letter, or enclosed in single quotes. Inductive definitions: base and inductive cases o Towers of Hanoi: move N disks from pin a to pin b using pin c. hanoi(N) : hanoi(N, a, b, c). hanoi(0,_,_,_). hanoi(N,FromPin,ToPin,UsingPin) : M is N1, hanoi(M,FromPin,UsingPin,ToPin), move(FromPin,ToPin), hanoi(M,UsingPin,ToPin,FromPin). move(From,To) : write([move, disk from, pin, From, to, pin, ToPin]), nl.
o
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! list([]). list([XL]) : [list(L). Abbrev: [X1[...[Xn[]...] = [X1,...Xn] append([],L,L). append([XL1],L2,[XL12]) : append(L1,L2,L12). member(X,L) : concat(_,[X_],L).
o
Ancestor ancestor(A,D) : parent(A,B). ancestor(A,D) : parent(A,C),ancestor(C,D). but not ancestor(A,D) : ancestor(A,P), parent(P,D). since infinite recursion may result.
Depthfirst search: Maze/Graph traversal A database of arcs (we will assume they are directed arcs) of the form: a(node_i,node_j). Rules for searching the graph: go(From,To,Trail). go(From,To,Trail) : a(From,In), not visited(In,Trail), go(In,To,[InTrail]). visited(A,T) : member(A,T).
I/O: terms, characters, files, lexical analyzer/scanner o read(T), write(T), nl. o get0(N), put(N): ascii value of character o name(Name,Ascii_list). o see(F), seeing(F), seen, tell(F), telling(F), told. Natural language processing: Contextfree grammars may be represented as Prolog rules. For example, the rule sentence ::= noun_clause verb_clause can be implemented in Prolog as sentence(S) : append(NC,VC,S), noun_clause(NC), verb_clause(VC). or in DCG as: sentence > noun_clause, verb_clause. ? sentence(S,[]).
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 20
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! Note that two arguments appear in the query. Both are lists and the first is the sentence to be parsed, the second the remaining elements of the list which in this case is empty. A Prolog program consists of a data base of facts and rules. There is no structure imposed on a Prolog program, there is no main procedure, and there is no nesting of definitions. All facts and rules are global in scope and the scope of a variable is the fact or rule in which it appears. The readability of a Prolog program is left up to the programmer. A Prolog program is executed by asking a question. The question is called a query. Facts, rules, and queries are called clauses
6.B WRITE THE STEP PROCEDURE TO COMPILE AND EXECUTE A PROGRAM Running a Prolog program involves 1. creating a file containing the program 2. saving the file 3. loading the file into Prolog (called compiling, consulting, or reconsulting the file in Prolog jargon) 4. finally, calling some goal defined in the program
How you start Prolog depends on your operating system; try typing prolog at the toplevel prompt. Prolog should respond with the `` ?'' prompt. To load in predicates from file, use reconsult(FileName) or reconsult([FileName1, FileName2, ...]). If one of the files contains a predicate that already occurs in the database, it replaces the old definition. [The similar predicate consult adds the new clauses after the existing predicates, rather than replacing them.] To type in predicates directly, use reconsult(user). The prompt will change from `` ?'' to ``''. Enter predicates as you would on a file. To quit this mode, enter an endoffile (probably ^D). ``Run'' the program by typing in inquiries at the Prolog prompt. You may call any predicate with any arguments, and you may make multiple calls in one inquiry by separating them with commas. Use a period at the end of each inquiry. There is no ``main'' program. When Prolog does not give you a new prompt after it answers an inquiry, that means there may be other answers. Enter
;<return>
to tell it to get the next answer, or just <return> to tell it you have seen enough. To begin tracing, use trace; to end tracing, use notrace. To exit Prolog, use halt. Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal pg. no: 21
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
7. EXPLAIN THE FOLLOWING WITH EXAMPLE i. NULL ii. SETF iii. FORMAT iv. CONS i. null In Lisp, functions can gracefully accept the special object nil, which reduces the amount of special case testing in application code. For instance although nil is an atom and does not have any fields, the functions car and cdr accept nil and just return it, which is very useful and results in shorter code. Since nil is the empty list in Lisp, the situation described in the introduction above doesn't exist. Code which returns nil is returning what is in fact the empty list (and not anything resembling a null reference to a list type), so the caller does not need to test the value to see whether or not it has a list. The null object pattern is also supported in multiple value processing. If the program attempts to extract a value from an expression which returns no values, the behavior is that the null object nil is substituted. Thus (list (values)) returns (nil) (a oneelement list containing nil). The (values) expression returns no values at all, but since the function call to list needs to reduce its argument expression to a value, the null object is automatically substituted.
CLOS
In Common Lisp, the object nil is the one and only instance of the special class null. What this means is that a method can be specialized to the null class, thereby implementing the null design pattern. Which is to say, it is essentially built into the object system:
;; empty dog class (defclass dog () ()) ;; a dog object makes a sound by barking: woof! is printed on standard output ;; when (makesound x) is called, if x is an instance of the dog class. (defmethod makesound ((obj dog)) (format t "woof!~%")) ;; allow (makesound nil) to work via specialization to null class. ;; innocuous empty body: nil makes no sound. (defmethod makesound ((obj null)))
The class null is a subclass of the symbol class, because nil is a symbol. Since nil also represents the empty list, null is a subclass of the list class, too. Methods parameters specialized to symbol or list will thus take a nil argument. Of course, a null specialization can still be defined which is a more specific match for nil.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 22
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! ii. setf
Setf
Certain forms in LISP naturally define a memory location. For example, if the value of x is a structure of type foo, then (foobar x) defines the bar field of the value of x. Or, if the value of y is a onedimensional array, (aref y 2) defines the third element of y. The setf special form uses its first argument to define a place in memory, evaluates its second argument, and stores the resulting value in the resulting memory location. For example,
> (setq a (makearray 3)) #(NIL NIL NIL) > (aref a 1) NIL > (setf (aref a 1) 3) 3 > a #(NIL 3 NIL) > (aref a 1) 3 > (defstruct foo bar) FOO > (setq a (makefoo)) #s(FOO :BAR NIL) > (foobar a) NIL > (setf (foobar a) 3) 3 > a #s(FOO :BAR 3) > (foobar a) 3 Setf
is the only way to set the fields of a structure or the elements of an array.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 23
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! iii. format Lisp's FORMAT function is analogous to C's printf function, but FORMAT can do a whole lot more. FORMAT can iterate, use conditionals, process nested format strings, & recurse into format strings embedded into its arguments. The moreorless official documentation for FORMAT is at the Common Lisp Hyperspec. There is a complete if terse description of it in Paul Graham's ANSI Common Lisp, but my favorite description of FORMAT is in Franz's Common Lisp The Reference. Knowing the details of how something works isn't the same as knowing how to use it well. Good applications of FORMAT aren't obvious from its documentation. Thus this article. Let's say you have a list containing the data for one row in a table, & you want to use FORMAT to print that row. In other words, you have something like this:
(1 green ribbit)
Notice that the third line, which has ``green'' & ``ribbit'' in it, is from the list that we have. The first column has a width of six; the second & third columns have widths of eight. The first column is prefixed by three spaces. The columns are separated by two spaces. Here's one way to print that line, assuming the data for the row is in a list called ROW:
(format t "~& ~6D ~8A ~8A" (first row) (second row) (third row))
Here are some examples, using NIL so that FORMAT will return strings.
> (setq row (list 1 'green 'ribbit)) (1 GREEN RIBBIT) > (format nil "~& ~6D ~8@A ~8@A" (first row) (second row) (third row)) " 1 GREEN RIBBIT"
It's a bummer that we have to separate the list into parts before calling FORMAT. We could avoid that by applying APPLY to the situation, but that would require more typing & some consing. A better (but not very good) way to make FORMAT do that work with the ~? directive, like this:
> (format nil "~?" "~& ~6D ~8@A ~8@A" row) " 1 GREEN RIBBIT"
A better way to make FORMAT do the work is with the ~{ directive. Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal pg. no: 24
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
> (format nil "~& ~{~6D ~8@A " 1 GREEN RIBBIT" ~8@A~}" row)
This is the best way I know so far to print a single row if you have the items of a row in a list. There's one more twist: What if the row list contains an item we don't want to print? We can use the ~* directive to skip the items we don't want to print.
> (format nil "~& ~{~6D ~*~8@A ~8@A~}" (list 2 'skipme 'yellow 'buzz)) " 2 YELLOW BUZZ"
If you want to print an entire table or report, iv. cons In computer programming, cons ( / knz/ or / kns/) is a fundamental function in most dialects of the Lisp programming language. cons constructs memory objects which hold two values or pointers to values. These objects are referred to as (cons) cells, conses, nonatomic sexpressions ("NATSes"), or (cons) pairs. In Lisp jargon, the expression "to cons x onto y" means to construct a new object with (cons x y). The resulting pair has a left half, referred to as the car (the first element), and a right half (the second element), referred to as the cdr. It is loosely related to the objectoriented notion of a constructor, which creates a new object given arguments, and more closely related to the constructor function of an algebraic data type system. The word "cons" and expressions like "to cons onto" are also part of a more general functional programming jargon. Sometimes operators that have a similar purpose, especially in the context of list processing, are pronounced "cons". (A good example is the :: operator in ML and Scala, which adds an element to the beginning of a list.) Use : Although cons cells can be used to hold ordered pairs of simplex data, they are more commonly used to construct more complex compound data structures, notably lists and binary trees. For example, the Lisp expression (cons 1 2) constructs a cell holding 1 in its left half (the socalled car field) and 2 in its right half (the cdr field). In Lisp notation, the value (cons 1 2) looks like:
(1 . 2)
Note the dot between 1 and 2; this indicates that the Sexpression is a "dotted pair," rather than a "list."
Lists
Cons cell diagram for the list (42 69 613), written with cons:
(cons 42 (cons 69 (cons 613 nil))) and written with list:
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 25
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
(list 42 69 613) In Lisp, lists are implemented on top of cons pairs. More specifically, any list structure in Lisp is either:
1. An empty list (), which is a special object usually called nil. 2. A cons cell whose car is the first element of the list and whose cdr is a list containing the rest of the elements. This forms the basis of a simple, singly linked list structure whose contents can be manipulated with cons, and cdr. Note that nil is the only list that is not also a cons pair. As an example, consider a list whose elements are 1, 2, and 3. Such a list can be created in three steps:
car,
1. Cons 3 onto nil, the empty list 2. Cons 2 onto the result 3. Cons 1 onto the result which is equivalent to the single expression:
(cons 1 (cons 2 (cons 3 nil)))
i.e.
i.e ***nil    1 2 3
Thus, cons can be used to add one element to the front of an existing linked list. For example, if x is the list we defined above, then (cons 5 x) will produce the list:
(5 1 2 3)
Another useful list procedure is append, which concatenates two existing lists (i.e. combines two lists into a single list).
Trees
Binary trees that only store data in their leaves are also easily constructed with cons. For example, the code:
(cons (cons 1 2) (cons 3 4))
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 26
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! results in the tree:
((1 . 2) . (3 . 4))
i.e.
* / \ * * / \ / \ 1 2 3 4
Technically, the list (1 2 3) in the previous example is also a binary tree, one which happens to be particularly unbalanced. To see this, simply rearrange the diagram:
***nil    1 2 3
Use in conversation
Cons can refer to the general process of memory allocation, as opposed to using destructive operations of the kind that would be used in an imperative programming language. For example: I sped up the code a bit by putting in side effects instead of having it cons like crazy. 8. 8.A WRITE A LISP PROGRAM TO FIND FREQUENCY OF A NUMBER IN A SINEN LIST LOGIC:
(defun sum (L) (reduce '+ L)) (sum '(1 2 3)) 6
This works:
(+ 1 2 3) 6
This works if 'cl*' is loaded: Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal pg. no: 27
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
(reduce '+ '(1 2 3)) 6
8.B WHAT IS RECURSION? WRITE A PROGRAM USING RECURSIVE CONCEPT TO FIND SUN OF NATURAL NUMBER A recursive function contains code that tells the Lisp interpreter to call a program that runs exactly like itself, but with slightly different arguments. The code runs exactly the same because it has the same name. However, even though the program has the same name, it is not the same entity. LISP has no loop constructs, so recursion is the only way to process data. A recursive function is a function which calls itself. This technique recognises that an operation on some data may be best expressed as the aggregate of the same operation performed on each item of data of which it is comprised. Obviously this technique is best used with data structures which have the same form at both higher and lower levels, differing only in scale. This focus on recursion is the reason for LISP's popularity with AI researchers, who often attempt to model largescale behaviour in terms of smallerscale decisions. For instance, recursion is often used in LISP to search state spaces. Many of the lists used in LISP programs would be better referred to as trees. Lists are simply the mechanism used to represent those trees. The car and cdr functions are generally used to recurse (or 'walk') through the elements in a tree, while cons is often used to gradually build build tree structures to form the result of a recursive operation. By also using the null function to test for an empty list, we can walk through the tree structure, dealing with successively smaller pieces of the tree. car returns the first element of a list. e.g. ( car '(a b c) ) evaluates to a. cdr returns the list with the first element removed. e.g. ( cdr '(a b c) ) evaluates to (b c). cons is an associated function which is used to build tree structures, often to form the result of a recursive operation. Note that it does not simply concatenate lists, but undoes the effects of a hypothetical use of car and cdr. e.g. ( cons '(a b) '(c d e) ) evaluates to ( (a b) (c d e)) rather than (a b c d e). Note that the use of these functions can lead to a great deal of inefficient copying
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 28
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
1.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 29
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! 1. A IT IS USEFUL TO STRUCTURE AI. PRODUCTION SYSTEM PROVIDES SUCH STRUCTURE? DISCUSS IN DETAIL A production system is a tool used in artificial intelligence and especially within the applied AI domain known as expert systems. Production systems consist of a database of rules, a working memory, a matcher, and a procedure that resolves conflicts between rules. These components are outlined below. Several different versions of productions systems have been developed, including the OPs series
Matching
The rules of a production consist of a condition and action in the form: (if x then y). The lefthandside conditions (x and y may be arbitrarily complex conjunctions of expressions) are compared against the elements of working memory to determine if the conditions are satisfied. Matching is an computationally intense procedure although the RETE algorithm of OPS5 is significantly more efficient than a simple conditionbycondition matcher.
Conflict Resolution
At any point in processing, several productions may match to the elements of working memory simultaneously. Since production systems are normally implemented on serial computers, this results in a conflict: there is a nonunique choice about which action to take next. Most conflict resolution schemes are very simple, dependent on the number of conditions in the production, the time stamps (ages) of the elements to which the conditions matched, or completely random. One of the advantages of production systems is that the computational complexity of the matcher, while large, is deterministically finite and the conflict resolution scheme is trivial. This is in contrast to logicist systems in which declarative knowledge may be accessed instantly but the time required to use the knowledge (in a theorem prover, for instance) can not be predetermined.
Actions
The actions of productions are manipulations to working memory. Elements may be added, deleted and modified. Since elements may be added and deleted, the production system is nonmonotonic: the addition of new knowledge may obviate previous knowledge. Nonmonotonicity increases the significance of the conflict resolution scheme since productions which match in one cycle may not match in the following because of the action of the intervening production. Some production systems are monotonic, however, and only add elements to working memory, never deleting or modifying knowledge through the action of production rules. Such systems may be regarded as implicitly parallel since all rules that match will be fired regardless of which is fired first.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 30
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! 2. A non monotonic production system 3. A partially commutative production system 4. A commutative production system. Advantages of production systems:1. Production systems provide an excellent tool for structuring AI programs. 2. Production Systems are highly modular because the individual rules can be added, removed or modified independently. 3. The production rules are expressed in a natural form, so the statements contained in the knowledge base should the a recording of an expert thinking out loud. Disadvantages of Production Systems:One important disadvantage is the fact that it may be very difficult analyse the flow of control within a production system because the individual rules dont call each other. Production systems describe the operations that can be performed in a search for a solution to the problem. They can be classified as follows. Monotonic production system : A system in which the application of a rule never prevents the later application of another rule, that could have also been applied at the time the first rule was selected. Partially commutative production system:A production system in which the application of a particular sequence of rules transforms state X into state Y, then any permutation of those rules that is allowable also transforms state x into state Y.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 31
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! 1.B EXPLAIN VARIOUS CHARACTERISTICS OF PROBLEM
Problems
"Can a machine act intelligently?" is still an open problem. Taking "A machine can act intelligently" as a working hypothesis, many researchers have attempted to build such a machine. The general problem of simulating (or creating) intelligence has been broken down into a number of specific subproblems. These consist of particular traits or capabilities that researchers would like an intelligent system to display. The traits described below have received the most attention.[12]
Knowledge representation
An ontology represents knowledge as a set of concepts within a domain and the relationships between those concepts. Main articles: Knowledge representation and Commonsense knowledge
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 32
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! Knowledge representation[43] and knowledge engineering[44] are central to AI research. Many of the problems machines are expected to solve will require extensive knowledge about the world. Among the things that AI needs to represent are: objects, properties, categories and relations between objects;[45] situations, events, states and time;[46] causes and effects;[47] knowledge about knowledge (what we know about what other people know);[48] and many other, less well researched domains. A representation of "what exists" is an ontology (borrowing a word from traditional philosophy), of which the most general are called upper ontologies.[49] Among the most difficult problems in knowledge representation are: Default reasoning and the qualification problem Many of the things people know take the form of "working assumptions." For example, if a bird comes up in conversation, people typically picture an animal that is fist sized, sings, and flies. None of these things are true about all birds. John McCarthy identified this problem in 1969[50] as the qualification problem: for any commonsense rule that AI researchers care to represent, there tend to be a huge number of exceptions. Almost nothing is simply true or false in the way that abstract logic requires. AI research has explored a number of solutions to this problem.[51] The breadth of commonsense knowledge The number of atomic facts that the average person knows is astronomical. Research projects that attempt to build a complete knowledge base of commonsense knowledge (e.g., Cyc) require enormous amounts of laborious ontological engineering they must be built, by hand, one complicated concept at a time.[52] A major goal is to have the computer understand enough concepts to be able to learn by reading from sources like the internet, and thus be able to add to its own ontology.[citation needed] The subsymbolic form of some commonsense knowledge Much of what people know is not represented as "facts" or "statements" that they could express verbally. For example, a chess master will avoid a particular chess position because it "feels too exposed"[53] or an art critic can take one look at a statue and instantly realize that it is a fake.[54] These are intuitions or tendencies that are represented in the brain nonconsciously and subsymbolically.[55] Knowledge like this informs, supports and provides a context for symbolic, conscious knowledge. As with the related problem of subsymbolic reasoning, it is hoped that situated AI or computational intelligence will provide ways to represent this kind of knowledge.[55]
Planning
A hierarchical control system is a form of control system in which a set of devices and governing software is arranged in a hierarchy.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 33
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! Main article: Automated planning and scheduling Intelligent agents must be able to set goals and achieve them.[56] They need a way to visualize the future (they must have a representation of the state of the world and be able to make predictions about how their actions will change it) and be able to make choices that maximize the utility (or "value") of the available choices.[57] In classical planning problems, the agent can assume that it is the only thing acting on the world and it can be certain what the consequences of its actions may be.[58] However, if this is not true, it must periodically check if the world matches its predictions and it must change its plan as this becomes necessary, requiring the agent to reason under uncertainty.[59] Multiagent planning uses the cooperation and competition of many agents to achieve a given goal. Emergent behavior such as this is used by evolutionary algorithms and swarm intelligence.[60]
Learning
Main article: Machine learning Machine learning[61] has been central to AI research from the beginning.[62] In 1956, at the original Dartmouth AI summer conference, Ray Solomonoff wrote a report on unsupervised probabilistic machine learning: "An Inductive Inference Machine".[63] Unsupervised learning is the ability to find patterns in a stream of input. Supervised learning includes both classification and numerical regression. Classification is used to determine what category something belongs in, after seeing a number of examples of things from several categories. Regression takes a set of numerical input/output examples and attempts to discover a continuous function that would generate the outputs from the inputs. In reinforcement learning[64] the agent is rewarded for good responses and punished for bad ones. These can be analyzed in terms of decision theory, using concepts like utility. The mathematical analysis of machine learning algorithms and their performance is a branch of theoretical computer science known as computational learning theory.[65]
A parse tree represents the syntactic structure of a sentence according to some formal grammar. Main article: Natural language processing Natural language processing[66] gives machines the ability to read and understand the languages that humans speak. Many researchers hope that a sufficiently powerful natural language processing system would be able
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 34
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! to acquire knowledge on its own, by reading the existing text available over the internet. Some straightforward applications of natural language processing include information retrieval (or text mining) and machine translation.[67]
Perception
Main articles: Machine perception, Computer vision, and Speech recognition Machine perception[71] is the ability to use input from sensors (such as cameras, microphones, sonar and others more exotic) to deduce aspects of the world. Computer vision[72] is the ability to analyze visual input. A few selected subproblems are speech recognition,[73] facial recognition and object recognition.[74]
Social intelligence
Main article: Affective computing
Kismet, a robot with rudimentary social skills Emotion and social skills[75] play two roles for an intelligent agent. First, it must be able to predict the actions of others, by understanding their motives and emotional states. (This involves elements of game theory, decision theory, as well as the ability to model human emotions and the perceptual skills to detect emotions.) Also, for good humancomputer interaction, an intelligent machine also needs to display emotions. At the very least it must appear polite and sensitive to the humans it interacts with. At best, it should have normal emotions itself.
Creativity
Main article: Computational creativity A subfield of AI addresses creativity both theoretically (from a philosophical and psychological perspective) and practically (via specific implementations of systems that generate outputs that can be considered creative, or systems that identify and assess creativity). A related area of computational research is Artificial Intuition and Artificial Imagination.[citation needed]
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 35
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
General intelligence
Main articles: Strong AI and AIcomplete Most researchers hope that their work will eventually be incorporated into a machine with general intelligence (known as strong AI), combining all the skills above and exceeding human abilities at most or all of them.[13] A few believe that anthropomorphic features like artificial consciousness or an artificial brain may be required for such a project.[76][77] Many of the problems above are considered AIcomplete: to solve one problem, you must solve them all. For example, even a straightforward, specific task like machine translation requires that the machine follow the author's argument (reason), know what is being talked about (knowledge), and faithfully reproduce the author's intention (social intelligence). Machine translation, therefore, is believed to be AIcomplete: it may require strong AI to be done as well as humans can do it.[78]
2. 2.A EXPLAIN STATE SPACE REPRESENTATION FOR WATER JUG PROBLEM The state space representation forms the basis of most of the AI methods. Its structure corresponds to the structure of problem solving in two important ways: It allows for a formal definition of a problem as the need to convert some given situation into some desired situation using a set of permissible operations. It permits us to define the process of solving a particular problem as a combination of known techniques (each represented as a rule defining a single step in the space) and search, the general technique of exploring the space to try to find some path from current state to a goal state. Search is a very important process in the solution of hard problems for which no more direct techniques are available. Example playing chess To build a program that could play chess, we could first have to specify the starting position of the chess board, the rules that define the legal moves, and the board positions that represent a win for one side or the other. In addition, we must make explicit the previously implicit goal of not only playing the legal game of chess but also winning the game, if possible,
..
Playing chess The starting position can be described as an 8by 8 array where each position contains a symbol for appropriate piece. We can define as our goal the check mate position. The legal moves provide the way of getting from initial state to a goal state. They can be described easily as a set of rules consisting of two parts: A left side that serves as a pattern to be matched against the current board position. And a right side that describes the change to be made to reflect the move However, this approach leads to large number of rules 10120 board positions !! Using so many rules poses problems such as: pg. no: 36
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! No person could ever supply a complete set of such rules. No program could easily handle all those rules. Just storing so many rules poses serious difficulties. Defining chess problem as State Space search We need to write the rules describing the legal moves in as general a way as possible. For example: White pawn at Square( file e, rank 2) AND Square( File e, rank 3) is empty AND Square(file e, rank 4) is empty, then move the pawn from Square( file e, rank 2) to Square( file e, rank 4). In general, the more succintly we can describe the rules we need, the less work we will have to do to provide them and more efficient the program. Water Jug Problem The state space for this problem can be described as the set of ordered pairs of integers (x,y) such that x = 0, 1,2, 3 or 4 and y = 0,1,2 or 3; x represents the number of gallons of water in the 4gallon jug and y represents the quantity of water in 3gallon jug The start state is (0,0) The goal state is (2,n) Production rules for Water Jug Problem Sl No Current state Next State Descritpion 1 (x,y) if x < 4 (4,y) Fill the 4 gallon jug 2 3 (x,y) if y <3 (x,y) if x > 0 (x,3) (xd, y) Fill the 3 gallon jug Pour some water out of the 4 gallon jug Pour some water out of the 3gallon jug Empty the 4 gallon jug Empty the 3 gallon jug on the ground Pour water from the 3 gallon jug into the 4 gallon jug until the 4gallon jug is full
(x,y) if y > 0
(x, yd)
5 6 7
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 37
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! Production rules 8 (x, y) if x+y >= 3 (x(3y), 3) Pour water from the 4and x>0 gallon jug into the 3gallon jug until the 3gallon jug is full Pour all the water 9 (x, y) if x+y <=4 and (x+y, 0) y>0 from the 3gallon jug into the 4gallon jug 10 (x, y) if x+y <= 3 (0, x+y) Pour all the water and x>0 from the 4gallon jug into the 3gallon jug 11 (0,2) (2,0) Pour the 2 gallons from 3gallon jug into the 4gallon jug 12 (2,y) (0,y) Empty the 2 gallons in the 4gallon jug on the ground To solve the water jug problem Required a control structure that loops through a simple cycle in which some rule whose left side matches the current state is chosen, the appropriate change to the state is made as described in the corresponding right side, and the resulting state is checked to see if it corresponds to goal state. One solution to the water jug problem Shortest such sequence will have a impact on the choice of appropriate mechanism to guide the search for solution. Gallons Gallons Rule applied in the in the 43gallon gallon jug jug 0 0 2 0 3 3 4 0 2 3 0 3 2 2 0 9 2 7 5 or 12 9 0r 11 Z
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 38
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! 2.B DIFFERENTIATE BETWEEN DEPTH FIRST VERSUS BREADTH FIRST SEARCH METHOD Breadthfirst search (BFS) and depthfirst search (DFS) are two distinct orders in which to visit the vertices and edges of a graph. BFS radiates out from a root to visit vertices in order of their distance from the root. Thus closer nodes get visited first. DFS prefers to visit undiscovered vertices immediately, so the search trees tend to be deeper rather than balanced as with BFS. Notice that the DFS consists of three ``Hamiltonian'' paths, one in each component while the BFS tree has far more degree3 nodes, reflecting balance.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 39
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! 3. 3.A WHAT IS HEURISTICS? EXPLAIN ANY HEURISTIC SEARCH METHOD A branch of artificial intelligence, which uses heuristics  commonsense rules drawn from experience  to solve problems. This is in contrast to algorithmic programming, which is based on mathematically provable procedures. Heuristic programming is characterized by programs that are selflearning; they get better with experience. Heuristic programs do not always reach the very best result but usually produce a good result. Many expert systems use heuristic programming. A heuristic is a method that
might not always find the best solution but is guaranteed to find a good solution in reasonable time. By sacrificing completeness it increases efficiency. Useful in solving tough problems which o could not be solved any other way. o solutions take an infinite time or very long time to compute.
Heuristic Search methods Generate and Test Algorithm 1. generate a possible solution which can either be a point in the problem space or a path from the initial state. 2. test to see if this possible solution is a real solution by comparing the state reached with the set of goal states. 3. if it is a real solution, return. Otherwise repeat from 1. This method is basically a depth first search as complete solutions must be created before testing. It is often called the British Museum method as it is like looking for an exhibit at random. A heuristic is needed to sharpen up the search. Consider the problem of four 6sided cubes, and each side of the cube is painted in one of four colours. The four cubes are placed next to one another and the problem lies in arranging them so that the four available colours are displayed whichever way the 4 cubes are viewed. The problem can only be solved if there are at least four sides coloured in each colour and the number of options tested can be reduced using heuristics if the most popular colour is hidden by the adjacent cube. The classic example of heuristic search methods is the travelling salesman problem. The travelling salesman problem (TSP) is an NPhard problem in combinatorial optimization studied in operations research and theoretical computer science. Given a list of cities and their pairwise distances, the task is to find a shortest possible tour that visits each city exactly once. The problem was first formulated as a mathematical problem in 1930 and is one of the most intensively studied problems in optimization. It is used as a benchmark for many optimization methods. Even though the problem is computationally difficult, a large number of heuristics and exact methods are known, so that some instances with tens of thousands of cities can be solved. The TSP has several applications even in its purest formulation, such as planning, logistics, and the manufacture of microchips. Slightly modified, it appears as a subproblem in many areas, such as DNA Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal pg. no: 40
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! sequencing. In these applications, the concept city represents, for example, customers, soldering points, or DNA fragments, and the concept distance represents travelling times or cost, or a similarity measure between DNA fragments. In many applications, additional constraints such as limited resources or time windows make the problem considerably harder. In the theory of computational complexity, the decision version of the TSP (where, given a length L, the task is to decide whether any tour is shorter than L) belongs to the class of NPcomplete problems. Thus, it is likely that the worst case running time for any algorithm for the TSP increases exponentially with the number of cities.
As a graph problem
Symmetric TSP with four cities TSP can be modeled as an undirected weighted graph, such that cities are the graph's vertices, paths are the graph's edges, and a path's distance is the edge's length. A TSP tour becomes a Hamiltonian cycle if and only if every edge has the same distance. Often, the model is a complete graph (i.e., an edge connects each pair of vertices). If no path exists between two cities, adding an arbitrarily long edge will complete the graph without affecting the optimal tour.
Example: Imagine that you have to navigate across 10 cities. Also assume that you have to visit all these cities. The number of possible routes for these 10 cities is 36000000. The shortest path is just one of these routes. A classical computer cannot solve or perform comparisons on all the possible route combinations in order to arrive at the best path in terms of distance travelled for a network of 50 cities. The problem is NP hard and cannot be solved in polynomial time. Djikstras algorithm states that the path lies only along the exterior path and the lowest distance path cannot be obtained by traversing the interior. The travelling sales man problem is principally based on finding the lowest distance in a network of N connected cities. The lowest distance is just one of these routes. There are however several transportation algorithms /advanced optimization technqiues that can perform a quick optimization and churn out the shortest path. There are also heuristic methods and graph based methods that are used to solve the TSP.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 41
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! The TSP has a lot of applications in the areas of Logistics, Network route planning, Town planning. An exact solution for 15,112 German towns was found in 2001, based on linear programming. The computations were performed on a network of 110 processors located at Rice University and Princeton University. The total computation time was equivalent to 22.6 years on a single 500 MHz Alpha processor. In May 2004, the travelling salesman problem of visiting all 24,978 towns in Sweden was solved: a tour of length approximately 72,500 kilometers was found and it was proven that no shorter tour exists. ( All the cities in Sweden can be covered within a network distance of 72500 Kms)
3.B DEFINE MATCHING. EXPLAIN ANY ONE MATCHING TECHNIQUE matching: In a biometric security system, the process of comparing a biometric sample with a stored reference template and subsequently assigning a score based on the level of similarity. The biometric system then issues an accept or reject decision based on the results of the matching. In its most general form a pervasive feature of, or basis for, AI systems: the essential objective is to test whether a specific received data structure is an instance of a given general pattern, and particularly, to establish whether input data items can provide values for pattern variables. The matching can be made more or less fuzzy, according to the conditions on the individual pattern variables, and on their joint satisfaction. Pattern matching is important in AI because it reflects (i) the fact that complex general concepts exhibit considerable variation in particular manifestations, and (ii) the fact that individual elements of these participate in relationships with one another
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 42
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
4. 4.A HOW DO YOU REPRESENT THE KNOWLEDGE USING PREDICATE LOGIC One of the trickier parts of designing artificial intelligence is how to represent information to something that can not understand language. Knowledge representation is defined by its syntax and its facts (semantics) which together along with the rules for deducing new sentences make up the logic. Entailment is the relationship between current sentences and new sentences derived from the current sentences. A good knowledge representation language will combine the ease of spoken and written languages, like English, with the conciseness of a computer language, like C. Propositional (Boolean) Logic This consists of a syntax, the semantics and rules for deducing new sentences. Symbols are used to represent facts which may or may not be true. W may 72 represent the fact it is windy outside. The symbols are combined with boolean logic to generate new sentences. Facts can be true or false only. The program may know a statement is true or false or be uncertain as to its truth or falsity. The syntax consists of , v, => (if x then y), (equal), and (not). BackusNaur Form (bnf) is the grammar used to put sentences together. The semantics are just the interpretation of a statement about a proposition. Truth tables are used to define the semantics of sentences or test validity of statements. Truth table for AND T and T = T T and F = F F and F = F F and T = F A model is a world in which a sentence is true under a particular interpreta tion. There can be several models at once that have the same interpretations. An inference rule is a rule that is derived from a pattern that is true all the time for specific cases.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 43
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! First Order Logic (firstorder predicate calculus) This consists of objects, predicates on objects, connectives and quantifiers. Predicates are the relations between objects, or properties of the objects. Connectives and quantifiers allow for universal sentences. Relations between objects can be true or false as well as the objects themselves. The program may not know whether something is true or false or give it a probability of truth or falseness. Procedural Representation This method of knowledge representation encodes facts along with the sequence of operations for manipulation and processing of the facts. This is what expert systems are based on. Knowledge engineers question experts in a given field and code this information into a computer program. It works best when experts follow set procedures for problem solving, i.e. a doctor making a diagnoses. The most popular of the Procedural Representations is the Declarative. In the Declarative Representation the user states facts, rules, and relationships. These represent pure knowledge. This is processed with hard coded procedures. Relational Representation Collections of knowledge are stored in table form. This is the method used for most commercial databases, Relational Databases. The information is manipulated with relational calculus using a language like SQL. This is a flexible way to store information but not good for storing complex relationships. Problems arise when more than one subject area is attempted. A new knowledge base from scratch has to be built for each area of expertise. Hierarchical Representation This is based on inherited knowledge and the relationships and shared attributes between objects. This good for abstracting or granulating knowledge. Java and C++ are based on this. Semantic Net A data graph structure is used and concrete and abstract knowledge is represented about a class of problems. Each one is designed to handle a specific problem. The nodes are the concepts features or processes. The edges are the relationships (is a, has a, begins, ends, duration, etc). The edges are bidirectional, backward edges are called Hyper Types or Back Links. This allows backward and forward walking through the net. The reasoning part of the nets includes: expert systems; blackboard architecture; and a semantic net description of the problem. These are used for natural language parsing and databases. Predicate Logic and propositional Most of the logic done with AI is predicate logic. It used to represent objects, functions and relationships. Predicate logic allows representation of complex facts about things and the world. (If A then B). A knowledge base is a set of facts about the world called sentences. These are put in a form of knowledge representation language. The program will ASK to get information from the knowledge base and TELL to put information into the knowledge base. Using objects, relations between them, and their attributes almost all knowledge can be represented. It does not do well deriving new knowledge. The knowledge representation must take perceptions and turn them into sentences for the program to be able to use them, and it must take queries and put them into a form the program can understand. Resolution and unification Resolution: prove A true by proving A Not is false. Unification: take two predicate logic sentences and using substitutions make them the same. Unification is the single operation that can be done on data structures (expression trees) in Prolog. These are the techniques used to process predicate logic knowledge and the are the basis for Lisp and Prolog.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 44
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! Frames Each frame has a name and a set of attributevalue pairs called slots. The frame is a node in a semantic network. Hybrid frame systems are meant to over come serious limitations in current setups. They work much like an object oriented language. A frame contains an object, its attributes, relationships and its inherited attributes. This is much like Java classes. We have a main class and sub classes that have attributes, relationships, and methods for use. A logic has a language, inference rules, and semantics. Two logical languages are propositional calculus and predicate calculus. Propositional Calculus which is a descendant of boolean algebra is a language that can express constraints among objects, values of objects, and inferences about objects and values of objects. The elements of propositonal calculus are: Atoms: the smallest elements Connectives: or, and, implies, not Sentences: aka wellformed formulas, wffs The legal wwfs disjunction: or conjunction: and implication: implies negation: not Rules of inference are used to produce other wwfs modus ponens: ( x AND ( x implies y) ) implies y AND introduction: x, y implies ( x AND y ) AND commutativity: x AND y implies x OR introduction: x, y implies ( x OR y ) NOT elimination: NOT ( NOT x ) implies x resolution: combining rules of inference into one rule: { example: (x OR y) AND ( NOT y OR z ) = x OR z Horn clauses: a clause having one TRUE literal, there are three types: a single atom (q); an implication or rule ( p AND q = r ); a set of negative literals ( p OR q => ) . These have linear time algorithms. Definitions: Semantics: associations of elements of a language with the elements of the domain Propositions: a statement about an atom, example: The car is running. Car is the atom, is running is the proposition. interpretation: is the association of the proposition with the atom denotation: in a given interpretation the proposition associated with the atom is the denotation value: TRUE, FALSE, given to an atom
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 45
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! knowledge base: a collection of propositional calculus statements that are true in the domain truth table: a tablular format for representing states satisfies: a true statement under a given interpretation model: an interpretation that satisfies each statement in a set of statements. validity: a statement that is TRUE under all interpretations equivalence: statements are equivalent if their truth values are identical under all interpretations. Examples: DeMorgans Laws: NOT (x OR y ) = ( NOT x ) AND ( NOT y ) NOT ( x AND y ) = ( Not x ) OR ( NOT y ) Contrapositive: ( x implies y ) = ( NOT x implies NOT y ) if ( x = y ) then ( x implies y ) = ( y implies x ) Propositional satisfiability, aka PSAT a model formula that comprises the conjunction of all the statements in the set. Predicate Calculus takes propositional calculus further by allowing statements about propositions as well as about objects. This is first order predicate calculus. Contains: object constants, term: strings of characters, xyz, linda, paris relation constants: divided by, distance to/from, larger than function constants: small, big, blue functional expression: examples: distance(here, there); xyz; worlds: can have infinite objects, functions on objects, relations over objects interpretations: maps object constants into objects in the world quantifiers: can be universal or for a selected object or group of objects Predicate Calculus is used to express mathematical theories. It consists of sentences, inference rules and symbols. Firstorder predicate calculus symbols consist of variables about which a statement can be made, logic symbols (and, or, not, for all, there exists, implies) and punctuation ( (, ) ). If we have a set S in which all of the statements are true then S is a model. If S implies U then U is true for all models of S and NOT U is false for all models of S. If we make a set S which has all of the statements of S and the statement NOT U it is not a model. All statements in a model must be true. S is unsatisfiable
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 46
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! since there is no way for the statements of S and the statement NOT U, both of which are in S to be true at the same time. This is used to prove formulas in theorem proving. To show S implies U is is sufficient to show S= S, NOT U is unsatisfiable. Resolution and unification Resolution: prove A true by proving A Not is false. Unification: take two predicate logic sentences and using substitutions make them the same. Unification is the single operation that can be done on data structures (expression trees) in Prolog. These are the techniques used to process predicate logic knowledge and the are the basis for Lisp and Prolog. Resolution is one way to prove unsatisfiability.
In propsoitional logic it is easy to determine that two literals can not both be true at the same time. Simply look for L and ~L . In predicate logic, this matching process is more complicated, since bindings of variables must be considered. For example man (john) and man(john) is a contradiction while man (john) and man(Himalayas) is not. Thus in order to determine contradictions we need a matching procedure that compares two literals and discovers whether there exist a set of substitutions that makes them identical . There is a recursive procedure that does this matching . It is called Unification algorithm. In Unification algorithm each literal is represented as a list, where first element is the name of a predicate and the remaining elements are arguments. The argument may be a single element (atom) or may be another list. For example we can have literals as ( tryassassinate Marcus Caesar) ( tryassassinate Marcus (ruler of Rome)) To unify two literals , first check if their first elements re same. If so proceed. Otherwise they can not be unified. For example the literals ( try assassinate Marcus Caesar) ( hate Marcus Caesar) Can not be Unfied. The unification algorithm recursively matches pairs of elements, one pair at a time. The matching rules are : Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal pg. no: 47
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! i) Different constants , functions or predicates can not match, whereas identical ones can. ii) A variable can match another variable , any constant or a function or predicate expression, subject to the condition that the function or [predicate expression must not contain any instance of the variable being matched (otherwise it will lead to infinite recursion). iii) The substitution must be consistent. Substituting y for x now and then z for x later is inconsistent. (a substitution y for x written as y/x) The Unification algorithm is listed below as a procedure UNIFY (L1, L2). It returns a list representing the composition of the substitutions that were performed during the match. An empty list NIL indicates that a match was found without any substitutions. If the list contains a single value F, it indicates that the unification procedure failed. UNIFY (L1, L2) 1. if L1 or L2 is an atom part of same thing do (a) if L1 or L2 are identical then return NIL (b) else if L1 is a variable then do (i) if L1 occurs in L2 then return F else return (L2/L1) else if L2 is a variable then do (i) if L2 occurs in L1 then return F else return (L1/L2) else return F. 2. If length (L!) is not equal to length (L2) then return F. 3. Set SUBST to NIL ( at the end of this procedure , SUBST will contain all the substitutions used to unify L1 and L2). 4. For I = 1 to number of elements in L1 do i) call UNIFY with the i th element of L1 and Ith element of L2, putting the result in S ii) if S = F then return F iii) if S is not equal to NIL then do (A) apply S to the remainder of both L1 and L2 (B) SUBST := APPEND (S, SUBST) return SUBST.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 48
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
5. 5.A DEFINE PREDICATE AN OBJECTS IN PROLOG. DISCUSS VARIOUS TYPES OF OBJECTS USED IN PROLOG
Predicates
Clauses with the same clause name, the same number of arguments and defined in the same module are combined in the database and form the definition of a predicate. The common clause name is called the predicate name or function of the predicate. The number of arguments is the parity. For example, the predicate fac/2 is defined by the collection of all clauses with the clause head fac(Arg1,Arg2), where Arg1 and Arg2 may be any terms. The separate clauses of a predicate are connected by disjunction, i.e. by inclusive OR. Clauses with the same clause name but a different number of arguments belong to different predicates. Likewise, clauses which have the same clause name and the same arity but are associated with different modules belong to different predicates. The Prolog predicate concept can be compared to the subprogram concept in conventional programming languages; we therefore also speak of "calling" a predicate in Prolog. The predicate concept ensures a high degree of modularity in Prolog programs and thereby supports structured programming.
Example
The two clauses below define the predicate fac/2 for calculating the factorial of a natural number.
fac( 0, 1) : !. fac( N, Nfac) :N > 0, M is N  1, fac( M, Mfac), Nfac is N * Mfac. You can call the predicate fac/2 in [user] ? fac(5,X). X = 120 % 0! is 1 % % % % for integers N > 0 defines NFac as N * (N1)! thus MFac is calculated recursively as (N1)!
The Prolog system searches the clauses belonging to the predicate fac/2 and displays the answer: The precise sequence in which Prolog performs this search operation is described in the section Procedure execution. Only predicates whose clauses have been included in the database with consult/1, reconsult/1 or with an assert predicate can be modified, i.e. clauses can be added (assert predicates) or removed (retract predicates), individual predicates can be deleted (abolish/1) or replaced (reconsult/1). The clauses of
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 49
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! these predicates can be output with listing/0/1 and analyzed with clause predicates. Note however that to do so you must call the Prolog system with the debug option.
Compiled predicates
IF/Prolog offers a number of ways of compiling userdefined predicates and including them in the database. This can be done by the system's incremental compiler by using the assert and consult predicates. In addition, predicate definitions stored in files can be compiled by the predicate compile/1 or the external compiler (procmp command). Predicates compiled with consult/1, reconsult/1, compile/1 or procmp are normally no longer modifiable. However, you can inform the compiler with the dynamic/1 directive that certain predicates are to remain modifiable. Predicates which you have generated with assert predicates or which you have declared as modifiable with other compilation methods are compiled only to the extent where the compilation is reversible, i.e. where decompilation is possible. Whenever references are made in this manual to compiled predicates they should be taken to mean predicates which cannot be decompiled. These can no longer be modified by simply adding or removing clauses. Further information about compiling Prolog source text and the related advantages and restrictions can be found in chapter 7.5 on Compiling and loading files.
C interface
IF/Prolog also gives you the option of using C functions without backtracking (simple C functions) and with backtracking (complex C functions) as Prolog predicates using the builtin C interface. The C interface is described in detail in chapter 10.
Builtin predicates
IF/Prolog provides a large number of builtin predicates which you can use to formulate your own predicates. Builtin predicates cannot be extended by additional clauses or entirely replaced. The module system does, however, give you the option to define your own predicates with the same clause names and the same arity as builtin predicates, since all the builtin predicates are defined in special system modules. An overview and an alphabetically arranged description of the builtin predicates can be found in the IF/Prolog Reference Manual [1].
Predicates which permit backtracking are indicated by a hash character ('#') in front of the functor. This character does not appear with predicates not having this capability. For metapredicates, the argument list is followed by the text [ @ + Module ] . The module qualification can be specified by @/2. Metapredicates are supplied with information on the calling module.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 50
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! Directives are special syntactic structures which can be specified in IF/Prolog texts and which are processed when these texts are read in (e.g. with consult/1). They are indicated by : in front of the functor, as they would be written in a Prolog text. User definable predicates are automatically called at particular points by IF/Prolog if the user has defined them. They are identified by the text [ : Body ] after the argument list. The call mode specifies the instantiation of an argument at the time of the call. In front of each argument there is a sign ('@', '+', '', or '?') to indicate the call type of the argument, as follows: @ The argument is a pure input parameter. The current parameter specified in the call must be of the prescribed type and any uninstantiated variables contained in this parameter are not instantiated in the call.
+
The argument is an input parameter. The current parameter specified in the call must be of the prescribed type. Any uninstantiated variables contained in this parameter may be instantiated in the call. When the argument is an atomic term, there is no difference between the modes + and @. The mode @ is therefore used only when the argument may be a compound term. ? The argument is an input/output parameter. The current parameter must be either a variable or a term of the prescribed type. In the course of the execution of the predicate, this parameter is unified. If this unification is not successful, then the entire predicate call will fail. Any uninstantiated variables contained in this parameter may be instantiated in the call.

The argument is a pure output parameter. The current parameter must be an uninstantiated variable. If the predicate succeeds, this variable is instantiated with the result of the predicate call. The type of result from the predicate call is indicated in the section on 'Arguments' in the full description. Several call patterns are possible for some predicates. In some predicates where an integer is expected as an input parameter, it is also possible to input an arithmetic expression with an integer value; an expression will be evaluated implicitly as with is/2.
Examples
If uninstantiated variables are permitted in the mode @, they will not be instantiated. The argument of atom/1 has the call mode @. It is therefore possible to specify a variable in order, for example, to test whether it is instantiated to an atom. This variable will not be instantiated, however. The three arguments of current_op/3 have the call mode ?. If all three arguments are uninstantiated variables, you can obtain all defined operators by means of backtracking:
[user] ? current_op(Precedence,Type,Name). Precedence = 50
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 51
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
Type Name = xfx = : ;
The instantiated arguments are unified; the uninstantiated variables are instantiated. The following queries operators with precedence 400: [user] ? current_op(400,Type,Name).
Type Name Type Name Yes = yfx = >> ; = yfx = <<
5.B WRITE A PROLOG PROGRAM TO GENERATE FIBONACCI SERIES Prolog program to generate a fibonacci series of N elements
domains x = integer predicates fibonacci(x) clauses fibonacci(1). fibonacci(N) :N1 = N  1, N1 >= 0,!, fibonacci(N1), write(F1," ,"), F = F1 + N. domains num,ans=integer. predicates fibo(num). clauses fibo(1):write("1"). fibo(X): X<5,!, fibo(X1 +1), Ans=X1+X.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 52
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
Fibonacci
The following program computes Fibonacci numbers using the top down method, i.e., if we are looking for Fibonacci number of N>1, we first compute Fibonacci numbers of N1 and N2 (usign the same procedure) and, then, we compose the Fibonacci number of N from the subresults. In this case, the recursion stops as soon as the Fibonacci number of 0 or 1 is computed.
fibo_td(0,0). fibo_td(1,1) fibo_td(N,F):N>1, N1 is N1, N2 is N2, fibo_td(N1,F1), fibo_td(N2,F2), F is F1+F2.
Note, that the above procedure is very inefficient if standard Prolog execution rule is used because we compute the same thing many times. For example, to compute F(N1) we need to compute F(N2) which is also required to compute F(N) that was decomposed to F(N1) and F(N2). In fact, the complexity of the above procedure is exponential thas is "not very efficient".
Bottom Up Computation
Even if the top down computation is typical for Prolog, we can still simulate the bottom up computation as well without changes of the Prolog interpreter. The bottom up computation starts with know facts and extends the set of know trues using rules. i.e., it derives new facts from old facts and rules. This extension continues till the solved problem is present in the computed set of facts. In general, pure bottom up method is less efficient than top down method because many facts are derived that has nothing in common with the original problem. Therefore, Prolog uses top down evaluation as a standard method of computation. However, in same cases, it is possible to guide the bottom up evaluation towards the solution of the original problem. The following two examples present bottom up versions of the above two procedures for computing factorial and Fibonacci numbers. The advantage of bottom up evaluation is visible mainly in the procedure fibo_bu that is a lot of faster than fibo_td.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 53
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
Fibonacci
We can use the same principle as in "bottomup factorial" to compute the Fibonacci numbers using bottom up method. Now, we need to remember last two Fibonacci numbers to be able to compute the next Fibonacci number.
fibo_bu(N,F):fibo_bu1(0,0,1,N,F). fibo_bu1(N,F,_,N,F) fibo_bu1(N1,F1,F2,N,F):N1<N, N2 is N1+1, F3 is F1+F2, fibo_bu1(N2,F2,F3,N,F).
Note, that the complexity of fibo_bu is linear and therefore the procedure fibo_bu is far away efficient than fibo_td that is exponential.
6. 6.A EXPLAIN VARIOUS LIST PROCESSING FUNCTIONS OF LISP >>>>>>>>>REPEATED<<<<<<<<< 2007 Lists are powerful data structures for holding and manipulating groups of things. In Prolog, a list is simply a collection of terms. The terms can be any Prolog data types,including structures and other lists.Syntactically, a list is denoted by square brackets with the terms separated by commas. For example, a list of alcohol is represented as
[Tequila,Whisky,Vodka,Martini,Muscat,Malibu,Soho,Epita]
This gives us an alternative way of representing the locations of things. Rather than having separate location predicates for each thing, we can have one location predicate per container, with a list of things in the container.
list_where([Tequila,Whisky,Vodka], bathroom). list_where([Martini,Muscat], kitchen). list_where([Malibu,Soho], under_the_bed). list_where([Epita], everywhere).
The empty list is represented by a set of empty brackets []. This is equivalent to the nil in other programming language.For our example in this section, it can describe the lack of things in a place :
list_where([], cave).
The Unification works on lists just as it works on other data structure of SWI Prolog. With that, we now can ask questions about lists to prolog:
? [_,_,X] = [lesson, work, sleeping]. X = sleeping ? list_where(X, under_the_bed). X = [Malibu,Soho]
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 54
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! Notice that there is a impractical method of getteing a list of elements in the first example, because of Prolog won't unify unless both list have the same number of elements. At last, the special notation for list structures.
[X  Y]
This structure is unified with a list, X is bound to the first element of the list, called the head. Y is bound to the list of remaining elements, called the tail.Note that the tail is considered as a list for Prolog and the empty list does not unify with the standart list syntax because it has no head. Here is an example :
? [XY] = [a, b, c, d, e]. X = a Y = [b, c, d, e] ? [XY] = []. no
The empty list does not unify with the standard list syntax because it has no head.
? [XY] = []. no
This failure is important, because it is often used to test for the boundary condition in a recursive routine. That is, as long as there are elements in the list, a unification with the [XY] pattern will succeed. When there are no elements in the list, that unification fails, indicating that the boundary condition applies. We can specify more than just the first element before the bar (). In fact, the only rule is that what follows it should be a list.
? [First, Second  Q] = [water,gin,tequila,whisky]. First = water Second = gin Q = [tequila,whisky]
We have said a list is a special kind of structure. In a sense it is, but in another sense it is just like any other Prolog term. The last example gives us some insight into the true nature of the list. It is really an ordinary twoargument predicate. The first argument is the head and the second is the tail. This predicate is represented by a period(.). To see this notation, we use the builtin predicate display, which writes lits in using this syntax.
? X = [TQ], display(X). .(_01,_02)
From this examples it should be clear why there is a different syntax for lists. The easier syntax makes for easier reading, but sometimes obscures the behavior of the predicate. It helps to keep this "real" structure of lists in mind when working with predicates that manipulate lists.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 55
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! The first one we will look at is member. As with most recursive predicates, we will start with the boundary condition, or the simple case. An element is a member of a list if it is the head of the list.
member(T,[TQ]).
This clause also illustrates how a fact with variable arguments acts as a rule. The second clause of member is the recursive rule. It says an element is a member of a list if it is a member of the tail of the list.
member(X,[TQ]) : member(X,Q).
As with many Prolog predicates, member can be used in multiple ways. If the first argument is a variable, member will, on backtracking, generate all of the terms in a given list.
? membre(X, [muscat, soho, martini]). X = muscat; X = soho; X = martini; no
Another very useful list predicate builds lists from other lists or alternatively splits lists into separate pieces. This predicate is usually called append. In this predicate the second argument is appended to the first argument to yield the third argument. For example
? append([a,b,c],[d,e,f],X). X = [a,b,c,d,e,f]
It is a little more difficult to follow, since the basic strategy of working from the head of the list does not fit nicely with the problem of adding something to the end of a list. append solves this problem by reducing the first list recursively. The boundary condition states that if a list X is appended to the empty list, the resulting list is also X.
append([],X,X).
The recursive condition states that if list X is appended to list [TQ1], then the head of the new list is also H, and the tail of the new list is the result of appending X to the tail of the first list.
append([TQ1],X,[TQ2]) : append(Q1,X,Q2).
Real Prolog magic is at work here, which the trace alone does not reveal. At each level, new variable bindings are built, that are unified with the variables of the previous level. Specifically, the third argument in the recursive call to append is the tail of the third argument in the head of the clause. These variable relationships are included at each step.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 56
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! 6 6.B WRITE A PROGRAM IN LISP TO FIND THE FACTORIAL OF A GIVEN NUMBER N. i. WITHOUT RECURSION ii. WITH RECURSION 1. without recursion recursion occurs when a program calls itself as a help function. How can a function be defined in terms of itself? That sounds like a circular definition! Recursion avoids circularity by defining the function in terms of simpler cases of itself. If we keep using the function on simpler cases, then eventually the function will get to a simple enough case and as such will know the answer without having to recur. Let's try a simple program, called RECITE, to print out all the elements in a list with one element per line of output. We will do this by having our function print out the CAR of the list, using the builtin Lisp function PRINT, and then call itself, recur with the CDR of the list. Notice that because we are going to pass the CDR of the list, the list will get smaller with each recursive call. Recursion is useless unless we can make it stop. RECITE, therefore, should do the following: If its argument is NIL, then it should return to NIL. [This type of test is called a termination condition. We need it to keep List from running away.] If its argument is not a NIL, then print the CAR of the argument and call RECITE again with the CDR. Here is RECITE.
:(DEFINE (RECITE (LAMBDA (STUFF) : : : : )))) RECITE :(RECITE '(THIS IS A TEST LIST)) THIS IS A TEST LIST NIL (COND ((NULL STUFF) ()) (T (PRINT (CAR STUFF)) (RECITE (CDR STUFF)))
When STUFF is NIL, the COND evaluates "(null stuff)" to T and evaluates the "()" as dictated by COND. Otherwise it prints the CAR of the list and calls RECITE, binding the CDR of STUFF to the new STUFF. Notice that it does not replace the value of STUFF but simply binds a new local value to it. When that particular call terminates, the previous value of STUFF will return. The NIL displayed at the end is not printed by the PRINT function. Rather, it is the value returned by the RECITE function. It came from the succession of recursive function terminations. When the function we started off with terminates, it prints out its value because there is no "caller" to return to other than the user. What would have happened if we had left out the termination condition? Answer: no end in sight.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 57
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
:(DEFINE (RECITE (LAMBDA (STUFF) : : (PRINT (CAR STUFF)) (RECITE (CDR STUFF))))))) RECITE :(RECITE '(THIS IS A TEST)) THIS IS A TEST NIL NIL NIL NIL NIL NIL +() NIL
{We hit control C.} The list of NILs in the above execution will go on forever. We've cut off at seven in order to preserve our forests. This is a good time to learn about how to do thatthat is, stop a function that is running wild. The answer is controlC. When a Lisp function starts repeating, you simply hold CONTROL and hit C. This causes Lisp to break the function, suspend it, and enter the "+" mode. [We've talked about this before.] Onward to another example. The function we are going to define is called MEMBER. This function will take two arguments, an atom and a list. MEMBER will return a T if the atom is one of the toplevel elements of the list, NIL otherwise. We now exhibit the function definition and some examples of its uses.
:(DEFINE (MEMBER (LAMBDA (A L) : : : : MEMBER :(MEMBER 'MAN '(UNION MAN)) T :(MEMBER 'SNURD '(ELMER SNERD)) NIL :(MEMBER 'A '((A B) C D)) (COND ((NULL L) NIL) ((EQUAL A (CAR L)) T) (T (MEMBER A (CDR L)))))))
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 58
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
NIL
Here, we first test to see if L is an empty list. If it is, we need to search no further. We then compare the specified atom A with the first element of list L. If they are equal, then we have a match and the value of T is returned. Otherwise, we try again, looking for the atom in the CDR of the list. Note that this process is guaranteed to terminate because the function either returns a value or tries again with a shorter list. A list can only contain a finite number of elements so that after a maximum number of calls equal to the number of toplevel elements in the initial list, we must reach an answer. Let's follow the MEMBER function with a debugging tool called TRACE. The Lisp TRACE function will tell us who calls whom and what is returned. When you see ">>", it means that the function is being called. When you see "<<", it indicates that the function is returning. Follow these examples and watch what's happening. Note that you get an extra set of parentheses around the arguments in the ">>" trace.
:(TRACE MEMBER) T :(MEMBER 'ARM '(HEAD LEG ARM FOOT)) >> >> >> <<<<<<MEMBER MEMBER MEMBER MEMBER MEMBER MEMBER :: :: :: :: :: :: (ARM (HEAD LEG ARM FOOT)) (ARM (LEG ARM FOOT)) (ARM (ARM FOOT)) T T T
Note that the "T" result is passed back through each level of the recursive call. It isn't just popped right back up to the top from the last call [the last ">>"]. Let's try one that fails [returns NIL].
:(MEMBER 'HAND '(ARM HEAD LEG FOOT)) >> MEMBER :: (HAND (ARM HEAD LEG FOOT ) ) >> MEMBER :: (HAND (HEAD LEG FOOT ) ) >> MEMBER :: (HAND (LEG FOOT ) ) >> MEMBER :: (HAND (FOOT ) ) >> MEMBER :: (HAND NIL ) << MEMBER :: NIL << MEMBER :: NIL << MEMBER :: NIL << MEMBER :: NIL << MEMBER :: NIL NIL
The same returning sequence happens with the NIL. In fact, the same type of thing will always happen in a Lisp function that returns the values to the routine that called it, never back to the user directly. We saw this in the ENDS example and it also applies to recursion. The opposite of TRACE is UNTRACE.
:(UNTRACE MEMBER)
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 59
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
NIL
If you forget to UNTRACE your functions they will keep tracing themselves until you either restart Lisp, or shut off your computer. If you wish to turn tracing off of all of your functions at once, simply type (UNTRACE).
:(UNTRACE) NIL
2. with recursion we will look at a recursive mathematical function, namely, the factorial. Recall that the factorial of n is the product of the first n integers and is defined by the following recursive formula:
n! = 1 n*(n1)! if n = 0 if n > 0
Notice that the termination condition is already specified in the definition, namely, that the recursion stops when n=0. The factorial can easily be defined in Lisp, as follows:
: :(DEFINE (FACTORIAL (LAMBDA (N) : : : : (COND ((EQUAL N 0) 1) (T (MULT N (FACTORIAL (SUB N 1)))) )))) FACTORIAL :(FACTORIAL 0) 1 :(FACTORIAL 1) 1 :(FACTORIAL 2) 2 :(FACTORIAL 3) 6 :(FACTORIAL 5) 120
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 60
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! It would be instructive to trace an evaluation of FACTORIAL to see how it works. Here's a trace of (FACTORIAL 5).
:(FACTORIAL 5) >> FACTORIAL >> FACTORIAL >> FACTORIAL >> FACTORIAL >> FACTORIAL >> FACTORIAL << FACTORIAL << FACTORIAL << FACTORIAL << FACTORIAL << FACTORIAL << FACTORIAL 120 :: :: :: :: :: :: :: :: :: :: :: :: (5 ) (4 ) (3 ) (2 ) (1 ) (0 ) 1 1 2 6 24 120
Notice how each value of FACTORIAL is passed back through every level of the recursive call, where it is multiplied by the value of n at that level. Work through the example to be sure you understand it.
domains Name,Password=Symbol predicates Getentry(Symbol,Symbol) Logon(Integer) User(Symbol,Symbol) go clauses go:Clearwindow, Logon(3), Write("YOU ARE NOW LOGGEDIN"),nl. Logon(0):!,Write("SORRY YOU CANNOT LOGON"),nl, Fail. Logon(X):Getentry(Name,Password), User(Name,Password); Write("ILLEGAL ENTRY\n"),nl, XX=X1, Logon(XX).
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 61
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! Getentry(Name,Password):Write("User Name: "), Readln(Name), Write("Password: "), Readln(Password). User(bill,bigfoot). User(mary,flower). User(john,devil). User(peter,rr). User(admin,pass).
OUTPUT: Goal:go User Name: bill Password: flower ILLEGAL ENTRY User Name: bill Password: devil ILLEGAL ENTRY User Name: bill Password: bigfoot YOU ARE NOW LOGGEDIN Yes 7.B LIST THE SIMILARITIES AND DIFFERENCES BETWEEN PROLOG AND CONVENTIONAL PROGRAMMING LANGUAGES Basically, if your program can be stated easily as declaritive formal logic statements, Prolog (or another language in that family) will give the fastest development time. If you use a good Prolog compiler, it will also give the best performance and reliability, because the engine will have had a lot of design and development effort. Trying to implement this kind of thing in another language tends to be a mess. The cleanest and most general solution probably involves implementing your own unification engine. Even naive implementations aren't exactly trivial, the Warren Abstract Machine has a book or two written about it, and doing better will at the very least involve a fair bit of research, reading some headacheinducing papers. Of course in the real world, key parts of your program may benefit from Prolog, but a lot of other stuff is better handled using another language. That's why a lot of Prolog compilers can interface with, e.g., C. 1 down vote **I'd say prolog works well for problems where a knowledge base forms an important part of the solution. Especially when the knowledge structure is suited to be encoded as logical rules.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 62
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! For example, writing a natural language interpreter for a particular problem domain would require a lot of knowledge in that domain. Expert systems also fall within this knowledge driven category. It's also a nice language to explore solutions to logical puzzles ;) ** One of the best times to use Prolog is when you have a problem suited to solving with backtracking. And that is when you have lots of possible solutions to a problem, and perhaps you want to order them to include/exclude depending on some context. This suggests a lot of ambiguity... as in natural language processing. It sure would be a lot tidier to write all the potential answers as Prolog clauses. With a imperative language all I think you can really do is write a giant (really giant) CASE statement, which is not too fun. ** The stuff that are inherit in prolog:
pattern matching! anything that involves a depth first search. ( in java if you want to do a DFS, you may want to implement it by a visitor pattern or do a (really giant) CASE unification ??
Paul Graham, is a Lisp person nonetheless he argues that prolog is really good for 2% of the problems, I am myself like to break this 2% down and figure how he'd come up with such number. His argument for "better" languages is "less code, more power". Prolog is definitely "less code" and if you go for latter flavours of it (Typed ones), you get more power too. The only thing that bothered me when using prolog is the fact that I dont have random access in lists (no arrays). ** 2 down vote accepted Compared to what exactly? Prolog is really just the preeminent implementation of logic programming so if your question is really about a comparison of programming paradigms well that's really very broad indeed and you should look here. If your question is more specifically about prolog vs the more commonly seen OO languages I would argue that you're really comparing apples to oranges  the "advantage" (such as it is) is just a different way of thinking about the world, and sometimes changing the way you ask a question provides a better tool for solving a problem.
History
Prolog (PROgramming LOGic) rose within the realm of Artificial Intelligence (AI). It originally became popular with AI researchers, who know more about "what" and "how" intelligent behaviour is achieved. The philosopy behind it deals with the logical and declarative aspects. Prolog represents a fundamentally new approach to computing and became a serious competitor to LISP.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 63
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
Intelligent Systems  programs which perform useful tasks by utilizing artificaial intelligence techniques. Expert Systems  intelligent systems which reproduce decisionmaking at the level of a human expert. Natural Language Systems  which can analys and respond to statements made in ordinary language as opposed to approved keywords or menu selections. Relational Database Systems
Areas of Application
Prolog is the highest level generalpurpose language widely used today. It is taught with a strong declarative emphasis on thinking of the logical relations between objects or entities relevant to a given problem, rather than on procedural steps necessary to solve it. The system decides the way to solve the problem, including the sequences of instructions that the computer must go through to solve it. It is easier to say what we want done and leave it to the computer to do it for us. Since a major criterion in the commercial world today is speed of performance, Prolog is an ideal prototyping language. Its concept makes use of parallel architectures. It solves problems by searching a knowledge base (or more correctly a database) which would be greatly improved if several processors are made to search different parts of the database.
8. WRITE A SHORT NOTES ON a. forward versus backward reasoning b. STRUCTURE OF PROLOG PROGRAM >>>>> REPEATED 2007 c. CHARACTERISTICS OF KNOWLEDGE d. SYNTAX AND SEMANTICS OF PROPOSITIONAL LOGIC A. forward versus backward reasoning Whether you use forward or backwards reasoning to sove a problem depends on the properties of your rule set and initial facts. Sometimes, if you have some particular goal (to test some hypothesis), then backward chaining will be much more efficient, as you avoid drawing conclusions from irrelevant facts. However, sometimes backward chaining can be very wasteful there may be many possible ways of trying to prove something, and you may have to try almost all of them before you find one that works. Forward chaining may be better if you have lots of things you want to prove (or if you just want to find out in general what new facts are true); when you have a small set of initial facts; and when there tend to be lots of different rules which allow you to draw the same conclusion. Backward chaining may be better if you are trying to prove a single fact, given a large set of initial facts, and where, if you used forward chaining, lots of rules would be eligible to fire in any cycle. The state space representation forms the basis of most of the AI methods. Its structure corresponds to the structure of problem solving in two important ways:
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 64
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! It allows for a formal definition of a problem as the need to convert some given situation into some desired situation using a set of permissible operations. It permits us to define the process of solving a particular problem as a combination of known techniques (each represented as a rule defining a single step in the space) and search, the general technique of exploring the space to try to find some path from current state to a goal state. Search is a very important process in the solution of hard problems for which no more direct techniques are available. Forward chaining means applying rules in a forward direction: recursively applying the rules over data to generate more data (and applying the rules over that data... I have a member of po:Person... it must also be a member of foaf:Person... and so it must be a foaf:Agent and dc:Agent... and so...) Backward chaining means applying rules in a backwards manner: taking a goal (e.g., a query) and recursively working backwards to find more data that can satisfy the goal (I'm looking for foaf:Agents... I should also look for dc:Agents and foaf:Persons and po:Persons...)
forwardchaining (~materialisation): precomputing and storing answers is suitable for: o frequently accessed data, o which are relatively static, o which are expensive to compute, and/or o which are small enough to efficiently store o (a la Lesson 6) backwardchaining (~queryrewriting): storing a minimal index from which answers can be computed on demand is more suitable where: o there is little scope for reuse of computed answers, o the answers are dynamic, o answers can be efficiently computed at runtime, and/or o the "answer space" is too large to materialise and store
A hybrid approach should then give the best of both worlds, materialising the inferences that are frequently accessed, static, and/or small, and supporting queryrewriting for inferences that are large, cheap to do at runtime, dynamic and/or infrequently accessed. For example, many largescale reasoners:
typically rely on materialisation to do the bulk of reasoning. use backwardchaining to support stuff like reflexive owl:sameAs statements, or rdf:type
rdfs:Resource/owl:Thing
use a hybrid approach for equality (to avoid ~quadratic materialisation: a maximum of n inferences where n is the no. of input triples), where o each set of "URI aliases" (identifiers related by owl:sameAs) is stored in a special index o one URI is chosen as a canonical identifier to represent all such aliases in the indexed data o queries are rewritten to use the chosen canonical identifer o results data can be (optionally as needed) expanded to use all combinations of identifiers. B.. STRUCTURE OF PROLOG PROGRAM >>>>> REPEATED 2007
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 65
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! C.CHARACTERISTICS OF KNOWLEDGE
Coverage, which means the KR covers a breath and depth of information. Without a wide coverage, the KR cannot determine anything or resolve ambiguities. Understandable by humans. KR is viewed as a natural language, so the logic should flow freely. It should support modularity and hierarchies of classes (Polar bears are bears, which are animals). It should also have simple primitives that combine in complex forms. Consistency. If John closed the door, it can also be interpreted as the door was closed by John. By being consistent, the KR can eliminate redundant or conflicting knowledge. Efficient Easiness for modifying and updating. Supports the intelligent activity which uses the knowledge base
To gain a better understanding of why these characteristics represent a good knowledge representation, think about how an encyclopedia (e.g. Wikipedia) is structured. There are millions of articles (coverage), and they are sorted into categories, content types, and similar topics (understandable). It redirects different titles but same content to the same article (consistency). It is efficient, easy to add new pages or update existing ones, and allows users on their mobile phones and desktops to view its knowledge base. D. SYNTAX AND SEMANTICS OF PROPOSITIONAL LOGIC
So misspiggy and kermit are constants representing objects in our domain. Notice that plump and highpitched is different from voiceof:
plump and highpitched are represent properties and so are boolean valued functions. They are often called predicates or relations. voiceof is a function that returns an object (not true/false). To help us differentiate we shall use ``of'' at the end of a function name.
The predicates plump and highpitched are unary predicates but of course we can have binary or nary predicates; e.g. loves(misspiggy, voiceof(kermit))
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 66
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
Simple Sentences
The fundamental components of logic are
object constants; e.g. misspiggy, kermit function constants; e.g. voiceof predicate constants; e.g. plump, highpitched, loved
Predicate and function constants take arguments which are objects in our domain. Predicate constants are used to describe relationships concerning the objects and return the value true/false. Function constants return values that are objects. Atom: An atom is a basic building block of logic consisting of a predicate constant applied to a set of objects
Prolog programs and Clips rules also contain knowledge organised in this way: Prolog terms:
loves(misspiggy, kermit)
Remember that in Clips ordered terms the first argument is special. It is common to represent knowledge in triples like this and so they have a name OAV (ObjectAttributeValue) triples where the attribute is predicate and the object and value are the arguments.
''Kermit does not love Miss Piggy's voice'' Conjunction: combines two conjuncts:
loves(misspiggy, kermit) loves(misspiggy, voiceof(kermit))
''Miss Piggy loves Kermit and Miss Piggy loves Kernit's voice'' Notice it is not correct syntax to write in logic
loves(misspiggy, kermit) voiceof(kermit)
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 67
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! because we have tried to conjoin a sentence (truth valued) with an object. Logic operators must apply to truthvalued sentences. Disjunction: combines two disjuncts:
loves(misspiggy, kermit) loves(misspiggy, voiceof(kermit))
''Miss Piggy loves Kermit or Miss Piggy loves Kermit's voice'' Implication: combines a condition and conclusion
loves(misspiggy, voiceof(kermit)) loves(misspiggy, kermit)
''If Miss Piggy loves Kermit's voice then Miss Piggy loves Kermit'' The language we have described so far contains atoms and the connectives , , and . This defines the syntax of propositional Logic. It is normal to represent atoms in propositional logic as single uppercase letters but here we have used a more meaningful terminology for the atoms that extends easily to Predicate Logic.
Example: Models Define Truth Suppose a language contains only one object constant misspiggy and two relation constants ugly and beautiful. The following models define different facts about Miss Piggy.
M= : In this model Miss Piggy is neither ugly nor beautiful. M={ugly(misspiggy)}: In this model Miss Piggy is ugly and not beautiful. M={beautiful(misspiggy)}: In this model Miss Piggy is beautiful and not ugly. M={ugly(misspiggy), beautiful(misspiggy)}: In this model Miss Piggy is both ugly and beautiful. The last statement is intuitively wrong but the model selected commits the truth of the atoms in the language. pg. no: 68
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
Compound Sentences
So far we have restricted our attention to the semantics of atoms: an atom is true if it is a member of the model M; otherwise it is false. Extending the semantics to compound sentences is easy. Notice that in the definitions below are reached. Conjunction: is true in M iff So the conjunct
loves(misspiggy, kermit) loves(misspiggy, voiceof(kermit))
and
do not need to be atoms because these definitions work recursively until atoms
and
Miss Piggy loves Kermit; and Miss Piggy loves Kermit's voice
or
is true in M.
is true whenever
Miss Piggy loves Kermit; Miss Piggy loves Kermit's voice; or Miss Piggy loves both Kermit and his voice.
Therefore the disjunction is weaker than either disjunct and the conjunction of these disjuncts. Negation: is true in M iff Implication: is not true in M. is not true in M or is true in M. they normally is false the
is true in M iff
is true. But if
causal link causes confusion because we can't tell whether should be true or not. Logic requires that the connectives are truth functional and so the truth of the compound sentence must be determined from the truth of its component parts. Logic defines that if is false then is true regardless of the truth of .
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 69
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! So both of the following implications are true (provided you believe pigs do not fly!):
fly(pigs) fly(pigs) beautiful(misspiggy) beautiful(misspiggy)
true?
M= Miss Piggy is not ugly and so the antecedent fails. Therefore the implication holds. (Miss Piggy is also not beautiful in this model.) M={beautiful(misspiggy)} Again, Miss Piggy is not ugly and so the implication holds. M={ugly(misspiggy)} Miss Piggy is not beautiful and so the conclusion is valid and hence the implication holds. M={ugly(misspiggy), beautiful(misspiggy)} Miss Piggy is ugly and so the antecedent holds. But she is also beautiful and so beautiful(misspiggy) is not true. Therefore the conclusion does not hold and so the implication fails in this (and only this) case.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 70
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!!
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 71
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! 1. 1.A WHAT IS AI? EXPLAIN DIFFERENT AI TECHNIQUES Part I: AI definition >>>> repeated in 2007 Part II: Suns view on different AI techniques
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 72
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! 1.B EXPLAIN APPLICATION AREA OF AI Intelligence is the ability to think, to imagine, to create, memorize, understand, recognize patterns, make choices, adapt to change and learn from experience. Artificial intelligence is a human endeavor to create a nonorganic machinebased entity, that has all the above abilities of natural organic intelligence. Hence it is known as 'Artificial Intelligence' (AI). It is the ultimate challenge for an intelligence, to create an equal, another intelligent being. It is the ultimate form of art, where the artist's creation, not only inherits the impressions of his thoughts, but also his ability to think! How will one recognize artificial intelligence? According to Alan Turing, if you question a human and an artificially intelligent being and if by their answers, you can't recognize which is the artificial one, then you have succeeded in creating artificial intelligence. Initial hopes of computer scientists of creating an artificial intelligence, were dashed hopelessly as they realized how much they had underrated the human mind's capabilities! How do you teach a machine to imagine? They realized that they must understand what makes natural intelligence, the human mind, possible. Only then could they get any near to their goal. Approaches to AI Initially, researchers thought that creating an AI would be simply writing programs for each and every function an intelligence performs! As they went on with this task, they realized that this approach was too shallow. Even simple functions like face recognition, spacial sense, pattern recognition and language comprehension were beyond their programming skills! They understood that to create an AI, they must delve deeper into natural intelligence first. They tried to understand how cognition, comprehension, decisionmaking happen in the human mind. They had to understand what understanding really means! Some went into the study of the brain and tried to understand how the network of neurons creates the mind. Thus, researchers branched into different approaches, but they had the same goal of creating intelligent machines. Let us introduce ourselves to some of the main approaches to artificial intelligence. They are divided into two main lines of thought, the bottom up and the top down approach: Applications of AI Artificial Intelligence in the form of expert systems and neural networks have applications in every field of human endeavor. They combine precision and computational power with pure logic, to solve problems and reduce error in operation. Already, robot expert systems are taking over many jobs in industries that are dangerous for or beyond human ability. Some of the applications divided by domains are as follows: game playing You can buy machines that can play master level chess for a few hundred dollars. There is some AI in them, but they play well against people mainly through brute force computationlooking at hundreds of thousands of positions. To beat a world champion by brute force and known reliable heuristics requires being able to look at 200 million positions per second. speech recognition
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 73
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! In the 1990s, computer speech recognition reached a practical level for limited purposes. Thus United Airlines has replaced its keyboard tree for flight information by a system using speech recognition of flight numbers and city names. It is quite convenient. On the the other hand, while it is possible to instruct some computers using speech, most users have gone back to the keyboard and the mouse as still more convenient. understanding natural language Just getting a sequence of words into a computer is not enough. Parsing sentences is not enough either. The computer has to be provided with an understanding of the domain the text is about, and this is presently possible only for very limited domains. computer vision The world is composed of threedimensional objects, but the inputs to the human eye and computers' TV cameras are two dimensional. Some useful programs can work solely in two dimensions, but full computer vision requires partial threedimensional information that is not just a set of twodimensional views. At present there are only limited ways of representing threedimensional information directly, and they are not as good as what humans evidently use. expert systems A ``knowledge engineer'' interviews experts in a certain domain and tries to embody their knowledge in a computer program for carrying out some task. How well this works depends on whether the intellectual mechanisms required for the task are within the present state of AI. When this turned out not to be so, there were many disappointing results. One of the first expert systems was MYCIN in 1974, which diagnosed bacterial infections of the blood and suggested treatments. It did better than medical students or practicing doctors, provided its limitations were observed. Namely, its ontology included bacteria, symptoms, and treatments and did not include patients, doctors, hospitals, death, recovery, and events occurring in time. Its interactions depended on a single patient being considered. Since the experts consulted by the knowledge engineers knew about patients, doctors, death, recovery, etc., it is clear that the knowledge engineers forced what the experts told them into a predetermined framework. In the present state of AI, this has to be true. The usefulness of current expert systems depends on their users having common sense. heuristic classification One of the most feasible kinds of expert system given the present knowledge of AI is to put some information in one of a fixed set of categories using several sources of information. An example is advising whether to accept a proposed credit card purchase. Information is available about the owner of the credit card, his record of payment and also about the item he is buying and about the establishment from which he is buying it (e.g., about whether there have been previous credit card frauds at this establishment). Heavy Industries and Space: Robotics and cybernetics have taken a leap combined with artificially intelligent expert systems. An entire manufacturing process is now totally automated, controlled and maintained by a computer system in car manufacture, machine tool production, computer chip production and almost every hightech process. They carry out dangerous tasks like handling hazardous radioactive materials. Robotic pilots carry out complex maneuvering techniques of unmanned spacecrafts sent in space. Japan is the leading country in the world in terms of robotics research and use. Finance: Banks use intelligent software applications to screen and analyze financial data. Software programs that can predict trends in the stock market have been created which have been known to beat humans in predictive power. Computer Science: Researchers in quest of artificial intelligence have created spin offs like dynamic programming, object oriented programming, symbolic programming, intelligent storage management
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 74
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! systems and many more such tools. The primary goal of creating an artificial intelligence still remains a distant dream but people are getting an idea of the ultimate path which could lead to it. Aviation: Air lines use expert systems in planes to monitor atmospheric conditions and system status. The plane can be put on auto pilot once a course is set for the destination. Weather Forecast: Neural networks are used for predicting weather conditions. Previous data is fed to a neural network which learns the pattern and uses that knowledge to predict weather patterns. Swarm Intelligence: This is an approach to, as well as application of artificial intelligence similar to a neural network. Here, programmers study how intelligence emerges in natural systems like swarms of bees even though on an individual level, a bee just follows simple rules. They study relationships in nature like the preypredator relationships that give an insight into how intelligence emerges in a swarm or collection from simple rules at an individual level. They develop intelligent systems by creating agent programs that mimic the behavior of these natural systems! Is artificial Intelligence really possible? Can an intelligence like a human mind surpass itself and create its own image? The depth and the powers of the human mind are just being tapped. Who knows, it might be possible, only time can tell! Even if such an intelligence is created, will it share our sense of morals and justice, will it share our idiosyncrasies? This will be the next step in the evolution of intelligence. Hope I have succeeded in conveying to you the excitement and possibilities this subject holds! 2. 2A EXPLAIN PRODUCTION SYSTEM IN DETAIL >>>>>>>>>>> REPEATED IN 2007 OLD SYLLABUS
2.B DISCUSS TRAVELING SALESMANS PROBLEM The traveling salesman problem is a traditional issue that has to do with making the most efficient use of resources while at the same time expending the least amount of energy in that utilization. The designation for this type of problem hails back to the days of the traveling salesman, who often wished to arrange travel in a manner that allowed for visiting the most towns without having to double back and cross into any given town more than once. In a wider sense, the traveling salesman problem is considered to be a classic example of what is known as a tour problem. Essentially, any type of tour problem involves making a series of stops along a designated route and making a return journey without ever making a second visit to any previous stop. Generally, a tour problem is present when there is concern on making the most of available resources such as time and mode of travel to accomplish the most in results. Finding a solution to a tour problem is sometimes referred to as discovering the leastcost path, implying that the strategic planning of the route will ensure maximum benefit with minimum expenditure incurred the concept of the traveling salesman problem can be translated into a number of different disciplines. For example, the idea of combinatorial optimization has a direct relationship to the traveling salesman model. As a form of optimization that is useful in both mathematical and computer science disciplines, combinatorial optimization seeks to team relevant factors and apply them in a manner that will yield the best results with repeated usage.
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 75
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! In a similar manner, discrete optimization attempts to accomplish the same goal, although the term is sometimes employed to refer to tasks or operations that occur on a onetime basis rather than recurring. Discrete optimization also is helpful in computer science and mathematical disciplines. In addition, discrete optimization has a direct relationship to computational complexity theory and is understood to be of use in the development of artificial intelligence. While the imagery associated with a traveling salesman problem may seem an oversimplification of these types of detailed options for optimization, the idea behind the imagery helps to explain a basic fundamental to any type of optimization that strives for efficiency. The traveling salesman problem that is solved will yield huge benefits in the way of maximum return for minimum investment of resources. ***The traveling salesman problem is a traditional issue that has to do with making the most efficient use of resources while at the same time expending the least amount of energy in that utilization. The designation for this type of problem hails back to the days of the traveling salesman, who often wished to arrange travel in a manner that allowed for visiting the most towns without having to double back and cross into any given town more than once.In a wider sense, the traveling salesman problem is considered to be a classic example of what is known as a tour problem. In addition, discrete optimization has a direct relationship to computational complexity theory and is understood to be of use in the development of artificial intelligence.Related topicsWhile the imagery associated with a traveling salesman problem may seem an oversimplification of these types of detailed options for optimization, the idea behind the imagery helps to explain a basic fundamental to any type of optimization that strives for efficiency. The travelling salesman problem is a classical problem in operations operations research that involves a travelling salesman who has to visit N number of cities. Here we are faced with the problem of determining the shortest path that he requires to traverse. This problem does not have a polynomial time solution as the complexity of determining the shortest path increases as a function of factorial N for large values of N. A computer that is assigned the task of finding out the shortest path from a set of different possible tours will not be able to compute the shortest path for very large values of the number of cities. Hence the Travelling salesman problem cannot run in polynomial time and hence the complexity of solving the TSP is NP complete. Let us illustrate with an example. For a tour of 3 cities the no of possible combinations is 6. Here in the list below is shown the no of possible tours vs the no of cities in the tour 4 city tour = no. of possible tours is 24 5 city tour = the no. of possible tours is 120 6 city tour = the no. of possible tours is 720 7 city tour = the no. of possible tours is 5040 8 city tour = the number of possible tours is 40320 9 city tour = the number of possible tours is 362880
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 76
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! 10 city tour = the number of possible tours is 3628800 As it can be seen easily the number of computations required by a computer to determine the shortest path increases to 362880 for a tour of just 9 cities and for a 50 city tour the complexity increases to 3.04141E+64. So a computer just cannot process so many instructions within a specified time for larger and real life requirements. The processing power available in modern day computers would take trillions of years to find a solution to Travelling Salesman Problem for an input value (no of cities) say equal to 100. But if the paradigm of computing changes and computers are invented using cross functional technologies such as Quantum Computing, we may be able to solve NP complete problems within prescribed time limits. There are a lot of other problems such as the graph coloring, knapsack problem, clique, vertex cover problem etc., that are NP complete or where the solution to the problem can only be verified but cannot be determined in polynomial time. 3. A. DISCUSS STATE SPACE REPRESENTATION FOR WATER JUG PROBLEM >>> REPEATED IN 2007 OLD SYLLABUS B. EXPLAIN ANY HEURISTIC RESEARCH METHOD >>>>>>>>> REPEATED IN 2007 OLD SYLLABUS 4. A. EXPLAIN VARIOUS CHARACTERISTICS OF PROBLEM >>>>>>>>>>>> REPEATED IN 2007 OLD SYLLABUS B. LIST THE VARIOUS DIFFERENCES BETWEEN DEPTH FIRST AND BREADTH FIRST SEARCH METHOD >>>>>>>REPEATED IN 2007 OLD SYLLABUS 5. A. EXPLAIN STRUCTURE OF A PROLOG PROGRAM >>>>>>>>> REPEATED IN 2007 B. WRITE A PROLOG PROGRAM TO GENERATE FIBONACCI NUMBERS >>>>>>> REPEATED IN 2007 OLD SYLLABUS
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 77
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! 6. 6.A WRITE A PROLOG PROGRAM TO FIND SUM OF N NATURAL NUMBERS sorry I didnt get the exact answer, nevertheless I got the logic for the answer and also a supporting program on which this logic can be implemented  suresh logic:
% nat(X) iff X is a natural number nat(0). nat(s(N)) : nat(N). % sum(X,Y,Z) iff Z = X + Y sum(0,Y,Y). sum(s(X),Y,s(Z)) : sum(X,Y,Z). supporting program *program to count the numbers from 1toN and down Nto 1*/ domains N=Integer predicates Counter(Integer,Integer) run clauses run:Clearwindow, Write("Enter the Value of N"),nl, Readint(N), Write("Counting Numbers are :\n"), I=1, Counter(I,N). Counter(II,NN):II>=NN+1; Write(II),nl, III=II+1, Counter(III,NN), Write(II),nl. OUTPUT: Goal:run Enter the Value of N 5 Counting Numbers are : 1 2 3 4 5 5 4 3 2 1
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 78
As Im not handling this subject, I cant guarantee the accuracy of every answer Read on your own risk!!! 6.B WRITE THE SIMILARITIES AND DIFFERENCES BETWEEN PROLOG AND CONVENTIONAL PROGRAMMING LANGUAGES >>>>>>>> REPEATED IN 2007 OLD SYLLABUS 7. b 7.A WRITE VARIOUS LIST PROCESSING FUNCTION OF LISP >>>>>>>> REPEATED IN 2007 OLD SYLLABUS
7.B WRITE A PROGRAM IN LISP TO FIND THE LARGEST OF THREE NUMBERS logic: (defun max3 (a b c) (cond ((> a b) (cond ((> a c) a) (t c)) ((> b c) b) (t c) ) ) 8. A. WRITE SHORT NOTES ON ANY TWO OF THE FOLLOWING >>>>>>>>>>>>>>>REPEATED IN 2007 i. forward verses backward reasoning ii. characteristics of knowledge iii.syntax and semantics of propositional LOGIC
Solved by SURESH the SUN, lecturer at BCA dept, SG College Campus  Koppal
pg. no: 79
Гораздо больше, чем просто документы.
Откройте для себя все, что может предложить Scribd, включая книги и аудиокниги от крупных издательств.
Отменить можно в любой момент.