{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "yWGTIPMXotxs" }, "source": [ "# **Exercise 06. Logic programs with choice rules.**\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": [ "\n", "a\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "{ a }." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Note**: There is an empty line in the output. It represents the empty stable model." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0 \n", "{a} :- b.\n", "b." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **2**" ] }, { "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": [ "c\n", "a b\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "{ a }.\n", "b :- a.\n", "c :- not a." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "{ a }.\n", "b :- a.\n", "b :- not a." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **3**" ] }, { "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": [ "\n", "a\n", "b\n", "b a\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "{ a }.\n", "{ b }." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "{ a } :- c.\n", "{ b } :- d.\n", "c.\n", "d :- c." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **4**" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "rVsiBrQSofDj", "outputId": "0790a4c1-5359-4669-d912-24d790f74c61" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "a\n", "a b\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "{ a }.\n", "{ b } :- a." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "{ a }.\n", "{ b } :- c.\n", "c :- a." ] }, { "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": [ "\n", "c\n", "a\n", "a b\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "{ a }.\n", "{ b } :- a.\n", "{ c } :- not a." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "tekDyDF_nJLf" }, "outputs": [], "source": [ "%%clingo -V0 0\n", "{ a }.\n", "{ b } :- d.\n", "{ c } :- not d.\n", "d :- a." ] }, { "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": [ "c\n", "b\n", "a\n", "a b d\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "{ a; b }.\n", "c :- not a, not b.\n", "d :- a, b." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "{ a; b }.\n", "c :- not a, b.\n", "d :- a, not b." ] }, { "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": [ "\n", "a b\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "{ a; b }.\n", "b :- a.\n", "a :- b." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "{ a; b; c }.\n", "b :- a.\n", "a :- c.\n", "c :- b." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **8**" ] }, { "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": [ "\n", "c\n", "a b\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "{ a; b }.\n", "b :- a.\n", "a :- b.\n", "{ c } :- not a, not b." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "{ a; b }.\n", "b :- a.\n", "a :- b.\n", "{ c } :- a, b." ] } ], "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 }