What are the syntactic forms and usage of fact and rule statements in Prolog?
Explain two ways in which the list-processing capabilities of Scheme and Prolog are similar?
FACTS AND RULES:
Facts
A fact is a predicate expression that makes a declarative statement about the problem domain. Whenever a variable occurs in a Prolog expression, it is assumed to be universally quantified. Note that all Prolog sentences must end with a period.
likes(john, susie). /* John likes Susie */ likes(X, susie). /* Everyone likes Susie */ likes(john, Y). /* John likes everybody */ likes(john, Y), likes(Y, john). /* John likes everybody and everybody likes John */ likes(john, susie); likes(john,mary). /* John likes Susie or John likes Mary */ not(likes(john,pizza)). /* John does not like pizza */ likes(john,susie) :- likes(john,mary)./* John likes Susie if John likes Mary.
Rules
A rule is a predicate expression that uses logical implication (:-) to describe a relationship among facts. Thus a Prolog rule takes the form
left_hand_side :- right_hand_side .
This sentence is interpreted as: left_hand_side if right_hand_side. The left_hand_side is restricted to a single, positive, literal, which means it must consist of a positive atomic expression. It cannot be negated and it cannot contain logical connectives.
This notation is known as a Horn clause. In Horn clause logic, the left hand side of the clause is the conclusion, and must be a single positive literal. The right hand side contains the premises. The Horn clause calculus is equivalent to the first-order predicate calculus.
Examples of valid rules:
friends(X,Y) :- likes(X,Y),likes(Y,X). /* X and Y are friends if they like each other */ hates(X,Y) :- not(likes(X,Y)). /* X hates Y if X does not like Y. */ enemies(X,Y) :- not(likes(X,Y)),not(likes(Y,X)). /* X and Y are enemies if they don't like each other */
Examples of invalid rules:
left_of(X,Y) :- right_of(Y,X) /* Missing a period */ likes(X,Y),likes(Y,X) :- friends(X,Y). /* LHS is not a single literal */ not(likes(X,Y)) :- hates(X,Y). /* LHS cannot be negated */
B)
The similarities between list processing capabilities in Scheme and Prolog are
PLZZZZZZZZZZZ RATE THUMBSUP
THANKS
What are the syntactic forms and usage of fact and rule statements in Prolog? Explain two...
CSE 240 Homework 5- Programming with PROLOG Due: Monday, April 22, 11:59 PM A. What This Assignment Is About: Facts, Rules, Goals Prolog execution model Arithmetic operations . Recursive Rules B. Use the following Guidelines Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc.) Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes classes, methods, and code associated with ifs, switches and loops. Be consistent with the number of...
Based on the prolog facts given below: 1.Given two medications, if they interact, tell what the effect of the interaction may be. Note there may be more than one result of the interaction. 2. Given a medical condition, list the drug interactions that may have caused it. 3. Given a drug, list the drugs, which have no interactions with it. 4. Given a drug, list the drugs, which do interact with it. interacts(gatifloxacin,mometasone,asthma). interacts(gatifloxacin,cisplatin,hyperglycaemia). interacts(gatifloxacin,cisplatin,bone_marrow_failure). interacts(gatifloxacin,montelukast,difficulty_breathing). interacts(temazepam,thalidomide,neutropenia). interacts(temazepam,thalidomide,thrombocytopenia). interacts(temazepam,timolol,drowsiness). interacts(temazepam,tizanidine,acid_reflux)....
1. Explain the function/purpose of the following sequence of program statements by expressing the postcondition and then prove that the program is correct using the axiomatic verification method. Precondition: {x = A and y = B} t=x x=y y=t Postcondition:________________ 2. Prove that the following grammar is ambiguous. <stmt> -> <assign> | <if-stmt> <assign> -> <id> := <expr> <if-stmt> -> if <bool> then <stmt> | if <bool> then <stmt> else <stmt> Modify the grammar above to make it unambiguous: 3....
Financial ratio statements In what ways can ratios be compared? (List and give examples of the different type of Comparisons - There should be four types - (i.e. Historical, and Projected ratios are two that can be done within the same company) What are the classifications of ratios (List them and explain what information they provide) For each classification above - list the ratios that fit within the classification
Chapter 15: 1. What is the significance of the fact that many synonymous codons differ in the third nucleotide position? 2. Define the following terms as they apply to the genetic code: a. Reading frame b. Overlapping code C. Nonoverlapping code d. Initiation codon e. Termination codon f. Sense codon 8. Nonsense codon h. Universal code i. Nonuniversal code 3. What role do the initiation factors play in protein synthesis? 4. Compare and contrast the process of protein synthesis in...
Understanding Movies College
6. Explain what structuralism is and provide one example of a structuralist technique that influenced mainstream filmmaking. (2 points) 7. Provide an example of your choosing of a film that uses dialectical conflict/binary oppositions (these terms are interchangeable) and explain how this technique is used to emphasize the film's themes or symbolism. (2 points) 8. List the three criteria that a film must meet to pass the Bechdel Test and explain what this test is designed to...
PLEASE help answer all of question 18 a-e
18. What would the lac operon look like in a eukaryote? List two possible changes in chromatin. Explain them to each other. a. b. Transcriptional control. Draw how a single gene (Lacz) would be transcribed and regulated c. If they are each in different chromosomes, draw how their expression would be coordinated Processing control. Pick one approach and explain to your partners d. Translational regulation. Pick one approach and explain to your...
7. What are the two major forms of Diabetes and what differentiates one form from the other? List the four basic diabetes treatment principles and state in one sentence why each is important. 18. Mr. S, a 65-year-old man, was in an automobile accident in which he suffered a concussion Soon after he was released, he noticed what he described as a "gray spot" in his field of vision. At first he ignored it, thinking it would go away, but...
1.Identify what two benefit objectives you will measure for your electronic commerce site? Explain why you picked those two? Describe how will you measure them? 2. List and describe all the ways that payments can be made for electronic commerce. Include at least one advantage and disadvantage for each payment system. Use your textbook as a reference and also research this topic on the internet and find one option that your textbook doesn't cover. Your posting should be in your...
Refer to the LawNow article, "The Rule of Law: Two Notable Supreme Court Decisions to Celebrate" written by Rob Normey. According to the article, which of the following statements is FALSE? Select one: a. The concept of the rule of law and the need to strictly comply with it is often presented with a flourish in legal and political debates. b. The article celebrated the Mackeigan v. Hickman (1989) and R. v Westendorp cases c. One essential aspect of the...