tailieunhanh - Lecture Programming languages (2/e): Chapter 15a - Tucker, Noonan

Chapter 15 - Logic programming. This chapter focuses on logic pro-gramming with Prolog, studying its applications in natural language processing and , problem solving. The main contents of this chapter include all of the following: Logic and horn clauses, logic programming in prolog, prolog program elements. | Programming Languages 2nd edition Tucker and Noonan Chapter 15 Logic Programming Q: How many legs does a dog have if you call its tail a leg? A: Four. Calling a tail a leg doesn’t make it one. Abraham Lincoln Contents Logic and Horn Clauses Logic Programming in Prolog Prolog Program Elements Practical Aspects of Prolog Prolog Examples Symbolic Differentiation Solving Word Puzzles Natural Language Processing Semantics of Clite 5 Eight Queens Problem Logic and Horn Clauses A Horn clause has a head h, which is a predicate, and a body, which is a list of predicates p1, p2, , pn. It is written as: h p1, p2, , pn This means, “h is true only if p1, p2, , and pn are simultaneously true.” ., the Horn clause: snowing(C) precipitation(C), freezing(C) says, “it is snowing in city C only if there is precipitation in city C and it is freezing in city C.” Horn Clauses and Predicates Any Horn clause h p1, p2, , pn can be written as a predicate: p1 p2 pn h or equivalently: (p1 p2 pn) h But not every predicate can be written as a Horn clause. ., literate(x) reads(x) writes(x) Resolution and Unification If h is the head of a Horn clause h terms and it matches one of the terms of another Horn clause: t t1, h, t2 then that term can be replaced by h’s terms to form: t t1, terms, t2 During resolution, assignment of variables to values is called instantiation. Unification is a pattern-matching process that determines what particular instantiations can be made to variables during a series of resolutions. Example The two clauses: speaks(Mary, English) talkswith(X, Y) speaks(X, L), speaks(Y, L), X Y can resolve to: talkswith(Mary, Y) speaks(Mary, English), speaks(Y, English), Mary Y The assignment of values Mary and English to the variables X and L is an instantiation for which this resolution can be made. Logic Programming in Prolog In logic programming the program . | Programming Languages 2nd edition Tucker and Noonan Chapter 15 Logic Programming Q: How many legs does a dog have if you call its tail a leg? A: Four. Calling a tail a leg doesn’t make it one. Abraham Lincoln Contents Logic and Horn Clauses Logic Programming in Prolog Prolog Program Elements Practical Aspects of Prolog Prolog Examples Symbolic Differentiation Solving Word Puzzles Natural Language Processing Semantics of Clite 5 Eight Queens Problem Logic and Horn Clauses A Horn clause has a head h, which is a predicate, and a body, which is a list of predicates p1, p2, , pn. It is written as: h p1, p2, , pn This means, “h is true only if p1, p2, , and pn are simultaneously true.” ., the Horn clause: snowing(C) precipitation(C), freezing(C) says, “it is snowing in city C only if there is precipitation in city C and it is freezing in city C.” Horn Clauses and Predicates Any Horn clause h p1, p2, , pn can be

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.