{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "yWGTIPMXotxs" }, "source": [ "# **Exercise 03. Normal logic programs.**\n" ] }, { "cell_type": "markdown", "metadata": { "id": "Ho57hy3em9Yi" }, "source": [ "#### **1**" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "j_3LyCQFnE7K", "outputId": "8c702cbe-9240-41dd-a812-6349904b5255" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a\n", "SATISFIABLE\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "-:1:10-11: info: atom does not occur in any rule head:\n", " b\n", "\n" ] } ], "source": [ "%%clingo -V0 0 \n", "a :- not b." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "tekDyDF_nJLf" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "a :- not b, c.\n", "c." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **2**" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "rVsiBrQSofDj", "outputId": "0790a4c1-5359-4669-d912-24d790f74c61" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "b\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "a :- not b.\n", "b." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "a :- not b.\n", "b :- c.\n", "c." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **3**" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "rVsiBrQSofDj", "outputId": "0790a4c1-5359-4669-d912-24d790f74c61" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "b\n", "SATISFIABLE\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "-:2:10-11: info: atom does not occur in any rule head:\n", " c\n", "\n" ] } ], "source": [ "%%clingo -V0 0 \n", "a :- not b.\n", "b :- not c." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "a :- not b, d.\n", "b :- not c, d.\n", "d." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **4**" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "rVsiBrQSofDj", "outputId": "0790a4c1-5359-4669-d912-24d790f74c61" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a c d\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "a :- not b.\n", "b :- not c.\n", "c :- d.\n", "d." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "a :- not b, d.\n", "b :- not c, d.\n", "c :- d.\n", "d :- not e." ] }, { "cell_type": "markdown", "metadata": { "id": "Ho57hy3em9Yi" }, "source": [ "#### **5**" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "j_3LyCQFnE7K", "outputId": "8c702cbe-9240-41dd-a812-6349904b5255" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "b\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "a :- not b.\n", "b :- not c.\n", "c :- d.\n", "d :- c." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "tekDyDF_nJLf" }, "outputs": [], "source": [ "%%clingo -V0 0\n", "a :- not b.\n", "b :- not c.\n", "c :- d.\n", "d :- c.\n", "d." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **6**" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "rVsiBrQSofDj", "outputId": "0790a4c1-5359-4669-d912-24d790f74c61" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "b d\n", "SATISFIABLE\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "-:2:10-11: info: atom does not occur in any rule head:\n", " c\n", "\n" ] } ], "source": [ "%%clingo -V0 0 \n", "a :- not b.\n", "b :- not c.\n", "d :- b.\n", "b :- d." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "a :- not b.\n", "b :- not c.\n", "d :- b.\n", "b :- d.\n", "c." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **7**" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "rVsiBrQSofDj", "outputId": "0790a4c1-5359-4669-d912-24d790f74c61" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "b a d\n", "SATISFIABLE\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "-:2:10-11: info: atom does not occur in any rule head:\n", " c\n", "\n" ] } ], "source": [ "%%clingo -V0 0 \n", "a :- not b.\n", "b :- not c.\n", "a :- d.\n", "d." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "a :- not b.\n", "b :- not c.\n", "a :- d.\n", "d.\n", "b :- d." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **8**" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "rVsiBrQSofDj", "outputId": "0790a4c1-5359-4669-d912-24d790f74c61" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a d\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "a :- not b.\n", "b :- c, d.\n", "c :- b.\n", "d." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "a :- not b.\n", "b :- c, d.\n", "c :- b.\n", "d.\n", "c :- d." ] } ], "metadata": { "colab": { "collapsed_sections": [], "name": "Learning Easy ASP from Examples.ipynb", "provenance": [], "toc_visible": true }, "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.9.0" } }, "nbformat": 4, "nbformat_minor": 1 }