{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "yWGTIPMXotxs" }, "source": [ "# **Exercise 2. Recursion in positive 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", "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "a :- a." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "tekDyDF_nJLf" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "a:- a, b.\n", "b." ] }, { "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": [ "\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "a :- b.\n", "b :- a." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "a :- b, c.\n", "b :- a, 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 a\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "a :- b.\n", "b :- a.\n", "b." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "a :- b.\n", "b :- a.\n", "b :- c.\n", "c." ] }, { "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": [ "b a c\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "a :- b.\n", "b :- a.\n", "b.\n", "c :- a." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "a :- b.\n", "b :- a.\n", "b.\n", "c :- a, b.\n", "d :- a, b, c." ] }, { "cell_type": "markdown", "metadata": { "id": "Ho57hy3em9Yi" }, "source": [ "#### **5**" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "j_3LyCQFnE7K", "outputId": "8c702cbe-9240-41dd-a812-6349904b5255" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "a :- b.\n", "b :- c.\n", "c :- a." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "tekDyDF_nJLf" }, "outputs": [], "source": [ "%%clingo -V0 0\n", "a :- b, d.\n", "b :- c, e.\n", "c :- a, e.\n", "d.\n", "e :- d." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **6**" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "rVsiBrQSofDj", "outputId": "0790a4c1-5359-4669-d912-24d790f74c61" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "b a c d\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "a :- b.\n", "b :- c.\n", "c :- a.\n", "d.\n", "c :- d." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "a :- b, d.\n", "b :- c, d.\n", "c :- a, d.\n", "d.\n", "c :- d." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **7**" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "rVsiBrQSofDj", "outputId": "0790a4c1-5359-4669-d912-24d790f74c61" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "a :- b.\n", "b :- a.\n", "c :- d.\n", "d :- c." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "a :- b, c.\n", "b :- a, d.\n", "c :- d.\n", "d :- c.\n", "d." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **8**" ] }, { "cell_type": "code", "execution_count": 8, "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 c\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "a :- b.\n", "b :- a.\n", "c :- d.\n", "d :- c.\n", "c.\n", "b :- d." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "a :- b, c, d.\n", "b :- a, c, d.\n", "c :- d.\n", "d :- c.\n", "c.\n", "b :- 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 }