AstLog. Outline. Microsoft Research.
|
|
- Roger Martin
- 5 years ago
- Views:
Transcription
1 AstLog Microsoft Research. Outline Where does it come from? Prolog, with examples. Basic concepts of ASTLog. Simple examples in ASTLog. More complex examples. Why is this (apparently) not very widely used? 1
2 Important Prolog Ideas Terms, Facts, and rules. Unification. Backtracking. late binding. Prolog Examples. family(x,y):- unify(y,atomic(v,w,x)),dad(v,x), mom(w,x). unify(x,x). first([h _],H). rest([],[]). rest([_ T],T). append([],l,l). append([h T],L,[H R]) :- append(t,l,r). 2
3 Prolog for querying ASTs Prolog is an extension of SQL with complex terms and recursion. Easy to extend and modify. Very compact and powerful. BUT. AST s too expensive to store in Prolog. Runtime can be slow (memory). Example: Append 3 lists. append([],l,l). append([h T],L,[H R]) :- append(t,l,r). append(a,b,c,d):-append(a,b,s),append(s,c,d). append([],b,c,d):-append(b,c,d). append([h T],B,C,[H R]):-append(T,B,C,R). What is the difference? Answer: No intermediate lists! (Deforestation). 3
4 AstLog basics: There s always an implicit current node. AST s are not converted to Prolog. Matching rules are more complex. Lots of built-in predicates for matching/traversing AST nodes. Elegant, but sometimes a bit obscure (like T.S. Elliot). AstLog Elements and Constructs. Constants: #function, #lhs, #fname, etc. Variables: X, Y, Z, etc. Predicates: op(#function), kid(#lhs,y)etc. Compound: kid(#lhs, and(op(#variable), varname(y))) 4
5 AstLog simple example somekid(y):-kid(_,y). somenode(p):-or(p,kid(_,somenode(p)). defuse():- and(asym(y), if(parent(and(op(#=),kid(#left,asym(y))), emit( definition ), emit( use ))). AstLog simple example 2 cgr():-and(op(#function),fname(asym(y)), funcall(y)). funcall(y):-somenode(and(op(#funcall), kid(#callname,z), print(y,z ), or())). op(#filenode),kid(_,cgr()),or(). 5
6 Sametree sametree(node) :- op(nodeop), with (Node, op(nodeop)), not(and(with(node, kid(n, Nkid)), kid(n,not(sametree(nkid))) Follows in AstLog follows(p1,p2) Will match a node if P1 and P2 are true of consecutive nodes in an abstract syntax tree. Can this be used to generate control flow graph (all edges?) If not, why not? What exactly is meant by consecutive? cosecutive = necessary control flow. 6
7 MOST LIKELY WE LL JUST STOP HERE. THE REST WON T BE COVERED IN CLASS. Flatten flatten(test,lst): collect a list of AST nodes (children) that satisfy a particular predicate. flatten(test,head,tail): collect the list of AST nodes below current node satisfying a predicate, and hook the end of the list to the 3 rd argument; return result in argument 2. flatten(test,n,head,tail): collect the list of descendent AST nodes starting at kid n and hook 4 th argument at the end return result in arg 3. 7
8 flatten(test,lst):- flatten(test,lst,[]). flatten(test,head,tail):- if(test,and(o,unify(head,[o hrest])), unify(head,hrest)) flattenkids(test,0,hrest,tail). flattenkids(test,n,head,tail):- if(kid(n,flatten(test,kid,mid)), and(with(n,minus(nplus1,1)), flattenkids(test,nplus1,mid,tail)), unify(head,tail)). unify(x,x). Abstracted predicates. Advantage: some variables bound entirely within the scope of the predicate, and never leaked. Syntax: FN{.vars.} (anonymous-clauses). Consider: set of all (x,y) such that p(x,y). Defined using the old flatten expands to: if(p(x,y), unify(head,[(x,y) hrest]), unify(head,hrest)) flattenkids(p(x,y),0,hrest,tail). Won t work! Why? 8
9 Solution Using abstracted predicates: if((pred)(x,y), unify(head,[(x,y) hrest]), unify(head,hrest)) flattenkids(pred,0,hrest,tail). Another advantage: Sametree example: consider a predicate that involves making a complicated matching decision involving both nodes. sametree(testif, node):-. opcode(op), with(node,opcode(op)), testif(node), /* how do we say this? */. not(and(with(node,kid(n,nkid)), kid(n,not(sametree(testif, nkid))))). testif(node) :- etc, etc. Answer: Define an abstract predicate! 9
10 Examples sametree(node,equ):- op(nodeop),with(node,op(nodeop)), (equ)(node) (not(and(with(node,kid(n,nkid)) kid(n,not(sametree(nkid,equ)))))) Paper has the same done with abstraction? consteq(node):-if(aconst( c ), with(n, aconst( c)), and()) sametree(node, consteq/1) Higher order queries. WHY? Iterating /retrying over queries, and accumulating state. Set comprehension (set of all x such that P(x)). Counting elements. Is Q(x) true of all elements x : P(x), etc. HOW? Make a query into an object, with state. Provide higher-order functions that control the state of a query. But what are the states of a query? 10
11 Higher order queries Get a query under higher order control: the query(fterm, query-pred) primitive, and get it started.. Step through several evaluations: query(pred, thisquery-pred,nextquery-pred). First arg when it fails (exit), second arg otherwise, and then third arg at next evaluation.. Get bindings: qget(object-pred.). Conclusion Powerful language, full use of Prolog + higher order primitives. Sits right on top of most widely used C++ dialect Visual C++!!! Efficient execution, about 5-10 times slower than GENOA (due to Prolog) still faster than many other tools. Language design is based on abstract, difficult concepts, unfamiliar to many practioners. However, very good for study. 11
3 Lists. List Operations (I)
3 Lists. List Operations (I) The list is the simplest yet the most useful Prolog structure. A list is a sequence of any number of objects. Example 3.1: L = [1, 2, 3], R = [a, b, c], T = [john, marry, tim,
More informationProlog-2 nd Lecture. Prolog Predicate - Box Model
Prolog-2 nd Lecture Tracing in Prolog Procedural interpretation of execution Box model of Prolog predicate rule How to follow a Prolog trace? Trees in Prolog use nested terms Unification Informally Formal
More informationImplementação de Linguagens 2016/2017
Implementação de Linguagens Ricardo Rocha DCC-FCUP, Universidade do Porto ricroc @ dcc.fc.up.pt Ricardo Rocha DCC-FCUP 1 Logic Programming Logic programming languages, together with functional programming
More informationsimplicity hides complexity flow of control, negation, cut, 2 nd order programming, tail recursion procedural and declarative semantics and & or
simplicity hides complexity flow of control, negation, cut, 2 nd order programming, tail recursion simple and/or composition of goals hides complex control patterns not easily represented by traditional
More informationSCHEME 7. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. October 29, 2015
SCHEME 7 COMPUTER SCIENCE 61A October 29, 2015 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationsimplicity hides complexity flow of control, negation, cut, 2 nd order programming, tail recursion procedural and declarative semantics and & or
simplicity hides complexity flow of control, negation, cut, 2 nd order programming, tail recursion simple and/or composition of goals hides complex control patterns not easily represented by traditional
More informationCombining Lists & Built-in Predicates
Combining Lists & Built-in Predicates Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 6 11/10/04 11/10/04 AIPP Lecture 6: Built-in Predicates 1 Collecting Results Last time we
More informationProlog lecture 5. Data structures Difference lists Appendless append
Prolog lecture 5 Data structures Difference lists Appendless append Appending two Lists Predicate definition is elegantly simple: append([],l,l). append([x T],L,[X R]) :- append(t,l,r). Run-time performance
More informationLecture 6: More Lists
Lecture 6: More Lists Theory Define append/3, a predicate for concatenating two lists, and illustrate what can be done with it Discuss two ways of reversing a list A naïve way using append/3 A more efficient
More information7 Related Work. The five systems which are compared in detail to CoffeeStrainer are:
7 Related Work There are a number of proposals and systems which are similar to CoffeeStrainer. The main part of this chapter, from Section 7.1 to Section 7.5 consists of a detailed comparison of five
More information1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.
1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered
More informationRecap: Functions as first-class values
Recap: Functions as first-class values Arguments, return values, bindings What are the benefits? Parameterized, similar functions (e.g. Testers) Creating, (Returning) Functions Iterator, Accumul, Reuse
More informationCOP4020 Fall 2006 Final Exam
COP4020 Fall 2006 Final Exam Name: (Please print) Put the answers on these sheets. You can collect 100 points in total for this exam. 1. Consider the following Ada program fragment: search: loop i := i+1;
More informationCSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)
CSE 413 Languages & Implementation Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) 1 Goals Representing programs as data Racket structs as a better way to represent
More informationCSC384: Intro to Artificial Intelligence Prolog Tutorials 3&4. Hojjat Ghaderi, Fall 2006, University of Toronto
CSC384: Intro to Artificial Intelligence Prolog Tutorials 3&4 1 Debugging Programs in Prolog We talked about the graphical debugger under Windows. Now, the text-based debugger: You can put a breakpoint
More informationCMSC 331 Final Exam Section 0201 December 18, 2000
CMSC 331 Final Exam Section 0201 December 18, 2000 Name: Student ID#: You will have two hours to complete this closed book exam. We reserve the right to assign partial credit, and to deduct points for
More informationCSE 431S Type Checking. Washington University Spring 2013
CSE 431S Type Checking Washington University Spring 2013 Type Checking When are types checked? Statically at compile time Compiler does type checking during compilation Ideally eliminate runtime checks
More informationCMSC 331 Final Exam Section 0201 December 18, 2000
CMSC 331 Final Exam Section 0201 December 18, 2000 Name: nswers Student ID#: You will have two hours to complete this closed book exam. We reserve the right to assign partial credit, and to deduct points
More informationType checking by theorem proving in IDRIS
Type checking by theorem proving in IDRIS p. 1 Type checking by theorem proving in IDRIS Scottish Theorem Proving, 10th February 2012 ecb10@st-andrews.ac.uk University of St Andrews Edwin Brady Type checking
More informationNotes on Higher Order Programming in Scheme. by Alexander Stepanov
by Alexander Stepanov August 1986 INTRODUCTION Why Scheme? Because it allows us to deal with: 1. Data Abstraction - it allows us to implement ADT (abstact data types) in a very special way. The issue of
More informationPrinciples of Programming Languages Topic: Scope and Memory Professor Louis Steinberg Fall 2004
Principles of Programming Languages Topic: Scope and Memory Professor Louis Steinberg Fall 2004 CS 314, LS,BR,LTM: Scope and Memory 1 Review Functions as first-class objects What can you do with an integer?
More informationAnnouncements. The current topic: Scheme. Review: BST functions. Review: Representing trees in Scheme. Reminder: Lab 2 is due on Monday at 10:30 am.
The current topic: Scheme! Introduction! Object-oriented programming: Python Functional programming: Scheme! Introduction! Numeric operators, REPL, quotes, functions, conditionals! Function examples, helper
More informationCOMP2411 Lecture 20: Logic Programming Examples. (This material not in the book)
COMP2411 Lecture 20: Logic Programming Examples (This material not in the book) There are several distinct but often equivalent ways to think about logic programs 1. As computing logical consequences of
More informationIdris: Implementing a Dependently Typed Programming Language
Idris: Implementing a Dependently Typed Programming Language Edwin Brady University of St Andrews ecb10@st-andrews.ac.uk @edwinbrady Type Inference and Automated Proving, Dundee, 12th May 2015 1 / 25 Idris
More informationUser-defined Functions. Conditional Expressions in Scheme
User-defined Functions The list (lambda (args (body s to a function with (args as its argument list and (body as the function body. No quotes are needed for (args or (body. (lambda (x (+ x 1 s to the increment
More informationExercises on the Fundamentals of Prolog
1 Introduction Exercises on the Fundamentals of Prolog These exercises are intended to help reinforce material taught in the lectures of CIS335 course in Prolog. They do not contribute any marks to the
More informationChapter 5. Pure PROLOG. Foundations of Logic Programming
Chapter 5 1 Outline vs. logic programming Lists in Adding Arithmetics to Adding the Cut to 2 Syntax of Pure Prolog p(x,a) :- q(x), r(x,yi). p(x, a) q(x), r(x,y i ) % Comment Ambivalent syntax: p(p(a,b),
More informationSemester Review CSC 301
Semester Review CSC 301 Programming Language Classes There are many different programming language classes, but four classes or paradigms stand out: l l l l Imperative Languages l assignment and iteration
More informationPart I Logic programming paradigm
Part I Logic programming paradigm 1 Logic programming and pure Prolog 1.1 Introduction 3 1.2 Syntax 4 1.3 The meaning of a program 7 1.4 Computing with equations 9 1.5 Prolog: the first steps 15 1.6 Two
More informationNeo4J: Graph Database
February 24, 2013 Basics is a data storage and query system designed for storing graphs. Data as a series of relationships, modelled as a directed graph. Recall, a graph is a pair of sets: G(V, E) vertices
More informationAnd Parallelism. Parallelism in Prolog. OR Parallelism
Parallelism in Prolog And Parallelism One reason that Prolog is of interest to computer scientists is that its search mechanism lends itself to parallel evaluation. In fact, it supports two different kinds
More informationLogic Languages. Hwansoo Han
Logic Languages Hwansoo Han Logic Programming Based on first-order predicate calculus Operators Conjunction, disjunction, negation, implication Universal and existential quantifiers E A x for all x...
More informationA second life for Prolog
A second life for Prolog Algorithm = Logic + Control Jan Wielemaker J.Wielemaker@cwi.nl 1 Overview Algorithm = Logic + Control Limitations of SLD Beyond SLD 2 Algorithm = Logic + Control In Logic programming
More informationCOMP 9416, session 1, 2006 p. 1. Datalog. COMP 9416, session 1, 2006
OMP 9416, session 1, 2006 p. 1 Datalog OMP 9416, session 1, 2006 OMP 9416, session 1, 2006 p. 2 Atoms, integers and variables The fact "person(socrates).", the fact "sum(2,3,y)." and the rule "mortal(x)
More informationDocumentation for LISP in BASIC
Documentation for LISP in BASIC The software and the documentation are both Copyright 2008 Arthur Nunes-Harwitt LISP in BASIC is a LISP interpreter for a Scheme-like dialect of LISP, which happens to have
More informationFundamentals of Prolog
Fundamentals of Prolog Prof. Geraint A. Wiggins Centre for Cognition, Computation and Culture Goldsmiths College, University of London Contents Summary of Lecture 1 What makes a good Prolog program? What
More informationStreams, Delayed Evaluation and a Normal Order Interpreter. CS 550 Programming Languages Jeremy Johnson
Streams, Delayed Evaluation and a Normal Order Interpreter CS 550 Programming Languages Jeremy Johnson 1 Theme This lecture discusses the stream model of computation and an efficient method of implementation
More informationMap coloring example
Map coloring example A B C D E F Database for map coloring coloring(a,b,c,d,e,f) :- different(a,b), different(a,c), different(a,d), different(a,f), different(b,c), different(b,e), different(c,d), different(c,e),
More informationUNIVERSITY OF TORONTO AT MISSISSAUGA April 2006 Examination CSC 324H5 S Instructor: Richard Krueger Duration 3 hours No Aids Allowed
UNIVERSITY OF TORONTO AT MISSISSAUGA April 2006 Examination CSC 324H5 S Instructor: Richard Krueger Duration 3 hours No Aids Allowed Student Number: Last (Family) Name(s): First (Given) Name(s): SOLUTIONS
More informationComputer Science 21b: Structure and Interpretation of Computer Programs (Spring Term, 2004)
Computer Science 21b: Structure and Interpretation of Computer Programs (Spring Term, 2004) There are only 5 ideas in Computer Science, and by the end of this course, you ll know 3 of them --Harry Mairson
More informationUNIVERSITY OF TORONTO Faculty of Arts and Science. Midterm Sample Solutions CSC324H1 Duration: 50 minutes Instructor(s): David Liu.
UNIVERSITY OF TORONTO Faculty of Arts and Science Midterm Sample s CSC324H1 Duration: 50 minutes Instructor(s): David Liu. No Aids Allowed Name: Student Number: Please read the following guidelines carefully.
More informationINTRODUCTION TO PROLOG
INTRODUCTION TO PROLOG PRINCIPLES OF PROGRAMMING LANGUAGES Norbert Zeh Winter 2018 Dalhousie University 1/44 STRUCTURE OF A PROLOG PROGRAM Where, declaratively, Haskell expresses a computation as a system
More informationHomework 6: Higher-Order Procedures Due: 11:59 PM, Oct 16, 2018
Integrated Introduction to Computer Science Klein Homework 6: Higher-Order Procedures Due: 11:59 PM, Oct 16, 2018 Contents 1 Fun with map (Practice) 2 2 Unfold (Practice) 3 3 Map2 3 4 Fold 4 5 All You
More informationPL Revision overview
PL Revision overview Course topics Parsing G = (S, P, NT, T); (E)BNF; recursive descent predictive parser (RDPP) Lexical analysis; Syntax and semantic errors; type checking Programming language structure
More informationObjects CHAPTER 6. FIGURE 1. Concrete syntax for the P 3 subset of Python. (In addition to that of P 2.)
CHAPTER 6 Objects The main ideas for this chapter are: objects and classes: objects are values that bundle together some data (attributes) and some functions (methods). Classes are values that describe
More informationLogic Programming. Efficiency Issues. Temur Kutsia
Logic Programming Efficiency Issues Temur Kutsia Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria kutsia@risc.uni-linz.ac.at Efficiency Issues in Prolog Narrow the
More informationMore Non-logical Features of Prolog
More Non-logical Features of Prolog Prof. Geraint A. Wiggins Centre for Cognition, Computation and Culture Goldsmiths College, University of London Contents Commit operators Implementing Negation as Failure
More informationAn Explicit Continuation Evaluator for Scheme
Massachusetts Institute of Technology Course Notes 2 6.844, Spring 05: Computability Theory of and with Scheme February 17 Prof. Albert R. Meyer revised March 3, 2005, 1265 minutes An Explicit Continuation
More informationCOP4020 Programming Languages. Logical programming with Prolog Prof. Xin Yuan
COP4020 Programming Languages Logical programming with Prolog Prof. Xin Yuan Topics Logic programming with Prolog COP4020 Spring 2013 2 Definitions: Prolog Terms Terms are symbolic expressions that are
More informationConcepts of Programming Languages
Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana State University Spring 2014 Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014
More informationCompilers and computer architecture: A realistic compiler to MIPS
1 / 1 Compilers and computer architecture: A realistic compiler to MIPS Martin Berger November 2017 Recall the function of compilers 2 / 1 3 / 1 Recall the structure of compilers Source program Lexical
More informationChapter 9: Constraint Logic Programming
9. Constraint Logic Programming 9-1 Deductive Databases and Logic Programming (Winter 2007/2008) Chapter 9: Constraint Logic Programming Introduction, Examples Basic Query Evaluation Finite Domain Constraint
More informationLecture 7: Binding Time and Storage
Lecture 7: Binding Time and Storage COMP 524 Programming Language Concepts Stephen Olivier February 5, 2009 Based on notes by A. Block, N. Fisher, F. Hernandez-Campos, and D. Stotts Goal of Lecture The
More informationProlog. Intro to Logic Programming
Prolog Logic programming (declarative) Goals and subgoals Prolog Syntax Database example rule order, subgoal order, argument invertibility, backtracking model of execution, negation by failure, variables
More informationProlog - 3 Prolog search trees + traces
Prolog - 3 Prolog search trees + traces 1 Review member(a, [A B]). member(a, [B C]) :- member (A,C). goal-oriented semantics: can get value assignment for goal member(a,[b C]) by showing truth of subgoal
More informationChapter 16. Logic Programming. Topics. Unification. Resolution. Prolog s Search Strategy. Prolog s Search Strategy
Topics Chapter 16 Logic Programming Summary (resolution, unification, Prolog search strategy ) Disjoint goals The cut operator Negative goals Predicate fail Debugger / tracer Lists 2 Resolution Resolution
More informationImplementation of Lambda-Free Higher-Order Superposition. Petar Vukmirović
Implementation of Lambda-Free Higher-Order Superposition Petar Vukmirović Automatic theorem proving state of the art FOL HOL 2 Automatic theorem proving challenge HOL High-performance higher-order theorem
More informationCS61A Notes Week 6: Scheme1, Data Directed Programming You Are Scheme and don t let anyone tell you otherwise
CS61A Notes Week 6: Scheme1, Data Directed Programming You Are Scheme and don t let anyone tell you otherwise If you re not already crazy about Scheme (and I m sure you are), then here s something to get
More informationCS 314 Principles of Programming Languages
CS 314 Principles of Programming Languages Lecture 16: Functional Programming Zheng (Eddy Zhang Rutgers University April 2, 2018 Review: Computation Paradigms Functional: Composition of operations on data.
More informationProgramming Paradigms
PP 2017/18 Unit 9 Prolog: Accumulators, Order of Goals/Clauses, and the Cut 1/38 Programming Paradigms Unit 9 Prolog: Accumulators, Order of Goals/Clauses, and the Cut J. Gamper Free University of Bozen-Bolzano
More informationIntroduction to Prolog Paper Refs. Prolog tutor. Julian Verdurmen. Seminar Softw. tech. for teaching and learning. September 30, 2009
Seminar Softw. tech. for teaching and learning September 30, 2009 Outline 1 Introduction to Prolog Basics Simple example 2 Basics Simple example Outline 1 Introduction to Prolog Basics Simple example 2
More informationPrinciples of Programming Languages. Lecture Outline
Principles of Programming Languages CS 492 Lecture 1 Based on Notes by William Albritton 1 Lecture Outline Reasons for studying concepts of programming languages Programming domains Language evaluation
More informationThe Logic Paradigm. Joseph Spring. 7COM1023 Programming Paradigms
The Logic Paradigm Joseph Spring 7COM1023 Programming Paradigms 1 Discussion The Logic Paradigm Propositional and Predicate Logic See also notes and slides on PP website Horn Clauses Definition, Examples
More informationEncoding functions in FOL. Where we re at. Ideally, would like an IF stmt. Another example. Solution 1: write your own IF. No built-in IF in Simplify
Where we re at We explored the three standard logics, and compared them along three dimensions expressiveness automation human-friendliness Next we ll look in more detail at FOL we will explore how to
More informationLecture 11: Feb. 10, 2016
CS323: AI (Hands on with Prolog) Spring 2016 Lecturer: K.R. Chowdhary Lecture 11: Feb. 10, 2016 : Professor of CS (VF) Disclaimer: These notes have not been subjected to the usual scrutiny reserved for
More informationIntro. Scheme Basics. scm> 5 5. scm>
Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if
More informationEnvironments
Environments PLAI Chapter 6 Evaluating using substitutions is very inefficient To work around this, we want to use a cache of substitutions. We begin evaluating with no cached substitutions, then collect
More informationDeclarative Programming. 7: inductive reasoning
Declarative Programming 7: inductive reasoning 1 Inductive reasoning: overview infer general rules from specific observations Given B: background theory (clauses of logic program) P: positive examples
More informationSummer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define
CS 6A Scheme Summer 207 Discussion 0: July 25, 207 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationUNIVERSITETET I OSLO
Exam in INF3110, December 12, 2013 Page 1 UNIVERSITETET I OSLO Det matematisk-naturvitenskapelige fakultet Exam in: INF3110 Programming Languages Day of exam: December 12, 2013 Exam hours: 14:30 18:30
More informationSCHEME AND CALCULATOR 5b
SCHEME AND CALCULATOR 5b COMPUTER SCIENCE 6A July 25, 203 In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationRecursive Functions. Recursive functions are built up from basic functions by some operations.
Recursive Functions Recursive functions are built up from basic functions by some operations. The Successor Function Let s get very primitive. Suppose we have 0 defined, and want to build the nonnegative
More informationIntroduction to Computer Science and Business
Introduction to Computer Science and Business The Database Programming with PL/SQL course introduces students to the procedural language used to extend SQL in a programatic manner. This course outline
More informationTests, Backtracking, and Recursion
Tests, Backtracking, and Recursion Artificial Intelligence Programming in Prolog Lecture 3 30/09/04 30/09/04 AIPP Lecture 3: Rules, Results, and Backtracking 1 Re-cap A Prolog program consists of predicate
More informationCS221: Algorithms and Data Structures. Asymptotic Analysis. Alan J. Hu (Borrowing slides from Steve Wolfman)
CS221: Algorithms and Data Structures Asymptotic Analysis Alan J. Hu (Borrowing slides from Steve Wolfman) 1 Learning Goals By the end of this unit, you will be able to Define which program operations
More informationLogical reasoning systems
Logical reasoning systems Theorem provers and logic programming languages Production systems Frame systems and semantic networks Description logic systems CS 561, Session 19 1 Logical reasoning systems
More informationCSCC24 Functional Programming Scheme Part 2
CSCC24 Functional Programming Scheme Part 2 Carolyn MacLeod 1 winter 2012 1 Based on slides from Anya Tafliovich, and with many thanks to Gerald Penn and Prabhakar Ragde. 1 The Spirit of Lisp-like Languages
More informationCS 360 Programming Languages Interpreters
CS 360 Programming Languages Interpreters Implementing PLs Most of the course is learning fundamental concepts for using and understanding PLs. Syntax vs. semantics vs. idioms. Powerful constructs like
More informationFunctional Programming
Functional Programming CS331 Chapter 14 Functional Programming Original functional language is LISP LISt Processing The list is the fundamental data structure Developed by John McCarthy in the 60 s Used
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Values and Types We divide the universe of values according to types A type is a set of values and
More informationWhat s the problem? fib(1,1). fib(2,1). fib(n,x) :- N>2, N1 is N-1, N2 is N-2, fib(n1,x2), fib(n2,x2).
39 What s the problem? A Fibonacci Implementation fib(1,1). fib(2,1). fib(n,x) :- N>2, N1 is N-1, N2 is N-2, fib(n1,x2), fib(n2,x2). List Concatenation conc([],l,l). conc([x L1], L2, [X L3]) :- conc(l1,l2,l3).
More informationWhy do we need an interpreter? SICP Interpretation part 1. Role of each part of the interpreter. 1. Arithmetic calculator.
.00 SICP Interpretation part Parts of an interpreter Arithmetic calculator Names Conditionals and if Store procedures in the environment Environment as explicit parameter Defining new procedures Why do
More informationThe Idea Underlying Logic Programming. CSci 8980, Fall 2012 Specifying and Reasoning About Computational Systems An Introduction to Logic Programming
The Idea Underlying CSci 8980, Fall 2012 Specifying and Reasoning About Computational Systems An Introduction to Department of Computer Science and Engineering University of Minnesota Lectures in Fall
More information(Refer Slide Time: 1:27)
Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture 1 Introduction to Data Structures and Algorithms Welcome to data
More informationR13 SET Discuss how producer-consumer problem and Dining philosopher s problem are solved using concurrency in ADA.
R13 SET - 1 III B. Tech I Semester Regular Examinations, November - 2015 1 a) What constitutes a programming environment? [3M] b) What mixed-mode assignments are allowed in C and Java? [4M] c) What is
More informationAdvanced Functional Programming, 1DL Lecture 2, Cons T Åhs
Advanced Functional Programming, 1DL450 2012 Lecture 2, 2012-11-01 Cons T Åhs Higher order functions hof() -> F = fun(x) -> X * X + 1 end, L = lists:map(f, [1, 2, 3], G = fun([]) -> nil; ([_ _]) -> cons
More informationOn the BEAM Implementation
On the BEAM Implementation Ricardo Lopes 1,Vítor Santos Costa 2, and Fernando Silva 1 1 DCC-FC and LIACC, Universidade do Porto, Portugal {rslopes,fds}@ncc.up.pt 2 COPPE-Sistemas, Universidade Federal
More informationSQL STORED ROUTINES. CS121: Relational Databases Fall 2017 Lecture 9
SQL STORED ROUTINES CS121: Relational Databases Fall 2017 Lecture 9 SQL Functions 2 SQL queries can use sophisticated math operations and functions Can compute simple functions, aggregates Can compute
More information;;; Determines if e is a primitive by looking it up in the primitive environment. ;;; Define indentation and output routines for the output for
Page 1/11 (require (lib "trace")) Allow tracing to be turned on and off (define tracing #f) Define a string to hold the error messages created during syntax checking (define error msg ""); Used for fancy
More informationLecture Overview Prolog 1. Introduction Interaction Terms 2. Clauses and predicates Clauses Predicates Variables 3.
1 Lecture Overview Prolog 1. Introduction Interaction Terms 2. Clauses and predicates Clauses Predicates Variables 3. Satisfying goals 2 Prolog A standard free Prolog can be downloaded from http://www.swi-prolog.org
More informationUNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger
UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division CS 164 Spring 2010 P. N. Hilfinger CS 164: Final Examination (revised) Name: Login: You have
More informationUNIVERSITY of CALIFORNIA at Berkeley Department of Electrical Engineering and Computer Sciences Computer Sciences Division
UNIVERSITY of CALIFORNIA at Berkeley Department of Electrical Engineering and Computer Sciences Computer Sciences Division CS61A Kurt Meinz Structure and Interpretation of Computer Programs Summer 2002
More informationINF4820: Algorithms for Artificial Intelligence and Natural Language Processing. Common Lisp Fundamentals
INF4820: Algorithms for Artificial Intelligence and Natural Language Processing Common Lisp Fundamentals Stephan Oepen & Murhaf Fares Language Technology Group (LTG) August 30, 2017 Last Week: What is
More informationBasic Scheme February 8, Compound expressions Rules of evaluation Creating procedures by capturing common patterns
Basic Scheme February 8, 2007 Compound expressions Rules of evaluation Creating procedures by capturing common patterns Previous lecture Basics of Scheme Expressions and associated values (or syntax and
More informationFP Foundations, Scheme
FP Foundations, Scheme In Text: Chapter 15 1 Functional Programming -- Prelude We have been discussing imperative languages C/C++, Java, Fortran, Pascal etc. are imperative languages Imperative languages
More informationProject Compiler. CS031 TA Help Session November 28, 2011
Project Compiler CS031 TA Help Session November 28, 2011 Motivation Generally, it s easier to program in higher-level languages than in assembly. Our goal is to automate the conversion from a higher-level
More informationImplementing languages on the Erlang VM
Robert Virding Principle Language Expert at Erlang Solutions Ltd. Erlang Solutions Ltd. Implementing languages on the Erlang VM 19992012 Erlang Solutions Ltd. What languages? Basic Tools 3 case studies
More informationCS 321 Programming Languages and Compilers. Prolog
CS 321 Programming Languages and Compilers Prolog Prolog PROgramming LOGic Algorithm = Logic + Control Logic programming deals with computing relations rather than functions. To understand Prolog one must
More informationAdvanced Prolog Programming
1 Introduction CIS335, Assignment 4 Advanced Prolog Programming Geraint Wiggins November 12, 2004 This practical is the second self-assessed exercise for MSc students on the Prolog module. It is intended
More informationRecursion, Structures, and Lists
Recursion, Structures, and Lists Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 4 04/10/04 30/09/04 AIPP Lecture 3: Recursion, Structures, and Lists 1 The central ideas of Prolog
More information