forked from pikalab-unibo/ise-lab-knowledge-representation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheass23-cl-in-mas.tex
2590 lines (2266 loc) · 101 KB
/
eass23-cl-in-mas.tex
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ISE Lab -- Knowledge Representation
% Giovanni Ciatto
% Alma Mater Studiorum - Università di Bologna
% mailto:giovanni.ciatto@unibo.it
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\documentclass[handout]{beamer}\mode<handout>{\usetheme{default}}
%
\documentclass[presentation]{beamer}\mode<presentation>{\usetheme{AMSBolognaFC}}
%\documentclass[handout]{beamer}\mode<handout>{\usetheme{AMSBolognaFC}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{ise-lab-common}
\usepackage{eass23-cl-in-mas}
% version
\newcommand{\versionmajor}{1}
\newcommand{\versionminor}{1}
\newcommand{\versionpatch}{0}
\newcommand{\version}{\versionmajor.\versionminor.\versionpatch}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title[CL in MAS]{On the role of computational logic in MAS}
%
\subtitle{Practice with \twopkt}
%
\author[\sspeaker{\gcShort}]{\speaker{\gcFull} \\ \gcEmail}
%
\institute[\disiShort, \uniboShort]{\disi{} (\disiShort)\\\unibo}
%
\date[EASS 2023 (v.\ \version)]{
23rd European Agent Systems Summer School
\\
July 17, 2023
\\
Prague, Czech Republic
\\
(version \version)
}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%/////////
\frame{\titlepage}
%/////////
%%===============================================================================
\section*{Outline}
%%===============================================================================
%
%/////////
\frame[c]{\tableofcontents[hideallsubsections]}
%/////////
%===============================================================================
\section{Why CL for MAS?}
%===============================================================================
%/////////
\begin{frame}[c]{Agent}
%
\begin{block}{Insight}
Any entity capable of \alert{acting}\footnote{``acting'' = ``affecting the environment, and (possibly) the agents therein contained''}
to reach some \alert{goals}
%
\begin{itemize}
\item while being situated into some \alert{environment}
%
\begin{itemize}
\item which can be both \alert{perceived} and \alert{affected}
\end{itemize}
\item possibly, along with other agents
%
\begin{itemize}
\item with which \alert{interaction} is possible
\end{itemize}
\end{itemize}
\end{block}
%
\begin{exampleblock}{Examples of agents}
\begin{multicols}{2}
\begin{itemize}
\item human beings
\item OS processes
\item OS threads
\item logic solvers
\item robots
\item BDI agents
\end{itemize}
\end{multicols}
\end{exampleblock}
%
\end{frame}
%/////////
%/////////
\begin{frame}[c,allowframebreaks]{Intelligence (of Agents)}
%
\begin{block}{Insight}
Agents are \alert{intelligent} when they have \alert{cognitive capabilities}, and they know when/how to use them to pursue their goal(s)
\end{block}
%
\begin{exampleblock}{Examples of \textbf{cognitive capabilities}}\small
\begin{itemize}
\item \alert{perceiving} stimuli and \alert{recognise} abstractions on top of them
\item \alert{representing knowledge} (e.g. perceptions, abstractions, goals, actions, etc) and \alert{memorising} it for later re-use
\item \alert{learning} from the experience (i.e. generalise the gathered knowledge)
\item \alert{planning} courses of action to pursue goals
\item \alert{reasoning} about knowledge (to \emph{deduce} implicit knowledge, to \emph{induce} new knowledge, to \emph{abduce} hypotheses)
\item \alert{interact} with other agents to exchange information (goals, knowledge, plans)
\item etc.
\end{itemize}
\end{exampleblock}
%
\begin{exampleblock}{Examples of intelligent agents}
\begin{itemize}
\item human agents behave intelligently (most of the times)
\item software agents require cognitive capabilities, to behave intelligently
%
\begin{itemize}
\item plus some criterion to decide when and how to use them
\end{itemize}
\end{itemize}
\end{exampleblock}
%
\framebreak
%
\begin{alertblock}{Cognitive capabilities $\nRightarrow$ Intelligence}
Cognitive behaviours may or may not be considered as intelligent depending on the \alert{context} they are applied into, and on the \alert{observer}
\end{alertblock}
%
\begin{exampleblock}{Examples of intelligent agents}
\begin{itemize}
\item agent stepping through the window at ground floor
\item agent stepping through the window at $N^{th}$ floor
\end{itemize}
\end{exampleblock}
%
\end{frame}
%/////////
%/////////
\begin{frame}[
c %,allowframebreaks
]{Fundamental Mechanisms of Intelligent Systems}
%
\begin{enumerate}
\item Knowledge representation
%
\begin{itemize}
\item How is information represented to favour memorisation and processing
\end{itemize}
%
\item Inference
%
\begin{itemize}
\item How novel/explicit knowledge is attained from prior/implicit knowledge
\end{itemize}
%
\item Perception / actuation
%
\begin{itemize}
\item How information exchange with the environment occurs
\end{itemize}
%
\item Planning
%
\begin{itemize}
\item How courses of actions (directed towards some goal) are computed
\end{itemize}
%
\item Learning
%
\begin{itemize}
\item How experience is transformed into knowledge
\end{itemize}
%
\item Deliberation
%
\begin{itemize}
\item Where all such aspects are tied together
\end{itemize}
%
\item Environment and artefacts
%
\begin{itemize}
\item Where (inter)actions are coordinated
\end{itemize}
%
\end{enumerate}
%
% \framebreak
% %
% \begin{block}{Special guest: \textbf{Explanation}}
% How knowledge is \alert{transferred} from an agent to another
% %
% \begin{itemize}
% \item software to human agent $\leftarrow$ symbolic knowledge \alert{extraction}
% \item human to software agent $\leftarrow$ symbolic knowledge \alert{injection}
% \end{itemize}
% \end{block}
% %
% \begin{block}{Special guest: \textbf{Argumentation}}
% Letting agents reach shared agreements by \alert{arguing}
% %
% \begin{itemize}
% \item reason about how arguments attack each other
% \item reason about when to present an argument to the opponent(s)
% \end{itemize}
% \end{block}
%
\end{frame}
%/////////
%/////////
\begin{frame}[c,allowframebreaks]{Orthogonal topics}
Topics necessary to understand two or more mechanisms:
\begin{block}{Data science (a.k.a. machine learning, a.k.a. data mining)}
The use of statistics and algorithms to extract knowledge out of data
%
\begin{itemize}
\item necessary or useful for:
\vspace{-10pt}
\begin{multicols}{2}
\begin{itemize}
\item perception
\item learning
\item inference
\item processing
\end{itemize}
\end{multicols}
\end{itemize}
\end{block}
%
\begin{itemize}
\item we assume students already have a background on this topic
%
\begin{itemize}
\item yet, most relevant aspects may be recalled when needed
\end{itemize}
\end{itemize}
\begin{block}{Computational Logic}
The use of logic to \emph{perform} or \emph{reason about} computation
%
\begin{itemize}
\item necessary or useful for:
\vspace{-10pt}
\begin{multicols}{2}
\begin{itemize}
\item knowledge representation
\item reasoning
\item planning
\item learning
\item perception
\item deliberation
\end{itemize}
\end{multicols}
\end{itemize}
\end{block}
%
\begin{itemize}
\item we provide background on this topic, along the course
\end{itemize}
\end{frame}
%/////////
%===============================================================================
\section{Knowledge Representation}
%===============================================================================
%===============================================================================
\subsection{Premises}
%===============================================================================
\begin{frame}{Lecture Goals}
\begin{itemize}
\item Understand basic notions concerning \alert{Horn clauses}
%
\begin{itemize}
\item logic terms (constants, functions, variables)
\item logic clauses (facts, rules, goals)
% \item unifiers and substitutions
% \item unification and MGU
\end{itemize}
\vfill
\item Understand how these notions can be exploited for \alert{knowledge representation}
%
\begin{itemize}
\item data structures representation in logic
\item propositional vs. relational representations
\item extensional vs. intensional representations
\end{itemize}
\vfill
\item Understand differences in expressiveness among different logics
%
\begin{itemize}
\item[eg] first-order logic vs. Horn clauses
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}{Motivations}
\begin{itemize}
\item Why Horn clauses?
%
\begin{itemize}
\item nice expressiveness-tractability trade-off
\item basis for Prolog, Datalog and Logic Programming
\item very well established
%
\begin{itemize}
\item involved in tons of literature, theorems, technologies
\end{itemize}
\end{itemize}
\vfill
\item Why (symbolic) knowledge representation?
%
\begin{itemize}
\item pre-requisite for reifying many cognitive capabilities in software systems
%
\begin{itemize}
\item[eg] reasoning, planning, deliberation, etc.
\end{itemize}
\item pre-requisite for logic programing
\item both human- and machine-interpretable
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[allowframebreaks]{Historical Overview}
\begin{enumerate}
\item In principle, it was first order logic (FOL)
%
\begin{itemize}
\item very expressive, very flexible
%
\begin{itemize}
\item[eg] (recursive) terms + variabiles + quantitiers + predicates + logic connectives
\end{itemize}
\item very hard to find a general \alert{resolution} algorithm for deciding the \alert{satisfiability} of any given FOL formula
\end{itemize}
\bigskip
\item In 1965, Robinson proposes the \alert{SL resolution principle}\ccite{Robinson1965}
%
\begin{itemize}
\item[ie] an algorithm for decising the \alert{unsatisfiability} of FOL formul\ae{} in \alert{Skolemized form}
%
\begin{itemize}
\item[ie] all variables are \alert{universally} quantified at the beginning of the formula
\item[cf] \uurl{https://mathworld.wolfram.com/SkolemizedForm.html}
\end{itemize}
\item SL = Selective Linear
\item logic \alert{unification} is a basic mechanism for the resolution principle
\end{itemize}
\framebreak
\item In 1974, Kowalski proposes the SL\alert{D} resolution procedure\ccite{KowVan1970}
%
\begin{itemize}
\item SL\alert{D} = Selective Linear [for] \alert{Definite} [clauses]
%
\begin{itemize}
\item definite clauses $\approx$ Horn clauses
\item[ie] very restricted subset of FOL, discussed in this lecture
%
\item[eg] no quantifiers, no negation, no connectors except conjunction and implication, \ldots
\end{itemize}
\end{itemize}
\bigskip
\item In the 1970s, first Prolog implementations appear
%
\begin{itemize}
\item essentially reifying the SLD procedure into a programming language
%
\begin{itemize}
\item cf. \cite{Korner2022} for the full history
\end{itemize}
\item that impacted virtually any subsequent logic/symbolic AI technology
\end{itemize}
\framebreak
\item In 1978, Clark proposes extends SLD with \alert{negation as failure}\ccite{Clark1978} (NaF)
%
\begin{itemize}
\item adding well-founded negation support
\end{itemize}
\bigskip
\item In 1982, Martelli and Montanari propose an efficient algorithm for unification\ccite{MartelliM82}
%
\begin{itemize}
\item paving the way towards many sorts of automated reasoning algorithms / software
\end{itemize}
\bigskip
\item[$\vdots$]
\end{enumerate}
\end{frame}
%===============================================================================
\subsection{Main notions}
%===============================================================================
\begin{frame}{Overview}
\begin{itemize}
\item[$\rightarrow$] Three main ingredients:
%
\begin{description}\small
\item[terms] --- for representing entities
\item[predicates] --- for representing statements about entities
\item[clauses] --- for representing properties of entities or relations among them
\end{description}
\vfill
\item Many ways of representing knowledge through them:
%
\begin{description}\small
\item[extensional vs. intensional] $\approx$ explicitly vs. implicitly
\item[propositional vs. relational] $\approx$ in tabular form vs. as a graph
\end{description}
\vfill
\item One powerful tool:
%
\begin{description}\small
\item[resolution] --- allowing for \alert{intensional} representations, programming, reasoning, \ldots
\end{description}
\vfill
\item Two fundamental mechanisms for manipulating knowledge:
%
\begin{description}\small
\item[substitution application] $\approx$ rewriting a formula by assigning variables
\item[most general unifier] $\approx$ computing the substitution making 2 formul\ae{} equal
\end{description}
\end{itemize}
\end{frame}
\subsubsection{Terms}
\begin{frame}[allowframebreaks]{Terms}
\begin{block}{Purpose}\centering
Terms are symbols representing entities from the \alert{domain of the discourse}
\end{block}
%
\begin{block}{Informal definition}
Terms can be
%
\begin{description}
\item[constants] --- denoting \alert{individual} / simple entities
\item[structures\footnote{a.k.a. functions}] --- denoting \alert{composed} / groups of entities
\item[variables] --- denoting \alert{placeholders} for / reference of \emph{unknown} entities
\end{description}
\end{block}
%
\begin{alertblock}{Formal syntax\hfill\textbf{\footnotesize(notice the syntactic convention!)}}
\label{slide:terms}
\begin{center}
$\begin{array}{rcl}
\meta{Term} & := & \meta{Variable} \mid \meta{Structure} \mid \meta{Constant}
\\
\meta{Variable} & := & \variable{X}_1 \mid \variable{X}_2 \mid \variable{X}_3 \mid \ldots
\\
\meta{Structure} & := & \meta{Functor} \terminal{(} \meta{Arguments} \terminal{)}
\\
\meta{Functor} & := & \functor{f}_1 \mid \functor{f}_2 \mid \functor{f}_3 \mid \ldots
\\
\meta{Arguments} & := & \meta{Term} \mid \meta{Term} \terminal{,} \meta{Arguments}
\\
\meta{Constant} & := & \meta{Functor} \mid \meta{Number}\mid \meta{Boolean}
\\
\meta{Number} & := & \mathbb{R} \qquad \meta{Boolean} := \functor{true} \mid \functor{false}
\end{array}$
\end{center}
%
\begin{itemize}
\item $\mathcal{X} = \{ \variable{X}_1, \variable{X}_2, \variable{X}_3, \ldots \}$ is a set of \alert{variables names}
\item $\mathcal{F} = \{ \functor{f}_1, \functor{f}_2, \functor{f}_3, \ldots \}$ is a set of \alert{functors}\footnote{a.k.a. function names/symbols} of given \alert{arities}
\item $\mathbb{R}$ is the set of real numbers
\end{itemize}
\end{alertblock}
\begin{block}{Syntactical convention}
\label{slide:convention}
\begin{itemize}
\item $\variable{Variables}$ $\rightarrow$ capitalised italics
\item $\functor{Functor}$ $\rightarrow$ lowercase monospaced
\item $\meta{Non\text{-}terminal\ symbols}$ $\rightarrow$ sans-serif, wrapped by angular parenteses
%
\begin{itemize}
\item this is just for grammar definitions
\end{itemize}
\item $\mathcal{SYMBOLS\ SET}$ $\rightarrow$ uppercase calligraphic italics
%
\begin{itemize}
\item this is just for theoretical definitions
\end{itemize}
\end{itemize}
\end{block}
\end{frame}
\begin{frame}[allowframebreaks]{Example -- Peano Numbers}
\begin{exampleblock}{Definition: unary representation of natural numbers, via terms}
\begin{description}
\item[$\functor{z}$] $\rightarrow$ zero
\item[$\functor{s}(\variable{X})$] $\rightarrow$ the successor of some (unknown) number $\variable{X}$
\item[$\functor{s}(\functor{z})$] $\rightarrow$ the successor zero (a.k.a. 1)
\item[$\functor{s}(\functor{s}(\functor{z}))$] $\rightarrow$ the successor of the successor of zero (a.k.a. 2)
\item[$\functor{s}(\functor{s}(\functor{s}(\functor{z})))$] $\rightarrow$ the successor of \ldots
\end{description}
\end{exampleblock}
%
\begin{exampleblock}{Notice that, in this case:}
\begin{itemize}
\item $\functor{z}$ is a constant
\item $\variable{X}$ is a variable
\item $\functor{s}(\variable{X})$, $\functor{s}(\functor{z})$, etc. are structures
\item $\mathcal{F} = \{ \functor{s}, \functor{z} \}$ \hfill {\footnotesize(where $\functor{s}$ is a 1-ary functor, while $\functor{z}$ is 0-ary)}
\item $\mathcal{V} = \{ \variable{X} \}$
\end{itemize}
\end{exampleblock}
\end{frame}
\begin{frame}[allowframebreaks]{Example -- Lists}
\begin{exampleblock}{Definition: (single-)linked lists\hfill\textbf{\footnotesize(LISP nomenclature\cccite{enwiki:cons})}}
\begin{description}
\item[$\functor{nil}$] $\rightarrow$ empty list
\item[$\functor{cons}(\variable{H}, \variable{T})$] $\rightarrow$ the list whose head is $\variable{H}$ and whose tail is $\variable{T}$
\item[$\functor{cons}(1, \variable{T})$] $\rightarrow$ the list whose first element is $1$ (and whose tail is $\variable{T}$)
\item[$\functor{cons}(1, \functor{nil})$] $\rightarrow$ the singleton list $[1]$
\item[$\functor{cons}(1, \functor{cons}(2, \functor{nil}))$] $\rightarrow$ the list $[1,2]$
\item[$\functor{cons}(1, \functor{cons}(2, \functor{cons}(3, \functor{nil})))$] $\rightarrow$ the list $[1,2,3]$
\end{description}
\end{exampleblock}
%
\begin{exampleblock}{Notice that, in this case:}
\begin{itemize}
\item $\functor{nil}$ is a constant
\item $\variable{H}$ and $\variable{T}$ are variables
\item $\functor{cons}(\variable{H}, \variable{T})$, etc. are structures
\item $\mathcal{F} = \{ \functor{nil}, \functor{cons} \}$ \hfill {\footnotesize(where $\functor{cons}$ is a binary functor, while $\functor{nil}$ is 0-ary)}
\item $\mathcal{V} = \{ \variable{H}, \variable{T}\}$
\end{itemize}
\end{exampleblock}
%
\begin{alertblock}{Fun fact: in Prolog\dots}
\begin{itemize}
\item the constant `\alert{$\functor{[]}$}' is used in place of `\alert{$\functor{nil}$}'
\item the binary functor `\alert{$\functor{.}$}' is used in place of `\alert{$\functor{cons}$}'
\item `\alert{\pl{[$\variable{H}$ | $\variable{T}$]}}' is syntactic sugar for `\alert{\pl{.($\variable{H}$, $\variable{T}$)}}'
\item `\alert{\pl{[1, 2, 3]}}' is syntactic sugar for `\alert{\pl{.(1, .(2, .(3, [])))}}'
\end{itemize}
\end{alertblock}
\end{frame}
% \subsubsubsection{Ancillary definitions}
\begin{frame}[allowframebreaks]{Groundness}
\begin{block}{Informal definition}\centering
A term is \alert{ground} iff it has (i.e. contains) no variable
\end{block}
\begin{alertblock}{Inductive definition}
\begin{itemize}
\item Any variable $X$ is \emph{not} ground
\item Any constant $\functor{c}$ is ground
\item Any $n$-ary structure $\functor{f}(t_1, \ldots, t_n)$ is ground iff \emph{all} terms $t_i$ are ground
\end{itemize}
\end{alertblock}
\begin{exampleblock}{Some examples}
\begin{description}
\item[$\functor{z}$] and \alert{$\functor{nil}$} $\rightarrow$ ground
\item[$\functor{s}(\variable{X})$] $\rightarrow$ non-ground
\item[$\functor{s}(\functor{z})$] $\rightarrow$ ground
\item[$\functor{s}(\functor{s}(\functor{z}))$] $\rightarrow$ ground
\item[$\functor{s}(\functor{s}(\functor{s}(\variable{X})))$] $\rightarrow$ non-ground
\item[$\functor{cons}(\variable{H}, \variable{T})$] $\rightarrow$ non-ground
\item[$\functor{cons}(1, \variable{T})$] $\rightarrow$ non-ground
\item[$\functor{cons}(1, \functor{nil})$] $\rightarrow$ ground
\item[$\functor{cons}(1, \functor{cons}(2, \variable{X}))$] $\rightarrow$ non-ground
\item[$\functor{cons}(1, \functor{cons}(\variable{X}, \functor{cons}(3, \functor{nil})))$] $\rightarrow$ non-ground
\end{description}
\end{exampleblock}
\end{frame}
\begin{frame}[allowframebreaks]{Herbrand Universe}
\begin{block}{Informal definition}
The set of all items which can be represented as terms
%
\begin{itemize}
\item attained by applying all $n$-ary functors to all possible terms, recursively
\end{itemize}
\end{block}
\begin{alertblock}{Inductive definition}\label{slide:herbrand}
Let $\mathcal{F}$ be the set of all $n$-ary functors s.t. $n \geq 0$ (including constants)
%
\begin{itemize}
\item let $\mathcal{H}_0$ be the set of all constants in $\mathcal{F}$
\item let $\mathcal{H}_1$ be $\mathcal{H}_0 \cup \{ f(t_1, \ldots, t_n) \mid \forall f \in \mathcal{F}, \forall t_1, \ldots, t_n \in \mathcal{H}_0 \}$
\item $\vdots$
\item let $\mathcal{H}_{i+1}$ be $\mathcal{H}_i \cup \{ f(t_1, \ldots, t_n) \mid \forall f \in \mathcal{F}, \forall t_1, \ldots, t_n \in \mathcal{H}_i \}$
\item $\vdots$
\item then $\mathcal{H}_\infty$ is the Herbrand universe (spawned by $\mathcal{F}$)
\end{itemize}
\end{alertblock}
\framebreak
\begin{exampleblock}{Example for Peano numbers ($\mathcal{F} = \{ \functor{z}/0, \functor{s}/1 \}$)}
\begin{itemize}
\item $\functor{z}$
\item $\functor{s}(\functor{z})$
\item $\functor{s}(\functor{s}(\functor{z}))$
\item $\functor{s}(\functor{s}(\functor{s}(\functor{z})))$
\item[$\vdots$]
\end{itemize}
\end{exampleblock}
\begin{exampleblock}{Example for lists ($\mathcal{F} = \{ \functor{nil}/0, \functor{cons}/2 \}$)}
\begin{itemize}
\item $\functor{nil}$
\item $\functor{cons}(\functor{nil}, \functor{nil})$
\item $\functor{cons}(\functor{cons}(\functor{nil}, \functor{nil}), \functor{nil})$
\item $\functor{cons}(\functor{nil}, \functor{cons}(\functor{nil}, \functor{nil}))$
\item $\functor{cons}(\functor{cons}(\functor{nil}, \functor{nil}), \functor{cons}(\functor{nil}, \functor{nil}))$
\item[$\vdots$]
\end{itemize}
\end{exampleblock}
\begin{alertblock}{Important take away}
As soon as $\mathcal{F}$ contains \emph{at least}
%
\begin{itemize}
\item one constant
\item and one $n$-ary functor s.t. $n>0$
\end{itemize}
%
the Herbrand base becomes of \alert{infinite} cardinality
\end{alertblock}
\begin{block}{Herbrand of \textbf{infinite} cardinality: implications}
\begin{itemize}
\item infinitely many terms can be represented
\item attempts to enumerate them all won't terminate
\item attempts to store them all will saturate the space
\end{itemize}
\end{block}
\end{frame}
\subsubsection{Predicates}
\begin{frame}[allowframebreaks]{Predicates}
\begin{block}{Purpose}\centering
Asserting statements about entities from the \alert{domain of the discourse}
\end{block}
%
\begin{block}{Informal definition}
A \alert{statement} about $n\geq 0$ \alert{terms}, which may or may not hold true
\end{block}
%
\begin{alertblock}{Formal syntax\hfill\textbf{\footnotesize(notice the syntactic convention!)}}\label{slide:predicate}
$$\begin{array}{rcl}
\meta{Predicate} & := & \top \mid \bot \mid \meta{Predication} \mid \meta{Predication} \terminal{(} \meta{Arguments} \terminal{)}
\\
\meta{Predication} & := & \predication{p}_1 \mid \predication{p}_2 \mid \predication{p}_3 \mid \ldots
\\
\meta{Arguments} & := & \meta{Term} \mid \meta{Term} \terminal{,} \meta{Arguments}
\\
\meta{Term} & := & \text{see slide \ref{slide:terms}}
\end{array}$$
%
\begin{itemize}
\item $\mathcal{P} = \{ \predication{p}_1, \predication{p}_2, \predication{p}_3, \ldots \}$ is a set of \alert{predications}\footnote{a.k.a. predicate names/symbols} of given \alert{arities}
\item \alert{$\top$} denotes the predicate which \alert{always} holds true (a.k.a. \alert{tautology})
\item \alert{$\bot$} denotes the predicate which \alert{never} holds true (a.k.a. \alert{contradiction})
\end{itemize}
\end{alertblock}
%
\begin{block}{Syntactical convention}
\begin{itemize}
\item $\predication{predication}$ $\rightarrow$ lowercase italics
\end{itemize}
\end{block}
\end{frame}
\begin{frame}{Example -- Peano numbers}
\begin{block}{Assumptions}
\begin{itemize}
\item $\mathcal{P} = \{ \predication{nat}, \predication{succ} \}$ \hfill {\footnotesize(where $\predication{nat}$ is a 1-ary predication, while $\predication{succ}$ is binary)}
\item $\predication{nat}$ states that a term denotes a \alert{natural} number
\item $\predication{succ}$ states that a term is the \alert{natural} of another one
%
\begin{itemize}
\item provided that they are both natural numbers
\end{itemize}
\end{itemize}
\end{block}
%
\begin{exampleblock}{Some possible predicates}
\begin{description}
\item[$\predication{nat}(\functor{z})$] $\rightarrow$ zero is a natural number
\item[$\predication{nat}(\functor{s}(\variable{X}))$] $\rightarrow$ given some term $X$, the term $\functor{s}(\variable{X})$ is a natural number
\item[$\predication{nat}(\functor{s}(\functor{z}))$] $\rightarrow$ one is a natural number
\item[$\predication{succ}(\functor{s}(\functor{z}), \functor{z})$] $\rightarrow$ one is the successor of zero
\item[$\predication{succ}(\functor{s}(\variable{X}), \variable{X})$] $\rightarrow$ given some term $X$, the term $\functor{s}(\variable{X})$ its successor
\end{description}
\end{exampleblock}
\end{frame}
\begin{frame}{Example -- Lists}
\begin{block}{Assumptions}
\begin{itemize}
\item $\mathcal{P} = \{ \predication{list}, \predication{head} \}$ \hfill {\footnotesize(where $\predication{list}$ is a 1-ary predication, while $\predication{head}$ is binary)}
\item $\predication{list}$ states that a term denotes a \alert{list}
\item $\predication{head}$ states that a term is the \alert{head} of another one
%
\begin{itemize}
\item provided that the latter is a list
\end{itemize}
\end{itemize}
\end{block}
%
\begin{exampleblock}{Some possible predicates}
\begin{description}
\item[$\predication{list}(\functor{nil})$] $\rightarrow$ the empty list is a list
\item[$\predication{list}(\functor{cons}(\variable{H}, \functor{nil}))$] $\rightarrow$ given some term $H$, the term $\functor{cons}(\variable{H}, \functor{nil})$ is a list
\item[$\predication{list}(\functor{cons}(\variable{H}, \variable{T}))$] $\rightarrow$ given some terms $H, T$, the term $\functor{cons}(\variable{H}, \variable{T})$ is a list
\item[$\predication{head}(\variable{H}, \functor{cons}(\variable{H}, \functor{nil}))$] $\rightarrow$ $H$ is the head of the list $\functor{cons}(\variable{H}, \functor{nil})$
\item[$\predication{head}(\variable{H}, \functor{cons}(\variable{H}, \variable{T}))$] $\rightarrow$ $H$ is the head of the list $\functor{cons}(\variable{H}, \variable{T})$
\end{description}
\end{exampleblock}
\end{frame}
\begin{frame}{Important Remark}
\begin{alertblock}{Predicates vs. structures}
\begin{itemize}
\item predicate and structures have a \emph{very} similar \alert{syntax}
\item however, they are deeply different, \alert{semantically}
%
\begin{description}
\item[terms] represent entities from the domain of the discourse
%
\begin{itemize}
\item they just exist
\end{itemize}
\item[predicates] represent statements about those entities
%
\begin{itemize}
\item they can either be true or false
\end{itemize}
\end{description}
\end{itemize}
\end{alertblock}
\end{frame}
\begin{frame}{Predicates and their arities}
\begin{description}
\item[0-ary predicate] (a.k.a. \alert{proposition}): denotes a statement which may either hold or not
%
\begin{itemize}
\item e.g. ``it's raining''
\end{itemize}
\vfill
\item[1-ary predicate] (a.k.a. \alert{set} or \alert{type}): denotes a group of items characterised by a given property
%
\begin{itemize}
\item e.g. ``the set of even numbers''
%
\begin{itemize}
\item[ie] ``the set of all numbers $X$ such that $X$ is a multiple of 2''
\end{itemize}
\end{itemize}
\vfill
\item[$n$-ary predicate] (a.k.a. \alert{relation}): denotes a relationship holding among $n$ entities
%
\begin{itemize}
\item i.e. a group of $n$-uples characterised by a given property
\item e.g. ``parenthood'' (binary relation)
%
\begin{itemize}
\item[ie] ``the set of all pairs $(X, Y)$ such that $Y$ is a child of $X$''
\end{itemize}
\item e.g. ``students' yearly school reports'' (ternary relation)
%
\begin{itemize}
\item[ie] ``the set of all triplets $(X, Y, Z)$ such that $X$ is a student, $Y$ is a course, and $Z$ is the mark of $X$ in $Y$''
\end{itemize}
\end{itemize}
\end{description}
\end{frame}
\subsubsection{Horn Clauses}
\begin{frame}[allowframebreaks]{Horn Clauses}
\begin{block}{Purpose}\centering
Defining (a.k.a. expressing, writing) \alert{propositions}, \alert{sets}, or \alert{relations} concerning the entities of the \alert{domain of the discourse}
\end{block}
%
\begin{block}{Informal definition}
Horn clauses are logic formul\ae{} of three sorts:
%
\begin{description}
\item[facts] --- denoting predicates which are known to hold
\item[rules\footnote{a.k.a. definite clauses}] --- denoting that a predicate holds true if a number of other predicates hold true
\item[goals\footnote{a.k.a. directives}] --- denoting a number of predicates to be proven (either true or false)
\end{description}
\end{block}
%
\begin{block}{Formal definition (pt. 1)}
Horn clauses are logic statements of the form
%
\begin{center}
$\overbrace{\underbrace{\phi}_{\text{positive literal}} \vee \underbrace{\neg\psi_1 \vee \ldots \vee \neg \psi_n}_{\text{negative literals}}}^{\text{disjunction form}}$
\qquad $\equiv$\footnote{$(\neg a \vee b) \equiv (a \Rightarrow b)$, cf. \uuurl{http://discrete.openmathbooks.org/dmoi3/sec_propositional.html}} \qquad
$\overbrace{\underbrace{\phi}_{\text{head}} \Leftarrow \underbrace{\psi_1 \wedge \ldots \wedge \psi_n}_{\text{body}}}^\text{implication form}$
\end{center}
%
\begin{itemize}
\item[ie] a \alert{disjunction} of \alert{literals} where \emph{at most} one literal is non-negated
%
\begin{itemize}
\item[aka] an \alert{implication} having \emph{at most} 1 post-condition (the \alert{head}) and $n$ pre-conditions in conjunction (the \alert{the body})
\end{itemize}
\item where literals $\phi, \psi_1, \ldots, \psi_n$ are \alert{predicates} of any arity
%
\begin{itemize}
\item possibly involving terms of any sorts
\end{itemize}
\end{itemize}
\end{block}
%
\begin{block}{Formal definition (pt. 2)}
Given a Horn clause $\phi \Leftarrow \psi_1 \wedge \ldots \wedge \psi_n$, it is
%
\begin{itemize}
\item a \alert{goal} iff $\phi \equiv \bot$
%
\begin{itemize}
\item[ie] when the head is a contradiction (a.k.a no head)
\item then the clause is written as `$\Leftarrow \psi_1 \wedge \ldots \wedge \psi_n$'
\end{itemize}
\item a \alert{fact} if $n = 1$ and $\psi_1 = \top$
%
\begin{itemize}
\item[ie] when the head is a tautology (a.k.a no body)
\item then the clause is written as `$\phi$'
\end{itemize}
\item a \alert{rule} otherwise
\end{itemize}
\end{block}
\end{frame}
\begin{frame}[allowframebreaks]{Logic Theories (a.k.a. Knowledge Bases)}
\begin{block}{Definition}
A \alert{set} of formul\ae{} which are known to be true \& \alert{consistent} with each others
%
\begin{description}
\item[set] $\rightarrow$ the order of formul\ae{} doesn't matter
\item[consistent] $\rightarrow$ (informal) no formula contradicts the others
%
\begin{itemize}
\item[ie] it is not possible to infer $\bot$ from the set of formul\ae{}
%
\begin{itemize}
\item[!] deciding whether this is the case or not requires some \alert{inference} algorithm
\end{itemize}
\end{itemize}
\end{description}
\end{block}
%
\begin{block}{Syntax for theories of definite clauses}
\begin{center}
$\begin{array}{rcl}
\meta{Theory} & := & \meta{Definite~Clause} \mid \meta{Theory} \meta{Theory}
\\
\meta{Definite~Clause} & := & \meta{Rule} \mid \meta{Fact}
\\
\meta{Rule} & := & \meta{Head} \terminal{\Leftarrow} \meta{Body} \terminal{\fullstop}
\\
\meta{Fact} & := & \meta{Head} \terminal{\fullstop}
\\
\meta{Head} & := & \meta{Predicate}
\\
\meta{Body} & := & \meta{Predicate} \mid \meta{Body} \terminal{\wedge} \meta{Body}
\\
\meta{Predicate} & := & \text{see slide \ref{slide:predicate}}
\end{array}$
\end{center}
\end{block}
\end{frame}
\begin{frame}{Examples -- Peano numbers}
\begin{exampleblock}{Defining $\predication{nat}/1$ via a theory of definite clauses}
\begin{description}
\item[$\predication{nat}(\functor{z})\fullstop$] $\rightarrow$ $\functor{z}$ is a natural number
\item[$\predication{nat}(\functor{s}(\variable{X})) \Leftarrow \predication{nat}(\variable{X})\fullstop$] $\rightarrow$ for all $\variable{X}$, $\functor{s}(\variable{X})$ is a natural number if $\variable{X}$ is a natural number as well
\end{description}
\end{exampleblock}
%
\begin{exampleblock}{Defining $\predication{succ}/2$ via a theory of definite clauses}
\begin{description}
\item[$\predication{succ}(\functor{s}(\variable{X}), \variable{X}) \Leftarrow \predication{nat}(\variable{X}) \fullstop$] $\rightarrow$ for all $\variable{X}$, $\functor{s}(\variable{X})$ is the successor of $\variable{X}$ if $\variable{X}$ is a natural number
\end{description}
\end{exampleblock}
\end{frame}
\begin{frame}{Examples -- Lists}
\begin{exampleblock}{Defining $\predication{list}/1$ via a theory of definite clauses}
\begin{description}
\item[$\predication{list}(\functor{nil})\fullstop$] $\rightarrow$ $\functor{nil}$ is a list
\item[$\predication{list}(\functor{cons}(\variable{H}, \variable{T})) \Leftarrow \predication{list}(\variable{T})\fullstop$] $\rightarrow$ for all $\variable{T}$ and regardless of $\variable{H}$, $\functor{cons}(\variable{H}, \variable{T})$ is a list if $\variable{T}$ is a list as well
\end{description}
\end{exampleblock}
%
\begin{exampleblock}{Defining $\predication{head}/2$ via a theory of definite clauses}
\begin{description}
\item[$\predication{head}(\variable{H}, \functor{cons}(\variable{H}, \variable{T})) \fullstop$] $\rightarrow$ for all $\variable{H}$ and regardless of $\variable{T}$, the head of $\functor{cons}(\variable{H}, \variable{T})$ is $\variable{H}$
\end{description}
\end{exampleblock}
\end{frame}
\begin{frame}[allowframebreaks]{Horn clauses vs. FOL formul\ae}
\begin{block}{Horn clauses are \textbf{particular cases} of FOL formul\ae, where}
\begin{itemize}
\item all variables in the head are \alert{universally} quantified
\item all variables occurring in the in the body (but not in the head) are \alert{existentially} quantified
\item where negation of predicates is forbidden
\item where all logic connectives are forbidden
%
\begin{itemize}
\item except conjunction and implication
\item implication can only occur once
\item conjunction can only occur among the pre-conditions of the implication
\end{itemize}
\end{itemize}
\end{block}
\begin{exampleblock}{How to read definite clauses}
\centering
$\predication{mother}(\variable{X}) \Leftarrow \predication{parent}(\variable{X}, \variable{Y}) \wedge \predication{female}(\variable{X})$
\medskip
$\downarrow$ {\footnotesize should be read as}
\medskip
$\alert{\forall \variable{X}} : \predication{mother}(\variable{X}) \Leftarrow \alert{\exists \variable{Y}} : \predication{parent}(\variable{X}, \variable{Y}) \wedge \predication{female}(\variable{X})$
\medskip
$\downarrow$ {\footnotesize i.e., in natural language}
\medskip
``for all $\variable{X}$, $\variable{X}$ is a mother if there exists some $\variable{Y}$ of which $\variable{X}$ is parent, \\ and if $\variable{X}$ is female''
\end{exampleblock}
\end{frame}
\begin{frame}{Skip to Exercises}
\begin{block}{You may already start some exercises}
\begin{enumerate}
\item exercise about terms on slide \ref{slide:first-exercise-on-terms}