CPSC 312 - Functional and Logic Programming
January-April 2024
Here are the slides, assignments practice midterms etc. The slides will be
available after class. Keep watching this space. It is your
responsibility to keep up-to-date.
- Jan 8 - Introduction to functional
programming and Haskell. First.hs Textbook: Sections 1.1,
1.2, 1.4, 1.5, 1.7, 1.8, 1.9, 1.10, 1.11, 2.1-2.7. Slides. terminal session.
- Jan 10 - Basic types and classes. Types.hs.
Textbook sections: 3.3, 3.4, 3.6,
5.1, 5.2, 6.1, 6.2. Slides. terminal session
- Jan 12 - Lists Lists.hs Textbook sections: 3.3, 3.4, 3.6,
5.1, 5.2, 6.1, 6.2. Slides. terminal session
- Jan 15 - Lists (cont) and Types (cont). Lists2.hs. Textbook: Chapter 4,
Sections 5.1, 5.2, 5.5. slides. Clicker answers: 7B, 8B, 9B,
10D, 11D, 12C, 13D, 14D, 15A, 16C. terminal session
- Jan 16 - Assignment 1 due. Submit
on Canvas. Solution.
- Jan 17 - Lists (cont), lambda, folding Lists3.hs Textbook: Sections 5.6,
11.2, 10.2, 10.3. slides. Clicker answers: 7D, 8As. terminal session
- Jan 19 - Lists and folding (cont) Lists4.hs Textbook: Sections 5.6,
11.2, 10.2, 10.3. slides. Clicker answers: 3C, 4D, 5A,
6E. terminal session
- Jan 22 - Lazy Evaluation. Textbook: Sections 17.1,
17.2, 17.3, 17.6. Lazy.hs. slides. Clicker answers: 3B, 4C, 5A,
6B, 7C. terminal session
- Jan 23 - Assignment 2 due. Submit
on Canvas. Solution.
- Jan 24 - User-defined types and data.
Textbook: Sections 4.3, 5.3, 14.1-14.3. slides. Clicker answers: 10A, 11D,
12A, 14B. Dataeg.hs, BSTree.hs. terminal session
- Jan 26 - Data BSTree2.hs.
slides. Clicker answers: 4E.
terminal session
- Jan 29 - Midterm 1. A previous midterm: mid1_2019.pdf
and a solution: Mid1_2019_sol.hs
- Jan 31. Input-output. IOAdder.hs, IOAdder2.hs. TestDo.hs. slides. Clicker answers: 7D, 8A, 9B,
10B, 11D, 12B, 13B.
terminal session
Textbook sections
8.2, 8.3, 8.4, 8.5 13.1, 13.2, 13.3, 18.1, 18.2. Much of this class
is based on the
"explaining IO" paper on the Readings tab.
- Feb 2. Classes and types revisited.
slides.
terminal session. Textbook sections 5.3
14.1-14.3.
- Feb 5. Games.
MagicSum.hs,
Play.hs, Minimax.hs. slides.
terminal session.
- Feb 6 - Assignment 3 due. Solutions: Q1
TwentyQssol.hs. Q2
PQsol.hs. Q3
ReadCSV.hs,
test.csv, Features.hs
- Feb 7. Games, play, minimax
CountGame.hs. slides.
terminal session.
- Feb 7. games and dictionaries.
TreeDict.hs, Minimax_mem.hs.
- Feb 9. Games, minimax
TreeDict.hs. slides.
terminal session.
- Feb 12. games and dictionaries.
Minimax_mem.hs. slides.
terminal session.
- Feb 12 - Project 1 proposal
due on the wiki.
- Feb 14. Games and Classes. slides.
terminal session. Clicker answers:
6C, 9C,
Hash.hs,
HashTreeDict.hs, Minimax_mem_hash.hs.
MagicSum_ord_hash.hs, MagicSum_hash.hs
- Feb 16. Games and functional programming in other languages.
slides.
Games2.hs, pythonDemo.py.
- Feb 26. Midterm #2. Same format as Midterm #1 (can do in the
previous 24 hours). Practice
questions and a solution: mid2prsol.hs. Previous exams: 2019: mid2_2019.pdf solution: mid2_sol_2019.hs. Last year:
mid2_2023.pdf solution:
mid2_2023_sol.pdf.
- Feb 28. Introduction to logic
programming and Prolog. See AIFCA
sections 5.1, 5.3. first.pl,
family.pl,
elect_prop.pl. slides.
terminal session.
- March 1 - proof procedures. slides. Clicker answers: 9B, 10C,
18C, 22A,
terminal session. Readings AIFCA
section 5.3.1
- March 4 - top-down proof procedures and the box model. slides. Clicker answers: 5C, 7B, 8D,
9C,
terminal session.
- March 6. Relations and Datalog. backeg.pl. elect_reln.pl. Readings: AIFCA
Sections 15.1-15.4. slides. Clicker answers: 3D, 6E, 8B.
terminal session
- March 7 - Assignment 4 due. solution
- March 8. function symbols. Slides, Clicker answers: 6B, 7A, 8B,
13D, 14D, 15C, dates.pl,
myis.pl,
mylist.pl.
lists.pl. terminal session.
- March 11 - Lists and Trees bstree.pl. bstreec.pl.
slides. Clicker answers: 8B, 9B, 10E,
terminal session
- March 13 - Natural Language Interfaces. Slides, Clicker answers: 5D, 16C, 17A, terminal session
geography_CFG.pl,
geography_DB.pl,
geography_QA.pl,
geography_QA_query.pl.
- March 14 - Assignment 5 due. Solutions: as5sol.pl
plumbing_reln.pl.
- March 15 - computer algebra and natural language. algebra.pl. Slides, terminal session
- Mar 18 - Midterm #3. It is online and can be done
anytime in 24 hours before the class time. It will only cover logic programming and
Prolog. It will
assume what we have covered in class and
assignments on logic programming. Some previous
exams: 2019, solution:
mid3sola.pl. From 2018: 2018
(2018
solution). 2017 (not q3) (2017
solution). Also try AIFCA Ch5
Exercises 5.1, - 5.4, AIFCA
Ch15 Exercises 15.1, 15.2, 15.11, 15.12 (note that some of these
are more like assignments than exam questions). Also most of the .pl files have test
cases at the end that you should understand.
- March 20. Slides, Clicker answers: 10D, 15B,
16A. terminal session
- March 22. Knowledge graphs. See AIFCA.
sem_web.pl. Slides,
terminal session.
- March 25 - knowledge graphs (cont)
Slides, clicker answers: 6B, 7D, 11D.
- March 25 - Project 2 proposal
due on the wiki.
- March 27 - ontologies
Slides, clicker answers: 14A, 15A,
16D.
- April 3 - Data in science, negation-as-failure.
Slides. terminal session.
elect_naf.pl,
naf.pl
beach.pl
- April 5 - Negation-as-failure. Extra-logical predicates.
Slides. terminal session. algebra_cut.pl
- April 8 - unification.
Slides. Clicker answers: 6B, 7D,
- April 8 - Project 2
due on the wiki, followed by
demos.
- April 10 - proofs.
Slides. Clicker answers: 10E, 11C,
12B.
See AIFCA
Section 15.5.
- April 12 - Haskell in Prolog, Prolog in Haskell, Prolog in
Prolog. funlog.pl,
meta.pl,
bprove.pl,
elect_a.pl,
trace2.pl,
elect_b.pl.
Slides,
terminal session.
- 2024-04-19
7:00 PM in
SWNG 221: Final Exam. You may bring in one sheet of
letter-sized paper with
anything you like on it. practice questions with solutions:
finalprsol.pl,
finalprsol.hs. And the exam from
2016 (but note that they did Prolog first):
final2016.pdf and solutions:
final2016.pl,
final2016.hs. And the second Prolog
midterm from 2017 when they did Prolog first: mid2_2017.pdf, and a solution mid2_2017_soll.txt.
Last page.
David Poole