100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Notas de lectura

Problem Solving and Search samenvatting

Puntuación
3.0
(1)
Vendido
2
Páginas
62
Subido en
10-09-2021
Escrito en
2020/2021

Dit document is een samenvatting van alle hoorcolleges die gegeven worden tijdens het vak Problem Solving and Search aan de UvA. Met deze samenvatting heb ik dit vak afgerond met een 8.

Institución
Grado










Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Libro relacionado

Escuela, estudio y materia

Institución
Estudio
Grado

Información del documento

Subido en
10 de septiembre de 2021
Archivo actualizado en
10 de septiembre de 2021
Número de páginas
62
Escrito en
2020/2021
Tipo
Notas de lectura
Profesor(es)
Bahareh afshari
Contiene
1 t/m 11

Temas

Vista previa del contenido

PROBLEM SOLVING AND SEARCH

Lecture 1

Imperative (programs as recipes)
function sum(list : List) : Nat
i = 0
while (i < list.lenght)
sum = sum + list[i]
i++
return sum


Functional (programs as functions e.g. Haskell)
sum [] = 0
sum (x : xs) = x + sum xs


Declarative (programs as ‘problems’ e.g. Prolog)
sum([], 0).
sum([Head | Tail, Result):-
sum(Tail, S),
Result is Head + S.


● Imperative programming: specify how to compute
● Declarative programming: specify what to compute


The origins of Prolog (PROgrammation en LOGique):
● Invented in the 1970s by Alain Colmerauer and a team of researchers in France – using
a natural language like French to reason and communicate directly with a computer
● Originally intended for natural language processing – clear and concise programs
● Prolog and Lisp are the two main AI programming languages today
● There are different interpreters, we will use SWI-Prolog

bigger(elephant, horse).
bigger(horse, donkey).
bigger(donkey, dog).
bigger(donkey, monkey).

,?- bigger(donkey, dog).
true



?- bigger(monkey, elephant).
false

?- bigger(elephant, monkey).
false

bigger(X, Y) :- bigger(X, Z), bigger(Z, Y).
?- bigger(elephant, monkey).
true

?- bigger(X, donkey).
X = horse ;
X = elephant ;
false

?- bigger(donkey, X), bigger (X, monkey).
X = dog

?- bigger(donkey, X), bigger(Y, monkey).
X = dog


Prolog terms are either:
● Variables
● Atomic terms: numbers and atoms
● Compound terms


Variables start with a capital letter or the underscore: X, Elephant, _G177, MyVariable, _
Anonymous variable: _
Atoms start with a lowercase letter or are enclosed in single quotes: elephant, xYZ, a_123,
‘Hello?’
Compound terms consist of a functor (an atom) and a number of arguments (terms) enclosed in
brackets: bigger(horse, X)
f(g(Alpha, _), 7)
‘female’(dog)


Ground terms are terms without variables
Facts are compound terms (or atoms), followed by a full stop

, Facts are used to define something as being unconditionally true
bigger(elephant, horse).
parent(john, mary).


Rules consist of a head and a body separated by ‘:-’
The head of a rule (a compound term or an atom) is true if all goals in the body (each a
compound term or an atom) can be proved to be true
grandfather(X, Y) :-
father(X, Z),
parent(Z, Y).


Facts and rules are used to define predicates
Facts and rules are also called clauses
A program is a list of clauses
● Compose your programs in a text editor



A query consists of one or several compound terms (or atoms), separated by commas and
followed by a full stop
● Type your queries in the Prolog prompt and expect a response
● ?- bigger(horse, X), bigger(X, dog).
X = donkey
true


Built-in predicates:
● Compiling a program file:
?- consult(‘big-animals.pl’).
true
● Writing something (a term) on the screen:
?- write (‘Hello!’), nl, write(‘Goodbye!’)
Hello!
Goodbye!
true


Two terms match if they are identical or can be made identical by substituting their variables
with suitable ground terms
We can explicitly ask Prolog whether two given terms match by using the built-in
equality-predicate:
?- born(mary, yorkshire) = born(mary, X).
X = yorkshire
true
$10.88
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor
Seller avatar
camilleniessink1
3.0
(1)

Reseñas de compradores verificados

Se muestran los comentarios
2 año hace

3.0

1 reseñas

5
0
4
0
3
1
2
0
1
0
Reseñas confiables sobre Stuvia

Todas las reseñas las realizan usuarios reales de Stuvia después de compras verificadas.

Conoce al vendedor

Seller avatar
camilleniessink1 Universiteit van Amsterdam
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
3
Miembro desde
5 año
Número de seguidores
3
Documentos
0
Última venta
2 año hace

3.0

1 reseñas

5
0
4
0
3
1
2
0
1
0

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes