Course materials for Sem 3 (Fall 2013): Computational Formal Semantics with Haskell
Wed 27 November 2013 by Adrian BrasoveanuSemantics 3 (fall 2013; upper div. undergraduate course, UCSC Linguistics) was dedicated to introducing computational formal semantics with Haskell. The course materials (syllabus, lectures notes, hw assignments, solutions etc.) are provided below. The ghci commands are numbered in the same way in the pdf and the corresponding hs files for ease of reference.
The syllabus:
Intro to Haskell lecture notes:
- intro-to-haskell1.pdf, intro-to-haskell1.hs: the basics, e.g., arithmetic, boolean operators, functions, “if” statements, lists, tuples etc.
- intro-to-haskell2.pdf, intro-to-haskell2.hs: types and typeclasses
- intro-to-haskell3.pdf, intro-to-haskell3.hs: the syntax for function definitions, e.g., pattern matching, as-patterns, guards, “where” bindings, “let” bindings, “case” expressions
- intro-to-haskell4.pdf, intro-to-haskell4.hs: recursion and thinking recursively
- intro-to-haskell5.pdf, intro-to-haskell5.hs: curried functions, higher order functions and the structure of complex computations (be they Haskell programs or natural language meanings)
- intro-to-haskell6.pdf, intro-to-haskell6.hs: maps and filters, lambdas, function application, function composition
- intro-to-haskell7.pdf, intro-to-haskell7.hs: left and right folds, strict and lazy folds, scans
- intro-to-haskell8.pdf, intro-to-haskell8.hs: modules (importing them, importing functions from modules, importing modules without certain functions, qualified imports) and intro to the Data.List module
- intro-to-haskell9.pdf, intro-to-haskell9.hs: intro to the Data.Char and Data.Set modules, making our own modules, hierarchical modules
- intro-to-haskell10.pdf, intro-to-haskell10.hs: intro to algebraic data types, record syntax, type constructors (a.k.a. parametrized types)
- intro-to-haskell11.pdf, intro-to-haskell11.hs: deriving instances of typeclasses, type synonyms, recursive data types
Intro to computational formal semantics lecture notes:
- comp_formal_sem1.pdf, comp_formal_sem1.hs, PropLsyn.hs, PropLsem.hs: syntax of propositional logic, semantics of propositional logic, tautologies, satisfiability and contradictions, checking for entailment between two formulas, Context Set update
- comp_formal_sem2.pdf, comp_formal_sem2.hs, PredLsyn.hs, Model.hs, PredLsem.hs: syntax of first-order predicate logic (the definition of terms, atomic formulas, more on variables, identity, propositional operators, complex terms, quantifiers), semantics of first-order predicate logic
- comp_formal_sem3.pdf, comp_formal_sem3.hs, EF1syn.hs, EF1sem.hs, PredLsyn.hs, Model.hs, PredLsem.hs: syntax of our English fragment, semantics part 1: English-to-FOL translation, semantics part 2: evaluation in a model (model checking)
- comp_formal_sem4.pdf, comp_formal_sem4.hs, EF1syn.hs, EF2sem.hs, Model.hs: syntax of our English fragment, (direct) semantics of our English fragment
- comp_formal_sem5.pdf, comp_formal_sem5.hs, BasicDef.hs, Palindromes.hs, ParserCombinatorsMini.hs: basic definitions for parsing, recognition, generation and parsing for a simple palindrome grammar, parser combinators, simple application of parser combinators: the palindrome grammar, another example: parsing based on a simple Eng. grammar
- comp_formal_sem6.pdf, comp_formal_sem6.hs, BasicDef.hs, Lexicon.hs, ParserCombinators.hs, ParserNoMvt.hs, Tree2Tex.hs: a more realistic lexicon (features, syntactic categories, the lexicon, combining syntactic categories, string preprocessing, the lexer), parsing a more realistic English fragment without mvt (parser for leaf nodes, parser for sentences, NP, DET, CN and PP parsers, VP parser, bringing it all together)
Hw assignments and example solutions: