Declarative Languages. Declarative languages In an imperative programming language, a program specifies how to solve a problem In a declarative language,

Slides:



Advertisements
Similar presentations
Modelling with expert systems. Expert systems Modelling with expert systems Coaching modelling with expert systems Advantages and limitations of modelling.
Advertisements

Simulation executable (simv)
1 Introduction to Prolog References: – – Bratko, I., Prolog Programming.
Separate compilation Large programs are generally separated into multiple files, e.g. tuples.h, ray.h, ray.c, tuples.c main.c With several files, we can.
CS 330 Programming Languages 12 / 02 / 2008 Instructor: Michael Eckmann.
CSE 425: Logic Programming I Logic and Programs Most programs use Boolean expressions over data Logic statements can express program semantics –I.e., axiomatic.
Fall 2007CS 2251 Programming Tools Eclipse JUnit Testing make and ant.
Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description.
Fall 2007CS 2251 Programming Tools Eclipse JUnit Testing make and ant.
Information Hiding and Encapsulation
Guide To UNIX Using Linux Third Edition
CS465 - Unix C Programming (cc/make and configuration control)
1 Building. 2 Goals of this Lecture Help you learn about: The build process for multi-file programs Partial builds of multi-file programs make, a popular.
Lecture 8  make. Overview: Development process  Creation of source files (.c,.h,.cpp)  Compilation (e.g. *.c  *.o) and linking  Running and testing.
1 Software Development Topic 2 Software Development Languages and Environments.
Formal Models of Computation Part II The Logic Model
Make: the good, the bad, and the ugly Dan Berger Titus Winters
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
July 29, 2003Serguei Mokhov, 1 Makefile Brief Reference COMP 229, 346, 444, 5201 Revision 1.2 Date: July 18, 2004.
AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,
Evolution of Programming Languages Generations of PLs.
COSC 2P93 Logic Programming Instructor: Brian Ross Instructor: Brian Ross Texts: Texts: Prolog Programming for Artificial Intelligence,4e, Ivan Bratko,
Introduction Use of makefiles to manage the build process Declarative, imperative and relational rules Environment variables, phony targets, automatic.
1-1 Introduction Logic programming languages, sometimes called declarative programming languages Express programs in a form of symbolic logic Use a logical.
Introduction to C Programming CE Lecture 7 Compiler options and makefiles.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
Introduction To PROLOG World view of imperative languages. World view of relational languages. A PROLOG program. Running a PROLOG program. A PROLOG.
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
Makefile M.A Doman. Compiling multiple objects Card.cpp -> Card.o Deck.cpp -> Deck.o main.cpp -> main.o main.o Deck.o Card.o -> Dealer.exe.
CHAPTER 15 & 16 Functional & Logic Programming Languages.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
GNU Make Computer Organization II 1 © McQuain What is make ? make is a system utility for managing the build process (compilation/linking/etc).
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
BMTRY 789 Lecture 10: SAS MACRO Facility Annie N. Simpson, MSc.
Dr. Muhammed Al-Mulhem ICS An Introduction to Logical Programming.
Makefiles. Multiple Source Files (1) u Obviously, large programs are not going to be contained within single files. u C provides several techniques to.
Logic Programming Languages Session 13 Course : T Programming Language Concept Year : February 2011.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
Introduction to Prolog. Outline What is Prolog? Prolog basics Prolog Demo Syntax: –Atoms and Variables –Complex Terms –Facts & Queries –Rules Examples.
Copyright © 2015 Curt Hill Make An Indispensable Developer’s Tool.
Makefiles CARYL RAHN. Separate compilation Large programs are generally separated into multiple files, e.g. main.c addmoney.c removemoney.c money.h With.
Logic Programming Tarik Booker. What will we cover?  Introduction  Definitions  Predicate Calculus  Prolog  Applications.
ISBN Chapter 16 Logic Programming Languages.
Modular Programming. Introduction As programs grow larger and larger, it is more desirable to split them into sections or modules. C allows programs to.
Knowledge Based Information System
1-1 An Introduction to Logical Programming Sept
Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
CSc 352 An Introduction to make Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
GNU Make Computer Organization II 1 © McQuain What is make ? make is a system utility for managing the build process (compilation/linking/etc).
Makefiles Manolis Koubarakis Data Structures and Programming Techniques 1.
Pengenalan Prolog Disampaikan Oleh : Yusuf Nurrachman, ST, MMSI.
The make utility (original presentation courtesy of Alark Joshi)
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha Fall 2015
Makefiles Caryl Rahn.
SCMP Special Topic: Software Development Spring 2017 James Skon
What is make? make is a system utility for managing the build process (compilation/linking/etc). There are various versions of make; these notes discuss.
Logic Programming Languages
Makefiles and the make utility
Data Structures and Programming Techniques
A programming language
SCMP Software Development Spring 2018 James Skon
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Makefiles and the make utility
Chapter 2: Prolog (Introduction and Basic Concepts)
SCMP Software Development Spring 2018 James Skon
What is make? make is a system utility for managing the build process (compilation/linking/etc). There are various versions of make; these notes discuss.
The make utility (original presentation courtesy of Alark Joshi)
Presentation transcript:

Declarative Languages

Declarative languages In an imperative programming language, a program specifies how to solve a problem In a declarative language, a program specifies what needs to be solved –The language itself needs to provide a way to find the solution –Sometimes called rule-based languages Examples –Prolog (logic programming) –MYCIN (Expert systems) –SQL (databases)

Logic Programming Non-procedural – program specifies the desired result, not how to get it Program consists of a set of data and a desired outcome Logical inference is used to get the result Prolog is the primary example of a logical language

Prolog program consists of a collection of statements each statement is constructed from terms a term can be a constant, a variable or a structure a constant is an atom (a specific object) or a number a variable can refer to different objects at different times a structure is an atomic proposition used to specify a facts (relations between objects) – functor( parameter list)

Prolog Statements Several forms of statements occur in a Prolog program. –Fact – a headless Horn clause such as male( joe) –Rule – consequent := antecedent (The antecedent must be either a single term or a conjunction which is a sequence of terms separated by commas in Prolog.) Rules may be specific to particular objects or general like female(X ) ⇐ mother(X ) –Goal (query) – the desired outcome, what needs to be proved by the program. Programs may have compound goals; each part is a subgoal. Goals look similar to facts and rules; they are entered in a different mode.

Example Facts: father( john) father( bob) Rules: man( x) := father( x) Query: man( bob)

Rule-Based Languages Rule-based languages are used for Expert Systems (Artificial Intelligence) –OPS5 –ART – CLIPS Mathematica and Maple are rule-based The make utility uses a rule-based approach

What is make make is a utility that comes with the Unix (and Linux) operating system make is a command generator make is designed to help you compile large projects make can be useful whenever you have long sequences of commands which are needed to accomplish a particular task or set of related tasks make is non-procedural –you tell make what you want (e.g. a particular class file or executable –you provide a set of rules showing dependencies between files –make uses the rules to get the job done

make make uses a file called makefile to determine what needs to be recompiled. The makefile contains a set of rules for executing the jobs it can be asked to do. When you run make, it uses the rules in the makefile to determine what has to be done. make does the minimum amount of work needed to get the job done.

The make utility is rule-based A makefile contains a set of rules explaining what needs to be done to compile the program. When you type make or make target, the make utility will look at the rule for the desired target. make without a target name will assume you mean to make the first real target in the makefile. –If the current version of the target file happens to be up-to- date, make will do nothing. – If the target file is older than any of the files that it depends on, or any of those files is older than a file it depends on, make will invoke whatever rules are needed to get everything up-to-date.

Rules in a makefile A typical rule has the form target: dependency list command list –target can be the name of a file that needs to be created –the dependency list is a space separated list of files needed to create the target –the command list is one or more linux commands needed to accomplish the task of creating the target file The target need not be a real file clean: rm --force *.class

How does make work? When you type make or make target, the make utility will look at the rule for the desired target. make will resursively search through the rules for all the dependencies to determine what has been modified If the current version of all the dependency files happen to be up-to-date, make will do nothing. If a target file is older than any of the files that it depends on, the command following the rule will be executed make without a target name will assume you mean to make the first real target in the makefile.

Example: the Interpreter The interpreter you are working on has (at least) the following classes or modules. – Interpreter – the main program or driver class –Evaluator – a module to do the evaluation –Environment – a data structure for storing a program’s state –Parser – a module for recognizing and parse-tree generation –Lexer – input module – Lexeme – data structure for storing the lexical units of the program –Token Every time you change one of the source files, you need to recompile at least that file. But how many of the others need to be recompiled? Do you do all of them every time you make a change?

Rules for the Interpreter Interpreter.class: Interpreter.java Environment.class \ Parser.class Lexer.class Lexeme.class Token.class javac Interpreter.java Environment.class: Environment.java Lexeme.class \ Token.class javac Environment.java Parser.class: Parser.class Lexer.class Lexeme.class \ Token.class javac Parser.java Lexer.class: Lexer.java Lexeme.class Token.class javac Lexer.java Lexeme.class: Lexeme.java Token.class javac Lexeme.java

Macros Sometimes, you find yourself using the same sequence of command line options in lots of commands. –We’ll use a C example You can define a macro with an assignment CC=gcc -O -Wall -g –then you use the macro by typing $(macroname) $(CC) -c ipl.c

Internal macros % - wildcard – the name of the current target $< – the list of dependencies for the current target

Substitution Rules Often, you will find that your makefile has many similar commands You can use patterns to define rules and commands for such cases For example, in the java version of the makefile, we could use the rule %.class: %.java javac $< which says that every.class file depends on the corresponding.java file and can be created from it with the javac command

It is common to put some dummy targets into a make file doc: html javadoc –author -d html/ *.java clean: rm --force *.class

Information about make Managing Projects with make by Andrew Oram and Steve Talbot (an O’Reilly book) The man page man make