{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# **Exercise 05. Conditional literals.**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### **1**" ] }, { "cell_type": "code", "execution_count": 57, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "c\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "a(1..2).\n", "b(1..2).\n", "c :- a(X) : b(X).\n", "#show c/0." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(1..3).\n", "b(1..3).\n", "c :- a(X) : b(X).\n", "#show c/0." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### **2**" ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "a(1).\n", "b(1..2).\n", "c :- a(X) : b(X).\n", "#show c/0." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(1..2).\n", "b(1..3).\n", "c :- a(X) : b(X).\n", "#show c/0." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### **3**" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "SATISFIABLE\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "-:3:6-10: info: atom does not occur in any rule head:\n", " a(X)\n", "\n" ] } ], "source": [ "%%clingo -V0 0\n", "\n", "b(1).\n", "c :- a(X) : b(X).\n", "#show c/0." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "\n", "b(1..2).\n", "c :- a(X) : b(X).\n", "#show c/0." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### **4**" ] }, { "cell_type": "code", "execution_count": 60, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "d\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "a(1..2).\n", "b(1..2).\n", "c(1..2).\n", "d :- a(X) : b(X), c(X).\n", "#show d/0." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(1..2).\n", "b(1..2).\n", "c(1..3).\n", "d :- a(X) : b(X), c(X).\n", "#show d/0." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This time we have another exercise for the same example." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(1..2).\n", "b(1..3).\n", "c(1..3).\n", "d :- a(X) : b(X), c(X).\n", "#show d/0." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### **5**" ] }, { "cell_type": "code", "execution_count": 61, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "d(1) d(2)\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "a(1..2).\n", "b(1..2).\n", "c(1..2).\n", "d(X) :- a(X) : b(X); c(X).\n", "#show d/1." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(1..2).\n", "b(1..2).\n", "c(1..3).\n", "d(X) :- a(X) : b(X); c(X).\n", "#show d/1." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And another exercise for the same example." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(1..2).\n", "b(1..3).\n", "c(1..3).\n", "d(X) :- a(X) : b(X); c(X).\n", "#show d/1." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### **6**" ] }, { "cell_type": "code", "execution_count": 62, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "d(1) d(2)\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "a(1..2).\n", "b(1..2,1..2).\n", "c(1..2).\n", "d(X) :- a(Y) : b(X,Y); c(X).\n", "#show d/1." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(1..2).\n", "b(1..2,1..2). b(2,3).\n", "c(1..2).\n", "d(X) :- a(Y) : b(X,Y); c(X).\n", "#show d/1." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And again another exercise for the same example." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0\n", "a(1..2).\n", "b(1..2,1..2). b(2,3).\n", "c(1..2). c(3).\n", "d(X) :- a(Y) : b(X,Y); c(X).\n", "#show d/1." ] } ], "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 }