Vous êtes sur la page 1sur 60

What is AI? Explain AI problem 012 1B What is depth first search?

Explain algorithm and advantages 033 2A what is representation and reasoning 064 2B explain the term iteration and recursion related to AI 075 3A explain water jug problem 126 3B solve the problem by decomposable method sin2xcos2dx 147 4A explain any four built in functions of lisp 54solved in2007 oldsyllabus8 4B what is predicates in lisp explain any two 159 5A write a lisp program to fib Fibonacci series 1710 5B write a lisp program to find a factorial of a given number 1811 6A briefly explain the structure of a prolog program 1912 6B write the step procedure to compile and execute a program 2113 7 explain the following with examplei. null -22 ii. setf - 23 iii. Format - 24 iv. Cons - 252214 8A write a lisp program to find frequency of a number in a sinenlist2715 8B What is recursion? Write a program using recursive conceptto find sun of natural number28 SN Q QUESTION P. NO 16 1.A it is useful to structure AI. Production system provide such structure?discuss in detail3017 1.B Explain various characteristics of problem 3218 2.A explain state space representation for water jug problem 3619 2.B differentiate between depth first versus breadth first search method 3920 3.A what is heuristics? Explain any heuristic search method 4021 3.B define matching. Explain any one matching technique 4222 4.A how do you represent the knowledge using predicate logic 4323 4.B discuss unification algorithm 4724 5.A define predicate an objects in prolog. Discuss various types of objects usedin prolog4925 5.B write a prolog program to generate Fibonacci series 52R 6.A explain various list processing functions of LISP 5426 6.B write a program in LISP to find the factorial of a given number Ni. without recursion 57 ii. with recursion 60 5727 7.A write a prolog program to verify username and password 6128 7.B list the similarities and differences between prolog and conventional programming languages6229 8 write a short notes ona. forward versus backward reasoning b. structure of prolog program repeated in 2007 c. characteristics of knowledge 66 d. syntax and semantics of propositional logic 66 64 SN Q QUESTION P. NO REPEATED IN30 1.A What is AI? Explain different AI techniques 7231 1.B explain application area of AI 732.A explain production system in detail 2007 old syllabus32 2.B discuss traveling salesmans problem 753.A discuss state space representation for water jug problem 2007 old syllabus3.B Explain any heuristic research method 2007 old syllabus4.A explain various characteristics of problem 2007 old syllabus4.B list the various differences between depth first and breadth firstsearch method2007 old syllabus5.A explain structures of a prolog program 20075.B write a prolog program to generate Fibonacci numbers 2007 old syllabus33 6.A write a prolog program to find sun of n natural numbers 786.B write the similarities and differences between prolog andconventional programming languages2007 old syllabus7.A write various list processing function of LISP 2007 old syllabus34 7.B write a program in LISP to find the largest of three numbers 798 write short notes on any two of the followingi. forward verses backward reasoningii. characteristics of knowledgeiii. syntax and semantics of propositional logic2007

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: 1 Artificial intelligence 2007 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 wascoined 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 real-life situations (for example, someexpert 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 physicalconnections that occur in animal brains robotics : programming computers to see and hear and react to other sensory stimuliCurrently, no computers exhibit full artificial intelligence (that is, are able to simulate human behavior). Thegreatest advances have occurred in the field of games playing. The best computer chess programs are nowcapable of beating humans. In May, 1997, an IBM super-computer called Deep Blue defeated world chesschampion 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 verylimited tasks. Robots have great difficulty identifying objects based on appearance or feel, and they still moveand handle objects clumsily. Natural-language processing offers the greatest potential rewards because it would allow people to interact with computers withoutneeding any specialized knowledge. You could simply walk up to a computer and talk to it. Unfortunately, programming computers tounderstand natural languages has proved to be more difficult than originally thought. Some rudimentary translation systems thattranslate from one human language to another are in existence, but they are not nearly as good as human translators. There are alsovoice recognition systems that can convert spoken sounds into written words, but they do not understand

what they are writing; theysimply take dictation. Even these systems are quite limited -- you must speak slowly and distinctly. 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 helphuman experts in such fields as medicine and engineering, but they are very expensive to produce and arehelpful 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 natural-language processing.There are several programming languages that are known as AI languages because they are used almostexclusively 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 learnlanguages and reproduce them properly. 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: 2 Applications There are many AI applications that we witness: Robotics, Machine translators, chatbots, voice recognizers to name a few. AItehniques are used to solve many real life problems. Some kind of robots are helping to find land-mines, searching humans trapped inrubbles 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 human-machine 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. Thereare inherent advantages of using computers as they do not get tired or loosing temper and are becoming faster and faster. Only timewill say what will be the future of AI: will it attain human-level or above human-level 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 systematicwill solve the problem efficiently. For systematic search knowledge and intelligence are the must. We alwaystry to use machines solve our day to day problems: calculators for calculation, washing machines for washingclothes 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 areseveral 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 tosearch blindly and so is the name blind search. The search is like traversing a tree of nodes where each noderepresents a state. one way is to explore all the nodes in each level and if the solution is not found go onexploring the nodes in the next level. This cycle should repeat till we reach a solution state or we found thatthere is no solution at all. This technique is known as breadth first search (BFS) because the

search is breadth-wise. The problem with breadth first search is that it takes a lot of time if the solution is far away from the rootnode in the tree. If there is a solution then BFS is guaranteed to find it.The exploration can be done depth-wise instead of breadth-wise. That is, exploring one branch completely tillsolution is found or it is found that there is no solution. If no solution is found in one branch, backtrackingshould be done to go back to the previous node and explore in another branch. This technique is called depthfirst search (DFS). If the goal state exists in an early node in one of the first few branches then depth first searchwill find it easily, otherwise DFS is no better than BFS. Searching can also be done on both directions: one fromthe initial state to the goal state and another from the goal state towards the initial state. This approach is called bidirectional search. 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: 3 Informed Search Some we luckily have sufficient information. The information may be a clue or some other information. In thiscase we can solve the problem in an efficient manner. The information that helps finding the solution is calledheuristic information. Heuristic search techniques provide solution to the problems for which we have sufficientinformation. 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 heuristicsearch techniques are pure heuristic Search, A* algorithm, iterative-deepening A*, depth-first branch-and- bound and recursive best-First search. 1.B WHAT IS DEPTH FIRST SEARCH? EXPLAIN ALGORITHM ANDADVANTAGESANSWER 1: Depth First Search Algorithm Depth First Search (DFS) searches deeper into the problem space. Breadth-first search always generates successor of the deepestunexpanded node. Depth First Search uses last-in first-out stack for keeping the unexpanded nodes. More commonly, depth-firstsearch is implemented recursively, with the recursion stack taking the place of an explicit node stack. Algorithm: Depth First Search 1.If the initial state is a goal state, quit and return success.2.Otherwise, loop until success or failure is signaled.a) Generate a state, say E, and let it be the successor of the initial state. If there is no successor, signal failure. b) Call Depth-First Search with E as the initial state.c) If success is returned, signal success. Otherwise continue in this loop. Advantages of Depth-First Search 1. The advantage of depth-first Search is that memory requirement is only linear with respect to the search graph. This is incontrast with breadth-first search which requires more space. The reason is that the algorithm only needs to store a stack of nodes on the path from the root to the current node.2. The time complexity of a depth-first Search to depth d is O(b^d) since it generates the same set of nodes as breadth-firstsearch, but simply in a different order. Thus practically depth-first search is time-limited rather than space-limited.3. If depth-first search finds solution without exploring much in a path then the time and space it takes will be very less. Disadvantages of Depth-First Search 1. The disadvantage of Depth-First Search is that there is a possibility that it may go down the left-most path forever. Even afinite graph can generate an infinite tree. One solution to this problem is to impose a cutoff depth on the search. Although theideal cutoff is the solution depth d and this value is rarely known in advance of actually solving the problem. If the chosencutoff depth is less than d, the algorithm will fail to find a solution, whereas if the cutoff depth is greater than d, a large priceis paid in execution time, and the first solution found may not be an optimal one.2. Depth-First Search is not guaranteed to find the solution.3.

And there is no guarantee to find a minimal solution, if more than one solution exists. 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: 4 ANSWER 2: Formally, DFS is an uninformed search that progresses by expanding the first child node of thesearch tree that appears and thus going deeper and deeper until a goal node is found, or until it hits anode that has no children. Then the search backtracks, returning to the most recent node it hasn'tfinished exploring. In a non-recursive implementation, all freshly expanded nodes are added to astack for exploration. The depth-first search explores each possible path to its conclusion before another path is tried. To understandexactly how this works, consider the tree that follows. F is the goal.A depth-first 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 isreached or the goal is found. If a terminal node is reached, the path backs up one level, goes right, and then leftuntil either the goal or a terminal node is encountered. This procedure is repeated until the goal is found or thelast node in the search space has been examined.EXAMPLE:For the following graph:a depth-first search starting at A, assuming that the left edges in the shown graph are chosen before right edges,and assuming the search remembers previously-visited nodes and will not repeat them (since this is a smallgraph), will visit the nodes in the following order: A, B, D, F, E, C, G. The edges traversed in this search form aTrmaux tree, a structure with important applications in graph theory. 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: 5Performing 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 areexplored, out of the most recently discovered vertex v that still has unexplored edges leaving it. When all of v 'sedges have been explored, the search backtracks to explore edges leaving the vertex from which v wasdiscovered. This process continues until we have discovered all the vertices that are reachable from the sourcevertex. 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 emptyStep 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 tothe 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 amaze by only including nodes on the current path in the visited set.) Maze generation may use a randomized depth-first search. Finding biconnectivity in graphs. 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: 6 2. 2.A WHAT IS REPRESENTATION AND REASONING is an area of artificial intelligence research aimed at representing knowledge in symbols to facilitate inferencingfrom those knowledge elements, creating new elements of knowledge. The KR can be made to be independentof 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 reasoningabout 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 aboutthe world? It is a fragmentary theory of intelligent reasoning, expressed in terms of three components: (i) therepresentation's fundamental conception of intelligent reasoning; (ii) the set of inferences therepresentation sanctions; and (iii) the set of inferences it recommends. It is a medium for pragmatically efficient computation, i.e., the computational environment in whichthinking is accomplished. One contribution to this pragmatic efficiency is supplied by the guidance

arepresentation provides for organizing information so as to facilitate making the recommendedinferences. It is a medium of human expression, i.e., a language in which we say things about the world."Some issues that arise in knowledge representation from an AI perspective are: 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, theKR cannot determine anything or resolve ambiguities. Understandable by humans. KR is viewed as a natural language, so the logic should flow freely. Itshould support modularity and hierarchies of classes (Polar bears are bears, which are animals). Itshould 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 beingconsistent, the KR can eliminate redundant or conflicting knowledge. Efficient Easiness for modifying and updating. Supports the intelligent activity which uses the knowledge base 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: 7 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 weremotivated by attempts to address the specific problems of various real-world domains of application. Thesedomains 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 knowledge-base management 2.B EXPLAIN THE TERM ITERATION AND RECURSIONRELATED TO AIRecursion 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. Bothmethods rely on breaking up the complex problems into smaller, simpler steps that can be solvedeasily, 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 stepsthat are finished one at a time, one after another. For instance, if you want to add up all the wholenumbers less than 5, you would start with 1 (in the 1st step), then (in step 2) add 2, then (step 3) add3, and so on. In each step, you add another number (which is the same number as the number of thestep you are on). This is called "iterating through the problem." The only part that really changesfrom step to step is the number of the step, since you can figure out all the other information (like thenumber you need to add) from that step number. This is the key to iteration: using the step number tofind 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 topof each other and then squashing them all into the solution. Recursion is like holding a mirror up toanother mirror: in each image, there is another, smaller image that's basically the same. 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: 8 This is best explained with an example.

How would you tell a computer to see if someone is adescendant 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 thiscase, phrase) in its own definition? Well, we aren't exactly using circular logic here, since we aren'tsaying "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 great-grandson 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 (hisgrandfather) isn't named Ghengis Khan, so we have to look at Jim's father's father's father (his great-grandfather). But wait! His great-grandfather is named Ghengis Khan. So, this means that Jim'sgrandfather 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 "self-cloning" technique of recursion leads to a famous programmer's joke:Recursion /ree-ker'-zhon/: See Recursion So, the difference between iteration and recursion is that with iteration, each step clearly leadsonto the next, like stepping stones across a river, while in recursion, each step replicates itself at asmaller scale, so that all of them combined together eventually solve the problem. These two basicmethods are very important to understand fully, since they appear in almost every computeralgorithm ever made. 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: 9 A Sierpinski triangle dividing the sides of each triangle forms a confined recursion of triangles. 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: 10 Answer 2: Recursive functions is a function that partially defined by itself and consists of some simple case with aknown answer. Example: Fibonacci number sequence, factorial function, quick sort and more. Some of thealgorithms/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 moredeclarative approach).Comparison between Iterative and Recursive approaches from performance considerationsFactorial: //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 100000 stackoverflow 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 push-pop of the registers in the IL level of each recursive call. Fibonacci: 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: 11 //--------------- 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 int FibonacciRecursiveOpt(int n){if (n == 0) return 0;if (n == 1) return 1;if (resultHistory.ContainsKey(n))return 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 holdingsuch 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 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: 12 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 iterativeapproach (but definitely improvement over the simple recursion).Summery 1. Try not to use recursion in system critical locations 2. Elegant solutions not always the best performing when used in "recursive situations". 3. If you required to use recursion at least try to optimize it with dynamic programming approaches(such as memoization) 3. 3.A EXPLAIN WATER JUG PROBLEM

This program implements an "environmentally responsible" solution to the water jugs problem. Rather thanfilling 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 thanthe traditional method, because it can solve problems that are constrained by a limited supply from thereservoir.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 orempting the jug. The search will be finding the sequence of production rules which transform the initial state to finalstate 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 Screen clipping taken: 10/21/2011, 4:47 PM 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: 14 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 theequation with different coefficients for our question sin2xcos2dx ----------- suresh. (5x2+sin2x cos2x) dx Can be decomposed into smaller and simpler problems viz.,sin2x cos2x dx x2 dx and 5I) Analysing a problem: It is useful in determining the characteristics of the problem under consideration, which mayhelp 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 facilitieslike 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, thesolution 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 inproving the lemma. Such a problem is called ignorable-step problem.b) Suppose we are interested in solving 8-puzzle problem of reaching from some initial state say2 8 71 3 56 4To some final state say1 2 38 47 6 5By sliding, any one of the digits from a cell adjacent to the blank cell, to the blank cell. Then a wrong step cannot beignored but has to be recovered. By recoverable we mean that we are allowed to move back

to the earlier state fromwhich we came to the current state, if current state seems to be less desirable than the earlier state. The 8-puzzleproblem 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 evenrecoverable. 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 ignorable-step, recoverable-step or irrecoverable step problem, we have tochoose 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 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: 15 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 helpus 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 onthe 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, generallyas a function of the size of the instances.(iii) Also sometimes, the man-hour or man-month taken by the team developing the program is also taken as a resourcefor the purpose. 4. 4.A EXPLAIN ANY FOUR BUILT IN FUNCTIONS OF LISP? >>>REPEATED IN 2007 OLD SYLLABUS, PLEASE REFER PAGE NO 544.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 thecondition is false, or some non-nil value if the condition is true. Name of the predicates in CL usually ends with p.Ex: numberp, standard-char-p etc. overviewLogical valuesData Type predicatesGeneral Type PredicatesSpecific data type predicatesEquality predicatesLogical operators Logical valuesThe names nil and t are constants in LispThis 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 determinewhether or not it belongs to a given type, or onecan compare two type specifies. General Type predicatesSyntax:typep object type 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: 16Typep is the predicate that is true if the object is of type type false otherwise.

Subtypep type1 type2 This predicate returns T if type1 is a subtype of type1 else it returns nil.returns T Ex: (subtypep t t) Subtypep are supposed to return a second value of nil unless one or both of its arguments involves satisfiesand, or, not or member.Subtypep should signal an error when one or both of its arguments involves values or the list form of thefunction type specifier Subtypep must always return the two values t and t in the case where its arguments, after expansion of specifiesdefined by deftype are equal.(subtypep (array A) (array B)) is true if and only if (upgraded-array-element-type A) is the same type as(upgraded-array-element-type b)(subtypep (complex A) (complex B)) is true if and only if (upgraded-complex-part-type A) and (upgraded-complex-part-type B) is of same type. Specific data type predicatesThe following data types test for specific individual data types.returns true if the argument is () or false otherwise. null objectreturns true if the argument is a symbol else returns false symbolp objectis true if the argument is not cons otherwise its false. atom objectis true if the argument is a cons, false otherwise consp objectis true if the argument is a cons or an empty list (), false otherwise listp objectis T if the argument is any kind of number Numberp object is T if the argument is a rational number false otherwise Rationalp objectSimilarly we have floatp, charaterp, vectorp, stringp, complexp, simple-bit-vector-p, simple-string-vector-p,arrayp etc.is T if its argument is a package and otherwise is false packagep objectfunctionp is T if its arguments are suitable for applying to arguments, object using for ex the funccall or applyfunction and otherwise is falseis T if its argument is any compiled code object and otherwise is false Compiled-function-p objectis T if its argument is any standard CL data type, and otherwise is false Commonp object Equality predicatesCl provides these predicates to test for the equality of the two objects: eq, eql, equal, equalpis true if and only if x and y are the same identical objects. eq x yfalse Ex: (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 the x y same type with the same value, or if thereare character objects that represent the same character is true if the arguments are structurally similar objects. (isomorphic objects) equal x ytrue Ex: (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 ytwo 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 hash-table when thetwo hash-tables are created. 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: 17 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) inthe 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 operatorsCL provides three operators as Boolean value: and, or, and notEx: not y Returns t if y is nil else returns nil.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 isstopped 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 non-nil 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 aretrueEx; (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 byadding the previous two. The sequence can be defined recursively byFibonacci 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 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: 18 (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) 5.B WRITE A LISP PROGRAM TO FIND A FACTORIAL OF A GIVEN NUMBER 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 nfor fact = 1 then (* fact i)finally (return fact)))(format t "Factorial of 6 is: ~A~%" (fact 6)) Calculates the factorial. Results 720 .Factorial (recursive) Common Lisp Marco Baringer (defun fact (n)(if (zerop n)1(* n (fact (1- n)))))(format t "Factorial of 6 is: ~A~%" (fact 6)) 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: 19 6. 6.A BRIEFLY EXPLAIN THE STRUCTURE OF A PROLOG PROGRAM 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 logicalinference. 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 whichhold 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 (bylogical deduction) the answer.Among the features of Prolog are `logical variables' meaning that they behave like mathematical variables, a powerful pattern-matching facility (unification), a backtracking strategy to search for proofs, uniform datastructures, 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 suchcases 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 reasoningsystems and expert systems. Expert systems usually consist of a data base of facts and rules and an inferenceengine, 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(Fr om,To) :- write([move, disk from, pin, From, to, pin, ToPin]),nl. o Lists: append, member 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: 20list([]).list([X|L]) :- [list(L).Abbrev: [X 1 |[...[X n |[]...] = [X 1 ,...X n ]append([],L,L).append([X|L1],L2,[X|L12]) :- 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. Depth-first search: Maze/Graph traversalA 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,[In|Trail]).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: Context-free grammars may be represented as Prolog rules. For example,the rulesentence ::= 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,[]). 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: 21 Note that two arguments appear in the query. Both are lists and the first is the sentence to be parsed, thesecond 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 thescope 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 arecalled clauses 6.B WRITE THE STEP PROCEDURE TO COMPILE AND EXECUTE APROGRAM Running a Prolog program involves1. creating a file containing the program2. saving the file3. loading the file into Prolog (called compiling, consulting, or reconsulting the file in Prolog jargon)4. finally, calling some goal defined in the programHow you start Prolog depends on your operating system; try typing prolog at the top-level prompt. Prologshould 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 end-of-file (probably ^D).``Run'' the program by typing in inquiries at the Prolog prompt. You may call any predicate with anyarguments, and you may make multiple calls in one inquiry by separating them with commas. Use a period atthe 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 . 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: 22 7. EXPLAIN THE FOLLOWING WITH EXAMPLEi. NULL ii. SETF iii. FORMAT iv. CONSi. null In Lisp, functions can gracefully accept the special object nil , which reduces the amount of special case testingin 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 whichreturns nil is returning what is in fact the empty list (and not anything resembling a null reference to a listtype), 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 valuefrom an expression which returns no values, the behavior is that the null object nil is substituted. Thus (list(values)) returns (nil) (a one-element 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 isautomatically substituted. CLOS In Common Lisp, the object nil is the one and only instance of the special class null . What this means is that amethod can be specialized to the null class, thereby implementing the null design pattern. Which is to say, it isessentially 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 (make-sound x) is called, if x is an instance of the dog class.(defmethod makesound ((obj dog))(format t "woof!~%"));; allow (make-sound nil) to work via specialization to null class.;; innocuous empty body: nil makes no sound.(defmethod make-sound ((obj null))) The class null is a subclass of the symbol class, because nil is a symbol. Since nil also represents the emptylist, 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 . 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: 23 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 (foo-bar x) defines the bar field of the value of x . Or, if the value of y is a one-dimensional 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, andstores the resulting value in the resulting memory location. For example, > (setq a (make-array 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 (make-foo))#s(FOO :BAR NIL)> (foo-bar a)NIL> (setf (foo-bar a) 3)3> a#s(FOO :BAR 3)> (foo-bar a)3Setf is the only way to set the fields of a structure or the elements of an array.Here are some more examples of setf and related functions. > (setf a (make-array 1)) ;setf on a variable is equivalent to setq#(NIL)> (push 5 (aref a 1)) ;push can act like setf(5)> (pop (aref a 1)) ;so can pop5> (setf (aref a 1) 5)5> (incf (aref a 1)) ;incf reads from a place, increments,6 ;and writes back> (aref a 1)6 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: 24 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 itsarguments.The more-or-less 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 inFranz'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) and you want to print something like this: number color noise------ -------- --------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 byapplying APPLY to the situation, but that would require more typing & some cons ing. A better (but not verygood) 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. 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: 25 > (format nil "~& ~{~6D ~8@A ~8@A~}" row)" 1 GREEN RIBBIT" 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 ~* directiveto skip the items we don't want to print. > (format nil "~& ~{~6D ~*~8@A ~8@A~}"(list 2 'skip-me 'yellow 'buzz))" 2 YELLOW BUZZ" If you want to print an entire table or report, iv. cons In computer programming, cons

ns/) is a fundamental function in most dialects of the Lisp programming language. cons cons tructs memory objects which hold two values or pointers to values. Theseobjects are referred to as (cons) cells, conses, non-atomic s-expressions ("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 object-oriented 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 toconstruct 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 so-called 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 S-expression 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 : 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: 26 (list 42 69 613)In Lisp, lists are implemented on top of cons pairs. More specifically, any liststructure 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 theelements.This forms the basis of a simple, singly linked list structure whose contents can be manipulated with cons , car , and cdr . Note that nil is the only list that is not also a cons pair. As an example, consider a list whoseelements are 1, 2, and 3. Such a list can be created in three steps:1. Cons 3 onto nil , the empty list2. Cons 2 onto the result3. Cons 1 onto the resultwhich is equivalent to the single expression: (cons 1 (cons 2 (cons 3 nil))) or its shorthand:(list 1 2 3)The resulting value is the list: (1 . (2 . (3 . nil))) i.e. i.e *--*--*--nil| | |1 2 3 which is generally abbreviated as: (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 wedefined 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 asingle 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)) 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: 27results 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 particularlyunbalanced. To see this, simply rearrange the diagram: *--*--*--nil| | |1 2 3 to the following equivalent: */ \1 */ \2 */ \3 nil Use in conversation Cons can refer to the general process of memory allocation, as opposed to using destructive operations of thekind 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 INA SINEN LISTLOGIC: (defun sum (L)(reduce '+ L))(sum '(1 2 3))6 This works: (+ 1 2 3)6 This doesn't work: (+ '(1 2 3)) This works if ' cl-* ' is loaded: 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: 28 (reduce '+ '(1 2 3)) 6 8.B WHAT IS RECURSION? WRITE A PROGRAM USING RECURSIVECONCEPT TO FIND SUN OF NATURAL NUMBER A recursive function contains code that tells the Lisp interpreter to call a program that runs exactly likeitself, 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 functionwhich calls itself. This technique recognises that an operation on some data may be best expressed as theaggregate of the same operation performed on each item of data of which it is comprised. Obviously thistechnique 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 modellarge-scale behaviour in terms of smaller-scale decisions. For instance, recursion is often used in LISP tosearch state spaces.Many of the lists used in LISP programs would be better referred to as trees. Lists are simply the mechanismused 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 alsousing the null function to test for an empty list, we can walk through the tree structure, dealing withsuccessively 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 recursiveoperation. 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 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: 29 1. 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: 30 1. A IT IS USEFUL TO STRUCTURE AI. PRODUCTION SYSTEMPROVIDES SUCH STRUCTURE? DISCUSS IN DETAIL A production system is a tool used in artificial intelligence and especially within the applied AIdomain known as expert systems. Production systems consist of a database of rules, a workingmemory, a matcher, and a procedure that resolves conflicts between rules. These components areoutlined 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 left-hand-sideconditions ( x and y may be arbitrarily complex conjunctions of expressions) are compared against theelements of working memory to determine if the conditions are satisfied. Matching is an computationallyintense procedure although the RETE algorithm of OPS5 is significantly more efficient than a simplecondition-by-condition matcher. Conflict Resolution At any point in processing, several productions may match to the elements of working memorysimultaneously. Since production systems are normally implemented on serial computers, this results in a conflict : there is a non-unique choice about which action to take next. Most conflict resolution schemes arevery simple, dependent on the number of conditions in the production, the time stamps (ages) of theelements to which the conditions matched, or completely random. One of the advantages of productionsystems is that the computational complexity of the matcher, while large, is deterministically finite and theconflict resolution scheme is trivial. This is in contrast to logicist systems in which declarative knowledgemay be accessed instantly but the time required to use the knowledge (in a theorem prover, for instance) cannot be pre-determined. 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 non-monotonic : the addition of new knowledge may obviate previous knowledge. Non-monotonicityincreases the significance of the conflict resolution scheme since productions which match in onecycle 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 beregarded as implicitly parallel since all rules that match will be fired regardless of which is firedfirst. Four classes of production systems:1. A monotonic production system 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: 312. A non monotonic production system3. A partially commutative production system4. 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 modifiedindependently.3. The production rules are expressed in a natural form, so the statements contained in the knowledge baseshould 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 stateY, then any permutation of those rules that is allowable also transforms state x into state Y. 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: 32 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 aworking 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 specificsub-problems. These consist of particular traits or capabilities that researchers would like an intelligentsystem to display. The traits described below have received the most attention. [12] Deduction, reasoning, problem solving Early AI researchers developed algorithms that imitated the step-by-step reasoning that humans use whenthey solve puzzles or make logical deductions. [39] By the late 1980s and '90s, AI research had alsodeveloped highly successful methods for dealing with uncertain or incomplete information, employingconcepts from probability and economics. [40] For difficult problems, most of these algorithms can require enormous computational resources mostexperience a "combinatorial explosion": the amount of memory or computer time required

becomesastronomical when the problem goes beyond a certain size. The search for more efficient problem solvingalgorithms is a high priority for AI research. [41] Human beings solve most of their problems using fast, intuitive judgments rather than the conscious, stepby-step deduction that early AI research was able to model. [42] AI has made some progress at imitating thiskind of "sub-symbolic" problem solving: embodied agent approaches emphasize the importance of sensorimotor skills to higher reasoning; neural net research attempts to simulate the structures inside humanand animal brains that give rise to this skill. Knowledge representation An ontology represents knowledge as a set of concepts within a domain and the relationships between thoseconcepts.Main articles: Knowledge representation and Commonsense knowledge 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: 33Knowledge 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 thethings 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 knowabout what other people know); [48] and many other, less well researched domains. A representation of "whatexists" is an ontology (borrowing a word from traditional philosophy), of which the most general are calledupper ontologies. [49] Among the most difficult problems in knowledge representation are:Default reasoning and the qualification problemMany of the things people know take the form of "working assumptions." For example, if a birdcomes up in conversation, people typically picture an animal that is fist sized, sings, and flies. Noneof these things are true about all birds. John McCarthy identified this problem in 1969 [50] as thequalification 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 logicrequires. AI research has explored a number of solutions to this problem. [51] The breadth of commonsense knowledgeThe number of atomic facts that the average person knows is astronomical. Research projects thatattempt to build a complete knowledge base of commonsense knowledge (e.g., Cyc) requireenormous amounts of laborious ontological engineering they must be built, by hand, onecomplicated concept at a time. [52] A major goal is to have the computer understand enough conceptsto be able to learn by reading from sources like the internet, and thus be able to add to its ownontology. [ citation needed ]

The subsymbolic form of some commonsense knowledgeMuch of what people know is not represented as "facts" or "statements" that they could expressverbally. For example, a chess master will avoid a particular chess position because it "feels tooexposed" [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 non-consciously and sub-symbolically. [55] Knowledge like this informs, supports and provides a context for symbolic,conscious knowledge. As with the related problem of sub-symbolic reasoning, it is hoped thatsituated 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 softwareis arranged in a hierarchy. 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: 34Main article: Automated planning and schedulingIntelligent 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 availablechoices. [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 periodicallycheck if the world matches its predictions and it must change its plan as this becomes necessary, requiringthe agent to reason under uncertainty. [59] Multi-agent 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 learningMachine learning [61] has been central to AI research from the beginning. [62] In 1956, at the originalDartmouth AI summer conference, Ray Solomonoff wrote a report on unsupervised probabilistic machinelearning: "An Inductive Inference Machine". [63] Unsupervised learning is the ability to find patterns in astream of input. Supervised learning includes both classification and numerical regression. Classification isused to determine what category something belongs in, after seeing a number of examples of things fromseveral categories. Regression takes a set of numerical input/output examples and attempts to discover acontinuous function that would generate the outputs from the inputs. In reinforcement learning [64] the agentis rewarded for good responses and punished for bad ones. These can be analyzed in terms of decisiontheory, 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] Natural language processing 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 humansspeak. Many researchers hope that a sufficiently powerful natural language processing system would be able 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: 35to acquire knowledge on its own, by reading the existing text available over the internet. Somestraightforward applications of natural language processing include information retrieval (or text mining)and machine translation. [67] Motion and manipulation Main article: RoboticsThe field of robotics [68] is closely related to AI. Intelligence is required for robots to be able to handle suchtasks as object manipulation [69] and navigation, with sub-problems of localization (knowing where you are),mapping (learning what is around you) and motion planning (figuring out how to get there). [70] Perception Main articles: Machine perception, Computer vision, and Speech recognitionMachine perception [71] is the ability to use input from sensors (such as cameras, microphones, sonar andothers 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 computingKismet, a robot with rudimentary social skillsEmotion and social skills [75] play two roles for an intelligent agent. First, it must be able to predict theactions of others, by understanding their motives and emotional states. (This involves elements of gametheory, decision theory, as well as the ability to model human emotions and the perceptual skills to detectemotions.) Also, for good human-computer 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, itshould have normal emotions itself. Creativity Main article: Computational creativityA sub-field of AI addresses creativity both theoretically (from a philosophical and psychological perspective) and practically (via specific implementations of systems that generate outputs that can beconsidered creative, or systems that identify and assess creativity). A related area of computational researchis Artificial Intuition and Artificial Imagination. [ citation needed ]

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: 36 General intelligence Main articles: Strong AI and AI-completeMost 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 brainmay be required for such a project. [76][77] Many of the problems above are considered AI-complete: to solve one problem, you must solve them all.For example, even a straightforward, specific task like machine translation requires that the machine followthe author's argument (reason), know what is being talked about (knowledge), and faithfully reproduce theauthor's intention (social intelligence). Machine translation, therefore, is believed to be AIcomplete: it mayrequire 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 intosome desired situation using a set of permissible operations. It permits us to define the process of solving a particular problem as a combination of knowntechniques (each represented as a rule defining a single step in the space) and search, thegeneral technique of exploring the space to try to find some path from current state to a goalstate. Search is a very important process in the solution of hard problems for which no more directtechniques are available. Example playing chess To build a program that could play chess, we could first have to specify the starting position of thechess 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: 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: 37 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 seriousdifficulties.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(filee, 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) suchthat x = 0, 1,2, 3 or 4 and y = 0,1,2 or 3; x represents the number of gallons of water in the 4-gallon jug and y represents the quantity of water in 3-gallon jug The start state is (0,0) The goal state is (2,n)Production rules for Water Jug ProblemSl No Current state Next State Descritpion1 (x,y) if x < 4 (4,y) Fill the 4 gallon jug2 (x,y) if y <3 (x,3) Fill the 3 gallon jug3 (x,y) if x > 0 (x-d, y) Pour some water out of the 4 gallonug4 (x,y) if y > 0 (x, y-d) Pour some water out of the 3-gallonug5 (x,y) if x>0 (0, y) Empty the 4 gallonug6 (x,y) if y >0 (x,0) Empty the 3 gallonug on the ground7 (x,y) if x+y >= 4and y >0(4, y-(4-x)) Pour water fromthe 3 gallon juginto the 4 gallonug until the 4-gallon jug is full 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: 38Production rules8 (x, y) if x+y >= 3and x>0(x-(3-y), 3) Pour water from the 4-gallon jug into the 3-gallon jug until the 3-gallon jug is full9 (x, y) if x+y <=4 andy>0(x+y, 0) Pour all the water from the 3-gallon juginto the 4-gallon jug10 (x, y) if x+y <= 3and x>0(0, x+y) Pour all the water from the 4-gallon juginto the 3-gallon jug11 (0,2) (2,0) Pour the 2 gallonsfrom 3-gallon jug intothe 4-gallon jug12 (2,y) (0,y) Empty the 2 gallons inthe 4-gallon jug on thegroundTo solve the water jug problem Required a control structure that loops through a simple cycle in which some rule whose left sidematches the current state is chosen, the appropriate change to the state is made as described in thecorresponding 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 thesearch for solution.Gallonsin the4-gallonugGallonsin the3-gallonugRule applied0 0 20 3 93 0 23 3 74 2 5 or 120 2 9

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: 39 2.B DIFFERENTIATE BETWEEN DEPTH FIRST VERSUSBREADTH FIRST SEARCH METHOD Breadth-first search (BFS) and depth-first search (DFS) are two distinct orders in which to visit the verticesand 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 degree-3 nodes, reflecting balance. 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: 40 3. 3.A WHAT IS HEURISTICS? EXPLAIN ANY HEURISTIC SEARCHMETHOD A branch of artificial intelligence, which uses heuristics -- common-sense rules drawn from experience -- tosolve problems. This is in contrast to algorithmic programming, which is based on mathematically provable procedures. Heuristic programming is characterized by programs that are self-learning; they get better withexperience. 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 theinitial 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 oftencalled the British Museum method as it is like looking for an exhibit at random. A heuristic is needed tosharpen up the search. Consider the problem of four 6-sided cubes, and each side of the cube is painted inone of four colours. The four cubes are placed next to one another and the problem lies in arranging them sothat 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 bereduced 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 NP-hard problem in combinatorial optimization studied inoperations research and theoretical computer science. Given a list of cities and their pairwise distances, thetask 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 intensivelystudied problems in optimization. It is used as a benchmark for many optimization methods. Even thoughthe problem is computationally difficult, a large number of heuristics and exact methods are known, so thatsome 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 themanufacture of microchips. Slightly modified, it appears as a sub-problem in many areas, such as DNA 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: 41sequencing. 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 timewindows make the problem considerably harder.In the theory of computational complexity, the decision version of the TSP (where, given a length L, thetask is to decide whether any tour is shorter than L) belongs to the class of NPcomplete problems. Thus, itis likely that the worst case running time for any algorithm for the TSP increases exponentially with thenumber of cities. As a graph problem Symmetric TSP with four citiesTSP can be modeled as an undirected weighted graph, such that cities are the graph's vertices, paths are thegraph's edges, and a path's distance is the edge's length. A TSP tour becomes a Hamiltonian cycle if andonly 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 graphwithout 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 toarrive at the best path in terms of distance travelled for a network of 50 cities. The problem is NP hard andcannot be solved in polynomial time. Djikstras algorithm states that the path lies only along the exterior pathand 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 Nconnected cities. The lowest distance is just one of these routes. There are however several transportationalgorithms /advanced optimization technqiues that can perform a quick optimization and churn out theshortest path. There are also heuristic methods and graph based methods that are used to solve the TSP. 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: 42The 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. Thecomputations were performed on a network of 110 processors located at Rice University and PrincetonUniversity. 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 thecities 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 storedreference template and subsequently assigning a score based on the level of similarity. The biometric systemthen 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 isto 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. Thematching can be made more or less fuzzy, according to the conditions on the individual patternvariables, 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 withone another 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: 43 4. 4.A HOW DO YOU REPRESENT THE KNOWLEDGE USINGPREDICATE LOGIC One of the trickier parts of designing artificial intelligence is how to represent information to something thatcan 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 therelationship between current sentences and new sentences derived from the current sentences. A goodknowledge 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 newsentences. Symbols are used to represent facts which may or may not be true. W may 72 represent the fact itis windy outside. The symbols are combined with boolean logic to generate new sentences. Facts can be trueor false only. The program may know a statement is true or false or be uncertain as to its truth or falsity. Thesyntax consists of , v, => (if x then y), (equal), and (not). Backus-Naur Form (bnf) is the grammar used to put sentences together. The semantics are just the interpretation of a statement about a proposition. Truthtables are used to define the semantics of sentences or test validity of statements.Truth table for ANDT and T = TT and F = FF and F = FF and T = FA model is a world in which a sentence is true under a particular interpreta tion. There can be severalmodels at once that have the same interpretations. An inference rule is a rule that is derived from a patternthat is true all the time for specific cases. 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: 44First Order Logic (first-order 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 knowwhether something is true or false or give it a probability of truth or falseness.Procedural RepresentationThis 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 engineersquestion experts in a given field and code this information into a computer program.

It works best whenexperts 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 theuser states facts, rules, and relationships. These represent pure knowledge. This is processed with hardcoded procedures.Relational RepresentationCollections 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 arisewhen more than one subject area is attempted. A new knowledge base from scratch has to be built for eacharea of expertise.Hierarchical RepresentationThis is based on inherited knowledge and the relationships and shared attributes between objects. This goodfor abstracting or granulating knowledge. Java and C++ are based on this.Semantic NetA 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. Theedges are the relationships (is a, has a, begins, ends, duration, etc). The edges are bidirectional, backwardedges 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 netdescription 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 andrelationships. Predicate logic allows representation of complex facts about things and the world. (If A thenB). 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 baseand 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. Theknowledge representation must take perceptions and turn them into sentences for the program to be able touse them, and it must take queries and put them into a form the program can understand.Resolution and unificationResolution: prove A true by proving A Not is false. Unification: take two predicate logic sentences andusing substitutions make them the same. Unification is the single operation that can be done on datastructures (expression trees) in Prolog. These are the techniques used to process predicate logic knowledgeand the are the basis for Lisp and Prolog. 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: 45FramesEach frame has a name and a set of attribute-value pairs called slots. The frame is a node in a semanticnetwork. 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 itsinherited attributes. This is much like Java classes. We have a main class and sub classes that haveattributes, 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 constraintsamong objects, values of objects, and inferences about objects and values of objects.The elements of propositonal calculus are:Atoms: the smallest elementsConnectives: or, and, implies, notSentences: aka well-formed formulas, wffs The legal wwfsdisjunction: or conjunction: andimplication: impliesnegation: notRules of inference are used to produce other wwfsmodus ponens: ( x AND ( x implies y) ) implies yAND introduction: x, y implies ( x AND y )AND commutativity: x AND y implies xOR introduction: x, y implies ( x OR y ) NOT elimination: NOT ( NOT x ) implies xresolution: combining rules of inference into one rule:{ example: (x OR y) AND ( NOT y OR z ) = x OR zHorn 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 domainPropositions: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 atomdenotation:in a given

interpretation the proposition associated with the atom is the denotationvalue:TRUE, FALSE, given to an atom 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: 46knowledge base:a collection of propositional calculus statements that are true in the domaintruth table:a tablular format for representing statessatisfies:a true statement under a given interpretationmodel:an interpretation that satisfies each statement in a set of statements.validity:a statement that is TRUE under all interpretationsequivalence: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 PSATa 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 asabout objects. This is first order predicate calculus.Contains:object constants, term: strings of characters, xyz, linda, parisrelation constants: divided by, distance to/from, larger thanfunction constants: small, big, bluefunctional expression: examples: distance(here, there); xyz;worlds: can have infinite objects, functions on objects, relations over objectsinterpretations: maps object constants into objects in the worldquantifiers: can be universal or for a selected object or group of objectsPredicate Calculus is used to express mathematical theories. It consists of sentences, inference rules andsymbols. First-order 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 statementsof S and the statement NOT U it is not a model. All statements in a model must be true. S is unsatisfiable 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: 47since there is no way for the statements of S and the statement NOT U, both of which are in S to be true atthe same time. This is used to prove formulas in theorem proving. To show S implies U is is sufficient toshow S= S, NOT U is unsatisfiable.Resolution and unificationResolution: prove A true by proving A Not is false.Unification: take two predicate logic sentences and using substitutions make them the same. Unification isthe single operation that can be done on data structures (expression trees) in Prolog. These are thetechniques used to process predicate logic knowledge and the are the basis for Lisp and Prolog.Resolution is one way to prove unsatisfiability. 4.B DISCUSS UNIFICATION ALGORITHM Unification is the name given to the way Prolog does its matching. We will not do more than sketch the basic ideashere. Basically, an attempt can be made to unify any pair of valid Prolog entities or terms . Unification is more than simple matching. It implies mutual coercion.There is an attempt to alter both the target and the current source object to make them look the same. Unification is a two-way matching process.

In propsoitional logic it is easy to determine that two literals can not both be true at the same time. Simplylook 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 anddiscovers whether there exist a set of substitutions that makes them identical . There is a recursive procedurethat 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 predicateand 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 beunified. 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. Thematching rules are : 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: 48i) 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 thecondition that the function or [predicate expression must not contain any instance of the variable beingmatched (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. (asubstitution y for x written as y/x)The Unification algorithm is listed below as a procedure UNIFY (L1, L2). It returns a list representing thecomposition of the substitutions that were performed during the match. An empty list NIL indicates that amatch was found without any substitutions. If the list contains a single value F, it indicates that theunification 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 doi) call UNIFY with the i th element of L1 and Ith element of L2, putting the result in Sii) if S = F then return Fiii) 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. 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: 49 5. 5.A DEFINE PREDICATE AN OBJECTS IN PROLOG. DISCUSSVARIOUS TYPES OF OBJECTS USED IN PROLOG Predicates Clauses with the same clause name, the same number of arguments and defined in the same module arecombined 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 theclause 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 differentmodules belong to different predicates.The Prolog predicate concept can be compared to the subprogram concept in conventional programminglanguages; we therefore also speak of "calling" a predicate in Prolog. The predicate concept ensures a highdegree 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) :- !. % 0! is 1fac( N, Nfac) :-N > 0, % for integers N > 0M is N - 1, % defines NFac as N * (N1)!fac( M, Mfac), % thus MFac is calculatedNfac is N * Mfac. % recursively as (N-1)! You can call the predicate fac/2 in the Prolog input loop by entering, for example, [user] ?fac(5,X). The Prolog system searches the clauses belonging to the predicate fac/2 and displays the answer: X = 120 The precise sequence in which Prolog performs this search operation is described in the section Procedureexecution .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 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: 50these predicates can be output with listing/0/1 and analyzed with

clause predicates. Note however thatto do so you must call the Prolog system with the -debug option. Compiled predicates IF/Prolog offers a number of ways of compiling user-defined predicates and including them in thedatabase. 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 areto remain modifiable. Predicates which you have generated with assert predicates or which you havedeclared as modifiable with other compilation methods are compiled only to the extent where thecompilation 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 removingclauses. Further information about compiling Prolog source text and the related advantages and restrictionscan 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) andwith backtracking (complex C functions) as Prolog predicates using the built-in C interface. The C interfaceis described in detail in chapter 10. Built-in predicates IF/Prolog provides a large number of built-in predicates which you can use to formulate your own predicates.Built-in 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 arityas built-in predicates, since all the built-in predicates are defined in special system modules.An overview and an alphabetically arranged description of the built-in 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. Thischaracter 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. 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: 51 Directives are special syntactic structures which can be specified in IF/Prolog texts and which are processedwhen these texts are read in (e.g. with consult/1 ). They are indicated by :in front of the functor, as theywould be written in a Prolog text. User definable predicates are automatically called at particular points by IF/Prolog if the user has definedthem. 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 argumentthere 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 inthe 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 thecall.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 aterm 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 uninstantiatedvariables 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 anarithmetic 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 uninstantiatedvariables, you can obtain all defined operators by means of backtracking: [user] ?current_op(Precedence,Type,Name). Precedence = 50 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: 52 Type = xfxName = : ;Precedence = 100Type = xfxName = @ ; etc. until you terminate backtracking. The instantiated arguments are unified; the uninstantiated variables are instantiated. The following queriesoperators with precedence 400: [user] ?current_op(400,Type,Name). Type = yfxName = >> ;Type = yfxName = <<Yes 5.B WRITE A PROLOG PROGRAM TO GENERATE FIBONACCISERIES Prolog program to generate a fibonacci series of N elements domainsx = integerpredicatesfibonacci(x)clausesfibonacci(1).fibonacci(N) :-N1 = N - 1,N1 >= 0,!,fibonacci(N1),write(F1," ,"),F = F1 +

N.domainsnum,ans=integer.predicatesfibo(num).clausesfibo(1):-write("1").fibo(X):- X<5,!,fibo(X1 +1),Ans=X1+X. 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: 53 Top Down Computation Top down computation, typically used in Prolog, starts with the original problem and itdecomposes this problem to simpler and simpler problems till the trivial problem, i.e., the fact inProlog database, is reached. Then, the solution of larger problems is composed of the solutions of simpler problems etc. till the solution of the original problem is obtained. Following two examplespresent programs that use the top down computation. Fibonacci The following program computes Fibonacci numbers using the top down method, i.e., if we arelooking for Fibonacci number of N>1, we first compute Fibonacci numbers of N-1 and N-2 (usignthe same procedure) and, then, we compose the Fibonacci number of N from the subresults. Inthis 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 N-1, N2 is N-2,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 usedbecause we compute the same thing many times. For example, to compute F(N-1) we need tocompute F(N-2) which is also required to compute F(N) that was decomposed to F(N-1) and F(N-2). 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 upcomputation as well without changes of the Prolog interpreter. The bottom up computation startswith know facts and extends the set of know trues using rules. i.e., it derives new facts from oldfacts 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 arederived that has nothing in common with the original problem. Therefore, Prolog uses top downevaluation as a standard method of computation. However, in same cases, it is possible to guidethe 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 visiblemainly in the procedure fibo_bu that is a lot of faster than fibo_td. 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: 54 Fibonacci We can use the same principle as in "bottom-up factorial" to compute the Fibonacci numbersusing bottom up method. Now, we need to remember last two Fibonacci numbers to be able tocompute 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 awayefficient 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 acollection 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 isrepresented 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 thecontainer. 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 canask questions about lists to prolog: ?- [_,_,X] = [lesson, work, sleeping].X = sleeping?- list_where(X, under_the_bed).X = [Malibu,Soho] 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: 55 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 liststructures. [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 tothe list of remaining elements, called the tail.Note that the tail is considered as a list for Prolog and theempty list does not unify with the standart list syntax because it has no head. Here is an example : ?- [X|Y] = [a, b, c, d, e].X = aY = [b, c, d, e]?- [X|Y] = [].no The empty list does not unify with the standard list syntax because it has no head. ?- [X|Y] = [].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 [X|Y] pattern will succeed. Whenthere are no elements in the list, that unification fails, indicating that the boundary condition applies. We canspecify 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 = waterSecond = ginQ = [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 ordinarytwo-argument predicate. The first argument is the head and the second is the tail. This predicate isrepresented by a period(.). To see this notation, we use the built-in predicate display, which writes lits inusing this syntax. ?- X = [T|Q], 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. How to manipulate list For lists to be useful,there must be easy way to access,add, and delete list elements.Moreover, we should nothave to concern ourselves about the number of list items, or their order.Two Prolog features enable us to accomplish this easy access. One is a special notation that allows referenceto the first element of a list and the list of remaining elements, and the other is recursion.These two features are very useful for coding list utility predicates, such as member, which finds membersof a list, and append, which joins two lists together. List predicates all follow a similar strategy--trysomething with the first element of a list, then recursively repeat the process on the rest of the list.

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: 56The first one we will look at is member. As with most recursive predicates, we will start with the boundarycondition, or the simple case. An element is a member of a list if it is the head of the list. member(T,[T|Q]). 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,[T|Q]) :- 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 firstargument 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 fitnicely with the problem of adding something to the end of a list. append solves this problem by reducing thefirst list recursively. The boundary condition states that if a list X is appended to the empty list, the resultinglist is also X. append([],X,X). The recursive condition states that if list X is appended to list [T|Q1], 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([T|Q1],X,[T|Q2]) :- append(Q1,X,Q2). Real Prolog magic is at work here, which the trace alone does not reveal. At each level, newvariable 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. 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: 57 66.B WRITE A PROGRAM IN LISP TO FIND THE FACTORIAL OF AGIVEN 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 thefunction on simpler cases, then eventually the function will get to a simple enough case and as such willknow 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 built-in Lisp functionPRINT, and then call itself, recur with the CDR of the list. Notice that because we are going to pass theCDR 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 itsargument is NIL, then it should return to NIL. [This type of test is called a termination condition . We need itto keep List from running away.] If its argument is not a NIL, then print the CAR of the argument and callRECITE again with the CDR. Here is RECITE.

:(DEFINE (RECITE (LAMBDA (STUFF): (COND ((NULL STUFF) ()): (T (PRINT (CAR STUFF)): (RECITE (CDR STUFF))): ))))RECITE:(RECITE '(THIS IS A TEST LIST))THISISATESTLISTNIL 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 thesuccession of recursive function terminations. When the function we started off with terminates, it prints outits 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.

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: 59 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 thespecified atom A with the first element of list L. If they are equal, then we have a match and the value of Tis returned. Otherwise, we try again, looking for the atom in the CDR of the list. Note that this process isguaranteed to terminate because the function either returns a value or tries again with a shorter list. A listcan only contain a finite number of elements so that after a maximum number of calls equal to the number of top-level 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 willtell us who calls whom and what is returned. When you see " -->> ", it means that the function is beingcalled. When you see " <<-", it indicates that the function is returning. Follow these examples and watchwhat'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 :: (ARM (HEAD LEG ARM FOOT))-->> MEMBER :: (ARM (LEG ARM FOOT))-->> MEMBER :: (ARM (ARM FOOT))<<-- MEMBER :: T<<-- MEMBER :: T<<-- MEMBER :: 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 LEGFOOT ) )>> MEMBER :: (HAND (HEAD LEG FOOT ))->> MEMBER :: (HAND (LEG FOOT ) )->> MEMBER :: (HAND (FOOT ) )->> MEMBER :: (HAND NIL )<<- MEMBER :: NIL<<- MEMBER :: NIL<<MEMBER :: NIL<<- MEMBER :: NIL<<- MEMBER :: NILNIL The same returning sequence happens with the NIL. In fact, the same type of thing will always happen in aLisp function that returns the values to the routine that called it, never back to the user directly. We saw thisin the ENDS example and it also applies to recursion.The opposite of TRACE is UNTRACE. :(UNTRACE MEMBER)

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: 60 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 if n = 0n*(n-1)! if n > 0 Notice that the termination condition is already specified in the definition, namely, that the recursion stopswhen 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 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: 61It would be instructive to trace an evaluation of FACTORIAL to see how it works. Here's a trace of (FACTORIAL 5). :(FACTORIAL 5)->> FACTORIAL :: (5 )->> FACTORIAL :: (4 )->> FACTORIAL :: (3 )->> FACTORIAL :: (2 )->> FACTORIAL :: (1 )->> FACTORIAL :: (0 )<<- FACTORIAL :: 1<<FACTORIAL :: 1<<- FACTORIAL :: 2<<- FACTORIAL :: 6<<- FACTORIAL :: 24<<- FACTORIAL :: 120120 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 youunderstand it. 7. 7.A WRITE A PROLOG PROGRAM TO VERIFY USERNAME ANDPASSWORD domains Name,Password=Symbol predicatesGetentry(Symbol,Symbol)Logon(Integer)User(Symbol,Symbol)goclausesgo:Clearwindow,Logon(3),Write("YOU ARE NOW LOGGED-IN"),nl.Logon(0):-!,Write("SORRY YOU CANNOT LOG-ON"),nl,Fail.Logon(X):Getentry(Name,Password),User(Name,Password);Write("ILLEGAL ENTRY\n"),nl,XX=X1,Logon(XX). 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: 62Getentry(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,pas s). OUTPUT: Goal:goUser Name: billPassword: flower ILLEGAL ENTRYUser Name: billPassword: devilILLEGAL ENTRYUser Name: billPassword: bigfootYOU ARE NOW LOGGED-INYes 7.B LIST THE SIMILARITIES AND DIFFERENCES BETWEENPROLOG 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 willalso give the best performance and reliability, because the engine will have had a lot of design anddevelopment effort.Trying to implement this kind of thing in another language tends to be a mess. The cleanest and mostgeneral solution probably involves implementing your own unification engine. Even naive implementationsaren't exactly trivial, the Warren Abstract Machine has a book or two written about it, and doing better willat the very least involve a fair bit of research, reading some headache-inducing 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. 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: 63For 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. Andthat is when you have lots of possible solutions to a problem, and perhaps you want to order them toinclude/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 languageall 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 toimplement 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 ammyself 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 yougo for latter flavours of it (Typed ones), you get more power too. The only thing that bothered me whenusing prolog is the fact that I dont have random access in lists (no arrays).** 2 down vote acceptedCompared to what exactly? Prolog is really just the pre-eminent implementation of logic programming so if your question is really about a comparison of programming paradigms well that's really very broad indeedand you should look here.If your question is more specifically about prolog vs the more commonly seen OO languages I would arguethat 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 newapproach to computing and became a serious competitor to LISP. 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: 64

Significant Language Features Prolog is a rich collection of data structures in the language and human reasoning, and a powerful notationfor encoding end-user applications. It has its logical and declarative aspects, interpretive natur, compactness,and inherent modularity. Intelligent Systems - programs which perform useful tasks by utilizing artificaial intelligencetechniques. Expert Systems - intelligent systems which reproduce decision-making at the level of a humanexpert. Natural Language Systems - which can analys and respond to statements made in ordinarylanguage as opposed to approved keywords or menu selections. Relational Database Systems Areas of Application Prolog is the highest level general-purpose language widely used today. It is taught with a strong declarativeemphasis 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, includingthe sequences of instructions that the computer must go through to solve it. It is easier to say what we wantdone and leave it to the computer to do it for us. Since a major criterion in the commercial world today isspeed of performance, Prolog is an ideal prototyping language. Its concept makes use of parallelarchitectures. 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 ONa. forward versus backward reasoning b. STRUCTURE OF PROLOG PROGRAM >>>>> REPEATED2007 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 somehypothesis), then backward chaining will be much more efficient, as you avoid drawingconclusions 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 almostall 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 whichallow 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, lotsof 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: 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: 65It allows for a formal definition of a problem as the need to convert some given situation intosome desired situation using a set of permissible operations.It permits us to define the process of solving a particular problem as a combination of knowntechniques (each represented as a rule defining a single step in the space) and search, the generaltechnique 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 directtechniques are available. Forward chaining means applying rules in a forward direction: recursively applying the rules over datato 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) andrecursively working backwards to find more data that can satisfy the goal (I'm looking for foaf:Agent s... Ishould also look for dc:Agent s and foaf:Person s and po:Person s...) forward-chaining (~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) backward-chaining (~query-rewriting): 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 storeA hybrid approach should then give the best of both worlds, materialising the inferences that are frequentlyaccessed, static, and/or small, and supporting query-rewriting for inferences that are large, cheap to do atruntime, dynamic and/or infrequently accessed.For example, many large-scale reasoners: typically rely on materialisation to do the bulk of reasoning. use backward-chaining to support stuff like reflexive owl:sameAs statements, or rdf:typerdfs:Resource/owl:Thing use a hybrid approach for equality (to avoid ~quadratic materialisation: a maximum of n inferenceswhere 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 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: 66 C.CHARACTERISTICS OF KNOWLEDGE 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. Itshould support modularity and hierarchies of classes (Polar bears are bears, which are animals). Itshould 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 baseTo 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 differenttitles but same content to the same article (consistency). It is efficient, easy to add new pages or updateexisting ones, and allows users on their mobile phones and desktops to view its knowledge base. D. SYNTAX AND SEMANTICS OF PROPOSITIONAL LOGIC Syntax of Propositional Logic Logic is used to represent properties of objects in the world about which we are going to reason. When wesay Miss Piggy is plump we are talking about the object Miss Piggy and a property plump. Similarly whenwe say Kermit's voice is high-pitched then the object is Kermit's voice and the property is high-pitched. It isnormal to write these in logic as: plump(misspiggy) highpitched(voiceof(kermit)) 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 areoften 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 n-ary predicates; e.g. loves(misspiggy, voiceof(kermit)) 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: 67 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 areused to describe relationships concerning the objects and return the value true/false . Function constantsreturn values that are objects . Atom : An atom is a basic building block of logic consisting of a predicate constant applied to a set of objectsProlog programs and Clips rules also contain knowledge organised in this way: Prolog terms: loves(misspiggy, kermit) Clips ordered terms: (loves misspiggy kermit) Remember that in Clips ordered terms the first argument is special. It is common to represent knowledge intriples like this and so they have a name OAV (Object-Attribute-Value) triples where the attribute is predicate and the object and value are the arguments. More Complex Sentences We need to apply operators to construct more complex sentences from atoms. Negation: applied to an atom negates the atom: loves(kermit, voiceof(misspiggy)) ''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) 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: 68 because we have tried to conjoin a sentence (truth valued) with an object. Logic operators mustapply to truth-valued 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 definesthe syntax of propositional Logic. It is normal to represent atoms in propositional logic as single upper-caseletters but here we have used a more meaningful terminology for the atoms that extends easily to PredicateLogic. Semantics of Propositional Logic We have defined the syntax of propositional Logic. However, this is of no use without talking about themeaning, or semantics, of the sentences. Suppose our logic contained only atoms; e.g. no logicalconnectives. This logic is very silly because any subset of these atoms is consistent; e.g. beautiful(misspiggy) and ugly(misspiggy) are consistent because we cannot represent ugly(misspiggy) beautiful(misspiggy) So we now need a way in our logic to define whichsentences are true. Model : A model is a subjet of the atoms defined for our language and contains exactly those atoms that aretrue. So all atoms in a model M are true and all atoms not in M are false 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 theatoms in the language. 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: 69 Compound Sentences So far we have restricted our attention to the semantics of atoms: an atom is true if it is a member of themodel M; otherwise it is false. Extending the semantics to compound sentences is easy. Notice that in thedefinitions below and do not need to be atoms because these definitions work recursively until atomsare reached.

Conjunction: is true in M iff and are true in M individually.So the conjunct loves(misspiggy, kermit) loves(misspiggy, voiceof(kermit)) is true only when both Miss Piggy loves Kermit; and Miss Piggy loves Kermit's voice Disjunction: is true in M iff at least one of or is true in M.So the disjunct loves(misspiggy, kermit) loves(misspiggy, voiceof(kermit)) 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 is not true in M. Implication: is true in M iff is not true in M or is true in M.We have been careful about the definition of . When people use an implication they normallyimply that causes . So if is true we are happy to say that is true iff is true. But if is false thecausal link causes confusion because we can't tell whether should be true or not. Logic requires that theconnectives are truth functional and so the truth of the compound sentence must be determined from thetruth of its component parts. Logic defines that if is false then is true regardless of the truth of . 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: 70So both of the following implications are true (provided you believe pigs do not fly!): fly(pigs) beautiful(misspiggy) fly(pigs) beautiful(misspiggy) Example: Implications and Models In which of the following models is ugly(misspiggy) beautiful(misspiggy) true? M= Miss Piggy is not ugly and so the antecedent fails. Therefore the implication holds. (Miss Piggy isalso 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 implicationfails in this (and only this) case. 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!!!Solved by SURESH the SUN , lecturer at BCA dept, SG College Campus --- Koppal pg. no: 72 1. 1.A WHAT IS AI? EXPLAIN DIFFERENT AI TECHNIQUESPart I: AI definition >>>> repeated in 2007 Part II:Suns view on different AI techniques 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: 73 1.B EXPLAIN APPLICATION AREA OF AI Intelligence is the ability to think, to imagine, to create, memorize, understand, recognize patterns, makechoices, adapt to change and learn from experience. Artificial intelligence is a human endeavor to create anon-organic machine-based entity, that has all the above abilities of natural organic intelligence. Hence it isknown as 'Artificial Intelligence' (AI).It is the ultimate challenge for an intelligence, to create an equal, another intelligent being. It is the ultimateform of art, where the artist's creation, not only inherits the impressions of his thoughts, but also his abilityto think!How will one recognize artificial intelligence? According to Alan Turing, if you question a human and anartificially intelligent being and if by their answers, you can't recognize which is the artificial one, then youhave succeeded in creating artificial intelligence. Initial hopes of computer scientists of creating an artificialintelligence, were dashed hopelessly as they realized how much they had underrated the human mind'scapabilities!How do you teach a machine to imagine? They realized that they must understand what makes naturalintelligence, 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 everyfunction an intelligence performs! As they went on with this task, they realized that this approach was tooshallow. Even simple functions like face recognition, spacial sense, pattern recognition and languagecomprehension were beyond their programming skills!They understood that to create an AI, they must delve deeper into natural intelligence first. They tried tounderstand how cognition, comprehension, decision-making happen in the human mind. They had tounderstand what understanding really means! Some went into the study of the brain and tried to understandhow the network of neurons creates the mind.Thus, researchers branched into different approaches, but they had the same goal of creating intelligentmachines. Let us introduce ourselves to some of the main approaches to artificial intelligence. They aredivided 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

andreduce error in operation. Already, robot expert systems are taking over many jobs in industries that aredangerous 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 AIin them, but they play well against people mainly through brute force computation--looking athundreds of thousands of positions. To beat a world champion by brute force and known reliableheuristics requires being able to look at 200 million positions per second. speech recognition 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: 74In the 1990s, computer speech recognition reached a practical level for limited purposes. ThusUnited Airlines has replaced its keyboard tree for flight information by a system using speechrecognition of flight numbers and city names. It is quite convenient. On the the other hand, while itis possible to instruct some computers using speech, most users have gone back to the keyboard andthe mouse as still more convenient. understanding natural language Just getting a sequence of words into a computer is not enough. Parsing sentences is not enougheither. The computer has to be provided with an understanding of the domain the text is about, andthis is presently possible only for very limited domains. computer vision The world is composed of three-dimensional 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 fullcomputer vision requires partial three-dimensional information that is not just a set of two-dimensional views. At present there are only limited ways of representing three-dimensionalinformation 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 knowledgein a computer program for carrying out some task. How well this works depends on whether theintellectual mechanisms required for the task are within the present state of AI. When this turned outnot to be so, there were many disappointing results. One of the first expert systems was MYCIN in1974, which diagnosed bacterial infections of the blood and suggested treatments. It did better thanmedical students or practicing doctors, provided its limitations were observed. Namely, its ontologyincluded 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 beingconsidered. 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 currentexpert 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 someinformation in one of a fixed set of categories using several sources of information. An example isadvising 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 theestablishment from which he is buying it (e.g., about whether there have been previous credit cardfrauds at this establishment). Heavy Industries and Space : Robotics and cybernetics have taken a leap combined with artificiallyintelligent expert systems. An entire manufacturing process is now totally automated, controlled andmaintained by a computer system in car manufacture, machine tool production, computer chip productionand almost every high-tech process. They carry out dangerous tasks like handling hazardous radioactivematerials. 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 beathumans 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 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: 75systems and many more such tools. The primary goal of creating an artificial intelligence still remains adistant 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 aneural 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 aneural network. Here, programmers study how intelligence emerges in natural systems like swarms of beeseven though on an individual level, a bee just follows simple rules. They study relationships in nature likethe prey-predator relationships that give an insight into how intelligence emerges in a swarm or collectionfrom simple rules at an individual level. They develop intelligent systems by creating agent programs thatmimic the behavior of these natural systems!Is artificial Intelligence really possible? Can an intelligence like a human mind surpass itself and create itsown 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 Ihave succeeded in conveying to you the excitement and possibilities this subject holds! 2. 2A EXPLAIN PRODUCTION SYSTEM IN DETAIL >>>>>>>>>>>REPEATED IN 2007 OLD SYLLABUS2.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 designationfor this type of problem hails back to the days of the traveling salesman, who often wished to arrange travelin a manner that allowed for visiting the most towns without having to double back and cross into any giventown more than once.In a wider sense, the traveling salesman problem is considered to be a classic example of what is known as atour problem. Essentially, any type of tour problem involves making a series of stops along a designatedroute 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 modeof travel to accomplish the most in results. Finding a solution to a tour problem is sometimes referred to asdiscovering the least-cost path, implying that the strategic planning of the route will ensure maximum benefit with minimum expenditure incurredthe 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 bestresults with repeated usage. 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: 76In a similar manner, discrete optimization attempts to accomplish the same goal, although the term issometimes employed to refer to tasks or operations that occur on a one-time basis rather than recurring.Discrete optimization also is helpful in computer science and mathematical disciplines. In addition, discreteoptimization has a direct relationship to computational complexity theory and is understood to be of use inthe development of artificial intelligence.While the imagery associated with a traveling salesman problem may seem an oversimplification of thesetypes of detailed options for optimization, the idea behind the imagery helps to explain a basic fundamentalto any type of optimization that strives for efficiency. The traveling salesman problem that is solved willyield 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 designationfor this type of problem hails back to the days of the traveling salesman, who often wished to arrange travelin a manner that allowed for visiting the most towns without having to double back and cross into any giventown more than once.In a wider sense, the traveling salesman problem is considered to be a classic exampleof what is known as a tour problem. In addition, discrete optimization has a direct relationship tocomputational complexity theory and is understood to be of use in the development of artificialintelligence.Related topicsWhile the imagery associated with a traveling salesman problem may seem anoversimplification of these types of detailed options for optimization, the idea behind the imagery helps toexplain 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 atravelling salesman who has to visit N number of cities. Here we are faced with the problem of determiningthe shortest path that he requires to traverse. This problem does not have a polynomial time solution as thecomplexity 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 tourswill not be able to compute the shortest path for very large values of the number of cities. Hence theTravelling 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 245 city tour = the no. of possible tours is 1206 city tour = the no. of possible tours is 7207 city tour = the no. of possible tours is 50408 city tour = the number of possible tours is 403209 city tour = the number of possible tours is 362880 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: 7710 city tour = the number of possible tours is 3628800As it can be seen easily the number of computations required by a computer to determine the shortest pathincreases to 362880 for a tour of just 9 cities and for a 50 city tour the complexity increases to3.04141E+64.So a computer just cannot process so many instructions within a specified time for larger and real liferequirements. The processing power available in modern day computers would take trillions of years to finda 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 technologiessuch 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 bedetermined in polynomial time. 3.

A. DISCUSS STATE SPACE REPRESENTATION FOR WATER JUGPROBLEM >>> REPEATED IN 2007 OLD SYLLABUSB. EXPLAIN ANY HEURISTIC RESEARCH METHOD>>>>>>>>> REPEATED IN 2007 OLD SYLLABUS4. A. EXPLAIN VARIOUS CHARACTERISTICS OF PROBLEM>>>>>>>>>>>> REPEATED IN 2007 OLD SYLLABUSB. LIST THE VARIOUS DIFFERENCES BETWEEN DEPTH FIRST ANDBREADTH FIRST SEARCH METHOD >>>>>>>REPEATED IN 2007OLD SYLLABUS5. A. EXPLAIN STRUCTURE OF A PROLOG PROGRAM >>>>>>>>>REPEATED IN 2007B. WRITE A PROLOG PROGRAM TO GENERATE FIBONACCINUMBERS >>>>>>> REPEATED IN 2007 OLD SYLLABUS 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: 78 6. 6.A WRITE A PROLOG PROGRAM TO FIND SUM OF N NATURALNUMBERSsorry I didnt get the exact answer, nevertheless I got the logic for the answer and also a supportingprogram on which this logic can be implemented ------- sureshlogic: % nat(X) iff X is a natural numbernat(0).nat(s(N)) :- nat(N).% sum(X,Y,Z) iff Z = X + Ysum(0,Y,Y).sum(s(X),Y,s(Z)) :- sum(X,Y,Z).supporting program*program to count the numbers from 1to-N and down N-to 1*/domainsN=IntegerpredicatesCounter(Integer,Integer)runclausesrun: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:runEnter the Value of N5Counting Numbers are :1234554321

Vous aimerez peut-être aussi