{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "yWGTIPMXotxs" }, "source": [ "# **Exercise 10. Bounded choice rules.**\n" ] }, { "cell_type": "markdown", "metadata": { "id": "Ho57hy3em9Yi" }, "source": [ "#### **1**" ] }, { "cell_type": "code", "execution_count": 10, "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", "a\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "{ a; b }.\n", ":- not 1 { a; b } 1." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "tekDyDF_nJLf" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "1 { a; b } 1." ] }, { "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 c\n", "a b c\n", "a c\n", "a b\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "{ a; b; c }.\n", ":- not 2 { a; b; c }." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "2 { a; b; 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": [ "a c\n", "b\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "{ a; b }.\n", ":- not 1 { a; b } 1.\n", "{ b; c }.\n", ":- not 1 { b; c } 1." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "1 { a; b } 1.\n", "1 { b; c } 1." ] }, { "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": [ "c\n", "a c\n", "b\n", "b c\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "{ a; b }.\n", ":- not { a; b } 1.\n", "{ b; c }.\n", ":- not 1 { b; c }." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "{ a; b } 1.\n", "1 { b; c }." ] }, { "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": [ "d b\n", "c a\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0\n", "1 { a; b } 1.\n", "c :- a.\n", "d :- b.\n", ":- { c; d } 0." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "tekDyDF_nJLf" }, "outputs": [], "source": [ "%%clingo -V0 0\n", "1 { a; b } 1.\n", "c :- a.\n", "d :- b.\n", ":- 1 { c ; d }." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **6**" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "rVsiBrQSofDj", "outputId": "0790a4c1-5359-4669-d912-24d790f74c61" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "b\n", "a c\n", "a d\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "1 { a; b }.\n", "1 { c; d } 1 :- a.\n", ":- b, 2 { a; c; d }." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%clingo -V0 0 \n", "1 { a; b }.\n", "1 { c; d } 1 :- a.\n", ":- not 2 { a; b; c; d }." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **7**" ] }, { "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": [ "\n", "b\n", "a c\n", "SATISFIABLE\n" ] } ], "source": [ "%%clingo -V0 0 \n", "{ a; b } 1.\n", "1 { b; c } :- a." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6ElK21vgok0e" }, "outputs": [], "source": [ "%%clingo -V0 0 \n", "1 { a; b } 1.\n", "1 { b; c } 1 :- a." ] }, { "cell_type": "markdown", "metadata": { "id": "2EPx4Jn6oRUc" }, "source": [ "#### **8**" ] }, { "cell_type": "code", "execution_count": 13, "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", "1 { a } 1 :- { b } 0.\n", "1 { b } 1 :- { c } 0." ] } ], "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 }