From e27af931d187f82ca58473fa8ce53c7b6aadb033 Mon Sep 17 00:00:00 2001 From: Michael Leuschel <leuschel@uni-duesseldorf.de> Date: Tue, 6 Jun 2023 10:39:38 +0200 Subject: [PATCH] update notebooks Signed-off-by: Michael Leuschel <leuschel@uni-duesseldorf.de> --- info4/kapitel-9/Ackermann.ipynb | 18 +- info4/kapitel-9/PrimitiveRekursion.ipynb | 1224 ++++++---------------- 2 files changed, 330 insertions(+), 912 deletions(-) diff --git a/info4/kapitel-9/Ackermann.ipynb b/info4/kapitel-9/Ackermann.ipynb index 1615a9b..f4fbd21 100644 --- a/info4/kapitel-9/Ackermann.ipynb +++ b/info4/kapitel-9/Ackermann.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "05d7c16f", + "id": "4f85588b", "metadata": {}, "source": [ "## Die Ackermann Funktion" @@ -11,7 +11,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "dc177e49", + "id": "fba4a5ee", "metadata": {}, "outputs": [], "source": [ @@ -24,7 +24,7 @@ { "cell_type": "code", "execution_count": 2, - "id": "4adf4ed2", + "id": "64a68f66", "metadata": {}, "outputs": [ { @@ -44,7 +44,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "c26e7fa4", + "id": "0ff57d9f", "metadata": {}, "outputs": [ { @@ -64,7 +64,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "d682c1fc", + "id": "190a83b9", "metadata": {}, "outputs": [ { @@ -84,7 +84,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "0e1603db", + "id": "3617d235", "metadata": {}, "outputs": [ { @@ -104,7 +104,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "41d483da", + "id": "5c189808", "metadata": {}, "outputs": [ { @@ -124,7 +124,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "19e3c25f", + "id": "ed5076a9", "metadata": {}, "outputs": [ { @@ -144,7 +144,7 @@ { "cell_type": "code", "execution_count": null, - "id": "95f45975", + "id": "0097f444", "metadata": {}, "outputs": [], "source": [] diff --git a/info4/kapitel-9/PrimitiveRekursion.ipynb b/info4/kapitel-9/PrimitiveRekursion.ipynb index d791299..e2890bd 100644 --- a/info4/kapitel-9/PrimitiveRekursion.ipynb +++ b/info4/kapitel-9/PrimitiveRekursion.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "76265463", + "id": "77ea4504", "metadata": {}, "source": [ "# Primitiv Rekursive Funktionen\n", @@ -16,8 +16,8 @@ }, { "cell_type": "code", - "execution_count": 2, - "id": "1be13bd0", + "execution_count": 1, + "id": "395e8879", "metadata": {}, "outputs": [], "source": [ @@ -28,9 +28,49 @@ "s(X,X1) :- X1 is X+1." ] }, + { + "cell_type": "code", + "execution_count": 2, + "id": "7217e3e5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\u001b[1mX = 11" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "?- s(10,X)." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "433c5d01", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\u001b[1mX = 0" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "?- zero(X)." + ] + }, { "cell_type": "markdown", - "id": "2a60777c", + "id": "8712cde7", "metadata": {}, "source": [ "Alle Identitäten (Projektionen) sind primitiv rekursiv:" @@ -38,13 +78,13 @@ }, { "cell_type": "code", - "execution_count": 3, - "id": "7aa01fb7", + "execution_count": 4, + "id": "2bf7755e", "metadata": {}, "outputs": [], "source": [ "% hier ein paar Projektionsfunktionen die wir benötigen:\n", - "id_1_1(X,X).\n", + "id_1_1(X,X). % id_1_1(x) = x\n", "id_2_1(X,_,X).\n", "id_2_2(_,Y,Y).\n", "id_3_1(X,_,_,X).\n", @@ -54,8 +94,8 @@ }, { "cell_type": "code", - "execution_count": 4, - "id": "08bb0d22", + "execution_count": 5, + "id": "0e7d58e3", "metadata": {}, "outputs": [ { @@ -74,8 +114,8 @@ }, { "cell_type": "code", - "execution_count": 5, - "id": "5e09a6e0", + "execution_count": 6, + "id": "77e24dba", "metadata": {}, "outputs": [ { @@ -90,19 +130,42 @@ } ], "source": [ - "?- zero(X), s(X,Res)." + "?- zero(X), s(X,Res). % s(zero)" ] }, { "cell_type": "code", "execution_count": 7, - "id": "8e91be0c", + "id": "34230fcb", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\u001b[1mRes = 33" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "?- id_3_3(11,22,33,Res)." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "0cc3e596", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "\u001b[1mRes = 22" + "\u001b[1mX = 0,\n", + "E1 = 1,\n", + "E2 = 2,\n", + "Res = 2" ] }, "metadata": {}, @@ -110,12 +173,12 @@ } ], "source": [ - "?- id_3_2(11,22,33,Res)." + "?- zero(X), s(X,E1), s(E1,E2), id_2_2(E1,E2,Res)." ] }, { "cell_type": "markdown", - "id": "0fae8b28", + "id": "644060ba", "metadata": {}, "source": [ "### Substitution\n", @@ -126,8 +189,8 @@ }, { "cell_type": "code", - "execution_count": 13, - "id": "cdece1e6", + "execution_count": 9, + "id": "fd8c32cc", "metadata": {}, "outputs": [], "source": [ @@ -136,8 +199,8 @@ }, { "cell_type": "code", - "execution_count": 14, - "id": "11da5fea", + "execution_count": 10, + "id": "064eadc6", "metadata": {}, "outputs": [ { @@ -156,7 +219,7 @@ }, { "cell_type": "markdown", - "id": "6af212c6", + "id": "9a2dd3b9", "metadata": {}, "source": [ "### Primitive Rekursion\n", @@ -168,8 +231,8 @@ }, { "cell_type": "code", - "execution_count": 15, - "id": "4e52bde2", + "execution_count": 11, + "id": "e777bd7f", "metadata": {}, "outputs": [], "source": [ @@ -181,14 +244,14 @@ }, { "cell_type": "code", - "execution_count": 16, - "id": "e44bf4b9", + "execution_count": 12, + "id": "306825eb", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "\u001b[1mRes = 3" + "\u001b[1mRes = 33" ] }, "metadata": {}, @@ -196,12 +259,12 @@ } ], "source": [ - "?- add_pr(1,2,Res)." + "?- add_pr(11,22,Res)." ] }, { "cell_type": "markdown", - "id": "474a8d10", + "id": "639588f5", "metadata": {}, "source": [ "Hier ein weiteres Beispiel:" @@ -209,11 +272,12 @@ }, { "cell_type": "code", - "execution_count": 20, - "id": "e0a5e76e", + "execution_count": 13, + "id": "2c2267a0", "metadata": {}, "outputs": [], "source": [ + "mul_pr(N1,X,Res) :- write(mul(N1,X)),nl,fail.\n", "mul_pr(0,_X,Res) :- zero(Res).\n", "mul_pr(N1,X,Res) :- N1>0, N is N1-1,\n", " mul_pr(N,X,RecRes), % rekursiver Aufruf\n", @@ -225,10 +289,29 @@ }, { "cell_type": "code", - "execution_count": 19, - "id": "6d457c8f", + "execution_count": 14, + "id": "a96102cf", "metadata": {}, "outputs": [ + { + "data": { + "text/plain": [ + "mul(10,20)\n", + "mul(9,20)\n", + "mul(8,20)\n", + "mul(7,20)\n", + "mul(6,20)\n", + "mul(5,20)\n", + "mul(4,20)\n", + "mul(3,20)\n", + "mul(2,20)\n", + "mul(1,20)\n", + "mul(0,20)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "data": { "text/plain": [ @@ -245,7 +328,7 @@ }, { "cell_type": "markdown", - "id": "6c83afad", + "id": "2e2ce8a9", "metadata": {}, "source": [ "## Gödelisierung\n", @@ -280,8 +363,8 @@ }, { "cell_type": "code", - "execution_count": 45, - "id": "c426862d", + "execution_count": 15, + "id": "c005a69d", "metadata": {}, "outputs": [], "source": [ @@ -294,8 +377,8 @@ }, { "cell_type": "code", - "execution_count": 46, - "id": "194ac4e1", + "execution_count": 16, + "id": "9293d9f0", "metadata": {}, "outputs": [ { @@ -323,13 +406,14 @@ }, { "cell_type": "code", - "execution_count": 47, - "id": "cd0e84d5", + "execution_count": 17, + "id": "2baee52c", "metadata": {}, "outputs": [], "source": [ "compute_pr(PR,Args,R) :- compute_pr(PR,Args,R,0).\n", "% rules to compute primitive recursive functions:\n", + "\n", "compute_pr(PR,Args,_Result,I) :- iformat(I,'Computing ~w with ~w~n',[PR,Args]),fail.\n", "compute_pr(cst(X),_Args,X,_).\n", "compute_pr(id(N),Args,X,_) :- nth1(N,Args,X).\n", @@ -353,8 +437,69 @@ }, { "cell_type": "code", - "execution_count": 49, - "id": "ba2d1d5b", + "execution_count": 18, + "id": "b507cb40", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Computing id(3) with [0,1,2,3]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "\u001b[1mRes = 2" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "?- compute_pr(id(3),[0,1,2,3],Res)." + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "362ebed5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Computing sub(s,[s]) with [11]\n", + "->Computing s with [11]\n", + "->Computing s with [12]\n", + "Result = 13" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "\u001b[1mRes = 13" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "?- compute_pr(sub(s,[s]),[11],Res)." + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "b9979af1", "metadata": {}, "outputs": [ { @@ -394,7 +539,7 @@ }, { "cell_type": "markdown", - "id": "729fa283", + "id": "e21b479f", "metadata": {}, "source": [ "Können wir prüfen ob eine Gödelisierung valide ist? Ist G[Pr] entscheidbar. Ja, hier ist der Code für unser Beispiel:" @@ -402,8 +547,8 @@ }, { "cell_type": "code", - "execution_count": 50, - "id": "9cc30401", + "execution_count": 21, + "id": "a694d69c", "metadata": {}, "outputs": [], "source": [ @@ -426,8 +571,8 @@ }, { "cell_type": "code", - "execution_count": 51, - "id": "b2dc1cb4", + "execution_count": 22, + "id": "5c9b5b3d", "metadata": {}, "outputs": [ { @@ -468,7 +613,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fccefd19", + "id": "9da8111a", "metadata": {}, "outputs": [ { @@ -487,8 +632,8 @@ }, { "cell_type": "code", - "execution_count": 53, - "id": "cb6e6ee5", + "execution_count": null, + "id": "21d20d2d", "metadata": {}, "outputs": [], "source": [ @@ -501,178 +646,17 @@ }, { "cell_type": "code", - "execution_count": 56, - "id": "23998b5d", + "execution_count": null, + "id": "b1150802", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Computing pr(cst(0),sub(pr(id(1),sub(s,[id(2)])),[id(2),id(3)])) with [5,2]\n", - "->Computing pr(cst(0),sub(pr(id(1),sub(s,[id(2)])),[id(2),id(3)])) with [4,2]\n", - "->->Computing pr(cst(0),sub(pr(id(1),sub(s,[id(2)])),[id(2),id(3)])) with [3,2]\n", - "->->->Computing pr(cst(0),sub(pr(id(1),sub(s,[id(2)])),[id(2),id(3)])) with [2,2]\n", - "->->->->Computing pr(cst(0),sub(pr(id(1),sub(s,[id(2)])),[id(2),id(3)])) with [1,2]\n", - "->->->->->Computing pr(cst(0),sub(pr(id(1),sub(s,[id(2)])),[id(2),id(3)])) with [0,2]\n", - "->->->->->->Computing cst(0) with [2]\n", - "->->->->->pr base case = 0\n", - "->->->->->Computing sub(pr(id(1),sub(s,[id(2)])),[id(2),id(3)]) with [0,0,2]\n", - "->->->->->->Computing id(2) with [0,0,2]\n", - "->->->->->->Computing id(3) with [0,0,2]\n", - "->->->->->->Computing pr(id(1),sub(s,[id(2)])) with [0,2]\n", - "->->->->->->->Computing id(1) with [2]\n", - "->->->->->->pr base case = 2\n", - "->->->->->Result = 2\n", - "->->->->Computing sub(pr(id(1),sub(s,[id(2)])),[id(2),id(3)]) with [1,2,2]\n", - "->->->->->Computing id(2) with [1,2,2]\n", - "->->->->->Computing id(3) with [1,2,2]\n", - "->->->->->Computing pr(id(1),sub(s,[id(2)])) with [2,2]\n", - "->->->->->->Computing pr(id(1),sub(s,[id(2)])) with [1,2]\n", - "->->->->->->->Computing pr(id(1),sub(s,[id(2)])) with [0,2]\n", - "->->->->->->->->Computing id(1) with [2]\n", - "->->->->->->->pr base case = 2\n", - "->->->->->->->Computing sub(s,[id(2)]) with [0,2,2]\n", - "->->->->->->->->Computing id(2) with [0,2,2]\n", - "->->->->->->->->Computing s with [2]\n", - "->->->->->->->Result = 3\n", - "->->->->->->Computing sub(s,[id(2)]) with [1,3,2]\n", - "->->->->->->->Computing id(2) with [1,3,2]\n", - "->->->->->->->Computing s with [3]\n", - "->->->->->->Result = 4\n", - "->->->->Result = 4\n", - "->->->Computing sub(pr(id(1),sub(s,[id(2)])),[id(2),id(3)]) with [2,4,2]\n", - "->->->->Computing id(2) with [2,4,2]\n", - "->->->->Computing id(3) with [2,4,2]\n", - "->->->->Computing pr(id(1),sub(s,[id(2)])) with [4,2]\n", - "->->->->->Computing pr(id(1),sub(s,[id(2)])) with [3,2]\n", - "->->->->->->Computing pr(id(1),sub(s,[id(2)])) with [2,2]\n", - "->->->->->->->Computing pr(id(1),sub(s,[id(2)])) with [1,2]\n", - "->->->->->->->->Computing pr(id(1),sub(s,[id(2)])) with [0,2]\n", - "->->->->->->->->->Computing id(1) with [2]\n", - "->->->->->->->->pr base case = 2\n", - "->->->->->->->->Computing sub(s,[id(2)]) with [0,2,2]\n", - "->->->->->->->->->Computing id(2) with [0,2,2]\n", - "->->->->->->->->->Computing s with [2]\n", - "->->->->->->->->Result = 3\n", - "->->->->->->->Computing sub(s,[id(2)]) with [1,3,2]\n", - "->->->->->->->->Computing id(2) with [1,3,2]\n", - "->->->->->->->->Computing s with [3]\n", - "->->->->->->->Result = 4\n", - "->->->->->->Computing sub(s,[id(2)]) with [2,4,2]\n", - "->->->->->->->Computing id(2) with [2,4,2]\n", - "->->->->->->->Computing s with [4]\n", - "->->->->->->Result = 5\n", - "->->->->->Computing sub(s,[id(2)]) with [3,5,2]\n", - "->->->->->->Computing id(2) with [3,5,2]\n", - "->->->->->->Computing s with [5]\n", - "->->->->->Result = 6\n", - "->->->Result = 6\n", - "->->Computing sub(pr(id(1),sub(s,[id(2)])),[id(2),id(3)]) with [3,6,2]\n", - "->->->Computing id(2) with [3,6,2]\n", - "->->->Computing id(3) with [3,6,2]\n", - "->->->Computing pr(id(1),sub(s,[id(2)])) with [6,2]\n", - "->->->->Computing pr(id(1),sub(s,[id(2)])) with [5,2]\n", - "->->->->->Computing pr(id(1),sub(s,[id(2)])) with [4,2]\n", - "->->->->->->Computing pr(id(1),sub(s,[id(2)])) with [3,2]\n", - "->->->->->->->Computing pr(id(1),sub(s,[id(2)])) with [2,2]\n", - "->->->->->->->->Computing pr(id(1),sub(s,[id(2)])) with [1,2]\n", - "->->->->->->->->->Computing pr(id(1),sub(s,[id(2)])) with [0,2]\n", - "->->->->->->->->->->Computing id(1) with [2]\n", - "->->->->->->->->->pr base case = 2\n", - "->->->->->->->->->Computing sub(s,[id(2)]) with [0,2,2]\n", - "->->->->->->->->->->Computing id(2) with [0,2,2]\n", - "->->->->->->->->->->Computing s with [2]\n", - "->->->->->->->->->Result = 3\n", - "->->->->->->->->Computing sub(s,[id(2)]) with [1,3,2]\n", - "->->->->->->->->->Computing id(2) with [1,3,2]\n", - "->->->->->->->->->Computing s with [3]\n", - "->->->->->->->->Result = 4\n", - "->->->->->->->Computing sub(s,[id(2)]) with [2,4,2]\n", - "->->->->->->->->Computing id(2) with [2,4,2]\n", - "->->->->->->->->Computing s with [4]\n", - "->->->->->->->Result = 5\n", - "->->->->->->Computing sub(s,[id(2)]) with [3,5,2]\n", - "->->->->->->->Computing id(2) with [3,5,2]\n", - "->->->->->->->Computing s with [5]\n", - "->->->->->->Result = 6\n", - "->->->->->Computing sub(s,[id(2)]) with [4,6,2]\n", - "->->->->->->Computing id(2) with [4,6,2]\n", - "->->->->->->Computing s with [6]\n", - "->->->->->Result = 7\n", - "->->->->Computing sub(s,[id(2)]) with [5,7,2]\n", - "->->->->->Computing id(2) with [5,7,2]\n", - "->->->->->Computing s with [7]\n", - "->->->->Result = 8\n", - "->->Result = 8\n", - "->Computing sub(pr(id(1),sub(s,[id(2)])),[id(2),id(3)]) with [4,8,2]\n", - "->->Computing id(2) with [4,8,2]\n", - "->->Computing id(3) with [4,8,2]\n", - "->->Computing pr(id(1),sub(s,[id(2)])) with [8,2]\n", - "->->->Computing pr(id(1),sub(s,[id(2)])) with [7,2]\n", - "->->->->Computing pr(id(1),sub(s,[id(2)])) with [6,2]\n", - "->->->->->Computing pr(id(1),sub(s,[id(2)])) with [5,2]\n", - "->->->->->->Computing pr(id(1),sub(s,[id(2)])) with [4,2]\n", - "->->->->->->->Computing pr(id(1),sub(s,[id(2)])) with [3,2]\n", - "->->->->->->->->Computing pr(id(1),sub(s,[id(2)])) with [2,2]\n", - "->->->->->->->->->Computing pr(id(1),sub(s,[id(2)])) with [1,2]\n", - "->->->->->->->->->->Computing pr(id(1),sub(s,[id(2)])) with [0,2]\n", - "->->->->->->->->->->->Computing id(1) with [2]\n", - "->->->->->->->->->->pr base case = 2\n", - "->->->->->->->->->->Computing sub(s,[id(2)]) with [0,2,2]\n", - "->->->->->->->->->->->Computing id(2) with [0,2,2]\n", - "->->->->->->->->->->->Computing s with [2]\n", - "->->->->->->->->->->Result = 3\n", - "->->->->->->->->->Computing sub(s,[id(2)]) with [1,3,2]\n", - "->->->->->->->->->->Computing id(2) with [1,3,2]\n", - "->->->->->->->->->->Computing s with [3]\n", - "->->->->->->->->->Result = 4\n", - "->->->->->->->->Computing sub(s,[id(2)]) with [2,4,2]\n", - "->->->->->->->->->Computing id(2) with [2,4,2]\n", - "->->->->->->->->->Computing s with [4]\n", - "->->->->->->->->Result = 5\n", - "->->->->->->->Computing sub(s,[id(2)]) with [3,5,2]\n", - "->->->->->->->->Computing id(2) with [3,5,2]\n", - "->->->->->->->->Computing s with [5]\n", - "->->->->->->->Result = 6\n", - "->->->->->->Computing sub(s,[id(2)]) with [4,6,2]\n", - "->->->->->->->Computing id(2) with [4,6,2]\n", - "->->->->->->->Computing s with [6]\n", - "->->->->->->Result = 7\n", - "->->->->->Computing sub(s,[id(2)]) with [5,7,2]\n", - "->->->->->->Computing id(2) with [5,7,2]\n", - "->->->->->->Computing s with [7]\n", - "->->->->->Result = 8\n", - "->->->->Computing sub(s,[id(2)]) with [6,8,2]\n", - "->->->->->Computing id(2) with [6,8,2]\n", - "->->->->->Computing s with [8]\n", - "->->->->Result = 9\n", - "->->->Computing sub(s,[id(2)]) with [7,9,2]\n", - "->->->->Computing id(2) with [7,9,2]\n", - "->->->->Computing s with [9]\n", - "->->->Result = 10\n", - "->Result = 10" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "\u001b[1mRes = 10" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?-mul(5,2,Res)." ] }, { "cell_type": "markdown", - "id": "b66ec641", + "id": "84411d3d", "metadata": {}, "source": [ "## Aufzählung der validen primitiv rekursiven Funktionen\n", @@ -682,8 +666,8 @@ }, { "cell_type": "code", - "execution_count": 62, - "id": "06533a42", + "execution_count": null, + "id": "d6c0485e", "metadata": {}, "outputs": [], "source": [ @@ -696,149 +680,70 @@ }, { "cell_type": "code", - "execution_count": 63, - "id": "bdeb602e", + "execution_count": null, + "id": "28bbdc38", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mX = 0" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- gen_any_nr(0,X)." ] }, { "cell_type": "code", - "execution_count": 64, - "id": "bcb27beb", + "execution_count": null, + "id": "79e6a410", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mX = 1" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] }, { "cell_type": "code", - "execution_count": 65, - "id": "d0ee04c3", + "execution_count": null, + "id": "1c95b30c", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mX = 2" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] }, { "cell_type": "code", - "execution_count": 66, - "id": "e2832af2", + "execution_count": null, + "id": "304dbe3e", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "% The new active goal is: mul(5,2,Res)" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "\u001b[1mtrue" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:cut." ] }, { "cell_type": "code", - "execution_count": 67, - "id": "65473e50", + "execution_count": null, + "id": "50441d86", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mX = 2" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- gen_nr_up_to(X,2)." ] }, { "cell_type": "code", - "execution_count": 68, - "id": "05ca76fd", + "execution_count": null, + "id": "ed217ef5", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mX = 1" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] }, { "cell_type": "code", - "execution_count": 69, - "id": "878e5dae", + "execution_count": null, + "id": "356b0b9a", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mX = 0" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] @@ -846,27 +751,17 @@ { "cell_type": "code", "execution_count": null, - "id": "f5828d6d", + "id": "d6c5ccc2", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1;31mfalse" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] }, { "cell_type": "code", - "execution_count": 100, - "id": "6e9af2a9", + "execution_count": null, + "id": "e783f586", "metadata": {}, "outputs": [], "source": [ @@ -888,297 +783,148 @@ }, { "cell_type": "code", - "execution_count": 85, - "id": "8413c05f", + "execution_count": null, + "id": "fbf1a64f", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mFunction = cst(0)" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- gen_valid_pr_fun(Function)." ] }, { "cell_type": "code", - "execution_count": 86, - "id": "c6857661", + "execution_count": null, + "id": "f8bba52b", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mFunction = s" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] }, { "cell_type": "code", - "execution_count": 87, - "id": "7fb572c6", + "execution_count": null, + "id": "18e28b48", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mFunction = cst(1)" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] }, { "cell_type": "code", - "execution_count": 88, - "id": "23d8ba01", + "execution_count": null, + "id": "1efc4295", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mFunction = cst(0)" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] }, { "cell_type": "code", - "execution_count": 89, - "id": "553312d9", + "execution_count": null, + "id": "c4919043", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mFunction = id(1)" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] }, { "cell_type": "code", - "execution_count": 90, - "id": "8b06c226", + "execution_count": null, + "id": "7d8b9a6f", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mFunction = s" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] }, { "cell_type": "code", - "execution_count": 91, - "id": "f10e13a7", + "execution_count": null, + "id": "ea215b42", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mFunction = cst(2)" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] }, { "cell_type": "code", - "execution_count": 92, - "id": "4a62362f", + "execution_count": null, + "id": "c2ed96b6", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mFunction = cst(1)" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] }, { "cell_type": "code", - "execution_count": 93, - "id": "8d9c5277", + "execution_count": null, + "id": "10beb801", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mFunction = cst(0)" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] }, { "cell_type": "code", - "execution_count": 94, - "id": "4b19394e", + "execution_count": null, + "id": "f5caef9f", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mFunction = id(1)" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] }, { "cell_type": "code", - "execution_count": 95, - "id": "a53a4113", + "execution_count": null, + "id": "36919b05", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mFunction = s" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] }, { "cell_type": "code", - "execution_count": 96, - "id": "2b461e04", + "execution_count": null, + "id": "0af54bcf", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mFunction = sub(cst(1),[])" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:retry." ] }, { "cell_type": "code", - "execution_count": 97, - "id": "22cbb7d4", + "execution_count": null, + "id": "443671f5", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "% The new active goal is: mul(5,2,Res)" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "\u001b[1mtrue" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- jupyter:cut." ] }, { "cell_type": "code", - "execution_count": 98, - "id": "bf5fd841", + "execution_count": null, + "id": "1983d9f0", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "\u001b[1mX = cst(3)" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- gen_pr(X,3), check_arity(X,1)." ] }, { "cell_type": "code", - "execution_count": 103, - "id": "c9979069", + "execution_count": null, + "id": "cf9cfd3f", "metadata": {}, "outputs": [], "source": [ @@ -1192,292 +938,27 @@ { "cell_type": "code", "execution_count": null, - "id": "b5d03b36", + "id": "e3d7e980", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Sol 1: cst(2)\n", - "Sol 2: cst(1)\n", - "Sol 3: cst(0)\n", - "Sol 4: id(1)\n", - "Sol 5: s\n", - "Sol 6: sub(cst(1),[])\n", - "Sol 7: sub(cst(1),[cst(1)])\n", - "Sol 8: sub(cst(1),[cst(0)])\n", - "Sol 9: sub(cst(1),[id(1)])\n", - "Sol 10: sub(cst(1),[s])\n", - "Sol 11: sub(cst(0),[])\n", - "Sol 12: sub(cst(0),[cst(1)])\n", - "Sol 13: sub(cst(0),[cst(0)])\n", - "Sol 14: sub(cst(0),[id(1)])\n", - "Sol 15: sub(cst(0),[s])\n", - "Sol 16: sub(id(1),[cst(1)])\n", - "Sol 17: sub(id(1),[cst(0)])\n", - "Sol 18: sub(id(1),[id(1)])\n", - "Sol 19: sub(id(1),[s])\n", - "Sol 20: sub(s,[cst(1)])\n", - "Sol 21: sub(s,[cst(0)])\n", - "Sol 22: sub(s,[id(1)])\n", - "Sol 23: sub(s,[s])\n", - "Sol 24: pr(cst(1),cst(1))\n", - "Sol 25: pr(cst(1),cst(0))\n", - "Sol 26: pr(cst(1),id(1))\n", - "Sol 27: pr(cst(0),cst(1))\n", - "Sol 28: pr(cst(0),cst(0))\n", - "Sol 29: pr(cst(0),id(1))" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "\u001b[1;31mfalse" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- set_limit(100),gen_pr(X,2), check_arity(X,1), print_sol(X)." ] }, { "cell_type": "code", - "execution_count": 108, - "id": "af201e0b", + "execution_count": null, + "id": "592804ce", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Sol 1: cst(0)\n", - "Sol 2: s\n", - "Sol 3: cst(1)\n", - "Sol 4: cst(0)\n", - "Sol 5: id(1)\n", - "Sol 6: s\n", - "Sol 7: cst(2)\n", - "Sol 8: cst(1)\n", - "Sol 9: cst(0)\n", - "Sol 10: id(1)\n", - "Sol 11: s\n", - "Sol 12: sub(cst(1),[])\n", - "Sol 13: sub(cst(1),[cst(1)])\n", - "Sol 14: sub(cst(1),[cst(0)])\n", - "Sol 15: sub(cst(1),[id(1)])\n", - "Sol 16: sub(cst(1),[s])\n", - "Sol 17: sub(cst(0),[])\n", - "Sol 18: sub(cst(0),[cst(1)])\n", - "Sol 19: sub(cst(0),[cst(0)])\n", - "Sol 20: sub(cst(0),[id(1)])\n", - "Sol 21: sub(cst(0),[s])\n", - "Sol 22: sub(id(1),[cst(1)])\n", - "Sol 23: sub(id(1),[cst(0)])\n", - "Sol 24: sub(id(1),[id(1)])\n", - "Sol 25: sub(id(1),[s])\n", - "Sol 26: sub(s,[cst(1)])\n", - "Sol 27: sub(s,[cst(0)])\n", - "Sol 28: sub(s,[id(1)])\n", - "Sol 29: sub(s,[s])\n", - "Sol 30: pr(cst(1),cst(1))\n", - "Sol 31: pr(cst(1),cst(0))\n", - "Sol 32: pr(cst(1),id(1))\n", - "Sol 33: pr(cst(0),cst(1))\n", - "Sol 34: pr(cst(0),cst(0))\n", - "Sol 35: pr(cst(0),id(1))\n", - "Sol 36: cst(3)\n", - "Sol 37: cst(2)\n", - "Sol 38: cst(1)\n", - "Sol 39: cst(0)\n", - "Sol 40: id(1)\n", - "Sol 41: s\n", - "Sol 42: sub(cst(2),[])\n", - "Sol 43: sub(cst(2),[cst(2)])\n", - "Sol 44: sub(cst(2),[cst(2),cst(1)])\n", - "Sol 45: sub(cst(2),[cst(2),cst(0)])\n", - "Sol 46: sub(cst(2),[cst(2),id(1)])\n", - "Sol 47: sub(cst(2),[cst(2),s])\n", - "Sol 48: sub(cst(2),[cst(1)])\n", - "Sol 49: sub(cst(2),[cst(1),cst(1)])\n", - "Sol 50: sub(cst(2),[cst(1),cst(0)])\n", - "Sol 51: sub(cst(2),[cst(1),id(1)])\n", - "Sol 52: sub(cst(2),[cst(1),s])\n", - "Sol 53: sub(cst(2),[cst(0)])\n", - "Sol 54: sub(cst(2),[cst(0),cst(1)])\n", - "Sol 55: sub(cst(2),[cst(0),cst(0)])\n", - "Sol 56: sub(cst(2),[cst(0),id(1)])\n", - "Sol 57: sub(cst(2),[cst(0),s])\n", - "Sol 58: sub(cst(2),[id(1)])\n", - "Sol 59: sub(cst(2),[id(1),cst(1)])\n", - "Sol 60: sub(cst(2),[id(1),cst(0)])\n", - "Sol 61: sub(cst(2),[id(1),id(1)])\n", - "Sol 62: sub(cst(2),[id(1),s])\n", - "Sol 63: sub(cst(2),[s])\n", - "Sol 64: sub(cst(2),[s,cst(1)])\n", - "Sol 65: sub(cst(2),[s,cst(0)])\n", - "Sol 66: sub(cst(2),[s,id(1)])\n", - "Sol 67: sub(cst(2),[s,s])\n", - "Sol 68: sub(cst(2),[sub(cst(1),[])])\n", - "Sol 69: sub(cst(2),[sub(cst(1),[]),cst(1)])\n", - "Sol 70: sub(cst(2),[sub(cst(1),[]),cst(0)])\n", - "Sol 71: sub(cst(2),[sub(cst(1),[]),id(1)])\n", - "Sol 72: sub(cst(2),[sub(cst(1),[]),s])\n", - "Sol 73: sub(cst(2),[sub(cst(1),[cst(1)])])\n", - "Sol 74: sub(cst(2),[sub(cst(1),[cst(1)]),cst(1)])\n", - "Sol 75: sub(cst(2),[sub(cst(1),[cst(1)]),cst(0)])\n", - "Sol 76: sub(cst(2),[sub(cst(1),[cst(1)]),id(1)])\n", - "Sol 77: sub(cst(2),[sub(cst(1),[cst(1)]),s])\n", - "Sol 78: sub(cst(2),[sub(cst(1),[cst(0)])])\n", - "Sol 79: sub(cst(2),[sub(cst(1),[cst(0)]),cst(1)])\n", - "Sol 80: sub(cst(2),[sub(cst(1),[cst(0)]),cst(0)])\n", - "Sol 81: sub(cst(2),[sub(cst(1),[cst(0)]),id(1)])\n", - "Sol 82: sub(cst(2),[sub(cst(1),[cst(0)]),s])\n", - "Sol 83: sub(cst(2),[sub(cst(1),[id(1)])])\n", - "Sol 84: sub(cst(2),[sub(cst(1),[id(1)]),cst(1)])\n", - "Sol 85: sub(cst(2),[sub(cst(1),[id(1)]),cst(0)])\n", - "Sol 86: sub(cst(2),[sub(cst(1),[id(1)]),id(1)])\n", - "Sol 87: sub(cst(2),[sub(cst(1),[id(1)]),s])\n", - "Sol 88: sub(cst(2),[sub(cst(1),[s])])\n", - "Sol 89: sub(cst(2),[sub(cst(1),[s]),cst(1)])\n", - "Sol 90: sub(cst(2),[sub(cst(1),[s]),cst(0)])\n", - "Sol 91: sub(cst(2),[sub(cst(1),[s]),id(1)])\n", - "Sol 92: sub(cst(2),[sub(cst(1),[s]),s])\n", - "Sol 93: sub(cst(2),[sub(cst(0),[])])\n", - "Sol 94: sub(cst(2),[sub(cst(0),[]),cst(1)])\n", - "Sol 95: sub(cst(2),[sub(cst(0),[]),cst(0)])\n", - "Sol 96: sub(cst(2),[sub(cst(0),[]),id(1)])\n", - "Sol 97: sub(cst(2),[sub(cst(0),[]),s])\n", - "Sol 98: sub(cst(2),[sub(cst(0),[cst(1)])])\n", - "Sol 99: sub(cst(2),[sub(cst(0),[cst(1)]),cst(1)])\n", - "Sol 100: sub(cst(2),[sub(cst(0),[cst(1)]),cst(0)])\n", - "Sol 101: sub(cst(2),[sub(cst(0),[cst(1)]),id(1)])\n", - "Sol 102: sub(cst(2),[sub(cst(0),[cst(1)]),s])\n", - "Sol 103: sub(cst(2),[sub(cst(0),[cst(0)])])\n", - "Sol 104: sub(cst(2),[sub(cst(0),[cst(0)]),cst(1)])\n", - "Sol 105: sub(cst(2),[sub(cst(0),[cst(0)]),cst(0)])\n", - "Sol 106: sub(cst(2),[sub(cst(0),[cst(0)]),id(1)])\n", - "Sol 107: sub(cst(2),[sub(cst(0),[cst(0)]),s])\n", - "Sol 108: sub(cst(2),[sub(cst(0),[id(1)])])\n", - "Sol 109: sub(cst(2),[sub(cst(0),[id(1)]),cst(1)])\n", - "Sol 110: sub(cst(2),[sub(cst(0),[id(1)]),cst(0)])\n", - "Sol 111: sub(cst(2),[sub(cst(0),[id(1)]),id(1)])\n", - "Sol 112: sub(cst(2),[sub(cst(0),[id(1)]),s])\n", - "Sol 113: sub(cst(2),[sub(cst(0),[s])])\n", - "Sol 114: sub(cst(2),[sub(cst(0),[s]),cst(1)])\n", - "Sol 115: sub(cst(2),[sub(cst(0),[s]),cst(0)])\n", - "Sol 116: sub(cst(2),[sub(cst(0),[s]),id(1)])\n", - "Sol 117: sub(cst(2),[sub(cst(0),[s]),s])\n", - "Sol 118: sub(cst(2),[sub(id(1),[cst(1)])])\n", - "Sol 119: sub(cst(2),[sub(id(1),[cst(1)]),cst(1)])\n", - "Sol 120: sub(cst(2),[sub(id(1),[cst(1)]),cst(0)])\n", - "Sol 121: sub(cst(2),[sub(id(1),[cst(1)]),id(1)])\n", - "Sol 122: sub(cst(2),[sub(id(1),[cst(1)]),s])\n", - "Sol 123: sub(cst(2),[sub(id(1),[cst(0)])])\n", - "Sol 124: sub(cst(2),[sub(id(1),[cst(0)]),cst(1)])\n", - "Sol 125: sub(cst(2),[sub(id(1),[cst(0)]),cst(0)])\n", - "Sol 126: sub(cst(2),[sub(id(1),[cst(0)]),id(1)])\n", - "Sol 127: sub(cst(2),[sub(id(1),[cst(0)]),s])\n", - "Sol 128: sub(cst(2),[sub(id(1),[id(1)])])\n", - "Sol 129: sub(cst(2),[sub(id(1),[id(1)]),cst(1)])\n", - "Sol 130: sub(cst(2),[sub(id(1),[id(1)]),cst(0)])\n", - "Sol 131: sub(cst(2),[sub(id(1),[id(1)]),id(1)])\n", - "Sol 132: sub(cst(2),[sub(id(1),[id(1)]),s])\n", - "Sol 133: sub(cst(2),[sub(id(1),[s])])\n", - "Sol 134: sub(cst(2),[sub(id(1),[s]),cst(1)])\n", - "Sol 135: sub(cst(2),[sub(id(1),[s]),cst(0)])\n", - "Sol 136: sub(cst(2),[sub(id(1),[s]),id(1)])\n", - "Sol 137: sub(cst(2),[sub(id(1),[s]),s])\n", - "Sol 138: sub(cst(2),[sub(s,[cst(1)])])\n", - "Sol 139: sub(cst(2),[sub(s,[cst(1)]),cst(1)])\n", - "Sol 140: sub(cst(2),[sub(s,[cst(1)]),cst(0)])\n", - "Sol 141: sub(cst(2),[sub(s,[cst(1)]),id(1)])\n", - "Sol 142: sub(cst(2),[sub(s,[cst(1)]),s])\n", - "Sol 143: sub(cst(2),[sub(s,[cst(0)])])\n", - "Sol 144: sub(cst(2),[sub(s,[cst(0)]),cst(1)])\n", - "Sol 145: sub(cst(2),[sub(s,[cst(0)]),cst(0)])\n", - "Sol 146: sub(cst(2),[sub(s,[cst(0)]),id(1)])\n", - "Sol 147: sub(cst(2),[sub(s,[cst(0)]),s])\n", - "Sol 148: sub(cst(2),[sub(s,[id(1)])])\n", - "Sol 149: sub(cst(2),[sub(s,[id(1)]),cst(1)])\n", - "Sol 150: sub(cst(2),[sub(s,[id(1)]),cst(0)])\n", - "Sol 151: sub(cst(2),[sub(s,[id(1)]),id(1)])\n", - "Sol 152: sub(cst(2),[sub(s,[id(1)]),s])\n", - "Sol 153: sub(cst(2),[sub(s,[s])])\n", - "Sol 154: sub(cst(2),[sub(s,[s]),cst(1)])\n", - "Sol 155: sub(cst(2),[sub(s,[s]),cst(0)])\n", - "Sol 156: sub(cst(2),[sub(s,[s]),id(1)])\n", - "Sol 157: sub(cst(2),[sub(s,[s]),s])\n", - "Sol 158: sub(cst(2),[pr(cst(1),cst(1))])\n", - "Sol 159: sub(cst(2),[pr(cst(1),cst(1)),cst(1)])\n", - "Sol 160: sub(cst(2),[pr(cst(1),cst(1)),cst(0)])\n", - "Sol 161: sub(cst(2),[pr(cst(1),cst(1)),id(1)])\n", - "Sol 162: sub(cst(2),[pr(cst(1),cst(1)),s])\n", - "Sol 163: sub(cst(2),[pr(cst(1),cst(0))])\n", - "Sol 164: sub(cst(2),[pr(cst(1),cst(0)),cst(1)])\n", - "Sol 165: sub(cst(2),[pr(cst(1),cst(0)),cst(0)])\n", - "Sol 166: sub(cst(2),[pr(cst(1),cst(0)),id(1)])\n", - "Sol 167: sub(cst(2),[pr(cst(1),cst(0)),s])\n", - "Sol 168: sub(cst(2),[pr(cst(1),id(1))])\n", - "Sol 169: sub(cst(2),[pr(cst(1),id(1)),cst(1)])\n", - "Sol 170: sub(cst(2),[pr(cst(1),id(1)),cst(0)])\n", - "Sol 171: sub(cst(2),[pr(cst(1),id(1)),id(1)])\n", - "Sol 172: sub(cst(2),[pr(cst(1),id(1)),s])\n", - "Sol 173: sub(cst(2),[pr(cst(0),cst(1))])\n", - "Sol 174: sub(cst(2),[pr(cst(0),cst(1)),cst(1)])\n", - "Sol 175: sub(cst(2),[pr(cst(0),cst(1)),cst(0)])\n", - "Sol 176: sub(cst(2),[pr(cst(0),cst(1)),id(1)])\n", - "Sol 177: sub(cst(2),[pr(cst(0),cst(1)),s])\n", - "Sol 178: sub(cst(2),[pr(cst(0),cst(0))])\n", - "Sol 179: sub(cst(2),[pr(cst(0),cst(0)),cst(1)])\n", - "Sol 180: sub(cst(2),[pr(cst(0),cst(0)),cst(0)])\n", - "Sol 181: sub(cst(2),[pr(cst(0),cst(0)),id(1)])\n", - "Sol 182: sub(cst(2),[pr(cst(0),cst(0)),s])\n", - "Sol 183: sub(cst(2),[pr(cst(0),id(1))])\n", - "Sol 184: sub(cst(2),[pr(cst(0),id(1)),cst(1)])\n", - "Sol 185: sub(cst(2),[pr(cst(0),id(1)),cst(0)])\n", - "Sol 186: sub(cst(2),[pr(cst(0),id(1)),id(1)])\n", - "Sol 187: sub(cst(2),[pr(cst(0),id(1)),s])\n", - "Sol 188: sub(cst(1),[])\n", - "Sol 189: sub(cst(1),[cst(2)])\n", - "Sol 190: sub(cst(1),[cst(2),cst(1)])\n", - "Sol 191: sub(cst(1),[cst(2),cst(0)])\n", - "Sol 192: sub(cst(1),[cst(2),id(1)])\n", - "Sol 193: sub(cst(1),[cst(2),s])\n", - "Sol 194: sub(cst(1),[cst(1)])\n", - "Sol 195: sub(cst(1),[cst(1),cst(1)])\n", - "Sol 196: sub(cst(1),[cst(1),cst(0)])\n", - "Sol 197: sub(cst(1),[cst(1),id(1)])\n", - "Sol 198: sub(cst(1),[cst(1),s])\n", - "Sol 199: sub(cst(1),[cst(0)])\n", - "Sol 200: sub(cst(1),[cst(0),cst(1)])" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "\u001b[1mFunction = sub(cst(1),[cst(0),cst(1)])" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ " ?- set_limit(200),gen_valid_pr_fun(Function),print_sol(Function)." ] }, { "cell_type": "code", - "execution_count": 109, - "id": "4d80d79e", + "execution_count": null, + "id": "b0a399f5", "metadata": {}, "outputs": [], "source": [ @@ -1493,8 +974,8 @@ }, { "cell_type": "code", - "execution_count": 110, - "id": "dba239a4", + "execution_count": null, + "id": "bad6c5af", "metadata": {}, "outputs": [], "source": [ @@ -1512,104 +993,38 @@ }, { "cell_type": "code", - "execution_count": 111, - "id": "d13019d5", + "execution_count": null, + "id": "666db331", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Running program 1 on input 2.\n", - "Program = cst(0)\n", - "Computing cst(0) with [2]\n", - "Result: 0" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "\u001b[1mRes = 0" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "?- upr(1,2,Res)." ] }, { "cell_type": "code", - "execution_count": 112, - "id": "2406f7bc", + "execution_count": null, + "id": "75688555", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Running program 10 on input 2.\n", - "Program = id(1)\n", - "Computing id(1) with [2]\n", - "Result: 2" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "\u001b[1mRes = 2" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ - "?- upr(10,2,Res)." + "?- upr(27,27,Res)." ] }, { "cell_type": "code", - "execution_count": 113, - "id": "3ffd9e1e", + "execution_count": null, + "id": "c7a960ac", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Running program 10 on input 10.\n", - "Program = id(1)\n", - "Computing id(1) with [10]\n", - "Result: 10" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "\u001b[1mRes = 10" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ - "?- upr(10,10,Res)." + "?- upr(100,100,Res)." ] }, { "cell_type": "code", - "execution_count": 114, - "id": "3042f06f", + "execution_count": null, + "id": "77dee3fe", "metadata": {}, "outputs": [], "source": [ @@ -1619,40 +1034,43 @@ }, { "cell_type": "code", - "execution_count": 115, - "id": "e23973dc", + "execution_count": null, + "id": "8a1a1a6c", + "metadata": {}, + "outputs": [], + "source": [ + "?- f(2000,R)." + ] + }, + { + "cell_type": "markdown", + "id": "4bbfd121", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Running program 10 on input 10.\n", - "Program = id(1)\n", - "Computing id(1) with [10]\n", - "Result: 10" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "\u001b[1mR = 11" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], "source": [ - "?- f(10,R)." + "Diese Funktion f ist total und offensichtlich berechenbar (wir haben die Funktion gerade implementiert), kann aber nicht primitiv rekursiv sein.\n", + "Denn wenn sie primitiv rekursiv wäre, hätte sie eine Nummer n und für diese Nummer n hätten wir dann den Widerspruch ```f(n) = f(n)+1```." + ] + }, + { + "cell_type": "markdown", + "id": "37538849", + "metadata": {}, + "source": [ + "### Geschichte\n", + "\n", + "Auszug aus (https://en.wikipedia.org/wiki/Primitive_recursive_function):\n", + "\n", + "Recursive definitions had been used more or less formally in mathematics before, but the construction of primitive recursion is traced back to Richard Dedekind's theorem 126 of his Was sind und was sollen die Zahlen? (1888). This work was the first to give a proof that a certain recursive construction defines a unique function.[8][9][10]\n", + "\n", + "Primitive recursive arithmetic was first proposed by Thoralf Skolem[11] in 1923.\n", + "\n", + "The current terminology was coined by Rózsa Péter (1934) after Ackermann had proved in 1928 that the function which today is named after him was not primitive recursive, an event which prompted the need to rename what until then were simply called recursive functions.[9][10]" ] }, { "cell_type": "code", "execution_count": null, - "id": "0ed724d0", + "id": "e09fefc6", "metadata": {}, "outputs": [], "source": [] -- GitLab