Semantic and Declarative Technologies
AIT Budapest
Semantic and Declarative Technologies
AIT Budapest
Péter Szeredi
http://cs.bme.hu/~szeredi/ait/
Péter Szeredi
http://cs.bme.hu/~szeredi/ait/
Semantic? Declarative? What the hell…?
• According to the Merriam-Webster dictionary:
– Semantic (adjective):
relating to the meanings of words and phrases – Declarative (adjective):
having the form of a statement
rather than a question or a command
• And in conjunction with technology?
– Semantic web:
let search engines understand the web, not just read it – Declarative programming:
solve tasks by just describing the desired solution
• Why together in the same course?
– Common foundation: (mathematical) logic 2
Question: X? Answer: X?
3
A puzzle scheme from the book …
• Imagine an island on which every native is either
– a knight – who always tells the truth; or – a knave – who always lies
But they cannot be distinguished otherwise…
• If you hear Alf saying: “1+1=2”, he is a …
• If you hear Bob saying “1+1=3”, he is a …
• What if Cecil says: “I am a knight”?
– Can Cecil be a knight? Can he be a knave?
• Can it happen that Dan says: “I am a knave”?
Puzzle # 28 from the book
• In this problem, there are two natives, A and B. A makes the following statement:
“At least one of us is a knave.” (*) What are A and B?
• Think of writing a program in your favorite programming language, which takes (*) or some similar text as input, and returns the solution(s)…
5
Let’s use “controlled English” input
<person> ::= A | B | C | …
<native> ::= knight | knave
<statement> ::= <person> is a <native> | <person> says <statement> |
<statement> and <statement> |
<statement> or <statement>
• “
A says: at least one of us is a knave.” becomes:
A says A is a knave or B is a knave
• Given this input format, how many lines of
code would the puzzle solver require in your
favorite programming language?
Prolog - Programming in logic (or English?)
• Prolog is a simple, yet very flexible programming language based on a subset of First Order Logic
• Examples (use syntax extensions, additional operators, etc.)
7
statements of a knight have truth value 1. % truth(knight, 1).
statements of a knave have truth value 0. % truth(knave, 0).
statement (Native1 is a Native2) evaluates to B if statements of a Native1 have truth value B1 and statements of a Native2 have truth value B2 and
B is 1-abs(B1-B2). % is is a built in for arithmetic, here B = 1 iff B1==B2 statement (Native1 says S) evaluates to B if
statements of a Native1 have truth value B1 and statement S evaluates to B2 and B is 1-abs(B1-B2).
statement (S1 or S2) evaluates to B if statement S1 evaluates to B1 and statement S2 evaluates to B2 and
B is B1 \/ B2. % B is the disjunction of B1 and B2
SWISH: a web environment for Prolog
Adding constraints to Prolog
• Constraint Logic Programming (CLP) – what is it?
– It extends Prolog with much stronger reasoning capabilities – for a limited data domain (e.g. integers, Booleans, etc.)
• CLPFD (CLP for Finite Domain) – very efficient solution of combinatorial problems, e.g.
Sudoku puzzles
7 4 2
1 9
1 9
1 1 1 1
9 9 9
5 3 8
5 3 3
6 8
7 4 2
1 9
1 9
1 1 1 1
9 9 9
5 3 8
5 3 3
6 8
9
The Semantic Web (SW) part of the course
• Description Logics (DL) – the maths behind SW
– DL variants with different complexity
– Transforming human knowledge to DL format – Reasoning algorithms (outline)
• The practical side of the Semantic Web
– OWL 2 (Web Ontology Language) – The Protégé editor and
reasoning framework
Course summary
• Rough course layout:
– Introduction to (First Order) Logic Weeks 1-2 – Prolog programming Weeks 2-7
– Constraint programming Weeks 8-12
– Logics for the Semantic Web Weeks 12-14
• Requirements:
– 2 assignments (15% each)30% total
– 2 tests (mid-term & final, 20% each) 40% total – Many small exercises + class activity 30%
• Course webpage:
http://cs.bme.hu/~szeredi/ait/
11
Abilities helpful for this course
• The ability of clean, logical formulation of one’s expectations of a function or a
procedure
• The ability to write recursive programs
• The acceptance of the single assignment
principle: a variable can be assigned a
value only once
Why should you attend this course?
• Learn a very different programming paradigm, which you can also use in other languages such as C, Java, etc.
• Learn techniques to quickly and concisely solve difficult algorithmic problems
• Learn Description Logics – the maths behind the next generation „intelligent" Web 3.0
• It’s a niche market – experts of declarative and semantic technologies enjoy high-paying jobs
13
Some real-life applications
• Clarissa: natural voice processing used in systems on the International Space Station
• NRM: network management system for
configuring multi-vendor IP backbone networks
• ContractExpress: intelligent contract creation system for law firms
• COPLEX: real-time logistics optimization
• Watson: cognitive system that defeated former human champions in the Jeopardy! quiz show
• SecuritEase: the dominant stock broking system in New Zealand