{"id":9425,"date":"2020-08-25T07:37:15","date_gmt":"2020-08-25T07:37:15","guid":{"rendered":"https:\/\/www.experfy.com\/blog\/?p=9425"},"modified":"2023-11-15T16:20:52","modified_gmt":"2023-11-15T16:20:52","slug":"knowledge-representation-and-reasoning-with-answer-set-programming","status":"publish","type":"post","link":"https:\/\/www.experfy.com\/blog\/ai-ml\/knowledge-representation-and-reasoning-with-answer-set-programming\/","title":{"rendered":"Knowledge Representation And Reasoning With Answer Set Programming"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"9425\" class=\"elementor elementor-9425\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"has_eae_slider elementor-section elementor-top-section elementor-element elementor-element-4f0f6778 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"4f0f6778\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"has_eae_slider elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-73828acf\" data-id=\"73828acf\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-48b314ad elementor-widget elementor-widget-text-editor\" data-id=\"48b314ad\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\n<p class=\"has-normal-font-size\"><em>Read about the difference between declarative and imperative programming and learn from code examples (Answer Set Programming, Python and C).<\/em><\/p>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c47699a elementor-widget elementor-widget-heading\" data-id=\"c47699a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Introduction<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f325a92 elementor-widget elementor-widget-text-editor\" data-id=\"f325a92\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>The amount of computational problems seems to be unlimited in both industry and science. There is a huge demand for new insights from the vast amount of available data. To obtain this knowledge, dedicated people use all kinds of programming languages for designing and implementing algorithms.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>However, many of the current real-world problems are complex (combinatorial) search problems with which we try to automate and optimize processes as well as support people in their decisions. This does not involve encoding of algorithms but encoding\u00a0<em>given knowledge<\/em>. In other words, given knowledge about all the rules and constraints to be considered to what is counted as a solution. Instead of writing statements describing the control flow of a computation, declarative programming expresses its logic.\u00a0<em>What<\/em>\u00a0do we want to achieve, not statements about\u00a0<em>how<\/em>\u00a0we can achieve it.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>This is called declarative programming.<\/p>\n<!-- \/wp:paragraph -->\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1deaf85 elementor-widget elementor-widget-heading\" data-id=\"1deaf85\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Why declarative programming?<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6d7807c elementor-widget elementor-widget-text-editor\" data-id=\"6d7807c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Using a promising declarative programming paradigm, namely Answer Set Programming (ASP, sometimes also Answer Set Prolog), offers unexpected advantages over the popular imperative programming approach, for example:<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:list -->\n<ul>\n<li>Short solutions (as measured by lines of code)<\/li>\n<li>Transparency (including readability)<\/li>\n<li>Reliability<\/li>\n<\/ul>\n<!-- \/wp:list -->\n\n<!-- wp:paragraph -->\n<p>and many more. Once you have broken the problem down into its smallest pieces and written down all the necessary knowledge, you will not only solve the computational challenge. A big advantage is that you have digitized the knowledge and can use it for further problems or make it available in other ways.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:quote -->\n<blockquote class=\"wp-block-quote\">\n<p>Experience and knowledge can be sustainably secured and protected against loss (e.g. through retirement or termination of employees).<\/p>\n<\/blockquote>\n<!-- \/wp:quote -->\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-79480a9 elementor-widget elementor-widget-text-editor\" data-id=\"79480a9\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Furthermore, it strengthens the cooperation between \u2018business people\u2019 and programmers. The integration of artificial intelligence is supported and acceptance at all levels will increase. This is a fundamental process that can only be achieved in cooperation with all departments of a company.<\/p>\n<!-- \/wp:paragraph -->\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-528be0e elementor-widget elementor-widget-heading\" data-id=\"528be0e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">What is ASP and how does it work?<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2ebb8c0 elementor-widget elementor-widget-text-editor\" data-id=\"2ebb8c0\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>An answer set program consists of given knowledge formulated as facts, rules (<code>head(X) :- body(X).<\/code>) or constraints. The program is loaded by a solver and returns a \u201cstable model\u201d. This so called\u00a0<em>answer set<\/em>\u00a0consists of all facts that can be derived using the given rules and constraints. A finite amount of stable models are generated as solutions, of which one is finally selected.<br \/><strong><em>Note:\u00a0<\/em><\/strong><em>grounding and solving the problems are not within the scope of this article.<\/em><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Let us consider a famous example from logic about birds and penguins. It is a well known fact that birds can fly. This can be encoded as an answert set rule:<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:preformatted -->\n<pre class=\"wp-block-preformatted\">canFly(X) :- bird(X).<\/pre>\n<!-- \/wp:preformatted -->\n\n<!-- wp:paragraph -->\n<p>The rule is read as\u00a0<em>\u201cIf\u00a0<\/em><code><em>X<\/em><\/code><em>\u00a0is a bird, then\u00a0<\/em><code><em>X<\/em><\/code><em>\u00a0can fly\u201d<\/em>. Now let\u2019s add more knowledge! For example, facts that tell the unconditional truth, just as seagull \u2018Malvin\u2019 is a bird, but also penguin \u2018Roger\u2019 is one.<\/p>\n<!-- \/wp:paragraph -->\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-18cbecc elementor-widget elementor-widget-text-editor\" data-id=\"18cbecc\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<!-- wp:preformatted -->\n<pre class=\"wp-block-preformatted\">canFly(X) :- bird(X).<br \/>bird(malvin).<br \/>bird(roger).== MODEL OUTPUT ==<br \/>Anwer: 1<br \/>bird(malvin) bird(roger) canFly(malvin) canFly(roger)<br \/>SATISFIABLE<\/pre>\n<!-- \/wp:preformatted -->\n\n<!-- wp:paragraph -->\n<p>As a result, the answer set tells us the known facts that Malvin and Roger are birds but also concluded that they are able to fly. The biology enthusiasts among us know, that penguins are unable to fly thus the model is wrong!<\/p>\n<!-- \/wp:paragraph -->\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7e1a749 elementor-widget elementor-widget-image\" data-id=\"7e1a749\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/3127\/0*-a2Z4y7ZnQ4Y83Cw\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-23f8e69 elementor-widget elementor-widget-text-editor\" data-id=\"23f8e69\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>In order to get acceptable results we need to add more knowledge in form of facts and integrity constraints to the program. Here, the model needs to know that Roger is not only a bird but also a penguin and that there is no bird that is a penguin which is able to fly.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:preformatted -->\n<pre class=\"wp-block-preformatted\">canFly(X) :- bird(X).<br \/>bird(malvin).<br \/>bird(roger).<br \/>seagull(malvin).<br \/>penguin(roger).<br \/>:- canFly(X), penguin(X).== MODEL OUTPUT ==<br \/>UNSATISFIABLE<\/pre>\n<!-- \/wp:preformatted -->\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f5856f1 elementor-widget elementor-widget-text-editor\" data-id=\"f5856f1\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>This does not bring the expected result and shows how important it is to think thoroughly and very carefully about the problem as well as the solution. The model tells, like stated by the programmer, that a bird can fly but there is no advise for birds that belong to the penguin family. To avoid this, we could add that only birds that are not penguins are able to fly.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:preformatted -->\n<pre class=\"wp-block-preformatted\">canFly(X) :- bird(X), not penguin(X).<br \/>bird(malvin).<br \/>bird(roger).<br \/>seagull(malvin).<br \/>penguin(roger).<br \/>:- canFly(X), penguin(X).== MODEL OUTPUT ==<br \/>Answer: 1<br \/>bird(malvin) bird(roger) seagull(malvin) penguin(roger) canFly(malvin)<br \/>SATISFIABLE<\/pre>\n<!-- \/wp:preformatted -->\n\n<!-- wp:paragraph -->\n<p>Adding this knwoledge in Line [1], the stable model consists of the expected outcome.<\/p>\n<!-- \/wp:paragraph -->\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-eb963c7 elementor-widget elementor-widget-heading\" data-id=\"eb963c7\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Imperative versus declarative programming<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4189deb elementor-widget elementor-widget-heading\" data-id=\"4189deb\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\"><h3 id=\"4d1c\">.. for solving Sudoku<\/h3>\n<!-- \/wp:heading -->\n<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c9eea6c elementor-widget elementor-widget-text-editor\" data-id=\"c9eea6c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Let\u2019s look at another example to highlight the advantages of ASP mentioned above. Sudoku is a well known puzzle game and popular for explaining search problems. Given an initial 9&#215;9 grid of cells containig numbers between 1 and 9 or blanks, all blanks must be filled with numbers. You win Sudoko if you find all values such that every row, column, and 3&#215;3 subsquare contains the numbers 1\u20139, each with a single occurrence.<\/p>\n<!-- \/wp:paragraph -->\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-01baa51 elementor-widget elementor-widget-text-editor\" data-id=\"01baa51\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<!-- wp:image {\"align\":\"center\"} -->\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/1780\/1*LBBgLEQLc-NEIjrK6Hd3xQ.png\" alt=\"Knowledge Representation And Reasoning With Answer Set Programming\" \/>\n<figcaption>Exemplary Sudoku game (adopted from Potassco.org).<\/figcaption>\n<\/figure>\n<\/div>\n<!-- \/wp:image -->\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9dfd44a elementor-widget elementor-widget-heading\" data-id=\"9dfd44a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\"><h3 id=\"3660\">Python (imperative)<\/h3>\n<!-- \/wp:heading --><\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9f02d20 elementor-widget elementor-widget-text-editor\" data-id=\"9f02d20\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<!-- wp:paragraph -->\n<p>The following Code snippet will show how to solve the Sudoku in Python.<\/p>\n<!-- \/wp:paragraph -->\n<!-- wp:image {\"align\":\"center\",\"id\":9430,\"sizeSlug\":\"large\"} -->\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\">Knowledge Representation And Reasoning With Answer Set Programming<\/figure>\n<\/div>\n<!-- \/wp:image -->\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-15ce2e2 elementor-widget elementor-widget-heading\" data-id=\"15ce2e2\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\"><h3 id=\"67f6\">C (imperative)<\/h3><\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-85a0ea1 elementor-widget elementor-widget-text-editor\" data-id=\"85a0ea1\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Solving the Sudoku game in C looks very similar to <a href=\"https:\/\/www.experfy.com\/blog\/python-data-science\/\" target=\"_blank\" rel=\"noreferrer noopener\">Python<\/a>. There is no significant difference in the approach.<\/p>\n<!-- \/wp:paragraph -->\n<!-- wp:image {\"align\":\"center\",\"id\":9432,\"width\":684,\"height\":541,\"sizeSlug\":\"large\"} -->\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\">Solving the Sudoku game in C looks very similar to Python<\/figure>\n<\/div>\n<!-- \/wp:image -->\n<!-- wp:paragraph -->\n<p>Both, Python and C, show written statements describing the control flow of a computation, thus, the \u2018<em>how to solve it\u2019\u00a0<\/em>and how the state has to be changed for the upcoming step.<\/p>\n<!-- \/wp:paragraph -->\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-42e7e60 elementor-widget elementor-widget-heading\" data-id=\"42e7e60\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\"><h3 id=\"8bc9\">ASP (declarative)<\/h3>\n<!-- \/wp:heading -->\n<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ea49921 elementor-widget elementor-widget-text-editor\" data-id=\"ea49921\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<!-- wp:paragraph -->\n<p>Last but no least, let\u2019s have a look at the ASP code snippet \u2014 after initalization, we are able to solve the Sudoku with<strong>\u00a0less than 10 lines of code<\/strong>!<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:preformatted -->\n<pre class=\"wp-block-preformatted\">% Initialize the game (given numbers)<br \/>sudoku(1, 1, 5).<br \/>sudoku(1, 2, 3).<br \/>sudoku(1, 5, 7).<br \/>sudoku(2, 1, 6).<br \/>sudoku(2, 4, 1).<br \/>sudoku(2, 5, 9).<br \/>sudoku(2, 6, 5).<br \/>sudoku(3, 2, 9).<br \/>sudoku(3, 3, 8).<br \/>sudoku(3, 8, 6).<br \/>sudoku(4, 1, 8).<br \/>sudoku(4, 5, 6).<br \/>sudoku(4, 9, 3).<br \/>sudoku(5, 1, 4).<br \/>sudoku(5, 4, 8).<br \/>sudoku(5, 6, 3).<br \/>sudoku(5, 9, 1).<br \/>sudoku(6, 1, 7).<br \/>sudoku(6, 5, 2).<br \/>sudoku(6, 9, 6).<br \/>sudoku(7, 2, 6).<br \/>sudoku(7, 7, 2).<br \/>sudoku(7, 8, 8).<br \/>sudoku(8, 4, 4).<br \/>sudoku(8, 5, 1).<br \/>sudoku(8, 6, 9).<br \/>sudoku(8, 9, 5).<br \/>sudoku(9, 5, 8).<br \/>sudoku(9, 8, 7).<br \/>sudoku(9, 9, 9).<br \/>% define the grid<br \/>n(1..9).<br \/>x(1..9).<br \/>y(1..9).% each field contains exactly one number from 1 to 9<br \/>{sudoku(X,Y,N): n(N)} = 1 :- x(X) ,y(Y).% helper<br \/>subgrid(X,Y,A,B) :- x(X), x(A), y(Y), y(B),(X-1)\/3 == (A-1)\/3, (Y-1)\/3 == (B-1)\/3.% constraints<br \/>:- sudoku(X,Y,N), sudoku(A,Y,N), X!=A.<br \/>:- sudoku(X,Y,N), sudoku(X,B,N), Y!=B.<br \/>:- sudoku(X,Y,V), sudoku(A,B,V), subgrid(X,Y,A,B), X != A, Y != B.#show sudoku\/3.== MODEL OUTPUT ==<br \/>Answer: 1<br \/>('sudoku', (2, 1, 6)), ('sudoku', (1, 2, 3)), ('sudoku', (9, 4, 2)), ('sudoku', (7, 2, 6)), ('sudoku', (7, 3, 1)), ('sudoku', (1, 9, 2)), ('sudoku', (5, 1, 4)), ('sudoku', (7, 4, 5)), ('sudoku', (4, 3, 9)), ('sudoku', (9, 1, 3)), ('sudoku', (4, 5, 6)), ('sudoku', (5, 6, 3)), ('sudoku', (2, 4, 1)), ('sudoku', (8, 1, 2)), ('sudoku', (8, 8, 3)), ('sudoku', (7, 9, 4)), ('sudoku', (8, 7, 6)), ('sudoku', (5, 4, 8)), ('sudoku', (7, 6, 7)), ('sudoku', (8, 6, 9)), ('sudoku', (6, 5, 2)), ('sudoku', (9, 7, 1)), ('sudoku', (3, 4, 3)), ('sudoku', (4, 7, 4)), ('sudoku', (3, 3, 8)), ('sudoku', (4, 8, 2)), ('sudoku', (1, 7, 9)), ('sudoku', (9, 9, 9)), ('sudoku', (9, 8, 7)), ('sudoku', (5, 9, 1)), ('sudoku', (4, 4, 7)), ('sudoku', (6, 9, 6)), ('sudoku', (7, 7, 2)), ('sudoku', (2, 7, 3)), ('sudoku', (5, 5, 5)), ('sudoku', (1, 5, 7)), ('sudoku', (1, 1, 5)), ('sudoku', (6, 3, 3)), ('sudoku', (2, 6, 5)), ('sudoku', (2, 9, 8)), ('sudoku', (8, 3, 7)), ('sudoku', (3, 6, 2)), ('sudoku', (3, 8, 6)), ('sudoku', (2, 8, 4)), ('sudoku', (1, 3, 4)), ('sudoku', (8, 2, 8)), ('sudoku', (3, 7, 5)), ('sudoku', (9, 5, 8)), ('sudoku', (4, 9, 3)), ('sudoku', (6, 4, 9)), ('sudoku', (7, 5, 3)), ('sudoku', (2, 5, 9)), ('sudoku', (8, 5, 1)), ('sudoku', (5, 3, 6)), ('sudoku', (4, 6, 1)), ('sudoku', (3, 9, 7)), ('sudoku', (1, 4, 6)), ('sudoku', (9, 2, 4)), ('sudoku', (5, 8, 9)), ('sudoku', (1, 8, 1)), ('sudoku', (6, 6, 4)), ('sudoku', (5, 7, 7)), ('sudoku', (7, 1, 9)), ('sudoku', (3, 5, 4)), ('sudoku', (6, 8, 5)), ('sudoku', (5, 2, 2)), ('sudoku', (2, 3, 2)), ('sudoku', (8, 9, 5)), ('sudoku', (9, 6, 6)), ('sudoku', (9, 3, 5)), ('sudoku', (6, 2, 1)), ('sudoku', (3, 1, 1)), ('sudoku', (4, 2, 5)), ('sudoku', (6, 1, 7)), ('sudoku', (4, 1, 8)), ('sudoku', (8, 4, 4)), ('sudoku', (2, 2, 7)), ('sudoku', (3, 2, 9)), ('sudoku', (1, 6, 8)), ('sudoku', (6, 7, 8)), ('sudoku', (7, 8, 8))}<br \/>SATISFIABLE<\/pre>\n<!-- \/wp:preformatted -->\n\n<!-- wp:paragraph -->\n<p><strong><em>Note<\/em><\/strong><em>: using for example a Python wrapper for ASP, the result can look as handy as in the code examples above.<\/em><\/p>\n<!-- \/wp:paragraph -->\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9382427 elementor-widget elementor-widget-text-editor\" data-id=\"9382427\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Compared to Python and C, this is all about the \u2018what\u2019 and not about the \u2018how\u2019 \u2014 a fundamental difference between the two approaches.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>At the very beginning, we define that the Sudoku board is 9&#215;9 cells (or fields) and we use the numbers from 1 to 9 as the values to fill in. Following the basic rule that only one number between 1 and 9 may be filled in each field, we define a little helper. It states which fields refer to the same\u00a0<em>sub-grid<\/em>. Finally, we only need the constraints to tell the solver what is possible and what is not. The first line checks, whether the choosen number is unique in the row whereas the second constraint checks the rule for columns. The third constraint completes the rules of the game, according to which a number must also be unique in the subgrid.<\/p>\n<!-- \/wp:paragraph -->\n<!-- wp:paragraph -->\n<p>That was it. I admit the syntax takes getting used to. But once you\u2019re familiar with it, you can create incredibly readable programs that solve highly complex problems for us.<\/p>\n<!-- \/wp:paragraph -->\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5155dc5 elementor-widget elementor-widget-heading\" data-id=\"5155dc5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2 id=\"140f\">Summary<\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-33fb8fe elementor-widget elementor-widget-text-editor\" data-id=\"33fb8fe\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>ASP is a very promising tool for knowledge preservation and declarative problem solving in the area of Knowledge Representation and Reasoning.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p><strong>Short solutions<\/strong>\u00a0\u2014 Apart from the initial effort to map the Sudoku game, ASP provides by far the shortest way (measured in lines of code) to the solution.<br \/><strong>Transparency<\/strong>\u00a0\u2014 There is no need to create rules which are unclear to the user and which concern the status of the programme. Only the basic conditions and the three rules of the game must be coded in order to end up at the correct result.<br \/><strong>Reliability<\/strong>\u00a0\u2014 All rules of the game are fixed and the solver cannot create a black box with solution steps that are not traceable afterwards. This may not be important in the example given, but it is a major issue in many industrial applications.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>To mention only a few real-world examples, decision support for space shuttles at NASA, train scheduling in Switzerland \u2014 one of the world\u2019s densest train network\u2014 , or team building at the largest transshipment terminal on the Mediterranean coast are evidence of its potential.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:separator --><hr class=\"wp-block-separator\" \/><!-- \/wp:separator -->\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-dc6ca97 elementor-widget elementor-widget-heading\" data-id=\"dc6ca97\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Bottom Line<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3710e7b elementor-widget elementor-widget-text-editor\" data-id=\"3710e7b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>The acceptance of artificial intelligence in industry is still very low. In addition, many companies are simply overwhelmed by the existing flood of data.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:quote -->\n<blockquote class=\"wp-block-quote\">\n<p>Bring the knowledge of operational subject matter experts together with the strengths of Artificial Intelligence.<\/p>\n<\/blockquote>\n<!-- \/wp:quote -->\n\n<!-- wp:paragraph -->\n<p>ASP offers an unique opportunity to digitalize and protect existing knowledge. Due to the good readability and the required understanding of the process as well as the problem to be solved, IT and business move closer together and thus achieve better and more sustainable success.<\/p>\n<!-- \/wp:paragraph -->\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>The amount of computational problems seems to be unlimited in both industry and science. There is a huge demand for new insights from the vast amount of available data. To obtain this knowledge, dedicated people use all kinds of programming languages for designing and implementing algorithms. <\/p>\n","protected":false},"author":894,"featured_media":9426,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","footnotes":""},"categories":[183],"tags":[574,837,408,575],"ppma_author":[3900],"class_list":["post-9425","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai-ml","tag-knowledge","tag-knowledge-representation","tag-programming","tag-reasoning"],"authors":[{"term_id":3900,"user_id":894,"is_guest":0,"slug":"natalie-kuster","display_name":"Natalie Kuster","avatar_url":"https:\/\/www.experfy.com\/blog\/wp-content\/uploads\/2020\/08\/0-3-150x150.jpg","user_url":"","last_name":"Kuster","first_name":"Natalie","job_title":"","description":"Natalie Kuster, Artificial Intelligence Researcher, is Founder &amp; Managing Director at  Kuster Algorithmics and holds a Master's degree in Atmospheric and Climate Science from the Swiss Federal Institute of Technology (ETH) in Zurich. She works in interdisciplinary teams dealing with a variety of complex problems within different industries as well as part-time honorary lecturer, bringing a wide range of experience and knowledge to the table."}],"_links":{"self":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts\/9425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/users\/894"}],"replies":[{"embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/comments?post=9425"}],"version-history":[{"count":9,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts\/9425\/revisions"}],"predecessor-version":[{"id":34116,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts\/9425\/revisions\/34116"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/media\/9426"}],"wp:attachment":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/media?parent=9425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/categories?post=9425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/tags?post=9425"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=9425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}