程序代写代做代考 database AI algorithm SQL Excel prolog Artificial Intelligence: Logic Programming I

Artificial Intelligence: Logic Programming I
Oliver Ray

1. Outline of the Unit

Unit Focus
• AI involves replicating aspects of intelligent behaviour from specific tasks (weak AI) to general problem solving (strong AI)
• We focus on agent-based, knowledge-driven, white-box forms of AI. Good Old-Fashioned AI (GOFAI)?
• We don’t study trendy sub-symbolic, data-driven, black-box types of AI like deep nets (available on other courses…)
• We believe data-driven and knowledge-driven AI will fuse to combine logical explainability with statistical robustness

Unit Structure
1
2 3
Week
Topic
Lecturer
Lab
1
Logic Programming I
Oliver Ray
Intro to Prolog
2
Logic Programming II
Oliver Ray
Intro to GridWorld
3
Logic Programming III
Oliver Ray
Problem Solving + Heuristic Search
4
Genetic Algorithms I
Seth Bullock
Simple Genetic Algorithm
5
Genetic Algorithms II
Seth Bullock
Coevolutionary Genetic Algorithm
6
Multi-Agent Systems I
Nirav Ajmeri
Agent-Based Simulation Model
7
Multi-Agent Systems II
Nirav Ajmeri
Multi-Agent System
8
Coursework (Exam)
9
Coursework (Exam)
10
Coursework (Exam)
11
Recap
All
Xmas
12
Revision
All
Jan
(Bookwork) Exam
COMS30014
COMS30012 (20CP)
COMS30013 (10CP)

In teaching weeks 1-7 there will be
• a set of pre-recorded online lecture materials to watch
• a live, timetabled Q&A with that week’s lecturer
• a live, timetabled lab session in which you get supported practical experience related to the topic being taught
• a monitored unit forum for you to ask questions
All will be on-line and all are very important for all students (irrespective of coursework or exam stream)
Blended Learning

Lectures
• Lectures will be delivered as pre-recorded videos uploaded into Blackboard by 2pm on Mondays
• Main weekly lecture(s) + an “AI Classic”
• You are free to view lectures whenever you like
• But, why not consider arranging “watch parties” • More likely to process material with your brain
• Ensure you stay in touch with friends
• Stay up to date to get the most out of live activities

Q&As
• Will probably work best if questions are posted on the forum in advance – so the lecturer (or maybe TAs and even students) can answer as many as possible
• Hopefully, as we get the hang of how that session runs, we can move towards more live interaction
• Students are encouraged to answer questions – if you (think you) know (part of) the answer
• Q&As will be live on MS Teams on Thursdays 6-7pm

Labs
• Labs will happen in Teams between 9-11 on Wednesdays
• Students should self-enrol in one of 8 lab bubble groups
(each of 13/14 students) by 5pm, on Tuesday 6th Oct
• We’ll randomly allocate any students that don’t self-enrol
(swapping will be permitted, if there are genuine reasons)
• Labs comprises 90 mins of group-work with each bubble
supported by a dedicated TA for the first and last 30 mins
• Labs are not assessed but are vital for both EXM & CWK)

Bubbles
• Bubbles will be interleaved – so your precise lab slot will alternate weekly between 09:00-10:30 and 9:30-11:00
Time
SLOT-A
for bubbles 1,3,5,7 in weeks 1,3,5,7
for bubbles 2,4,6,8 in weeks 2,4,6
SLOT-B
for bubbles 2,4,6,8 in weeks 1,3,5,7 for bubbles 1,3,5,7 in weeks 2,4,6
09:00-09:25
TA-supported Group work (get-going)
###############################
9:30-10:55
Staff-monitored Group Work (crack-on)
TA-supported Group work (get-going)
10:00-10:25
TA-supported Group work (wrap-up)
Staff-monitored Group Work (crack- on)
10:30-10:55
###############################
TA-supported Group work (wrap-up)

Unit Staff
This unit is taught by three academics:
• Oliver Ray (lecturer and director)
• Seth Bullock (lecturer)
• Nirav Ajmeri (lecturer, just joined North Carolina State Uni) …and a team of Teaching Assistants:
• Ed Barker (Head TA), Ruairi Fox, Orion Luo, Holly Millea Please contact any of us through the Unit Discussion Forum.

Grid-World
• Artificial world where agents must efficiently navigate a grid and use charging stations to visit oracles and solve various tasks
• Focus of Prolog labs (weeks 2&3) will help with understanding for exam and will be directly used in the coursework, where it will tie- in with multi-agent systems

2. Intro to Prolog

1950s
Functional: evaluate function definitions on given arguments
1960s
1970s
1980s
1990s 2000s
Programming Languages (simplified)
Procedural: execute instruction sequences from a given state
Logical: search within relational constraints for answers to queries
Sequel
SQL
Turbo
Prolog Sicstus ANSI
Prolog SQL ISO SQL
Prolog
Edinburgh Prolog
IC- Prolog
λ Prolog
Parlog
SWI
Prolog
Constraint programming
probabalistic Answer Set relational models Programming
Description Logics
SQL-2003
ISO Prolog
Graphical Databases
XQuery

PROgrammation en LOGique
Prolog is the most commonly logic programming language
• Simple syntax, no typing, homoiconic, queries may return any number of answers: none, one or many
• It focuses effort on problem definition, is great for proto- typing and has powerful language processing abilities
• It is also the basis of a many powerful extensions used in real-world tasks: e.g. Constraint Logic Prog. (CLP), Inductive Logic Prog. (ILP), Answer Set Prog. (ASP), …

SWI-Prolog
SWI-Prolog is a popular, well-supported, free Prolog system • SWIPL Engine + SWISH IDE
• Easy to install on Linux, Mac and Windows
• Hosted as a sand-boxed web-service
• Pre-installed on CS lab machines
• User-friendly with lots of examples
• https://www.swi-prolog.org/ https://www.swi-prolog.org/pldoc/man?section=implhistory
All these methods will be suitable for the week 1 lab, but weeks 2&3 will be best done with local installation

load
SWI for Sharing (SWISH)
Menu Bar
create
search
Knowledge Base
Answers
Queries
Can run locally or on hosted server at https://swish.swi-prolog.org/

Example Program

Example Program
in-line comments:
% …
facts: predicate(terms)
rules:
head :- body
block comments
/* … */
(example) queries
VaRS, cOnsts

Example Program
(; or enter)
(ctrl-enter)

Example Program

Example Program
?

Overview of Prolog Term Syntax (simplified)
simple constant
complex
var
atomic
compound
variable
X.. _
start uppercase underscore (anonymous)
_..
start underscore (don’t-care)
number
-5 0 15
e.g. integers
string
“..”
double- quoted
empty list
[ ]
square brackets
atom
a.. ‘..’
(.,.)
Tuple (‘,’/2)
[.,.]
non-empty list (‘[|]’/2)
f(.,.)
functor
start lowercase or single-quoted
https://www.swi-prolog.org/pldoc/man?section=standardorder
comparison operators for (ground) numbers: < , > , =< , >= , == , \==
comparison operators for (arbitrary) terms: @< , @> , @=< , @>= , == , \== (take care if comparing variables!)

Actions!
• Have a look around the SWI Prolog website and try to download, install, and run the SWIPL engine and SWISH IDE locally on your computer (highly recommended!)
• This should be relatively easy, but in case of issues, for now try working through this web-hosted SWISH server or try and remotely run SWIPL on the CS lab machines.
• Work through chapters 1 and 3 of the excellent free on-line tutorial Learn Prolog Now! which will take you through the basics of Prolog very simply and effectively

Thank you