probasp.tex 42.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203
% !TeX program=xelatex
\documentclass[bigger,xcolor={x11names,svgnames}]{beamer}

\useinnertheme{circles}
\usefonttheme[onlymath]{serif}
\usefonttheme{structurebold}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}[frame number]
%\usepackage[x11names,usenames]{xcolor}
\setbeamercolor{highlight block}{bg=gray}
\setbeamercolor{alerted text}{fg=Crimson}
\usepackage{tikz}
\usetikzlibrary{
automata,%
positioning,%
calc,%
patterns,
decorations,%
decorations.pathmorphing,%
arrows.meta,
shapes.misc
}
\tikzset{
    vert/.style={draw, circle, inner sep=2pt},
    event/.style={},
    smodel/.style={fill=gray!25},
    tchoice/.style={draw, circle},
    indep/.style={},%{draw, dashed},
    proptc/.style = {-latex, dashed},
    propsm/.style = {-latex, thick},
    doubt/.style = {gray}
}

\usepackage{tkz-graph}
\newcommand{\qlr}[2]{\ensuremath{\begin{matrix}#1\cr\begin{aligned}\hline #2\end{aligned}\end{matrix}}}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[normalem]{ulem} % To strikeout
\usepackage{commath}
\usepackage{amssymb}
\usepackage[normalem]{ulem}
\usepackage[nice]{nicefrac}
\usepackage{stmaryrd}
\usepackage{acronym}
\usepackage{multicol}
\usepackage{cleveref}

\usepackage{listings}

\newcommand{\at}[1]{\ensuremath{\!\del{#1}}}
\newcommand{\class}[1]{\ensuremath{[{#1}]_{\sim}}}
\newcommand{\co}[1]{\ensuremath{\overline{#1}}}
\newcommand{\condsymb}[2]{\ensuremath{p_{#1|#2}}}
\newcommand{\cset}[2]{\ensuremath{\set{#1,~#2}}}
\newcommand{\deft}[1]{\textbf{#1}}
\newcommand{\emptyevent}{\ensuremath{\vartriangle}}
\newcommand{\ent}{\ensuremath{\lhd}}
\newcommand{\err}[1]{\ensuremath{\mathrm{err}\at{#1}}}
\newcommand{\fml}[1]{\ensuremath{{\cal #1}}}
\newcommand{\given}{\ensuremath{~\middle|~}}
\newcommand{\inconsistent}{\bot}
\newcommand{\indepclass}{\ensuremath{\Diamond}}
\newcommand{\isep}{~,~}
\newcommand{\langof}[1]{\ensuremath{\fml{L}\at{#1}}}
\newcommand{\larr}{\ensuremath{\leftarrow}}
\newcommand{\lclass}[1]{\ensuremath{\intoc{#1}}}
\newcommand{\lfrac}[2]{\ensuremath{{#1}/{#2}}}
\newcommand{\lrep}[1]{\ensuremath{\rep{}{#1}}}
\newcommand{\lset}[1]{\ensuremath{#1_{\ast}}}
\newcommand{\naf}{\ensuremath{\sim\!}}
\newcommand{\pr}[1]{\ensuremath{\mathrm{P}\at{#1}}}
\newcommand{\probfact}[2]{\ensuremath{#2:#1}}
\newcommand{\probrule}[3]{\probfact{#2}{#1} \leftarrow #3}
\newcommand{\pset}[1]{\ensuremath{\mathbb{P}\at{#1}}}
\newcommand{\pw}[1]{\ensuremath{\mu\at{#1}}}
\newcommand{\pwc}[1]{\ensuremath{\pwcfname\at{#1}}}
\newcommand{\pwcfname}{\ensuremath{\mu_{\textrm{TC}}}}
\newcommand{\q}[1]{\mathbf{#1}}
\newcommand{\rep}[2]{\ensuremath{\left\langle #1 \middle| #2 \right\rangle}}
\newcommand{\smclass}[1]{\ensuremath{\intcc{#1}}}
\newcommand{\stablecore}[1]{\ensuremath{\left\llbracket #1 \right\rrbracket}}
\newcommand{\tcgen}[1]{\ensuremath{\left<#1\right>}}
\newcommand{\uclass}[1]{\ensuremath{\intco{#1}}}
\newcommand{\urep}[1]{\ensuremath{\rep{#1}{}}}
\newcommand{\uset}[1]{\ensuremath{#1^{\ast}}}
\newcommand{\yset}[1]{\ensuremath{\left\langle #1 \right\rangle}}
%\newcommand{\tcgen}[1]{\ensuremath{\widehat{#1}}}

\title{Stochastic Answer Set Programming}
\subtitle{A Research Program}
\author{Francisco Coelho}
\date{November 15, 2023}
\institute[\texttt{fc@uevora.pt}]{
NOVA LINCS\\
High Performance Computing Chair\\
Departamento de Informática, Universidade de Évora
}
%
%===============================================================
%
\begin{document}
%
\lstset{language=Prolog}
%
%===============================================================
%
\begin{frame}[plain]
    \titlepage

    \begin{center}
        \footnotesize This is a join work with \textbf{Salvador Abreu}@DInf and \textbf{Bruno Dinis}@DMat.
    \end{center}
\end{frame}
%
%===============================================================
%
\section*{Motivation}
%
%===============================================================
%
\begin{frame}
    \frametitle{In Short}


    \begin{itemize}
        \item About \textbf{Machine Learning}:
              \begin{itemize}
                  \item Vector or matrix based models lack ``structure''.
                  \item Large models don't \emph{explain} data.
              \end{itemize}
        \item About \textbf{Logic Programs}:
              \begin{itemize}
                  \item Logic programs formalize knowledge.
                  \item Logic doesn't \emph{capture} uncertainty and is \emph{fragile} to noise.
              \end{itemize}
        \item \textbf{Probabilistic Logic Programs} extend formal knowledge with probabilities.
              \begin{itemize}
                  \item How to propagate probabilities through rules?
              \end{itemize}
    \end{itemize}
    \vfill
    \begin{center}
        \alert{\bf Goal:} Combine Logic and Statistics.
    \end{center}   
\end{frame}
%
%===============================================================
% \begin{frame}
%     %-------------------------------------------------------------
%     %[fragile]
%     %-------------------------------------------------------------
%     \frametitle{Statistics and Machine Learning}
%     %-------------------------------------------------------------
%     \vfill
%     \begin{itemize}
%         \item \textbf{Data Analysis:} understand and summarize.
%         \item \textbf{Model Building:} tools and techniques.
%         \item \textbf{Model Evaluation:} performance.
%         \item []
%         \item To calculate the accuracy/precision/recall of a model.
%         \item To choose the right model for a problem.
%         \item To tune the hyperparameters of a model.
%     \end{itemize}
%     \vfill
%     \begin{center}\footnotesize
%         Highlights of \texttt{Bard}'s (Google's LLM) reply to ``Explain what is the role of statistics in machine learning''.
%     \end{center}
% \end{frame}
%
%===============================================================
%
\section{Machine Learning}
%
%===============================================================
\begin{frame}
    %------------------------------------------------------------- %-------------------------------------------------------------
    \frametitle{}
    %-------------------------------------------------------------
    \begin{center}
        \vfill
        {\huge\bf Machine Learning}
    \end{center}
    \vfill
    \begin{itemize}
        \item Standard Example --- Iris Classification
        \item Assumptions of Machine Learning
        \item Where Machine Learning Fails
    \end{itemize}
    \vfill
    %-------------------------------------------------------------
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{The Standard Example --- Iris Classification}
    %-------------------------------------------------------------
    \small
    \begin{center}
        Learning Functions: \href{https://en.wikipedia.org/wiki/Iris_flower_data_set}{The famous Iris database}
    \end{center}
    \begin{columns}
        \column{0.4\textwidth}
        \begin{itemize}\setlength{\itemsep}{-0.5em}
            \item[$x_1$] sepal length.
            \item[$x_2$] sepal width.
            \item[$x_3$] petal length.
            \item[$x_4$] petal width.
            \item[$y$] species (one of \emph{setosa}, \emph{versicolor}, \emph{virginica}).
        \end{itemize}
        \column{0.6\textwidth}
        \begin{center}
            \includegraphics[width=\textwidth]{iris_plot.pdf}
        \end{center}
    \end{columns}
    \vfill
    \begin{itemize}
        \item A \emph{setosa} model: $ - 0.40 -0.65x_1 + 1.00x_2  > 0.00$.
        \item A general \textbf{model template}:
              $$
                  f_\theta(\vec{x}) = \theta_0 + \theta_1 x_1 + \theta_2 x_2 + \theta_3 x_3 + \theta_4 x_4> 0
              $$
    \end{itemize}
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Assumptions of Machine Learning}
    %-------------------------------------------------------------
    \begin{itemize}
        \item Each instance is described in a \textbf{single row} by a \textbf{fixed set of features}
              $$
                  \begin{array}{cccc|c}
                      \mathbf{x_1} & \mathbf{x_2} & \ldots & \mathbf{x_n} & \mathbf{y} \\
                      \hline
                      x_{11}       & x_{21}       & \ldots & x_{n1}       & y_1        \\
                                   &              & \vdots                             \\
                      x_{1m}       & x_{2m}       & \ldots & x_{nm}       & y_m        \\
                  \end{array}
                  .$$
        \item Instances are \textbf{independent} of one another, \textbf{given the model}
              $$
                  y = f_\theta(\vec{x}).
              $$
        \item Parameters \textbf{minimize estimation error} \emph{e.g.}
              $$
                  \hat{\theta} = \arg\min_\theta \sum_i \norm{y_i - f_\theta(\vec{x_{i}})}.
              $$
    \end{itemize}
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Failing Assumptions\hfill~1/2}
    %-------------------------------------------------------------
    \vfill
    \begin{columns}[c]
        \column{0.5\textwidth}
        $$
            \begin{array}{ccc}
                \text{student} & \text{course} & \text{grade} \\
                \hline
                s_1            & c_1           & a            \\
                s_2            & c_1           & c            \\
                s_1            & c_2           & b            \\
                s_2            & c_3           & b            \\
                s_3            & c_2           & b            \\
                s_4            & c_3           & b            \\
                s_3            & c_4           & X            \\
                s_4            & c_4           & Y            \\
            \end{array}
        $$
        \column{0.5\textwidth}
        \emph{Infer $X \succ_g Y$.}

        \bigskip
        ``\emph{Proof.}'' 

            \bigskip
            $s_1 \succ_s s_2$ (rows 1 \& 2)\\ so $c_2 \succ_c c_3$ (3 \& 4). 
            
            \bigskip
            Then $s_3 \succ_s s_4$ (5 \& 6)\\ therefore $X \succ_g Y\qed$.
    \end{columns}
    \vfill
    \begin{itemize}
        \item Instances are not independent.
        \item Small dataset, so \emph{no statistics}.
    \end{itemize}
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Failing Assumptions\hfill~2/2}
    %-------------------------------------------------------------
    \footnotesize
    \begin{center}
        \textbf{Prompt:} Given \texttt{f(machine) = e}, \texttt{f(learning) = g} and \texttt{f(algorithm) = m}, what is the value of \texttt{f(ksadbf)}?
    \end{center}

    \vfill
    \begin{columns}[t]
        \scriptsize
        \column{0.35\textwidth}
        $$
            \begin{array}{r|l}
                \textbf{input} & \textbf{output} \\
                \hline
                machine        & e               \\
                learning       & g               \\
                algorithm      & m               \\
                ksadbf         & ?
            \end{array}
        $$

        \bigskip
        \textbf{Bard:} \tt f(ksadbf) = 11.

        We can see that the value of f(x) is simply the first letter of x minus 96.

        \column{0.65\textwidth}

        \textbf{ChatGPT:} \tt The information provided seems to define a function $f$ where certain inputs are associated with specific outputs. Based on the given information:
        \begin{itemize}
            \item $f(\text{machine}) = e$
            \item $f(\text{learning}) = g$
            \item $f(\text{algorithm}) = m$
        \end{itemize}
        However, there is no information given about \( f(\text{ksadbf}) \). Without additional information or a specific rule that determines the output for \( f(\text{ksadbf}) \), \emph{it is not possible to determine its value}.
        %
        If there is a pattern or rule for how the outputs are assigned based on the inputs, you would need to provide that information for me to help determine the value of \( f(\text{ksadbf}) \).
    \end{columns}

    \vfill
    \begin{center}
        No help from state-of-the-art Natural Language Processing or LLMs.
    \end{center}
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Where Machine Learning Fails}
    %-------------------------------------------------------------
    \begin{itemize}
        \item No \emph{interpretability}: large models ($\dim \theta \sim \text{millions}$) are \alert{not understandable by humans}.
        \item Need for \emph{large number of training} examples.
        \item Unfit for \emph{multiple relations}, \emph{intersample dependencies} and \emph{variable features}: The \textit{Students, Courses and Results} and \emph{Last Letter} examples.
        \item Poor \emph{generalization}: A model trained in the iris dataset is useless in any other domain.
        \item \alert{No use of background knowledge}.
    \end{itemize}
\end{frame}
%
%===============================================================
%
\section{Logic Programming}
%
%===============================================================
\begin{frame}
    %------------------------------------------------------------- %-------------------------------------------------------------
    \frametitle{}
    %-------------------------------------------------------------
    \begin{center}
        \vfill
        {\huge\bf Logic Programming}
    \end{center}
    \vfill
    \begin{itemize}
        \item An Example of Logic Programming.
        \item Inductive Logic Programming.
        \item Where ILP Fails.
    \end{itemize}
    \vfill
    %-------------------------------------------------------------
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    [fragile]
    %-------------------------------------------------------------
    \frametitle{An Example of Logic Programming}
    %-------------------------------------------------------------
    \begin{columns}[c]
        \column{0.4\textwidth}
        \begin{tikzpicture}[>=Latex]
            \node[vert] (v6) {6};
            \node[vert, above left = of v6] (v3) {3};
            \node[vert, above right = of v6] (v5) {5};
            \node[vert, below left = of v6] (v1) {1};
            \node[vert, below right = of v6] (v2) {2};
            \node[vert, below right = of v1] (v4) {4};
            \draw[->] (v6) to (v3);
            \draw[<->] (v6) to (v5);
            \draw[<->] (v6) to (v2);
            \draw[<->] (v3) to (v5);
            \draw[<->] (v3) to (v1);
            \draw[->] (v3) to[bend right, out=225, in =180,relative=false] (v4);
            \draw[->] (v1) to (v2);
            \draw[<->] (v1) to (v4);
            \draw[->] (v2) to (v5);
            \draw[<->] (v2) to (v4);
            \draw[->] (v5) to[bend left, out=-45, in=0,relative=false] (v4);
        \end{tikzpicture}
        \column{0.6\textwidth}
        \scriptsize
        \begin{lstlisting} 
node(1..6).

edge(1,2). edge(2,4). edge(3,1).
edge(4,1). edge(5,3). edge(6,2).
edge(1,3). edge(2,5). edge(3,4).
edge(4,2). edge(5,4). edge(6,3).
edge(1,4). edge(2,6). edge(3,5).
edge(5,6). edge(6,5).

col(r). col(b). col(g).

1 { color(X,C) : col(C) } 1 :- node(X).
:- edge(X,Y), color(X,C), color(Y,C).

#show color/2.
        \end{lstlisting}
    \end{columns}
    \vfill
    \scriptsize
    \begin{lstlisting}    
color(2,b) color(1,g) color(4,r) color(3,b) color(5,g) color(6,r)
color(1,r) color(2,b) color(4,g) color(3,b) color(5,r) color(6,g)
color(1,r) color(2,g) color(4,b) color(3,g) color(5,r) color(6,b)
color(1,b) color(2,g) color(4,r) color(3,g) color(5,b) color(6,r)
color(2,r) color(1,g) color(4,b) color(3,r) color(5,g) color(6,b)
color(2,r) color(1,b) color(4,g) color(3,r) color(5,b) color(6,g)
    \end{lstlisting}
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Inductive Logic Programming}
    %-------------------------------------------------------------
    \small

    \vfill
    \begin{center}
        Learning Logic Programs from Examples.
    \end{center}

    \vfill
    \alert{Generate rules} that\ldots
    \begin{itemize}
        \item use \textbf{background knowledge}
        $$
            \begin{aligned}
                 & parent(john,mary),  &  & parent(david,steve), \\
                 & parent(kathy,mary), &  & female(kathy),       \\
                 & male(john),         &  & male(david).
            \end{aligned}
        $$
        \item to entail all the \textbf{positive examples}, $father(john,mary), father(david,steve)$,
        \item but none of the \textbf{negative examples}. $father(kathy,mary), father(john,steve)$,
        
    \end{itemize}

    \vfill
    A \textbf{solution} is $$father(X,Y) \leftarrow parent(X,Y) \wedge male(X).$$

\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Where Logic Programming Fails}
    %-------------------------------------------------------------
    \begin{center}
        Meanwhile, in the \textbf{real world}, samples are \emph{incomplete} and come with \emph{noise}.
    \end{center}
    \vfill
    \textbf{Logic inference is \alert{fragile}}: a mistake in the transcription of a fact is dramatic to the consequences:
    \begin{itemize}
        \item $parent(david,mary)$.
        \item $parent(jonh,mary)$.
    \end{itemize}
    \vfill
    \begin{center}
        The statistic essence of machine learning provides \alert{robustness}.
    \end{center}
\end{frame}
%
%===============================================================
%
\section{Probabilistic Logic Programming}
%
%===============================================================
%
\begin{frame}
    %------------------------------------------------------------- %-------------------------------------------------------------
    \frametitle{}
    %-------------------------------------------------------------
    \vfill
    \begin{center}
        {\huge\bf Probabilistic Logic Programming}
    \end{center}
    \vfill
    \begin{itemize}
        \item Define distributions from logic programs.
        \item Stochastic ASP: Specifying distributions.
    \end{itemize}
    \vfill
    %-------------------------------------------------------------
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Probabilistic Logic Programs (PLPs)}
    %-------------------------------------------------------------
    \small

    \vfill
    \begin{center}
        Logic programs \textbf{annotated} with probabilities.
    \end{center}

    \vfill
    \begin{columns}[c]

        \column{0.4\textwidth}
        \begin{tikzpicture}[>=Latex]
            \node[draw, rounded rectangle] (A) {$Alarm$};
            \node[draw, rounded rectangle, below = of A] (J) {$Johncalls$};
            \draw[->] (A) to (J);
        \end{tikzpicture}

        \column{0.6\textwidth}
        $
            \begin{aligned}
                alarm:0.00251, &                       \\
                johncalls:0.9  & \leftarrow alarm,     \\
                johncalls:0.05 & \leftarrow \neg alarm
            \end{aligned}
        $
    \end{columns}

    \vfill
    \begin{itemize}
        \item \alert{$alarm:0.00251$} is $alarm \vee \neg alarm$ plus $P(Alarm = true) = 0.00251$.
        \item \alert{$johncalls:0.9 \leftarrow alarm$} is
              $$P\del{Johncalls = true \middle| Alarm = true} = 0.9$$
    \end{itemize}

    \vfill
    \begin{center}
        Any bayesian network can be represented by a PLP.
    \end{center}
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Distributions from Logic Programs}
    %-------------------------------------------------------------
    \vfill
    The program
    $$
        \begin{aligned}
            alarm:0.00251, &                       \\
            johncalls:0.9  & \leftarrow alarm,     \\
            johncalls:0.05 & \leftarrow \neg alarm
        \end{aligned}
    $$
    entails four possible models (or worlds):
    $$
        \begin{array}{r|r}
            \text{model}               & \text{probability} \\
            \hline
            alarm, johncalls           & 0.002259   \\
            alarm, \neg johncalls      & 0.000251   \\
            \neg alarm, johncalls      & 0.049874   \\
            \neg alarm, \neg johncalls & 0.947616   \\
        \end{array}
    $$
    \begin{itemize}
        \item \alert{\textbf{Models}} are special sets of \emph{literals} \textbf{entailed} from the program.
        \item Probabilities \emph{propagate} from facts, through rules.
    \end{itemize}
    \vfill
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{There's a Problem\ldots}
    %-------------------------------------------------------------
    \vfill
    The program
    $$
        \begin{aligned}
            alarm:0.00251,           &                  \\
            johncalls \vee marycalls & \leftarrow alarm
        \end{aligned}
    $$
    entails three \alert{stable}  (\emph{i.e.}\ minimal) models
    $$
        \begin{array}{r|l}
            \text{model}     & \text{probability} \\
            \hline
            alarm, johncalls & x                  \\
            alarm, marycalls & y                  \\
            \neg alarm       & 0.99749
        \end{array}
    $$
    but \textbf{no single way to set $x,y$}.
    \vfill
    \begin{center}
        Some \emph{Probabilistic Logic Programs} define more than one joint distribution.
    \end{center}
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{\ldots and an Oportunity}
    %-------------------------------------------------------------
    \begin{center}
        Some \emph{PLP}s define more than one joint distribution.
    \end{center}
    \vfill
    \begin{itemize}
        \item There is \textbf{no single probability assignment} from the facts stable models: $x,y \in \intcc{0,1}$.
        \item But any assignment is bound by Kolmogorov's axioms, and \textbf{forms equations} such as:
              $$x + y = P\del{alarm}.$$
        \item Existing \textbf{data can be used to estimate the unknowns} in those equations.
    \end{itemize}
    \vfill
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Stable Models, Events and Probabilities}
    %-------------------------------------------------------------
    \vfill
    \begin{center}
        What are we talking about?
    \end{center}
    \vfill
    \begin{itemize}
        \item A logic program has \textbf{atoms} (and \textbf{literals}) and \textbf{rules}:
            $$
            \begin{aligned}
                &male(john), \neg parent(kathy,mary), \\
                &father(X, Y) \leftarrow parent(X, Y) \wedge male(X).
            \end{aligned}
            $$
        \item A \alert{\textbf{stable model}} is a \textbf{minimal} model that contains:
              \begin{itemize}
                  \item program's \emph{facts}: $parent(john,mary),~male(john)$.
                  \item consequences, by the \emph{rules}: $father(john,mary)$.
              \end{itemize}
        \item Some programs have more than one model:
              \begin{tabular}{c|c}
                  \textbf{Logic Program} & \textbf{Stable Models} \\
                  \hline
                  $a \vee \neg a,  b \vee c \leftarrow a$
                                         &
                  $\set{\neg a}, \set{a, b}, \set{a, c}$
              \end{tabular}
    \end{itemize}
    \vfill
    \begin{center}
        How to propagate probability from annotated facts to other \emph{events}?
    \end{center}
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Logic Programs and Probabilities}
    %-------------------------------------------------------------
    % \vfill
    % \begin{center}
    %     The \textbf{space of events}, $\Omega$, is the set of all sets of literals. 
    % \end{center}
    \vfill
    \begin{itemize}
        \item Consider the literals of a logic program $$L = \set{a_1, \ldots a_n, \neg a_1, \ldots \neg a_n}.$$
        \item Any model of that program is a (consistent) subset of $L$.
        \item Let $\Omega = \mathbf{P}\del{L}$, \emph{i.e.} an \alert{event} $e$ is a subset of $L$, $e \subseteq L$.
              \begin{itemize}
                  \item Setting a probability for some events seems straightforward: $P\del{\neg alarm} = 0.997483558$.
                  \item For others, not so much:
                        \begin{itemize}
                            \item $P\del{alarm, johncalls}$, $P\del{johncalls, marycalls, alarm}$, $P\del{marycalls}$?
                            \item $P\del{alarm, \neg alarm}$, $P\del{\neg marycalls}$?
                        \end{itemize}
              \end{itemize}
    \end{itemize}
    \vfill
    \begin{center}
        How to \alert{propagate} probability from \emph{facts} to \emph{consequences} or other \emph{events}?
    \end{center}
\end{frame}
%
\newcommand{\diagram}{
    \resizebox{!}{24ex}{
        \begin{tikzpicture}%[scale=0.6, every node/.style={scale=0.6}]
            \node[event] (E) {$\emptyevent$};
            \node[tchoice, above left = of E, pin={[red!50!black]175:$0.3$}] (a) {$a$};
            \node[smodel, above left = of a, pin={[red!50!black]175:$0.3\theta$}] (ab) {$ab$};
            \node[smodel, above right = of a, pin={[red!50!black]175:$0.3\co{\theta}$}] (ac) {$ac$};
            \node[event, below = of ab] (b) {$b$};
            \node[event, below = of ac] (c) {$c$};
            \node[event, above right = of ab] (abc) {$abc$};
            \node[event, above left = of ab] (abC) {$\co{c}ab$};
            \node[event, above right = of ac] (aBc) {$\co{b}ac$};
            \node[indep, right = of ac] (bc) {$bc$};
            \node[tchoice, smodel, below right = of bc, pin={[red!50!black]175:$0.7$}] (A) {$\co{a}$};
            \node[event, above = of A] (Ac) {$\co{a}c$};
            \node[event, above right = of Ac] (Abc) {$\co{a}bc$};
            % ----
            \path[draw, rounded corners, fill=cyan, opacity=0.1]
            (ab.west) --
            (ab.north west) --
            %
            (abC.south west) --
            (abC.north west) --
            (abC.north) --
            %
            (abc.north east) --
            (abc.east) --
            (abc.south east) --
            %
            (ab.north east) --
            (ab.east) --
            (ab.south east) --
            %
            (a.north east) --
            %
            (E.north east) --
            (E.east) --
            (E.south east) --
            (E.south) --
            (E.south west) --
            %
            (b.south west) --
            %
            (ab.west)
            ;
            % ----
            \path[draw, rounded corners, fill=yellow, opacity=0.1]
            (ac.south west) --
            (ac.west) --
            (ac.north west) --
            %
            (abc.south west) --
            (abc.west) --
            (abc.north west) --
            %
            (aBc.north east) --
            (aBc.east) --
            (aBc.south east) --
            %
            (ac.north east) --
            %
            (c.east) --
            %
            (E.east) --
            (E.south east) --
            (E.south) --
            (E.south west) --
            %
            (a.south west) --
            (a.west) --
            (a.north west) --
            (a.north) --
            %
            (ac.south west)
            ;
            % ----
            \path[draw, rounded corners, fill=magenta, opacity=0.1]
            % (A.north west) --
            %
            (Ac.north west) --
            %
            (Abc.north west) --
            (Abc.north) --
            (Abc.north east) --
            (Abc.south east) --
            %
            % (Ac.north east) --
            % (Ac.east) --
            %
            % (A.east) --
            (A.south east) --
            %
            (E.south east) --
            (E.south) --
            (E.south west) --
            (E.west) --
            (E.north west) --
            %
            (Ac.north west)
            ;
        \end{tikzpicture}
    }
}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Classes of Events}
    %-------------------------------------------------------------
    \small

    \vfill
    \begin{center}
        \diagram
    \end{center}

    \vfill
    \begin{center}
        \begin{tabular}{lr}
            $\begin{aligned}
                     \probfact{0.3}{a}       \\
                     b \vee c & \leftarrow a
                 \end{aligned}$
             &
            $\co{a} = \set{\neg a}, ab = \set{a, b}, ac = \set{a, c}$
        \end{tabular}
    \end{center}

    \vfill
    \begin{itemize}
        \item Define \alert{equivalence classes} for all events, based on $\subseteq, \supseteq$ relations with the \textbf{stable models}.
        \item This example shows $6$ out of $2^3 + 1$ classes.
    \end{itemize}
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Probabilities for all Events}
    %-------------------------------------------------------------
    \vfill
    \begin{center}
        \diagram
    \end{center}
    \vfill
    \footnotesize
    \begin{enumerate}
        \item Set \alert{weights} in the stable models (shaded nodes), using parameters when needed: $\mu\del{\co{a}} = 0.7; \mu\del{ab} = 0.3\theta; \mu\del{ac}=0.3\del{1 - \theta}$
        \item Assume that the stable models are \alert{disjoint events}.
        \item Define \alert{weight of an event} as the sum of the weights of the related stable models.
        \item Normalize weights to get a (probability) \alert{distribution}.
    \end{enumerate}
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Probabilities for all Events}
    %-------------------------------------------------------------
    \vfill
    % \begin{center}
    %     \diagram
    % \end{center}
    % \vfill
    % \scriptsize

    \begin{equation*}
        \begin{array}{clr|cc|cc}
            & \stablecore{e}
            & \# \class{e}
            & \pw{\class{e}}
            & \pw{e}
            & \pr{E = e}
            & \pr{E \in \class{e}}
            \\
            \hline
            %
            & \inconsistent
            & 37
            & 0
            & 0
            & 0
            & 0
            \\[4pt]
            %
            \square 
            & \indepclass
            & 9
            & 0
            & 0
            & 0
            & 0
            \\[4pt]
            %
            {\color{magenta!20}\blacksquare }
            & \co{a}
            & 9
            & \frac{7}{10}
            & \frac{7}{90}
            & \frac{7}{207}
            & \frac{7}{23}
            \\[4pt]
            %
            {\color{cyan!20}\blacksquare }
            & ab
            & 3
            & \frac{3}{10}\theta
            & \frac{1}{10}\theta
            & \frac{1}{23}\alert{\theta}
            & \frac{3}{23}\theta
            \\[4pt]
            %
            {\color{yellow!20}\blacksquare }
            & ac
            & 3
            & \frac{3}{10}\co{\theta}
            & \frac{1}{10}\co{\theta}
            & \frac{1}{23}\alert{\co{\theta}}
            & \frac{3}{23}\co{\theta}
            \\[4pt]
            %
            & \co{a}, ab
            & 0
            & \frac{7 + 3\theta}{10}
            & 0
            & 0
            & 0
            \\[4pt]
            %
            & \co{a}, ac
            & 0
            & \frac{7 + 3\co{\theta}}{10}
            & 0
            & 0
            & 0
            %
            \\[4pt]
            %
            {\color{green!20}\blacksquare }
            & ab, ac
            & 2
            & \frac{3}{10}
            & \frac{3}{20}
            & \frac{3}{46}
            & \frac{3}{23}
            \\[4pt]
            %
            {\color{gray!20}\blacksquare }
            & \co{a}, ab, ac
            & 1
            & 1
            & 1
            & \frac{10}{23}
            & \frac{10}{23}
            \\[4pt]
            %
            \hline
            &
            & 64
            & 
            & Z = \frac{23}{10}
            &
            %& \Sigma = 1
        \end{array}
    \end{equation*}
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Estimating the Parameters}
    %-------------------------------------------------------------
    A \alert{sample} can be used to estimate the parameters $\theta$, by minimizing
    \begin{equation*}
        \err{\theta} := \sum_{e\in\fml{E}} \del{\pr{E = e\given \Theta = \theta} - \pr{S = e}}^2.\label{eq:err.e.s}
    \end{equation*}
    where
    \begin{itemize}
        \item $\fml{E}$ is the set of all events,
        \item $\pr{E\given \Theta}$ the \textbf{model+parameters} based distribution, 
        \item $\pr{S}$ is the \textbf{empiric} distribution from the given sample.
    \end{itemize}  
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Behind Parameter Estimation}
    %-------------------------------------------------------------
    \vfill
    So, we can derive a distribution $\pr{E\given \Theta = \hat{\theta}}$ from a program $P$ and a sample $S$.
    \begin{itemize}
        \item The sample defines an empiric distribution $\pr{S}$\ldots
        \item \ldots that is used to estimate $\theta$ in $\pr{E\given \Theta}$\ldots
        \item \ldots and \alert{score the program} $P$ w.r.t.\ that sample using, \emph{e.g.} the $\err{}$ function.
    \end{itemize}
    \vfill

\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Back to Inductive Logic Programming}
    %-------------------------------------------------------------
    \vfill
    Recall the \emph{Learning Logic Programs from Examples} setting:
    \begin{itemize}
        \item Given \textbf{positive} and \textbf{negative} examples, and \textbf{background knowledge}\ldots
        \item find a \textbf{program}\ldots
              \begin{itemize}
                  \item \ldots using the facts and relations from the \textbf{BK}\ldots
                  \item \ldots such that \textbf{all the PE} and \textbf{none the NE} examples are entailed.
              \end{itemize}
    \end{itemize}
    \vfill
    \begin{quotation}
        Given a sample of events, and a set of programs, \alert{the score} of those programs (w.r.t. the sample) \alert{can be used in evolutionary algorithms} while searching for better solutions.
    \end{quotation}
\end{frame}
%
%===============================================================
%
\section{In Conclusion}
%
%===============================================================
%
\begin{frame}
    %------------------------------------------------------------- %-------------------------------------------------------------
    \frametitle{}
    %-------------------------------------------------------------
    \vfill
    \begin{center}
        {\huge\bf In Conclusion}
    \end{center}
    \vfill
    %-------------------------------------------------------------
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    % \frametitle{In Conclusion}
    %-------------------------------------------------------------
    \begin{itemize}
        \item \textbf{Machine Learning} has limitations.
        \item As does \textbf{Inductive Logic Programming}.
        \item But, distributions can be defined by \textbf{Stochastic Logic Programs}.
    \end{itemize}
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    % \frametitle{In Conclusion}
    %-------------------------------------------------------------
    Distributions can be defined by \textbf{Stochastic Logic Programs}. Here we:
    \begin{enumerate}
        \item Look at the program's \textbf{stable models} and
        \item Use them to partition the \textbf{events} and then
        \item Using annotated probabilities, define:
        \begin{enumerate}
            \item a finite \textbf{measure}\ldots
            \item that, normalized, is a  \textbf{distribution} on all events.
        \end{enumerate}
    \end{enumerate}
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    % \frametitle{In Conclusion}
    %-------------------------------------------------------------
    Distributions can be defined by \textbf{Stochastic Logic Programs}.
    \begin{itemize}
        \item These distributions might have some \textbf{parameters}, due to indeterminism in the program.
        \item A \textbf{sample} can be used to estimate those parameters\ldots
        \item \ldots and \textbf{score} programs concurring to describe it.
        \item This score a key ingredient in \textbf{evolutionary algorithms}.
    \end{itemize}
    \begin{quotation}
        \ldots and a step towards the \alert{induction of stochastic logic programs} using \textbf{data} and \textbf{background knowledge}.
    \end{quotation}
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{Future Work}
    %-------------------------------------------------------------
    \vfill
    \begin{center}
        Induction of Stochastic Logic (ASP) Programs.
    \end{center}
    \vfill
    \begin{enumerate}
        \item \textbf{Meta-programming:} formal rules for rule generation.
        \item \textbf{Generation}, \textbf{Combination} and \textbf{Mutation} operators.
        \item \textbf{Complexity.}
        \item \textbf{Applications.}
        \item \textbf{Profit.}
    \end{enumerate}
    \vfill
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{}
    %-------------------------------------------------------------
    \begin{center}
        \vfill
        {\huge\alert{\bf Thank You!}}
        \vfill
        Questions?
    \end{center}
\end{frame}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{References}
    \begin{itemize}
        \item \href{https://arxiv.org/abs/1801.00631}{Gary Marcus, \emph{Deep Learning: A Critical Appraisal}, 2018}.
        \item \href{https://arxiv.org/abs/1911.01547}{François Chollet, \emph{On the Measure of Intelligence}, 2019}.
        \item \href{https://arxiv.org/abs/1801.00631}{Bengio \emph{et al.}, \emph{A Meta-Transfer Objective for Learning to Disentangle Causal Mechanisms}, 2019}.
        \item \href{https://arxiv.org/abs/1801.00631}{Cropper \emph{et al.}, \emph{Turning 30: New Ideas in Inductive Logic Programming}, 2020}.
        \item \href{https://doi.org/10.1201/9781003427421}{Fabrizio Riguzzi, \emph{Foundations of Probabilistic Logic Programming }, 2023}.
    \end{itemize}
    %-------------------------------------------------------------
\end{frame}
%
\end{document}
%
%===============================================================
\begin{frame}
    %-------------------------------------------------------------
    %[fragile]
    %-------------------------------------------------------------
    \frametitle{TITLE}
    %-------------------------------------------------------------
\end{frame}
%