Docsity

Introduction to Logic Programming, Lecture notes of Programming Languages

Partial preview of the text

Download Introduction to Logic Programming and more Lecture notes Programming Languages in PDF only on Docsity!

Logic Programming

Introduction

Michael Genesereth

Computer Science Department

Stanford University

Lecture will begin at ~1:35 PDT.

Logic Programming is a style of programming based on Symbolic Logic. Logic Program is a collection of sentences encoded in the language of Symbolic Logic. Logic Programming Language is a specific language for writing such programs. Logic Programming System is a computer system that manages the creation, modification, and execution of logic programs. Logic Programming (Spoiler Alert)

Declarative Programming Inputs Interpreter Outputs e=mc^2 A triangle is a polygon with 3 sides.

Runnable Specifications Specification What we believe about the application area What we want to know or to achieve in application area With no arbitrary decisions With no concern for internal processing details Runnable Can be directly interpreted Can be compiled into traditional programs

Specialized Languages A triangle is a polygon with 3 sides.

Logic as a Specification Language Language Declarative language

Highly expressive Other declarative languages exist but statements in most of those languages can be translated to logical form. Interpreter Automated Reasoners capable of drawing conclusions Can take advantage of domain-dependent reasoners but are also capable domain-independent reasoning

Programming Ease Easier to create and modify than traditional programs Programmers can get by with little or no knowledge of the capabilities of systems executing those programs. Less work. The specification is the program; no need to make choices about data structures and algorithms. Easier to learn logic programming than traditional programming. Think spreadsheets. Oddly, expert computer programmers often have more trouble with logic programming than novices.

Agility Ability to respond to changing circumstances or goals

McCarthy’s Example of Versatility

McCarthy’s Example of Versatility

Circuit: Premises: Applications: Simulation Configuration Diagnosis Test Generation o ⇔ ( x ∧ ¬ y ) ∨ (¬ x ∧ y ) a ⇔ z ∧ o b ⇔ x ∧ y s ⇔ ( o ∧ ¬ z ) ∨ (¬ o ∧ z ) c ⇔ a ∨ b x y z s c o a b Engineering

Deductive Databases Database Manager g( X , Z ) :- p( X , Y ) ∧ p( Y , Z ) q( X ) :- p( X , Y ) ∧ p( X , Z ) ∧ Y!=Z illegal :- p(X,Y) ∧ p(Y,X) p(a,b) p(b,c) p(a,b) Ques1ons Updates Answers No1fica1ons

Constraint Satisfaction

Worksheets http://logicprogramming.stanford.edu/examples/programsheets/demonstration.html