236x Filetype PDF File size 0.10 MB Source: www.dcc.fc.up.pt
Logic Programming & Prolog RRiiccararddoo RRoocchhaa Computer Science Department Faculty of Sciences, University of Porto Implementation of Programming Languages 2019/2020 Implementation of Programming Languages 2019/2020 Logic Programming & Prolog 1 / 21 Declarative Languages Logic programming languages, together with functional programming languages,formamajorclassoflanguagescalleddeclarativelanguages. Acommoncharacteristicofbothgroupsoflanguagesisthattheyhavea ssttrroonngg mmaatthheemmaattiiccaall bbaassiiss:: • Logicprogramminglanguagesarebasedonthepredicatecalculus • Functionalprogramminglanguagesarebasedonthelambdacalculus Implementation of Programming Languages 2019/2020 Logic Programming & Prolog 2/ 21 Declarative Languages Declarative languages are considered to be very high-level languages when compared with conventional imperative languages because, generally, they allow the programmer to concentrate more on what the problem is, leaving much of the details of how to solve the problem to tthhee ccoommppuutteerr.. The programmer specifies the problem at a more application-oriented level, which simplifies the formal reasoning about it. Implementation of Programming Languages 2019/2020 Logic Programming & Prolog 3/ 21 Logic Programming Logic programming is a programming paradigm based on Horn Clause Logic, a subset of First Order Logic. Logic programming is a simple theorem prover that given a theory (or program) and a query, uses the theory to search for alternative ways to ssatatiissffyy tthhee qquueerryy:: • Variablesarelogicalvariables which canbeinstantiatedonlyonce • Variablesareuntypeduntilinstantiated • Variables are instantiated via unification, a pattern matching operation finding themostgeneralcommoninstanceoftwodataobjects • At unification failure the execution backtracks and tries to find another way to satisfy the original query Implementation of Programming Languages 2019/2020 Logic Programming & Prolog 4/ 21
no reviews yet
Please Login to review.