SlideShare a Scribd company logo
1 of 39
Download to read offline
2P-Kt: logic programming with objects & functions
in Kotlin
Giovanni Ciatto∗ Roberta Calegari◦ Enrico Siboni†
Enrico Denti‡ Andrea Omicini
∗‡ Dipartimento di Informatica – Scienza e Ingegneria (DISI)
◦Alma Mater Research Institute for Human-Centered Artificial Intelligence
Alma Mater Studiorum—Universit`a di Bologna, Italy
{giovanni.ciatto, roberta.calegari, enrico.denti, andrea.omicini}@unibo.it
†University of Applied Sciences and Arts of Western Switzerland (HES-SO)
enrico.siboni@hevs.ch
21st Workshop “From Objects to Agents” (WOA)
Sept. 16, 2020, Bologna, Italy
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 1 / 22
Motivation & Context
Next in Line. . .
1 Motivation & Context
2 Kotlin DSL for Prolog
3 Behind the scenes
4 Conclusions & future works
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 1 / 22
Motivation & Context
Context
New opportunities for logic-based technologies: (X)AI and MAS
AI side
AI is shining, brighter than ever
mostly thanks to the advances in ML and sub-symbolic AI
⇒ symbolic AI is gaining momentum because of eXplanable AI (XAI)
! hybrid solution mixing logic & data-driven AI are flourishing [3]
MAS side
The MAS community is eager for logic-based technologies [2]
to support agents’ knowledge representation, reasoning, or execution
or to prove MAS properties
! despite few mature tech. exist, and even fewer are actively maintained
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 2 / 22
Motivation & Context
Motivation
The problem with logic-based technologies
There is technological barrier slowing
the adoption of logic programming (LP) as paradigm
the exploitation of logic-based technologies
while programming in the large
e.g. Scala, Kotlin, Python, C#
mainstream programming languages are blending several paradigms
e.g. imperative, object-oriented (OOP), and functional programming (FP)
except LP!
mainstream platforms
e.g. JVM, .NET, JS, Python
are poorly interoperable with logic-based tech.
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 3 / 22
Motivation & Context
Motivating example – SWI-Prolog’s FLI for Java
Prolog [4] implementors rely on Foreign Language Interfaces (FLI) [1]
(mostly targetting Java, or C)
For instance, SWI-Prolog comes with a FLI for Java1:
Query query = new Query("parent", new Term[] {
new Atom("adam"),
new Variable("X")
}
); // ?- parent(adam, X).
Map<String,Term> solution = query.oneSolution();
System.out.println("The child of Adam is " + solution.get("X"));
→ No paradigm harmonization between Prolog and the hosting language
i.e. Java
1
https://jpl7.org
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 4 / 22
Motivation & Context
Contribution of the paper
Show that OOP, FP, and LP can be blended into a single language
Propose a DSL blending Kotlin (OOP + FP) and Prolog (LP)
! DSL = domain specific language
Pave the way to the creation of similar DSL in mainstream languages
eg Scala
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 5 / 22
Kotlin DSL for Prolog
Next in Line. . .
1 Motivation & Context
2 Kotlin DSL for Prolog
3 Behind the scenes
4 Conclusions & future works
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 5 / 22
Kotlin DSL for Prolog Overview
Focus on. . .
1 Motivation & Context
2 Kotlin DSL for Prolog
Overview
Principles
Functioning
Advantages
3 Behind the scenes
Overview
2P-Kt
Kotlin
2P-Kt + Kotlin
4 Conclusions & future works
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 5 / 22
Kotlin DSL for Prolog Overview
Whet your appetite
Our Kotlin DSL for Prolog vs. actual Prolog
prolog {
staticKb(
rule {
"ancestor"("X", "Y") `if` "parent"("X", "Y") // ancestor(X, Y) :- parent(X, Y).
}, //
rule { //
"ancestor"("X", "Y") `if` ( // ancestor(X, Y) :-
"parent"("X", "Z") and "ancestor"("Z", "Y") // parent(X, Z), ancestor(Z, Y).
) //
}, //
fact { "parent"("abraham", "isaac") }, // parent(abraham, isaac).
fact { "parent"("isaac", "jacob") }, // parent(isaac, jacob).
fact { "parent"("jacob", "joseph") } // parent(jacob, joseph).
) //
//
for (sol in solve("ancestor"("abraham", "D"))) // ?- ancestor(abraham, D),
if (sol is Solution.Yes) // write(D), nl.
println(sol.substitution["D"])
}
! try it here: https://github.com/tuProlog/prolog-dsl-example
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 6 / 22
Kotlin DSL for Prolog Principles
Focus on. . .
1 Motivation & Context
2 Kotlin DSL for Prolog
Overview
Principles
Functioning
Advantages
3 Behind the scenes
Overview
2P-Kt
Kotlin
2P-Kt + Kotlin
4 Conclusions & future works
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 6 / 22
Kotlin DSL for Prolog Principles
Design Principles
P1 – The DSL strictly extends the hosting language
→ no feature of the hosting language is forbidden within the DSL
P2 – The DSL is interoperable with hosting language
→ all features of the hosting language are allowed within the DSL
→ LP is harmonised with the hosting language paradigm(s)
P3 – The DSL is well encapsulated within the hosting language
→ i.e. only usable within well-identifiable sections
P4 – The DSL is as close as possible to Prolog
→ both syntactically & semantically
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 7 / 22
Kotlin DSL for Prolog Principles
Design Principles
P1 – The DSL strictly extends the hosting language
→ no feature of the hosting language is forbidden within the DSL
P2 – The DSL is interoperable with hosting language
→ all features of the hosting language are allowed within the DSL
→ LP is harmonised with the hosting language paradigm(s)
P3 – The DSL is well encapsulated within the hosting language
→ i.e. only usable within well-identifiable sections
P4 – The DSL is as close as possible to Prolog
→ both syntactically & semantically
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 7 / 22
Kotlin DSL for Prolog Principles
Design Principles
P1 – The DSL strictly extends the hosting language
→ no feature of the hosting language is forbidden within the DSL
P2 – The DSL is interoperable with hosting language
→ all features of the hosting language are allowed within the DSL
→ LP is harmonised with the hosting language paradigm(s)
P3 – The DSL is well encapsulated within the hosting language
→ i.e. only usable within well-identifiable sections
P4 – The DSL is as close as possible to Prolog
→ both syntactically & semantically
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 7 / 22
Kotlin DSL for Prolog Principles
Design Principles
P1 – The DSL strictly extends the hosting language
→ no feature of the hosting language is forbidden within the DSL
P2 – The DSL is interoperable with hosting language
→ all features of the hosting language are allowed within the DSL
→ LP is harmonised with the hosting language paradigm(s)
P3 – The DSL is well encapsulated within the hosting language
→ i.e. only usable within well-identifiable sections
P4 – The DSL is as close as possible to Prolog
→ both syntactically & semantically
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 7 / 22
Kotlin DSL for Prolog Functioning
Focus on. . .
1 Motivation & Context
2 Kotlin DSL for Prolog
Overview
Principles
Functioning
Advantages
3 Behind the scenes
Overview
2P-Kt
Kotlin
2P-Kt + Kotlin
4 Conclusions & future works
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 7 / 22
Kotlin DSL for Prolog Functioning
Functioning in the Kotlin case I
The DSL is only enabled within prolog { DSL block } expressions
there, Kotlin objects are automatically converted into Prolog terms
Expressions of the form: "functor"( e1 , e2 , . . .)
are interpreted as terms: functor(t1, t2, . . .)
provided that ∀i : ei can be converted into ti
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 8 / 22
Kotlin DSL for Prolog Functioning
Functioning in the Kotlin case I
The DSL is only enabled within prolog { DSL block } expressions
there, Kotlin objects are automatically converted into Prolog terms
Expressions of the form: "functor"( e1 , e2 , . . .)
are interpreted as terms: functor(t1, t2, . . .)
provided that ∀i : ei can be converted into ti
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 8 / 22
Kotlin DSL for Prolog Functioning
Functioning in the Kotlin case II
Expressions of the form:
rule {"head"( e1 , . . ., eN ) `if` ( eN+1 and . . . and eM ) }
are interpreted as rules: head(t1, . . . , tN) :- tN+1, . . . , tM
provided that ∀i : ei can be converted into ti
similar syntax for facts
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 9 / 22
Kotlin DSL for Prolog Functioning
Functioning in the Kotlin case III
Within prolog { . . . } blocks
staticKb(Clause1, Clause2, ...) sets up the local static KB
dynamicKb(Clause1, Clause2, ...) sets up the local dynamic KB
solve(Query, Timeout) returns a lazy stream of solutions
assert(Clause) appends a new clause to the local dynamic KB
. . .
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 10 / 22
Kotlin DSL for Prolog Functioning
Kotlin to Prolog conversions
Kotlin Object Type Prolog Term Type
lowercase string atom
uppercase string variable
int, long, short, byte integer
double, float real
boolean atom
list, array, iterable list
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 11 / 22
Kotlin DSL for Prolog Advantages
Focus on. . .
1 Motivation & Context
2 Kotlin DSL for Prolog
Overview
Principles
Functioning
Advantages
3 Behind the scenes
Overview
2P-Kt
Kotlin
2P-Kt + Kotlin
4 Conclusions & future works
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 11 / 22
Kotlin DSL for Prolog Advantages
Advantages of a Prolog-like DSL
No further parser / code generator / compiler is needed
Features of the hosting language can be exploited if Prolog falls short
Support tools of the hosting language can be exploited for Prolog
eg debugger, type checker, IDE, etc
Bring the power of LP to mainstream programming
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 12 / 22
Behind the scenes
Next in Line. . .
1 Motivation & Context
2 Kotlin DSL for Prolog
3 Behind the scenes
4 Conclusions & future works
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 12 / 22
Behind the scenes Overview
Focus on. . .
1 Motivation & Context
2 Kotlin DSL for Prolog
Overview
Principles
Functioning
Advantages
3 Behind the scenes
Overview
2P-Kt
Kotlin
2P-Kt + Kotlin
4 Conclusions & future works
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 12 / 22
Behind the scenes Overview
Recipe for a Prolog-like DSL
1 A language with a flexible API
e.g. Kotlin, Scala, Python, Groovy, etc.
2 Full fledged API for Prolog, supporting that language
e.g. 2P-Kt ! see next slide
3 Leverage flexibility to hide the exploitation of the API
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 13 / 22
Behind the scenes 2P-Kt
Focus on. . .
1 Motivation & Context
2 Kotlin DSL for Prolog
Overview
Principles
Functioning
Advantages
3 Behind the scenes
Overview
2P-Kt
Kotlin
2P-Kt + Kotlin
4 Conclusions & future works
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 13 / 22
Behind the scenes 2P-Kt
2P-Kt – Overview
Comprehensive, modular, re-usable API covering most aspects of LP:
unification
Unificator
mgu(Term, Term): Substitution
unify(Term, Term): Term?
match(Term, Term): Boolean
terms
Term
apply(Substitution): Term
freshCopy(): Term
Constant
value: Any
Var
name: String
Struct
functor: String
args: Array<Term>
Numeric
Integer
value: Int
Real
value: Double
Atom
value: String
Truth
isTrue: Boolean
EmptyList
List
Cons
head: Term
tail: Term
clauses & theories
Clause
head: Struct?
body: Term
RuleDirective Fact
Theory
assertA(Clause)
assertZ(Clause)
retract(Clause)
retractAll(Clause)
get(Clause): Sequence<Clause>
1
*
resolution
Solver
solve(Struct,Long): Sequence<Solution>
MutableSolver
loadStaticKb(Theory)
loadDynamicKb(Theory)
Solution
query: Struct
Yes
substitution: Unifier
No
Halt
exception: PrologError
substitutions
Substitution
get(Var): Term
contains(Var): Boolean
Unifier Fail
runs on several platforms (e.g., JVM, NodeJS, Browsers, Android)
more info here: https://github.com/tuProlog/2p-kt
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 14 / 22
Behind the scenes Kotlin
Focus on. . .
1 Motivation & Context
2 Kotlin DSL for Prolog
Overview
Principles
Functioning
Advantages
3 Behind the scenes
Overview
2P-Kt
Kotlin
2P-Kt + Kotlin
4 Conclusions & future works
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 14 / 22
Behind the scenes Kotlin
Kotlin mechanisms for DSL I
We exploited 4 basic mechanisms:
1 Operator overloading
interface Term {
operator fun plus(other: Term): Struct =
Struct.of("+", this, other)
}
// now one can write:
val term3: Term = term1 + term2
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 15 / 22
Behind the scenes Kotlin
Kotlin mechanisms for DSL II
2 Block-like lambda expressions
solutions.filter({ it -> it is Solution.Yes })
.map({ it -> it.substitution["X"] })
.joinToString(" ", { it.toString() })
// ↑ can be rewritten as ↓
solutions.filter { it is Solution.Yes }
.map { it.substitution["X"] }
.joinToString(" ") { it.toString() }
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 16 / 22
Behind the scenes Kotlin
Kotlin mechanisms for DSL III
3 Extension methods
fun Any.toTerm(): Term = // converts Kotlin objects into terms
operator fun String.invoke(vararg args: Term): Struct =
Struct.of(this, args.map { it.toTerm() })
// now one can write
"member"("X", arrayOf(1 .. 3)) // member(X, [1, 2, 3])
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 17 / 22
Behind the scenes Kotlin
Kotlin mechanisms for DSL IV
4 Function types/lambdas with receivers
class PrologDsl {
fun Any.toTerm(): Term = // ...
operator fun String.invoke(vararg args: Term): Struct = // ...
operator fun Any.plus(other: Any): Struct =
this.toTerm() + other.toTerm()
}
// ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ type with receiver
fun prolog(action: PrologDsl.() -> Any): Any =
PrologDsl().action()
// ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ lambda with receiver
prolog { "f"("1") + "f"("2") } // in braces this is PrologDsl
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 18 / 22
Behind the scenes Kotlin
Kotlin mechanisms for DSL V
This is a Kotlin-specific solution!
Other languages may support DSL through different mechanisms
e.g. implicits in Scala
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 19 / 22
Behind the scenes 2P-Kt + Kotlin
Focus on. . .
1 Motivation & Context
2 Kotlin DSL for Prolog
Overview
Principles
Functioning
Advantages
3 Behind the scenes
Overview
2P-Kt
Kotlin
2P-Kt + Kotlin
4 Conclusions & future works
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 19 / 22
Behind the scenes 2P-Kt + Kotlin
DSL design on top of 2P-Kt
JVM JS
Kotlin
2P-Kt
Prolog DSL
Scope
_: Var
varOf(String): Var
atomOf(String): Atom
structOf(String, Iterable<Term>): Struct
emptyList(): EmptyList
listOf(Iterable<Term>): List
numOf(Double): Real
numOf(Int): Integer
Prolog
Any.toTerm(): Term
String.invoke(Any, vararg Any): Struct
Substitution.get(String): Term?
PrologWithUnification
Any.mguWith(Any): Substitution
Any.matches(Any): Boolean
Any.unifyWith(Any): Term?
PrologWithTheories
theoryOf(vararg Clause): Theory
rule(PrologWithTheories.() -> Any): Rule
fact(PrologWithTheories.() -> Any): Fact
and(Any, Any): Term
or(Any, Any): Term
PrologWithResolution
solve(Any): Sequence<Solution>
solverOf(...)
member(Any, Any): Term
is(Any, Any): Term
!: Atom
fail: Atom
extends
Onion design with incremental features
Built on top of 2P-Kt and Kotlin
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 20 / 22
Conclusions & future works
Next in Line. . .
1 Motivation & Context
2 Kotlin DSL for Prolog
3 Behind the scenes
4 Conclusions & future works
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 20 / 22
Conclusions & future works
Conclusions & future works
Summing up, in this study we. . .
argued LP should be integrated in modern languages/paradigms
designed an in-language, DSL-based solution
prototyped an actual Kotlin-based DSL for Prolog
In the future, we will try to. . .
design Prolog-like DSL for other languages (e.g. Scala)
design an agent-oriented (possibly BDI?) DSL
extend 2P-Kt to support other sorts of inference mechanisms
design a logic-based API for sub-symbolic AI
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 21 / 22
2P-Kt: logic programming with objects & functions
in Kotlin
Giovanni Ciatto∗ Roberta Calegari◦ Enrico Siboni†
Enrico Denti‡ Andrea Omicini
∗‡ Dipartimento di Informatica – Scienza e Ingegneria (DISI)
◦Alma Mater Research Institute for Human-Centered Artificial Intelligence
Alma Mater Studiorum—Universit`a di Bologna, Italy
{giovanni.ciatto, roberta.calegari, enrico.denti, andrea.omicini}@unibo.it
†University of Applied Sciences and Arts of Western Switzerland (HES-SO)
enrico.siboni@hevs.ch
21st Workshop “From Objects to Agents” (WOA)
Sept. 16, 2020, Bologna, Italy
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 22 / 22
Bibliography
References I
[1] Roberto Bagnara and Manuel Carro.
Foreign language interfaces for Prolog: A terse survey.
ALP Newsletter, 15(2), May 2002.
[2] Roberta Calegari, Giovanni Ciatto, Viviana Mascardi, and Andrea Omicini.
Logic-based technologies for multi-agent systems: A systematic literature review.
Autonomous Agents and Multi-Agent Systems, In press.
Special Issue “Current Trends in Research on Software Agents and Agent-Based
Software Development”.
[3] Roberta Calegari, Giovanni Ciatto, and Andrea Omicini.
On the integration of symbolic and sub-symbolic techniques for XAI: A survey.
Intelligenza Artificiale, In press.
[4] Alain Colmerauer and Philippe Roussel.
The birth of prolog.
In John A. N. Lee and Jean E. Sammet, editors, History of Programming Languages
Conference (HOPL-II), pages 37–52. ACM, April 1993.
Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020

More Related Content

What's hot

Introduction to ci with jenkins
Introduction to ci with jenkinsIntroduction to ci with jenkins
Introduction to ci with jenkinsEric Hogue
 
Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)
Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)
Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)Deep Learning Italia
 
Open Source .NET
Open Source .NETOpen Source .NET
Open Source .NETOnyxfish
 
IDL to C++11 OMG RTWS presentations
IDL to C++11 OMG RTWS presentationsIDL to C++11 OMG RTWS presentations
IDL to C++11 OMG RTWS presentationsRemedy IT
 
Programming languages vienna
Programming languages viennaProgramming languages vienna
Programming languages viennagreg_s
 
Tree-based Translation Models (『機械翻訳』§6.2-6.3)
Tree-based Translation Models (『機械翻訳』§6.2-6.3)Tree-based Translation Models (『機械翻訳』§6.2-6.3)
Tree-based Translation Models (『機械翻訳』§6.2-6.3)Yusuke Oda
 
Ekon bestof rtl_delphi
Ekon bestof rtl_delphiEkon bestof rtl_delphi
Ekon bestof rtl_delphiMax Kleiner
 
Text as Data: processing the Hebrew Bible
Text as Data: processing the Hebrew BibleText as Data: processing the Hebrew Bible
Text as Data: processing the Hebrew BibleDirk Roorda
 
Learning to Generate Pseudo-code from Source Code using Statistical Machine T...
Learning to Generate Pseudo-code from Source Code using Statistical Machine T...Learning to Generate Pseudo-code from Source Code using Statistical Machine T...
Learning to Generate Pseudo-code from Source Code using Statistical Machine T...Yusuke Oda
 

What's hot (11)

Introduction to ci with jenkins
Introduction to ci with jenkinsIntroduction to ci with jenkins
Introduction to ci with jenkins
 
Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)
Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)
Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)
 
Open Source .NET
Open Source .NETOpen Source .NET
Open Source .NET
 
IDL to C++11 OMG RTWS presentations
IDL to C++11 OMG RTWS presentationsIDL to C++11 OMG RTWS presentations
IDL to C++11 OMG RTWS presentations
 
Programming languages vienna
Programming languages viennaProgramming languages vienna
Programming languages vienna
 
Tree-based Translation Models (『機械翻訳』§6.2-6.3)
Tree-based Translation Models (『機械翻訳』§6.2-6.3)Tree-based Translation Models (『機械翻訳』§6.2-6.3)
Tree-based Translation Models (『機械翻訳』§6.2-6.3)
 
Ekon bestof rtl_delphi
Ekon bestof rtl_delphiEkon bestof rtl_delphi
Ekon bestof rtl_delphi
 
Text as Data: processing the Hebrew Bible
Text as Data: processing the Hebrew BibleText as Data: processing the Hebrew Bible
Text as Data: processing the Hebrew Bible
 
LaTeX 3 Paper
LaTeX 3 PaperLaTeX 3 Paper
LaTeX 3 Paper
 
Fall in love with Kotlin
Fall in love with KotlinFall in love with Kotlin
Fall in love with Kotlin
 
Learning to Generate Pseudo-code from Source Code using Statistical Machine T...
Learning to Generate Pseudo-code from Source Code using Statistical Machine T...Learning to Generate Pseudo-code from Source Code using Statistical Machine T...
Learning to Generate Pseudo-code from Source Code using Statistical Machine T...
 

Similar to 2P-Kt: logic programming with objects & functions in Kotlin

Getty Vocabulary Program LOD: Ontologies and Semantic Representation
Getty Vocabulary Program LOD: Ontologies and Semantic RepresentationGetty Vocabulary Program LOD: Ontologies and Semantic Representation
Getty Vocabulary Program LOD: Ontologies and Semantic RepresentationVladimir Alexiev, PhD, PMP
 
Comparing Vocabularies for Representing Geographical Features and Their Geometry
Comparing Vocabularies for Representing Geographical Features and Their GeometryComparing Vocabularies for Representing Geographical Features and Their Geometry
Comparing Vocabularies for Representing Geographical Features and Their GeometryGhislain Atemezing
 
Getty Vocabulary Program LOD: Ontologies and Semantic Representation
Getty Vocabulary Program LOD: Ontologies and Semantic RepresentationGetty Vocabulary Program LOD: Ontologies and Semantic Representation
Getty Vocabulary Program LOD: Ontologies and Semantic RepresentationVladimir Alexiev, PhD, PMP
 
ITU - MDD - Textural Languages and Grammars
ITU - MDD - Textural Languages and GrammarsITU - MDD - Textural Languages and Grammars
ITU - MDD - Textural Languages and GrammarsTonny Madsen
 
Will iPython replace Bash?
Will iPython replace Bash?Will iPython replace Bash?
Will iPython replace Bash?Babel
 
Will iPython replace bash?
Will iPython replace bash?Will iPython replace bash?
Will iPython replace bash?Roberto Polli
 
Spark Streaming Intro @KTech
Spark Streaming Intro @KTechSpark Streaming Intro @KTech
Spark Streaming Intro @KTechOleg Korolenko
 
Reasoning with Big Knowledge Graphs: Choices, Pitfalls and Proven Recipes
Reasoning with Big Knowledge Graphs: Choices, Pitfalls and Proven RecipesReasoning with Big Knowledge Graphs: Choices, Pitfalls and Proven Recipes
Reasoning with Big Knowledge Graphs: Choices, Pitfalls and Proven RecipesOntotext
 
New Features of Python 3.10
New Features of Python 3.10New Features of Python 3.10
New Features of Python 3.10Gabor Guta
 
Querying the Web of Data
Querying the Web of DataQuerying the Web of Data
Querying the Web of DataRinke Hoekstra
 
Having Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo SurabayaHaving Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo SurabayaDILo Surabaya
 
TypeScript Vs. KotlinJS
TypeScript Vs. KotlinJSTypeScript Vs. KotlinJS
TypeScript Vs. KotlinJSGarth Gilmour
 
Streams of information - Chicago crystal language monthly meetup
Streams of information - Chicago crystal language monthly meetupStreams of information - Chicago crystal language monthly meetup
Streams of information - Chicago crystal language monthly meetupBrian Cardiff
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple InheritanceMichal Píše
 
Re-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextRe-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextEdward Willink
 
Kotlin – Alternative oder Ergänzung zu Java?
Kotlin – Alternative oder Ergänzung zu Java?Kotlin – Alternative oder Ergänzung zu Java?
Kotlin – Alternative oder Ergänzung zu Java?gedoplan
 
Plone - A History of Python Web
Plone - A History of Python WebPlone - A History of Python Web
Plone - A History of Python WebAlexander Loechel
 

Similar to 2P-Kt: logic programming with objects & functions in Kotlin (20)

Getty Vocabulary Program LOD: Ontologies and Semantic Representation
Getty Vocabulary Program LOD: Ontologies and Semantic RepresentationGetty Vocabulary Program LOD: Ontologies and Semantic Representation
Getty Vocabulary Program LOD: Ontologies and Semantic Representation
 
Comparing Vocabularies for Representing Geographical Features and Their Geometry
Comparing Vocabularies for Representing Geographical Features and Their GeometryComparing Vocabularies for Representing Geographical Features and Their Geometry
Comparing Vocabularies for Representing Geographical Features and Their Geometry
 
Getty Vocabulary Program LOD: Ontologies and Semantic Representation
Getty Vocabulary Program LOD: Ontologies and Semantic RepresentationGetty Vocabulary Program LOD: Ontologies and Semantic Representation
Getty Vocabulary Program LOD: Ontologies and Semantic Representation
 
ITU - MDD - Textural Languages and Grammars
ITU - MDD - Textural Languages and GrammarsITU - MDD - Textural Languages and Grammars
ITU - MDD - Textural Languages and Grammars
 
Kotlin
KotlinKotlin
Kotlin
 
Will iPython replace Bash?
Will iPython replace Bash?Will iPython replace Bash?
Will iPython replace Bash?
 
Will iPython replace bash?
Will iPython replace bash?Will iPython replace bash?
Will iPython replace bash?
 
Spark Streaming Intro @KTech
Spark Streaming Intro @KTechSpark Streaming Intro @KTech
Spark Streaming Intro @KTech
 
Reasoning with Big Knowledge Graphs: Choices, Pitfalls and Proven Recipes
Reasoning with Big Knowledge Graphs: Choices, Pitfalls and Proven RecipesReasoning with Big Knowledge Graphs: Choices, Pitfalls and Proven Recipes
Reasoning with Big Knowledge Graphs: Choices, Pitfalls and Proven Recipes
 
New Features of Python 3.10
New Features of Python 3.10New Features of Python 3.10
New Features of Python 3.10
 
Pg big fast ugly acid
Pg big fast ugly acidPg big fast ugly acid
Pg big fast ugly acid
 
Querying the Web of Data
Querying the Web of DataQuerying the Web of Data
Querying the Web of Data
 
Dl2014 slides
Dl2014 slidesDl2014 slides
Dl2014 slides
 
Having Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo SurabayaHaving Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo Surabaya
 
TypeScript Vs. KotlinJS
TypeScript Vs. KotlinJSTypeScript Vs. KotlinJS
TypeScript Vs. KotlinJS
 
Streams of information - Chicago crystal language monthly meetup
Streams of information - Chicago crystal language monthly meetupStreams of information - Chicago crystal language monthly meetup
Streams of information - Chicago crystal language monthly meetup
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
 
Re-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextRe-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for Xtext
 
Kotlin – Alternative oder Ergänzung zu Java?
Kotlin – Alternative oder Ergänzung zu Java?Kotlin – Alternative oder Ergänzung zu Java?
Kotlin – Alternative oder Ergänzung zu Java?
 
Plone - A History of Python Web
Plone - A History of Python WebPlone - A History of Python Web
Plone - A History of Python Web
 

More from Giovanni Ciatto

An Abstract Framework for Agent-Based Explanations in AI
An Abstract Framework for Agent-Based Explanations in AIAn Abstract Framework for Agent-Based Explanations in AI
An Abstract Framework for Agent-Based Explanations in AIGiovanni Ciatto
 
Towards XMAS: eXplainability through Multi-Agent Systems
Towards XMAS: eXplainability through Multi-Agent SystemsTowards XMAS: eXplainability through Multi-Agent Systems
Towards XMAS: eXplainability through Multi-Agent SystemsGiovanni Ciatto
 
TuSoW: Tuple Spaces for Edge Computing
TuSoW: Tuple Spaces for Edge ComputingTuSoW: Tuple Spaces for Edge Computing
TuSoW: Tuple Spaces for Edge ComputingGiovanni Ciatto
 
Comparative Analysis of Blockchain Technologies under a Coordination Perspective
Comparative Analysis of Blockchain Technologies under a Coordination PerspectiveComparative Analysis of Blockchain Technologies under a Coordination Perspective
Comparative Analysis of Blockchain Technologies under a Coordination PerspectiveGiovanni Ciatto
 
Smart Contracts are More than Objects: Pro-activeness on the Blockchain
Smart Contracts are More than Objects: Pro-activeness on the BlockchainSmart Contracts are More than Objects: Pro-activeness on the Blockchain
Smart Contracts are More than Objects: Pro-activeness on the BlockchainGiovanni Ciatto
 
Towards Agent-oriented Blockchains: Autonomous Smart Contracts
Towards Agent-oriented Blockchains: Autonomous Smart ContractsTowards Agent-oriented Blockchains: Autonomous Smart Contracts
Towards Agent-oriented Blockchains: Autonomous Smart ContractsGiovanni Ciatto
 
Blockchain and Smart Contracts
Blockchain and Smart ContractsBlockchain and Smart Contracts
Blockchain and Smart ContractsGiovanni Ciatto
 
From the Blockchain to Logic Programming and back: Research perspectives
From the Blockchain to Logic Programming and back: Research perspectivesFrom the Blockchain to Logic Programming and back: Research perspectives
From the Blockchain to Logic Programming and back: Research perspectivesGiovanni Ciatto
 
Logic Programming in Space-Time: The Case of Situatedness in LPaaS
Logic Programming in Space-Time: The Case of Situatedness in LPaaSLogic Programming in Space-Time: The Case of Situatedness in LPaaS
Logic Programming in Space-Time: The Case of Situatedness in LPaaSGiovanni Ciatto
 
Blockchain & Smart Contracts Basics and Perspectives for MAS
Blockchain & Smart Contracts Basics and Perspectives for MASBlockchain & Smart Contracts Basics and Perspectives for MAS
Blockchain & Smart Contracts Basics and Perspectives for MASGiovanni Ciatto
 
A gentle introduction to the Blockchain and Smart Contracts
A gentle introduction to the Blockchain and Smart ContractsA gentle introduction to the Blockchain and Smart Contracts
A gentle introduction to the Blockchain and Smart ContractsGiovanni Ciatto
 
Introduzione alla Blockchain
Introduzione alla BlockchainIntroduzione alla Blockchain
Introduzione alla BlockchainGiovanni Ciatto
 

More from Giovanni Ciatto (12)

An Abstract Framework for Agent-Based Explanations in AI
An Abstract Framework for Agent-Based Explanations in AIAn Abstract Framework for Agent-Based Explanations in AI
An Abstract Framework for Agent-Based Explanations in AI
 
Towards XMAS: eXplainability through Multi-Agent Systems
Towards XMAS: eXplainability through Multi-Agent SystemsTowards XMAS: eXplainability through Multi-Agent Systems
Towards XMAS: eXplainability through Multi-Agent Systems
 
TuSoW: Tuple Spaces for Edge Computing
TuSoW: Tuple Spaces for Edge ComputingTuSoW: Tuple Spaces for Edge Computing
TuSoW: Tuple Spaces for Edge Computing
 
Comparative Analysis of Blockchain Technologies under a Coordination Perspective
Comparative Analysis of Blockchain Technologies under a Coordination PerspectiveComparative Analysis of Blockchain Technologies under a Coordination Perspective
Comparative Analysis of Blockchain Technologies under a Coordination Perspective
 
Smart Contracts are More than Objects: Pro-activeness on the Blockchain
Smart Contracts are More than Objects: Pro-activeness on the BlockchainSmart Contracts are More than Objects: Pro-activeness on the Blockchain
Smart Contracts are More than Objects: Pro-activeness on the Blockchain
 
Towards Agent-oriented Blockchains: Autonomous Smart Contracts
Towards Agent-oriented Blockchains: Autonomous Smart ContractsTowards Agent-oriented Blockchains: Autonomous Smart Contracts
Towards Agent-oriented Blockchains: Autonomous Smart Contracts
 
Blockchain and Smart Contracts
Blockchain and Smart ContractsBlockchain and Smart Contracts
Blockchain and Smart Contracts
 
From the Blockchain to Logic Programming and back: Research perspectives
From the Blockchain to Logic Programming and back: Research perspectivesFrom the Blockchain to Logic Programming and back: Research perspectives
From the Blockchain to Logic Programming and back: Research perspectives
 
Logic Programming in Space-Time: The Case of Situatedness in LPaaS
Logic Programming in Space-Time: The Case of Situatedness in LPaaSLogic Programming in Space-Time: The Case of Situatedness in LPaaS
Logic Programming in Space-Time: The Case of Situatedness in LPaaS
 
Blockchain & Smart Contracts Basics and Perspectives for MAS
Blockchain & Smart Contracts Basics and Perspectives for MASBlockchain & Smart Contracts Basics and Perspectives for MAS
Blockchain & Smart Contracts Basics and Perspectives for MAS
 
A gentle introduction to the Blockchain and Smart Contracts
A gentle introduction to the Blockchain and Smart ContractsA gentle introduction to the Blockchain and Smart Contracts
A gentle introduction to the Blockchain and Smart Contracts
 
Introduzione alla Blockchain
Introduzione alla BlockchainIntroduzione alla Blockchain
Introduzione alla Blockchain
 

Recently uploaded

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 

Recently uploaded (20)

Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

2P-Kt: logic programming with objects & functions in Kotlin

  • 1. 2P-Kt: logic programming with objects & functions in Kotlin Giovanni Ciatto∗ Roberta Calegari◦ Enrico Siboni† Enrico Denti‡ Andrea Omicini ∗‡ Dipartimento di Informatica – Scienza e Ingegneria (DISI) ◦Alma Mater Research Institute for Human-Centered Artificial Intelligence Alma Mater Studiorum—Universit`a di Bologna, Italy {giovanni.ciatto, roberta.calegari, enrico.denti, andrea.omicini}@unibo.it †University of Applied Sciences and Arts of Western Switzerland (HES-SO) enrico.siboni@hevs.ch 21st Workshop “From Objects to Agents” (WOA) Sept. 16, 2020, Bologna, Italy Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 1 / 22
  • 2. Motivation & Context Next in Line. . . 1 Motivation & Context 2 Kotlin DSL for Prolog 3 Behind the scenes 4 Conclusions & future works Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 1 / 22
  • 3. Motivation & Context Context New opportunities for logic-based technologies: (X)AI and MAS AI side AI is shining, brighter than ever mostly thanks to the advances in ML and sub-symbolic AI ⇒ symbolic AI is gaining momentum because of eXplanable AI (XAI) ! hybrid solution mixing logic & data-driven AI are flourishing [3] MAS side The MAS community is eager for logic-based technologies [2] to support agents’ knowledge representation, reasoning, or execution or to prove MAS properties ! despite few mature tech. exist, and even fewer are actively maintained Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 2 / 22
  • 4. Motivation & Context Motivation The problem with logic-based technologies There is technological barrier slowing the adoption of logic programming (LP) as paradigm the exploitation of logic-based technologies while programming in the large e.g. Scala, Kotlin, Python, C# mainstream programming languages are blending several paradigms e.g. imperative, object-oriented (OOP), and functional programming (FP) except LP! mainstream platforms e.g. JVM, .NET, JS, Python are poorly interoperable with logic-based tech. Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 3 / 22
  • 5. Motivation & Context Motivating example – SWI-Prolog’s FLI for Java Prolog [4] implementors rely on Foreign Language Interfaces (FLI) [1] (mostly targetting Java, or C) For instance, SWI-Prolog comes with a FLI for Java1: Query query = new Query("parent", new Term[] { new Atom("adam"), new Variable("X") } ); // ?- parent(adam, X). Map<String,Term> solution = query.oneSolution(); System.out.println("The child of Adam is " + solution.get("X")); → No paradigm harmonization between Prolog and the hosting language i.e. Java 1 https://jpl7.org Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 4 / 22
  • 6. Motivation & Context Contribution of the paper Show that OOP, FP, and LP can be blended into a single language Propose a DSL blending Kotlin (OOP + FP) and Prolog (LP) ! DSL = domain specific language Pave the way to the creation of similar DSL in mainstream languages eg Scala Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 5 / 22
  • 7. Kotlin DSL for Prolog Next in Line. . . 1 Motivation & Context 2 Kotlin DSL for Prolog 3 Behind the scenes 4 Conclusions & future works Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 5 / 22
  • 8. Kotlin DSL for Prolog Overview Focus on. . . 1 Motivation & Context 2 Kotlin DSL for Prolog Overview Principles Functioning Advantages 3 Behind the scenes Overview 2P-Kt Kotlin 2P-Kt + Kotlin 4 Conclusions & future works Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 5 / 22
  • 9. Kotlin DSL for Prolog Overview Whet your appetite Our Kotlin DSL for Prolog vs. actual Prolog prolog { staticKb( rule { "ancestor"("X", "Y") `if` "parent"("X", "Y") // ancestor(X, Y) :- parent(X, Y). }, // rule { // "ancestor"("X", "Y") `if` ( // ancestor(X, Y) :- "parent"("X", "Z") and "ancestor"("Z", "Y") // parent(X, Z), ancestor(Z, Y). ) // }, // fact { "parent"("abraham", "isaac") }, // parent(abraham, isaac). fact { "parent"("isaac", "jacob") }, // parent(isaac, jacob). fact { "parent"("jacob", "joseph") } // parent(jacob, joseph). ) // // for (sol in solve("ancestor"("abraham", "D"))) // ?- ancestor(abraham, D), if (sol is Solution.Yes) // write(D), nl. println(sol.substitution["D"]) } ! try it here: https://github.com/tuProlog/prolog-dsl-example Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 6 / 22
  • 10. Kotlin DSL for Prolog Principles Focus on. . . 1 Motivation & Context 2 Kotlin DSL for Prolog Overview Principles Functioning Advantages 3 Behind the scenes Overview 2P-Kt Kotlin 2P-Kt + Kotlin 4 Conclusions & future works Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 6 / 22
  • 11. Kotlin DSL for Prolog Principles Design Principles P1 – The DSL strictly extends the hosting language → no feature of the hosting language is forbidden within the DSL P2 – The DSL is interoperable with hosting language → all features of the hosting language are allowed within the DSL → LP is harmonised with the hosting language paradigm(s) P3 – The DSL is well encapsulated within the hosting language → i.e. only usable within well-identifiable sections P4 – The DSL is as close as possible to Prolog → both syntactically & semantically Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 7 / 22
  • 12. Kotlin DSL for Prolog Principles Design Principles P1 – The DSL strictly extends the hosting language → no feature of the hosting language is forbidden within the DSL P2 – The DSL is interoperable with hosting language → all features of the hosting language are allowed within the DSL → LP is harmonised with the hosting language paradigm(s) P3 – The DSL is well encapsulated within the hosting language → i.e. only usable within well-identifiable sections P4 – The DSL is as close as possible to Prolog → both syntactically & semantically Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 7 / 22
  • 13. Kotlin DSL for Prolog Principles Design Principles P1 – The DSL strictly extends the hosting language → no feature of the hosting language is forbidden within the DSL P2 – The DSL is interoperable with hosting language → all features of the hosting language are allowed within the DSL → LP is harmonised with the hosting language paradigm(s) P3 – The DSL is well encapsulated within the hosting language → i.e. only usable within well-identifiable sections P4 – The DSL is as close as possible to Prolog → both syntactically & semantically Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 7 / 22
  • 14. Kotlin DSL for Prolog Principles Design Principles P1 – The DSL strictly extends the hosting language → no feature of the hosting language is forbidden within the DSL P2 – The DSL is interoperable with hosting language → all features of the hosting language are allowed within the DSL → LP is harmonised with the hosting language paradigm(s) P3 – The DSL is well encapsulated within the hosting language → i.e. only usable within well-identifiable sections P4 – The DSL is as close as possible to Prolog → both syntactically & semantically Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 7 / 22
  • 15. Kotlin DSL for Prolog Functioning Focus on. . . 1 Motivation & Context 2 Kotlin DSL for Prolog Overview Principles Functioning Advantages 3 Behind the scenes Overview 2P-Kt Kotlin 2P-Kt + Kotlin 4 Conclusions & future works Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 7 / 22
  • 16. Kotlin DSL for Prolog Functioning Functioning in the Kotlin case I The DSL is only enabled within prolog { DSL block } expressions there, Kotlin objects are automatically converted into Prolog terms Expressions of the form: "functor"( e1 , e2 , . . .) are interpreted as terms: functor(t1, t2, . . .) provided that ∀i : ei can be converted into ti Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 8 / 22
  • 17. Kotlin DSL for Prolog Functioning Functioning in the Kotlin case I The DSL is only enabled within prolog { DSL block } expressions there, Kotlin objects are automatically converted into Prolog terms Expressions of the form: "functor"( e1 , e2 , . . .) are interpreted as terms: functor(t1, t2, . . .) provided that ∀i : ei can be converted into ti Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 8 / 22
  • 18. Kotlin DSL for Prolog Functioning Functioning in the Kotlin case II Expressions of the form: rule {"head"( e1 , . . ., eN ) `if` ( eN+1 and . . . and eM ) } are interpreted as rules: head(t1, . . . , tN) :- tN+1, . . . , tM provided that ∀i : ei can be converted into ti similar syntax for facts Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 9 / 22
  • 19. Kotlin DSL for Prolog Functioning Functioning in the Kotlin case III Within prolog { . . . } blocks staticKb(Clause1, Clause2, ...) sets up the local static KB dynamicKb(Clause1, Clause2, ...) sets up the local dynamic KB solve(Query, Timeout) returns a lazy stream of solutions assert(Clause) appends a new clause to the local dynamic KB . . . Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 10 / 22
  • 20. Kotlin DSL for Prolog Functioning Kotlin to Prolog conversions Kotlin Object Type Prolog Term Type lowercase string atom uppercase string variable int, long, short, byte integer double, float real boolean atom list, array, iterable list Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 11 / 22
  • 21. Kotlin DSL for Prolog Advantages Focus on. . . 1 Motivation & Context 2 Kotlin DSL for Prolog Overview Principles Functioning Advantages 3 Behind the scenes Overview 2P-Kt Kotlin 2P-Kt + Kotlin 4 Conclusions & future works Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 11 / 22
  • 22. Kotlin DSL for Prolog Advantages Advantages of a Prolog-like DSL No further parser / code generator / compiler is needed Features of the hosting language can be exploited if Prolog falls short Support tools of the hosting language can be exploited for Prolog eg debugger, type checker, IDE, etc Bring the power of LP to mainstream programming Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 12 / 22
  • 23. Behind the scenes Next in Line. . . 1 Motivation & Context 2 Kotlin DSL for Prolog 3 Behind the scenes 4 Conclusions & future works Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 12 / 22
  • 24. Behind the scenes Overview Focus on. . . 1 Motivation & Context 2 Kotlin DSL for Prolog Overview Principles Functioning Advantages 3 Behind the scenes Overview 2P-Kt Kotlin 2P-Kt + Kotlin 4 Conclusions & future works Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 12 / 22
  • 25. Behind the scenes Overview Recipe for a Prolog-like DSL 1 A language with a flexible API e.g. Kotlin, Scala, Python, Groovy, etc. 2 Full fledged API for Prolog, supporting that language e.g. 2P-Kt ! see next slide 3 Leverage flexibility to hide the exploitation of the API Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 13 / 22
  • 26. Behind the scenes 2P-Kt Focus on. . . 1 Motivation & Context 2 Kotlin DSL for Prolog Overview Principles Functioning Advantages 3 Behind the scenes Overview 2P-Kt Kotlin 2P-Kt + Kotlin 4 Conclusions & future works Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 13 / 22
  • 27. Behind the scenes 2P-Kt 2P-Kt – Overview Comprehensive, modular, re-usable API covering most aspects of LP: unification Unificator mgu(Term, Term): Substitution unify(Term, Term): Term? match(Term, Term): Boolean terms Term apply(Substitution): Term freshCopy(): Term Constant value: Any Var name: String Struct functor: String args: Array<Term> Numeric Integer value: Int Real value: Double Atom value: String Truth isTrue: Boolean EmptyList List Cons head: Term tail: Term clauses & theories Clause head: Struct? body: Term RuleDirective Fact Theory assertA(Clause) assertZ(Clause) retract(Clause) retractAll(Clause) get(Clause): Sequence<Clause> 1 * resolution Solver solve(Struct,Long): Sequence<Solution> MutableSolver loadStaticKb(Theory) loadDynamicKb(Theory) Solution query: Struct Yes substitution: Unifier No Halt exception: PrologError substitutions Substitution get(Var): Term contains(Var): Boolean Unifier Fail runs on several platforms (e.g., JVM, NodeJS, Browsers, Android) more info here: https://github.com/tuProlog/2p-kt Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 14 / 22
  • 28. Behind the scenes Kotlin Focus on. . . 1 Motivation & Context 2 Kotlin DSL for Prolog Overview Principles Functioning Advantages 3 Behind the scenes Overview 2P-Kt Kotlin 2P-Kt + Kotlin 4 Conclusions & future works Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 14 / 22
  • 29. Behind the scenes Kotlin Kotlin mechanisms for DSL I We exploited 4 basic mechanisms: 1 Operator overloading interface Term { operator fun plus(other: Term): Struct = Struct.of("+", this, other) } // now one can write: val term3: Term = term1 + term2 Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 15 / 22
  • 30. Behind the scenes Kotlin Kotlin mechanisms for DSL II 2 Block-like lambda expressions solutions.filter({ it -> it is Solution.Yes }) .map({ it -> it.substitution["X"] }) .joinToString(" ", { it.toString() }) // ↑ can be rewritten as ↓ solutions.filter { it is Solution.Yes } .map { it.substitution["X"] } .joinToString(" ") { it.toString() } Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 16 / 22
  • 31. Behind the scenes Kotlin Kotlin mechanisms for DSL III 3 Extension methods fun Any.toTerm(): Term = // converts Kotlin objects into terms operator fun String.invoke(vararg args: Term): Struct = Struct.of(this, args.map { it.toTerm() }) // now one can write "member"("X", arrayOf(1 .. 3)) // member(X, [1, 2, 3]) Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 17 / 22
  • 32. Behind the scenes Kotlin Kotlin mechanisms for DSL IV 4 Function types/lambdas with receivers class PrologDsl { fun Any.toTerm(): Term = // ... operator fun String.invoke(vararg args: Term): Struct = // ... operator fun Any.plus(other: Any): Struct = this.toTerm() + other.toTerm() } // ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ type with receiver fun prolog(action: PrologDsl.() -> Any): Any = PrologDsl().action() // ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ lambda with receiver prolog { "f"("1") + "f"("2") } // in braces this is PrologDsl Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 18 / 22
  • 33. Behind the scenes Kotlin Kotlin mechanisms for DSL V This is a Kotlin-specific solution! Other languages may support DSL through different mechanisms e.g. implicits in Scala Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 19 / 22
  • 34. Behind the scenes 2P-Kt + Kotlin Focus on. . . 1 Motivation & Context 2 Kotlin DSL for Prolog Overview Principles Functioning Advantages 3 Behind the scenes Overview 2P-Kt Kotlin 2P-Kt + Kotlin 4 Conclusions & future works Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 19 / 22
  • 35. Behind the scenes 2P-Kt + Kotlin DSL design on top of 2P-Kt JVM JS Kotlin 2P-Kt Prolog DSL Scope _: Var varOf(String): Var atomOf(String): Atom structOf(String, Iterable<Term>): Struct emptyList(): EmptyList listOf(Iterable<Term>): List numOf(Double): Real numOf(Int): Integer Prolog Any.toTerm(): Term String.invoke(Any, vararg Any): Struct Substitution.get(String): Term? PrologWithUnification Any.mguWith(Any): Substitution Any.matches(Any): Boolean Any.unifyWith(Any): Term? PrologWithTheories theoryOf(vararg Clause): Theory rule(PrologWithTheories.() -> Any): Rule fact(PrologWithTheories.() -> Any): Fact and(Any, Any): Term or(Any, Any): Term PrologWithResolution solve(Any): Sequence<Solution> solverOf(...) member(Any, Any): Term is(Any, Any): Term !: Atom fail: Atom extends Onion design with incremental features Built on top of 2P-Kt and Kotlin Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 20 / 22
  • 36. Conclusions & future works Next in Line. . . 1 Motivation & Context 2 Kotlin DSL for Prolog 3 Behind the scenes 4 Conclusions & future works Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 20 / 22
  • 37. Conclusions & future works Conclusions & future works Summing up, in this study we. . . argued LP should be integrated in modern languages/paradigms designed an in-language, DSL-based solution prototyped an actual Kotlin-based DSL for Prolog In the future, we will try to. . . design Prolog-like DSL for other languages (e.g. Scala) design an agent-oriented (possibly BDI?) DSL extend 2P-Kt to support other sorts of inference mechanisms design a logic-based API for sub-symbolic AI Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 21 / 22
  • 38. 2P-Kt: logic programming with objects & functions in Kotlin Giovanni Ciatto∗ Roberta Calegari◦ Enrico Siboni† Enrico Denti‡ Andrea Omicini ∗‡ Dipartimento di Informatica – Scienza e Ingegneria (DISI) ◦Alma Mater Research Institute for Human-Centered Artificial Intelligence Alma Mater Studiorum—Universit`a di Bologna, Italy {giovanni.ciatto, roberta.calegari, enrico.denti, andrea.omicini}@unibo.it †University of Applied Sciences and Arts of Western Switzerland (HES-SO) enrico.siboni@hevs.ch 21st Workshop “From Objects to Agents” (WOA) Sept. 16, 2020, Bologna, Italy Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020 22 / 22
  • 39. Bibliography References I [1] Roberto Bagnara and Manuel Carro. Foreign language interfaces for Prolog: A terse survey. ALP Newsletter, 15(2), May 2002. [2] Roberta Calegari, Giovanni Ciatto, Viviana Mascardi, and Andrea Omicini. Logic-based technologies for multi-agent systems: A systematic literature review. Autonomous Agents and Multi-Agent Systems, In press. Special Issue “Current Trends in Research on Software Agents and Agent-Based Software Development”. [3] Roberta Calegari, Giovanni Ciatto, and Andrea Omicini. On the integration of symbolic and sub-symbolic techniques for XAI: A survey. Intelligenza Artificiale, In press. [4] Alain Colmerauer and Philippe Roussel. The birth of prolog. In John A. N. Lee and Jean E. Sammet, editors, History of Programming Languages Conference (HOPL-II), pages 37–52. ACM, April 1993. Ciatto et al. (UniBo, HES-SO) 2P-Kt: LP in Kotlin WOA, 2020