Streams and Monads - Prolog




CS152

Chris Pollett

Nov 22, 2021

Outline

Introduction

Streams, Monads, Haskell

Random Number Generation with and Without Monads

A Logic-based Language Paradigm...

Logic and Logic Programs

More First-Order Logic

Rules of Inference

Horn Clauses

Prolog

Resolution, and Unification

Beginning in Prolog

Example Program

Here is a short Prolog program:

/* Jane's connections */
/* Comments in Prolog are just like in C or C++ */
bird(ostrich).
bird(penguin).
bird(seagull).
bird(eagle).
flies(W) :- bird(W),
            W \= ostrich,
            W \= penguin.
loves(jane,X) :- flies(X).
loves(penguin, jane).
loves(aadvark, jane).

Basic Syntax - Facts

Basic Syntax - Rules

Querying a Program

Queries With a Variable