LING 581: Advanced Computa7onal Linguis7cs. Lecture Notes April 16th

Size: px
Start display at page:

Download "LING 581: Advanced Computa7onal Linguis7cs. Lecture Notes April 16th"

Transcription

1 LING 581: Advanced Computa7onal Linguis7cs Lecture Notes April 16th

2 Administrivia Factoid Ques-on Answering homework did you submit your simula.on?

3 Seman7cs New topic! We want computers to be able to understand sentences, model the world, compute meaning, truth values, entailments etc.

4 Meaning What is a meaning and how do we represent it? difficult to pin down precisely for computers even difficult for humans some.mes Example: word dog by reference to other words Merriam- Webster: a highly variable domes.c mammal (Canis familiaris) closely related to the gray wolf transla7on 犬 (inu, Japanese) = (gou, Chinese) = dog (English) Computer: meaning è formal concept (or thought or idea) dog maps to DOG <word> maps to <concept> need to provide a concept for every meaningful piece of language?

5 Understanding Suppose we write a computer program to compute the meaning of sentences Ques7on: does it understand sentences? How do you know? Ask ques7ons? Turing test: converse with a human, convince human the computer is a human Searle s Chinese room experiment (adapted) suppose we have a Perl/Python/Prolog program capable of processing Chinese, and we run the program manually i.e. we carry out the instruc.ons of the program do we understand Chinese? Weak AI / Strong AI

6 Truth Condi7ons and Values What is the meaning of a sentence anyway? What is Meaning? (Portner 2005) Example: the circle is inside the square We can draw a picture of scenarios for which the statement is true and the statement is false Proposi7on expressed by a sentence is its truth- condi7ons under what condi7ons a sentence is true i.e. sets of possible worlds (aka situa7ons) truth- condi.ons different from truth- value

7 Truth Condi7ons and Values Example: The circle is inside the square and the circle is dark What is the meaning of and here? and = set intersec7on (of scenarios) [The circle is inside the square] and [the circle is dark] Example: Mary is a student and a baseball fan and = set intersec7on (of???) Mary is [a student] and [a baseball fan]

8 Truth Condi7ons and Values Example: Mary and John bought a book Does and = set intersec7on? Are Mary and John sets anyway? [Mary] and [John] bought a book Set intersec7on = how about and = set union then?

9 Truth Condi7ons and Values Example: The square is bigger than the circle The circle is smaller than the square Are they synonymous? Are they contradictory? Is there an entailment rela7onship? Are they tautologies?

10 More examples 1. Does sleep entail snore? A. He is sleeping entails He is snoring B. He is snoring entails He is sleeping 2. Does snore presuppose sleep? 3. What does when did you stop bea.ng your wife? presuppose? 3. Given the statement All crows are black, give an example of a sentence expressing a tautology involving this statement? Stmt or nega7on Stmt

11 Proposi7onal Logic Recall the dis7nc7on between truth condi7ons and truth values Possible world or situa7on: we can create a possible world in Prolog by asser7ng (posi7ve) facts into its database Prolog use the closed world assump7on i.e. things not explicity stated to be true are assumed to be false

12 Proposi7onal Logic Cheat sheet Star7ng SWI Prolog from Terminal/Shell: swipl (if in PATH) /opt/local/bin/swipl (default install loca7on on my mac) ^D (control- D) or halt. to quit

13 Proposi7onal Logic Cheat sheet Viewing the database: listing. Assert (and delete) facts at the command line directly using predicates: assert(fact). retract(fact). Put facts into a file and load file [filename]. (assumed to have extension.pl) (or via pull- down menu in Windows) Proposi7ons: named beginning with a lower case lejer (not number, not star7ng with capital lejer or underscore: variable no variables in proposi7onal logic), examples: assert(p). (makes p true in this situa7on) p. (asks Prolog if p true in this situa7on) dynamic q. (registers proposi7on q, prevents error message)

14 Proposi7onal Logic Example: Note: meta- level predicates like dynamic and assert evaluate to true if they succeed

15 Proposi7onal Logic Proposi7ons can be combined using logical connec7ves and operators Conjunc7on p, q. Disjunc7on p ; q. Nega7on \+ p. Not directly implemented in Prolog Implica7on p - > q. (IS NOT THIS!!!) Use parentheses ( ) to restrict/clarify scope can t add p, q. to the database can only query it needs both p and q to be true, see next slide

16 Proposi7onal Logic Help:?- help(->). true. takes a very long 7me for this window to pop up it uses the X11 Window system, which may or may not exist on your system IF - > THEN ; ELSE is a programming construct

17 Proposi7onal Logic Also not implemented Logical equality p = q.

18 Proposi7onal Logic Help: Not quite the right documenta7on page = is unifiability in Prolog

19 Proposi7onal Logic Prolog exercise: evaluate formula below for different truth values of A and B From wikipedia

20 Proposi7onal Logic How to demonstrate a proposi7onal formula is a tautology? One answer: exhaus7vely enumerate a truth table hjp://en.wikipedia.org/wiki/truth_table

21 Proposi7onal Logic Example: (A, B) ; (\+ A) ; (\+ B) T T T T F T F F T T F F T F T T T F F F T T T F T F T F F F T T F T T F table has 2 n rows, where n is the number of proposi7onal elements complexity: exponen7al in n

22 Proposi7onal Logic Other connec7ves (are non- primi7ve)

23 Proposi7onal Logic Other connec7ves (are non- primi7ve) aka p q From 1 st and 4 th line of truth table, we can easily deduce how to simulate p q in Prolog using, ; and \+

24 Proposi7onal Logic Let s prove the law of contraposi7on hjp://en.wikipedia.org/wiki/tautology_(logic)

25 Proposi7onal Logic Prove both sides of De Morgan s Laws: Note: De Morgan s laws tell us we can do without one of conjunc7on or disjunc7on. Why?

26 Proposi7onal Logic It s easy to write a short program in Prolog to automate all this Program: plogic.pl

27 Example using try/2: Proposi7onal Logic It's a tautology! true under all possible condi7ons

28 Proposi7onal Logic We can get a bit fancier, support - > and <- > Program: plogic2.pl

29 Proposi7onal Logic We can get even fancier; eliminate having to supply the proposi7onal variables Program: plogic3.pl

30 Truth table enumera7on Parsing the formula: 11. \+ X converts to \+ A if (subformula) X converts to A 12. X,Y converts to A,B if X converts to A and Y converts to B 13. X;Y converts to A;B if X converts to A and Y converts to B 14. X- >Y converts to \+A;B if X converts to A and Y converts to B 15. X<- >Y converts to (A,B) ; (\+A,\+B) if X converts to A and Y converts to B 16. X converts to X and add X to the list of proposi7onal variables if it isn t already in the list

31 Proposi7onal Logic Program: plogic3.pl

32 Seman7c Grammars Use slides from course LING 324 Introduc-on to Seman-cs Simon Frasier University, Prof. F.J. Pelle7er hjp:// Difference is we re computa.onal linguists so we re going to implement the slides We ll do the syntax part this lecture, and the seman7cs next 7me

33 Syntax ypslides4.pdf Slide 3

34 Syntax We already know how to build Prolog grammars See hjp:// prolog.org/pldoc/doc_for? object=sec7on(2,'4.12',swi('/doc/manual/dcg.html')) for the execu7ve summary

35 Class exercise Syntax

36 Syntax Step 1: let s build the simplest possible Prolog grammar for this ypslides4.pdf Slide 4

37 Simplest possible grammar g1.pl Excluding (2b) for the 7me being

38 Simplest possible grammar Examples (3), (4) and (5) from two slides back

39 Syntax Step 2: let s add the parse tree component to our grammar Recall: grammar rules can have extra arguments (1) Parse tree (2) Implement agreement etc.

40 Syntax Note: on handling lez recursion in Prolog grammar rules techniques: 1. use a bojom- up parser 2. rewrite grammar (lez recursive - > right recursive) 3. or use lookahead (today s lecture) lookahead is a dummy nonterminal that does not contribute to the parse, it is a guard that prevents rule from firing unless appropriate lookahead succeeds if it can find a conjunc7on in the input and marks it (so it can t find it twice)

41 g2.pl Grammar: version 2

42 Grammar: version 2

43 Grammar: version 2 Examples (3), (4) and (5) again from slide 9

44 Grammar: version 2 Examples (6) and (7) from slide 9

45 Seman7cs We want to obtain a seman7c parse for our sentences that we can run (i.e. evaluate) against the Prolog database (i.e. situa7on or possible world). So the seman7c parse should be valid Prolog code (that we can call) We ll need (built- in) member/2 and setof/3 defined in the following 2 slides (a quick review)

46 setof/3 See hjp:// prolog.org/pldoc/doc_for? object=sec7on(2,'4.29',swi('/doc/manual/allsolu7ons.html')) SWI Prolog built- in:

47 Example: setof/3

48 member/2 See hjp:// prolog.org/pldoc/man? predicate=member%2f2

49 Seman7cs ypslides4.pdf Slide 7

50 Seman7cs ypslides4.pdf Slide 8

51 Seman7cs ypslides4.pdf Slide 9

52 Seman7cs ypslides4.pdf Slide 10

53 Seman7cs: Implementa7on Desired implementa7on: The extra argument returns a Prolog query that can be evaluated against the database Note: we are bypassing the (explicit) construc7on of the syntax tree Imagine if the Penn Treebank was labeled using a seman.c representa.on

54 Seman7cs: Implementa7on Let s write the seman7c grammar to handle Jack is hungry first, let s introduce a bit of nota7on (lambda calculus) λ = func7on λx.x+1 denotes a func7on that takes an argument x and computes value x+1 (a period separates the argument from the func.on body) (λx.x+1)(5) means apply 5 to the lambda func7on subs7tute 5 in place of x and evaluate answer = 6

55 Seman7cs: Implementa7on Syntax: setof(x,hungry(x),s), member(jack,s) jack setof(x,hungry(x),s)

56 Seman7cs: Implementa7on Seman7c grammar:

57 Seman7cs: Implementa7on Seman7c grammar:

58 Seman7cs: Implementa7on More examples of computa7on: ypslides4.pdf Slide 10

59 Seman7cs: Implementa7on More examples of computa7on:

60 Seman7cs: Implementa7on More examples of computa7on:

61 Seman7cs ypslides4.pdf Slide 11

62 Seman7cs: Implementa7on Scope of nega7on: wide or narrow narrow wide

63 g3.pl Grammar: version 3

64 Grammar: version 3

65 Evalua7on Check our computer implementa7on on ypslides4.pdf Slide 12

Predicate Logic and Quan0fies

Predicate Logic and Quan0fies Predicate Logic and Quan0fies Sec0ons 1.4, and 1.5 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page: cse.unl.edu/~cse235h All ques7ons: Piazza LaTeX Using the

More information

Intelligent Systems Knowledge Representa6on

Intelligent Systems Knowledge Representa6on Intelligent Systems Knowledge Representa6on SCJ3553 Ar6ficial Intelligence Faculty of Computer Science and Informa6on Systems Universi6 Teknologi Malaysia Outline Introduc6on Seman6c Network Frame Conceptual

More information

Introduction to Prolog

Introduction to Prolog Introduction to Prolog David Woods dwoods@scss.tcd.ie Week 3 - HT Declarative Logic The Prolog programming language is, at its theoretical core, a declarative language. This is unlike more commonly used

More information

Func+on applica+ons (calls, invoca+ons)

Func+on applica+ons (calls, invoca+ons) Func%ons in Racket Racket Functions: most important building block in Racket (and 25) Functions/procedures/methods/subroutines abstract over computations Like Java methods, Python functions have arguments

More information

Rela+onal Algebra. Rela+onal Query Languages. CISC437/637, Lecture #6 Ben Cartere?e

Rela+onal Algebra. Rela+onal Query Languages. CISC437/637, Lecture #6 Ben Cartere?e Rela+onal Algebra CISC437/637, Lecture #6 Ben Cartere?e Copyright Ben Cartere?e 1 Rela+onal Query Languages A query language allows manipula+on and retrieval of data from a database The rela+onal model

More information

LL(k) Parsing. Predictive Parsers. LL(k) Parser Structure. Sample Parse Table. LL(1) Parsing Algorithm. Push RHS in Reverse Order 10/17/2012

LL(k) Parsing. Predictive Parsers. LL(k) Parser Structure. Sample Parse Table. LL(1) Parsing Algorithm. Push RHS in Reverse Order 10/17/2012 Predictive Parsers LL(k) Parsing Can we avoid backtracking? es, if for a given input symbol and given nonterminal, we can choose the alternative appropriately. his is possible if the first terminal of

More information

Proofs about Programs

Proofs about Programs Proofs about Programs Program Verification (Rosen, Sections 5.5) TOPICS Program Correctness Preconditions & Postconditions Program Verification Assignment Statements Conditional Statements Loops Composition

More information

Principles of Programming Languages

Principles of Programming Languages Principles of Programming Languages h"p://www.di.unipi.it/~andrea/dida2ca/plp- 14/ Prof. Andrea Corradini Department of Computer Science, Pisa Lesson 11! Syntax- Directed Transla>on The Structure of the

More information

Related Course Objec6ves

Related Course Objec6ves Syntax 9/18/17 1 Related Course Objec6ves Develop grammars and parsers of programming languages 9/18/17 2 Syntax And Seman6cs Programming language syntax: how programs look, their form and structure Syntax

More information

(Func&onal (Programming (in (Scheme)))) Jianguo Lu

(Func&onal (Programming (in (Scheme)))) Jianguo Lu (Func&onal (Programming (in (Scheme)))) Jianguo Lu 1 Programming paradigms Func&onal No assignment statement No side effect Use recursion Logic OOP AOP 2 What is func&onal programming It is NOT what you

More information

LING/C SC/PSYC 438/538. Lecture 20 Sandiway Fong

LING/C SC/PSYC 438/538. Lecture 20 Sandiway Fong LING/C SC/PSYC 438/538 Lecture 20 Sandiway Fong Today's Topics SWI-Prolog installed? We will start to write grammars today Quick Homework 8 SWI Prolog Cheatsheet At the prompt?- 1. halt. 2. listing. listing(name).

More information

CSc 120. Introduc/on to Computer Programming II. 02: Problem Decomposi1on and Program Development. Adapted from slides by Dr.

CSc 120. Introduc/on to Computer Programming II. 02: Problem Decomposi1on and Program Development. Adapted from slides by Dr. CSc 120 Introduc/on to Computer Programming II Adapted from slides by Dr. Saumya Debray 02: Problem Decomposi1on and Program Development A common student lament "I have this big programming assignment.

More information

CMSC330 Spring 2017 Midterm 2

CMSC330 Spring 2017 Midterm 2 CMSC330 Spring 2017 Midterm 2 Name (PRINT YOUR NAME as it appears on gradescope ): Discussion Time (circle one) 10am 11am 12pm 1pm 2pm 3pm Discussion TA (circle one) Aaron Alex Austin Ayman Daniel Eric

More information

Lecture 5. Logic I. Statement Logic

Lecture 5. Logic I. Statement Logic Ling 726: Mathematical Linguistics, Logic. Statement Logic V. Borschev and B. Partee, September 27, 2 p. Lecture 5. Logic I. Statement Logic. Statement Logic...... Goals..... Syntax of Statement Logic....2.

More information

Student Outcomes. Classwork. Opening Exercise (3 minutes) Example 1 (8 minutes)

Student Outcomes. Classwork. Opening Exercise (3 minutes) Example 1 (8 minutes) Student Outcomes Students model and write equivalent expressions using the distributive property. They move from a factored form to an expanded form of an expression. Classwork Opening Exercise (3 minutes)

More information

CS 44 Exam #2 February 14, 2001

CS 44 Exam #2 February 14, 2001 CS 44 Exam #2 February 14, 2001 Name Time Started: Time Finished: Each question is equally weighted. You may omit two questions, but you must answer #8, and you can only omit one of #6 or #7. Circle the

More information

Document Databases: MongoDB

Document Databases: MongoDB NDBI040: Big Data Management and NoSQL Databases hp://www.ksi.mff.cuni.cz/~svoboda/courses/171-ndbi040/ Lecture 9 Document Databases: MongoDB Marn Svoboda svoboda@ksi.mff.cuni.cz 28. 11. 2017 Charles University

More information

The Vampire Theorem Prover. Krystof Hoder Andrei Voronkov

The Vampire Theorem Prover. Krystof Hoder Andrei Voronkov The Vampire Theorem Prover Krystof Hoder Andrei Voronkov Automated First- Order Automated we do not rely on user interac@on can be used a black- box by other tools Theorem Proving Automated First- Order

More information

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,, CMPSCI 601: Recall From Last Time Lecture 5 Definition: A context-free grammar (CFG) is a 4- tuple, variables = nonterminals, terminals, rules = productions,,, are all finite. 1 ( ) $ Pumping Lemma for

More information

COP4020 Spring 2011 Midterm Exam

COP4020 Spring 2011 Midterm Exam COP4020 Spring 2011 Midterm Exam Name: (Please print Put the answers on these sheets. Use additional sheets when necessary or write on the back. Show how you derived your answer (this is required for full

More information

Vulnerability Analysis (III): Sta8c Analysis

Vulnerability Analysis (III): Sta8c Analysis Computer Security Course. Vulnerability Analysis (III): Sta8c Analysis Slide credit: Vijay D Silva 1 Efficiency of Symbolic Execu8on 2 A Sta8c Analysis Analogy 3 Syntac8c Analysis 4 Seman8cs- Based Analysis

More information

Introduction to Artificial Intelligence CISC-481/681 Program 1: Simple Lisp Programs

Introduction to Artificial Intelligence CISC-481/681 Program 1: Simple Lisp Programs CISC-481/681 Program 1: Simple Lisp Programs 1 Introduction to Artificial Intelligence CISC-481/681 Program 1: Simple Lisp Programs Reading: Handouts Summarizing Common Lisp Functions Paul Graham s ANSI

More information

CS251 Programming Languages Spring 2016, Lyn Turbak Department of Computer Science Wellesley College

CS251 Programming Languages Spring 2016, Lyn Turbak Department of Computer Science Wellesley College Functions in Racket CS251 Programming Languages Spring 2016, Lyn Turbak Department of Computer Science Wellesley College Racket Func+ons Functions: most important building block in Racket (and 251) Functions/procedures/methods/subroutines

More information

Parsing. Zhenjiang Hu. May 31, June 7, June 14, All Right Reserved. National Institute of Informatics

Parsing. Zhenjiang Hu. May 31, June 7, June 14, All Right Reserved. National Institute of Informatics National Institute of Informatics May 31, June 7, June 14, 2010 All Right Reserved. Outline I 1 Parser Type 2 Monad Parser Monad 3 Derived Primitives 4 5 6 Outline Parser Type 1 Parser Type 2 3 4 5 6 What

More information

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m.

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m. CS 6110 S18 Lecture 8 Structural Operational Semantics and IMP Today we introduce a very simple imperative language, IMP, along with two systems of rules for evaluation called small-step and big-step semantics.

More information

Evaluation of Predicate Calculus By Arve Meisingset, retired research scientist from Telenor Research Oslo Norway

Evaluation of Predicate Calculus By Arve Meisingset, retired research scientist from Telenor Research Oslo Norway Evaluation of Predicate Calculus By Arve Meisingset, retired research scientist from Telenor Research 31.05.2017 Oslo Norway Predicate Calculus is a calculus on the truth-values of predicates. This usage

More information

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson Propositional Calculus: Boolean Functions and Expressions CS 270: Mathematical Foundations of Computer Science Jeremy Johnson Propositional Calculus Objective: To provide students with the concepts and

More information

Modules and Representa/on Invariants

Modules and Representa/on Invariants Modules and Representa/on Invariants COS 326 David Walker Princeton University slides copyright 2017 David Walker permission granted to reuse these slides for non-commercial educa/onal purposes LAST TIME

More information

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics 400 lecture note #4 [Ch 6] Set Theory 1. Basic Concepts and Definitions 1) Basics Element: ; A is a set consisting of elements x which is in a/another set S such that P(x) is true. Empty set: notated {

More information

Compila(on (Semester A, 2013/14)

Compila(on (Semester A, 2013/14) Compila(on 0368-3133 (Semester A, 2013/14) Lecture 4: Syntax Analysis (Top- Down Parsing) Modern Compiler Design: Chapter 2.2 Noam Rinetzky Slides credit: Roman Manevich, Mooly Sagiv, Jeff Ullman, Eran

More information

CS 4110 Programming Languages & Logics. Lecture 17 Programming in the λ-calculus

CS 4110 Programming Languages & Logics. Lecture 17 Programming in the λ-calculus CS 4110 Programming Languages & Logics Lecture 17 Programming in the λ-calculus 10 October 2014 Announcements 2 Foster Office Hours 11-12 Enjoy fall break! Review: Church Booleans 3 We can encode TRUE,

More information

Propositional Calculus. Math Foundations of Computer Science

Propositional Calculus. Math Foundations of Computer Science Propositional Calculus Math Foundations of Computer Science Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they can use it to

More information

Announcements. Working in pairs is only allowed for programming assignments and not for homework problems. H3 has been posted

Announcements. Working in pairs is only allowed for programming assignments and not for homework problems. H3 has been posted Announcements Working in pairs is only allowed for programming assignments and not for homework problems H3 has been posted 1 Syntax Directed Transla@on 2 CFGs so Far CFGs for Language Defini&on The CFGs

More information

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou Administrative! Any questions about the syllabus?! Course Material available at www.cs.unic.ac.cy/ioanna! Next time reading assignment [ALSU07]

More information

Overview. A mathema5cal proof technique Proves statements about natural numbers 0,1,2,... (or more generally, induc+vely defined objects) Merge Sort

Overview. A mathema5cal proof technique Proves statements about natural numbers 0,1,2,... (or more generally, induc+vely defined objects) Merge Sort Goals for Today Induc+on Lecture 22 Spring 2011 Be able to state the principle of induc+on Iden+fy its rela+onship to recursion State how it is different from recursion Be able to understand induc+ve proofs

More information

Func%onal Programming in Scheme and Lisp

Func%onal Programming in Scheme and Lisp Func%onal Programming in Scheme and Lisp http://www.lisperati.com/landoflisp/ Overview In a func(onal programming language, func(ons are first class objects You can create them, put them in data structures,

More information

Propositional Logic Formal Syntax and Semantics. Computability and Logic

Propositional Logic Formal Syntax and Semantics. Computability and Logic Propositional Logic Formal Syntax and Semantics Computability and Logic Syntax and Semantics Syntax: The study of how expressions are structured (think: grammar) Semantics: The study of the relationship

More information

CS101 Introduction to Programming Languages and Compilers

CS101 Introduction to Programming Languages and Compilers CS101 Introduction to Programming Languages and Compilers In this handout we ll examine different types of programming languages and take a brief look at compilers. We ll only hit the major highlights

More information

Antisymmetric Relations. Definition A relation R on A is said to be antisymmetric

Antisymmetric Relations. Definition A relation R on A is said to be antisymmetric Antisymmetric Relations Definition A relation R on A is said to be antisymmetric if ( a, b A)(a R b b R a a = b). The picture for this is: Except For Example The relation on R: if a b and b a then a =

More information

Func%onal Programming in Scheme and Lisp

Func%onal Programming in Scheme and Lisp Func%onal Programming in Scheme and Lisp http://www.lisperati.com/landoflisp/ Overview In a func(onal programming language, func(ons are first class objects You can create them, put them in data structures,

More information

Programming Paradigms

Programming Paradigms PP 2017/18 Unit 6 Prolog Basics 1/42 Programming Paradigms Unit 6 Prolog Basics J. Gamper Free University of Bozen-Bolzano Faculty of Computer Science IDSE PP 2017/18 Unit 6 Prolog Basics 2/42 Outline

More information

Op#miza#on Problems, John Gu7ag MIT Department of Electrical Engineering and Computer Science LECTURE 2 1

Op#miza#on Problems, John Gu7ag MIT Department of Electrical Engineering and Computer Science LECTURE 2 1 Op#miza#on Problems, John Gu7ag MIT Department of Electrical Engineering and Computer Science 6.0002 LECTURE 2 1 Relevant Reading for Today s Lecture Chapter 13 6.0002 LECTURE 2 2 The Pros and Cons of

More information

Homework & NLTK. CS 181: Natural Language Processing Lecture 9: Context Free Grammars. Motivation. Formal Def of CFG. Uses of CFG.

Homework & NLTK. CS 181: Natural Language Processing Lecture 9: Context Free Grammars. Motivation. Formal Def of CFG. Uses of CFG. C 181: Natural Language Processing Lecture 9: Context Free Grammars Kim Bruce Pomona College pring 2008 Homework & NLTK Review MLE, Laplace, and Good-Turing in smoothing.py Disclaimer: lide contents borrowed

More information

LING/C SC/PSYC 438/538. Lecture 15 Sandiway Fong

LING/C SC/PSYC 438/538. Lecture 15 Sandiway Fong LING/C SC/PSYC 438/538 Lecture 15 Sandiway Fong Did you install SWI Prolog? SWI Prolog Cheatsheet At the prompt?- Everything typed at the 1. halt. prompt must end in a period. 2. listing. listing(name).

More information

Seminar in Programming Languages

Seminar in Programming Languages Seminar in Programming Languages Shuly Wintner Fall 2010-11 Course web site: http://cs.haifa.ac.il/~shuly/teaching/10/plseminar/ Course Goals Programming Language Concepts A language is a conceptual universe

More information

MIDTERM EXAMINATION - CS130 - Spring 2003

MIDTERM EXAMINATION - CS130 - Spring 2003 MIDTERM EXAMINATION - CS130 - Spring 2003 Your full name: Your UCSD ID number: This exam is closed book and closed notes Total number of points in this exam: 120 + 10 extra credit This exam counts for

More information

Project: Embedded SMC

Project: Embedded SMC Project: Embedded SMC What is Secure Computa1on [SMC] A Compute f(a, B) Without revealing A to Bob and B to Alice B 2 Using a Trusted Third Party A B f(a, B) f(a, B) A Compute f(a, B) Without revealing

More information

CSE431 Translation of Computer Languages

CSE431 Translation of Computer Languages CSE431 Translation of Computer Languages Top Down Parsers Doug Shook Top Down Parsers Two forms: Recursive Descent Table Also known as LL(k) parsers: Read tokens from Left to right Produces a Leftmost

More information

6.001 Notes: Section 4.1

6.001 Notes: Section 4.1 6.001 Notes: Section 4.1 Slide 4.1.1 In this lecture, we are going to take a careful look at the kinds of procedures we can build. We will first go back to look very carefully at the substitution model,

More information

CS 314 Principles of Programming Languages

CS 314 Principles of Programming Languages CS 314 Principles of Programming Languages Lecture 5: Syntax Analysis (Parsing) Zheng (Eddy) Zhang Rutgers University January 31, 2018 Class Information Homework 1 is being graded now. The sample solution

More information

Code Genera*on for Control Flow Constructs

Code Genera*on for Control Flow Constructs Code Genera*on for Control Flow Constructs 1 Roadmap Last *me: Got the basics of MIPS CodeGen for some AST node types This *me: Do the rest of the AST nodes Introduce control flow graphs Scanner Parser

More information

Algorithms Lecture 11. UC Davis, ECS20, Winter Discrete Mathematics for Computer Science

Algorithms Lecture 11. UC Davis, ECS20, Winter Discrete Mathematics for Computer Science UC Davis, ECS20, Winter 2017 Discrete Mathematics for Computer Science Prof. Raissa D Souza (slides adopted from Michael Frank and Haluk Bingöl) Lecture 11 Algorithms 3.1-3.2 Algorithms Member of the House

More information

EDA180: Compiler Construc6on Context- free grammars. Görel Hedin Revised:

EDA180: Compiler Construc6on Context- free grammars. Görel Hedin Revised: EDA180: Compiler Construc6on Context- free grammars Görel Hedin Revised: 2013-01- 28 Compiler phases and program representa6ons source code Lexical analysis (scanning) Intermediate code genera6on tokens

More information

Programming Languages Third Edition

Programming Languages Third Edition Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand

More information

Semantics of programming languages

Semantics of programming languages Semantics of programming languages Informatics 2A: Lecture 28 Mary Cryan School of Informatics University of Edinburgh mcryan@inf.ed.ac.uk 21 November 2018 1 / 18 Two parallel pipelines A large proportion

More information

Extra Credit Question

Extra Credit Question Top-Down Parsing #1 Extra Credit Question Given this grammar G: E E+T E T T T * int T int T (E) Is the string int * (int + int) in L(G)? Give a derivation or prove that it is not. #2 Revenge of Theory

More information

Module 8. Other representation formalisms. Version 2 CSE IIT, Kharagpur

Module 8. Other representation formalisms. Version 2 CSE IIT, Kharagpur Module 8 Other representation formalisms 8.1 Instructional Objective The students should understand the syntax and semantic of semantic networks Students should learn about different constructs and relations

More information

ARTIFICIAL INTELLIGENCE (CS 370D)

ARTIFICIAL INTELLIGENCE (CS 370D) Princess Nora University Faculty of Computer & Information Systems ARTIFICIAL INTELLIGENCE (CS 370D) (CHAPTER-7) LOGICAL AGENTS Outline Agent Case (Wumpus world) Knowledge-Representation Logic in general

More information

Informa/on Retrieval. Text Search. CISC437/637, Lecture #23 Ben CartereAe. Consider a database consis/ng of long textual informa/on fields

Informa/on Retrieval. Text Search. CISC437/637, Lecture #23 Ben CartereAe. Consider a database consis/ng of long textual informa/on fields Informa/on Retrieval CISC437/637, Lecture #23 Ben CartereAe Copyright Ben CartereAe 1 Text Search Consider a database consis/ng of long textual informa/on fields News ar/cles, patents, web pages, books,

More information

CSCI1410 Fall 2018 Assignment 3: Knowledge Representation and Reasoning

CSCI1410 Fall 2018 Assignment 3: Knowledge Representation and Reasoning CSCI1410 Fall 2018 Assignment 3: Knowledge Representation and Reasoning Code Due Monday, October 1 Writeup due Thursday, October 4 1 Introduction Someone has been taking George s Diet Dr. Pepper from his

More information

15. PARAMETRIZED CURVES AND GEOMETRY

15. PARAMETRIZED CURVES AND GEOMETRY 15. PARAMETRIZED CURVES AND GEOMETRY Parametric or parametrized curves are based on introducing a parameter which increases as we imagine travelling along the curve. Any graph can be recast as a parametrized

More information

CS164: Midterm I. Fall 2003

CS164: Midterm I. Fall 2003 CS164: Midterm I Fall 2003 Please read all instructions (including these) carefully. Write your name, login, and circle the time of your section. Read each question carefully and think about what s being

More information

LL(1) predictive parsing

LL(1) predictive parsing LL(1) predictive parsing Informatics 2A: Lecture 11 Mary Cryan School of Informatics University of Edinburgh mcryan@staffmail.ed.ac.uk 10 October 2018 1 / 15 Recap of Lecture 10 A pushdown automaton (PDA)

More information

LING/C SC/PSYC 438/538. Lecture 22 Sandiway Fong

LING/C SC/PSYC 438/538. Lecture 22 Sandiway Fong LING/C SC/PSYC 438/538 Lecture 22 Sandiway Fong Today's Topics Quick Homework 10 Review Three different views on grammars for the language {a n b n c n n>0} 1. CFG (context-free grammar) + extra arguments

More information

CS 242. Fundamentals. Reading: See last slide

CS 242. Fundamentals. Reading: See last slide CS 242 Fundamentals Reading: See last slide Syntax and Semantics of Programs Syntax The symbols used to write a program Semantics The actions that occur when a program is executed Programming language

More information

Wednesday, August 31, Parsers

Wednesday, August 31, Parsers Parsers How do we combine tokens? Combine tokens ( words in a language) to form programs ( sentences in a language) Not all combinations of tokens are correct programs (not all sentences are grammatically

More information

SETS. Sets are of two sorts: finite infinite A system of sets is a set, whose elements are again sets.

SETS. Sets are of two sorts: finite infinite A system of sets is a set, whose elements are again sets. SETS A set is a file of objects which have at least one property in common. The objects of the set are called elements. Sets are notated with capital letters K, Z, N, etc., the elements are a, b, c, d,

More information

Lecture 6,

Lecture 6, Lecture 6, 4.16.2009 Today: Review: Basic Set Operation: Recall the basic set operator,!. From this operator come other set quantifiers and operations:!,!,!,! \ Set difference (sometimes denoted, a minus

More information

From the λ-calculus to Functional Programming Drew McDermott Posted

From the λ-calculus to Functional Programming Drew McDermott Posted From the λ-calculus to Functional Programming Drew McDermott drew.mcdermott@yale.edu 2015-09-28 Posted 2015-10-24 The λ-calculus was intended from its inception as a model of computation. It was used by

More information

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions): CS 70 Discrete Mathematics for CS Spring 2005 Clancy/Wagner Notes 7 This lecture returns to the topic of propositional logic. Whereas in Lecture Notes 1 we studied this topic as a way of understanding

More information

Chapter 2 & 3: Representations & Reasoning Systems (2.2)

Chapter 2 & 3: Representations & Reasoning Systems (2.2) Chapter 2 & 3: A Representation & Reasoning System & Using Definite Knowledge Representations & Reasoning Systems (RRS) (2.2) Simplifying Assumptions of the Initial RRS (2.3) Datalog (2.4) Semantics (2.5)

More information

There are many other applications like constructing the expression tree from the postorder expression. I leave you with an idea as how to do it.

There are many other applications like constructing the expression tree from the postorder expression. I leave you with an idea as how to do it. Programming, Data Structures and Algorithms Prof. Hema Murthy Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 49 Module 09 Other applications: expression tree

More information

Contents. Chapter 1 SPECIFYING SYNTAX 1

Contents. Chapter 1 SPECIFYING SYNTAX 1 Contents Chapter 1 SPECIFYING SYNTAX 1 1.1 GRAMMARS AND BNF 2 Context-Free Grammars 4 Context-Sensitive Grammars 8 Exercises 8 1.2 THE PROGRAMMING LANGUAGE WREN 10 Ambiguity 12 Context Constraints in Wren

More information

Semantics of programming languages

Semantics of programming languages Semantics of programming languages Informatics 2A: Lecture 27 John Longley School of Informatics University of Edinburgh jrl@inf.ed.ac.uk 21 November, 2011 1 / 19 1 2 3 4 2 / 19 Semantics for programming

More information

CS 536 Midterm Exam Spring 2013

CS 536 Midterm Exam Spring 2013 CS 536 Midterm Exam Spring 2013 ID: Exam Instructions: Write your student ID (not your name) in the space provided at the top of each page of the exam. Write all your answers on the exam itself. Feel free

More information

Chapter 3. Set Theory. 3.1 What is a Set?

Chapter 3. Set Theory. 3.1 What is a Set? Chapter 3 Set Theory 3.1 What is a Set? A set is a well-defined collection of objects called elements or members of the set. Here, well-defined means accurately and unambiguously stated or described. Any

More information

Answer Key #1 Phil 414 JL Shaheen Fall 2010

Answer Key #1 Phil 414 JL Shaheen Fall 2010 Answer Key #1 Phil 414 JL Shaheen Fall 2010 1. 1.42(a) B is equivalent to B, and so also to C, where C is a DNF formula equivalent to B. (By Prop 1.5, there is such a C.) Negated DNF meets de Morgan s

More information

Ambiguity. Lecture 8. CS 536 Spring

Ambiguity. Lecture 8. CS 536 Spring Ambiguity Lecture 8 CS 536 Spring 2001 1 Announcement Reading Assignment Context-Free Grammars (Sections 4.1, 4.2) Programming Assignment 2 due Friday! Homework 1 due in a week (Wed Feb 21) not Feb 25!

More information

Computer Programming-I. Developed by: Strawberry

Computer Programming-I. Developed by: Strawberry Computer Programming-I Objec=ve of CP-I The course will enable the students to understand the basic concepts of structured programming. What is programming? Wri=ng a set of instruc=ons that computer use

More information

A Compiler and Run- 1me System for Network Programming Languages

A Compiler and Run- 1me System for Network Programming Languages A Compiler and Run- 1me System for Network Programming Languages Christopher Monsanto, Princeton Nate Foster, Cornell Rob Harrison, West Point David Walker, Princeton 1 SoFware- Defined Networks Controller

More information

EDA180: Compiler Construc6on. Top- down parsing. Görel Hedin Revised: a

EDA180: Compiler Construc6on. Top- down parsing. Görel Hedin Revised: a EDA180: Compiler Construc6on Top- down parsing Görel Hedin Revised: 2013-01- 30a Compiler phases and program representa6ons source code Lexical analysis (scanning) Intermediate code genera6on tokens intermediate

More information

LOGIC AND DISCRETE MATHEMATICS

LOGIC AND DISCRETE MATHEMATICS LOGIC AND DISCRETE MATHEMATICS A Computer Science Perspective WINFRIED KARL GRASSMANN Department of Computer Science University of Saskatchewan JEAN-PAUL TREMBLAY Department of Computer Science University

More information

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1 Introduction to Automata Theory BİL405 - Automata Theory and Formal Languages 1 Automata, Computability and Complexity Automata, Computability and Complexity are linked by the question: What are the fundamental

More information

LISP: LISt Processing

LISP: LISt Processing Introduc)on to Racket, a dialect of LISP: Expressions and Declara)ons LISP: designed by John McCarthy, 1958 published 1960 CS251 Programming Languages Spring 2017, Lyn Turbak Department of Computer Science

More information

Principles of Programming Languages

Principles of Programming Languages Principles of Programming Languages h"p://www.di.unipi.it/~andrea/dida2ca/plp- 14/ Prof. Andrea Corradini Department of Computer Science, Pisa Lesson 10! Con:nua:on of the course Syntax- Directed Transla:on

More information

BBM 101 Introduc/on to Programming I Fall 2014, Lecture 5. Aykut Erdem, Erkut Erdem, Fuat Akal

BBM 101 Introduc/on to Programming I Fall 2014, Lecture 5. Aykut Erdem, Erkut Erdem, Fuat Akal BBM 101 Introduc/on to Programming I Fall 2014, Lecture 5 Aykut Erdem, Erkut Erdem, Fuat Akal 1 Today Itera/on Control Loop Statements for, while, do- while structures break and con/nue Some simple numerical

More information

R13 SET Discuss how producer-consumer problem and Dining philosopher s problem are solved using concurrency in ADA.

R13 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 information

ques4ons? Midterm Projects, etc. Path- Based Sta4c Analysis Sta4c analysis we know Example 11/20/12

ques4ons? Midterm Projects, etc. Path- Based Sta4c Analysis Sta4c analysis we know Example 11/20/12 Midterm Grades and solu4ons are (and have been) on Moodle The midterm was hard[er than I thought] grades will be scaled I gave everyone a 10 bonus point (already included in your total) max: 98 mean: 71

More information

Racket Values. cons Glues Two Values into a Pair. The Pros of cons: Pairs and Lists in Racket. Box-and-pointer diagrams for cons trees

Racket Values. cons Glues Two Values into a Pair. The Pros of cons: Pairs and Lists in Racket. Box-and-pointer diagrams for cons trees The Pros of cons: in Racket CS251 Programming Languages Fall 2018, Lyn Turbak Department of Computer Science Wellesley College booleans: #t, #f numbers: integers: 42, 0, -273 ra3onals: 2/3, -251/17 floa3ng

More information

CS: Formal Methods in Software Engineering

CS: Formal Methods in Software Engineering CS:5810 Formal Methods in So7ware Engineering Sets and Rela

More information

1. 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. 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 information

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS 1 THE FORMALIZATION OF MATHEMATICS by Harvey M. Friedman Ohio State University Department of Mathematics friedman@math.ohio-state.edu www.math.ohio-state.edu/~friedman/ May 21, 1997 Can mathematics be

More information

Context-Free Grammars

Context-Free Grammars Context-Free Grammars Describing Languages We've seen two models for the regular languages: Finite automata accept precisely the strings in the language. Regular expressions describe precisely the strings

More information

LL(1) predictive parsing

LL(1) predictive parsing LL(1) predictive parsing Informatics 2A: Lecture 11 John Longley School of Informatics University of Edinburgh jrl@staffmail.ed.ac.uk 13 October, 2011 1 / 12 1 LL(1) grammars and parse tables 2 3 2 / 12

More information

Program Verification (Rosen, Sections 5.5)

Program Verification (Rosen, Sections 5.5) Program Verification (Rosen, Sections 5.5) TOPICS Program Correctness Preconditions & Postconditions Program Verification Assignments Composition Conditionals Loops Proofs about Programs Why study logic?

More information

Midterm I - Solution CS164, Spring 2014

Midterm I - Solution CS164, Spring 2014 164sp14 Midterm 1 - Solution Midterm I - Solution CS164, Spring 2014 March 3, 2014 Please read all instructions (including these) carefully. This is a closed-book exam. You are allowed a one-page handwritten

More information

Hoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré

Hoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré Hoare Logic COMP2600 Formal Methods for Software Engineering Rajeev Goré Australian National University Semester 2, 2016 (Slides courtesy of Ranald Clouston) COMP 2600 Hoare Logic 1 Australian Capital

More information

Artificial Intelligence Lecture 1

Artificial Intelligence Lecture 1 Artificial Intelligence Lecture 1 istrative Matters Webpage: www.aass.oru.se/~mbl/ai Examiner: Mathias Broxvall Assistant: Lia Susana d.c. Silva Lopez Schedule 20 hours/week on this course. 4 hours lectures,

More information

This book is licensed under a Creative Commons Attribution 3.0 License

This book is licensed under a Creative Commons Attribution 3.0 License 6. Syntax Learning objectives: syntax and semantics syntax diagrams and EBNF describe context-free grammars terminal and nonterminal symbols productions definition of EBNF by itself parse tree grammars

More information

CSE 120. Computer Science Principles

CSE 120. Computer Science Principles Adam Blank Lecture 17 Winter 2017 CSE 120 Computer Science Principles CSE 120: Computer Science Principles Proofs & Computation e w h e q 0 q 1 q 2 q 3 h,e w,e w,h w,h q garbage w,h,e CSE = Abstraction

More information