{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# **Exercise 01. Normal logic programs.**\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### **1**" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "b(1) b(2) a(1) a(2)\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X).\n", "b(1). b(2)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X).\n", "b(1). b(2). b(3)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### **2**" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "c(1) b(1) b(2) a(1)\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X), c(X).\n", "b(1). b(2). \n", "c(1). " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X), c(X).\n", "b(1). b(2). \n", "c(1). c(2). c(3)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### **3**" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "c(10) b(1,5) b(2,10) a(2)\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X,Y), c(Y).\n", "b(1,5). b(2,10).\n", "c(10)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X,Y), c(Y).\n", "b(1,5). b(2,10).\n", "c(10). c(5)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### **4**" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "b(1) b(2) a(2)\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X), Y=X+1, not b(Y).\n", "b(1). b(2)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X), Y=X+1, not b(Y).\n", "b(1). b(3)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### **5**" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "b(1) b(2) c(1) a(2)\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X), not c(X).\n", "b(1). b(2). c(1)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X), not c(X).\n", "b(1). b(2). c(1).\n", "b(3). c(2)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### **6**" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "b(1,5) b(2,10) c(10) a(1)\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X,Y), not c(Y).\n", "b(1,5). b(2,10). c(10)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X,Y), not c(Y).\n", "b(1,5). b(2,10)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### **7**" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "c(2) b(1,2) b(2,3) a(1)\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X,Y), c(Y).\n", "b(1,2). b(2,3). \n", "c(2)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X,Y), c(Y).\n", "b(1,2). b(2,3). \n", "c(2). c(3)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### **8**" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "b(1) b(2) b(3) a(3)\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X), Y = X+1, not b(Y).\n", "b(1). b(2). b(3)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(X) :- b(X), Y = X+1, not b(Y).\n", "b(1). b(5)." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.3" } }, "nbformat": 4, "nbformat_minor": 2 }