From 75ead529797c35c687d45e641b28b7661caa72c0 Mon Sep 17 00:00:00 2001 From: Francisco Coelho Date: Fri, 16 Feb 2024 08:50:29 +0000 Subject: [PATCH] START - PEx preparation --- 2024-02-05--biblio.zip | Bin 0 -> 32494301 bytes code/asplang/ASPLang.jl | 35 ++++++++++++++++++++++++++--------- code/asplang/drafts.jl | 3 +-- code/asplang/sbf.plp | 3 ++- pex2024/candidatura.md | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- pex2024/candidatura.pdf | Bin 0 -> 106829 bytes projecto-NovaLINCS.gdlink | 1 - 7 files changed, 128 insertions(+), 14 deletions(-) create mode 100644 2024-02-05--biblio.zip create mode 100644 pex2024/candidatura.pdf delete mode 100644 projecto-NovaLINCS.gdlink diff --git a/2024-02-05--biblio.zip b/2024-02-05--biblio.zip new file mode 100644 index 0000000..fd52aa0 Binary files /dev/null and b/2024-02-05--biblio.zip differ diff --git a/code/asplang/ASPLang.jl b/code/asplang/ASPLang.jl index 3c686eb..ad7d6bb 100644 --- a/code/asplang/ASPLang.jl +++ b/code/asplang/ASPLang.jl @@ -1,8 +1,8 @@ module ASPLang -export parse_asp, debug_asp, +export parse_asp, debug_asp, pstring, literal_grammar, term_grammar, aggregate_grammar, asp_grammar, - Node, Variable, StringConstant, SymbolicConstant, AnonymousVariable, NumberConstant, Variable, + Node, Terminal, NonTerminal, Variable, StringConstant, SymbolicConstant, AnonymousVariable, NumberConstant, Variable, Functor, FunctionTerm, Negated, Inverted, Product, Sum, LT, LE, EQ, NE, GE, GT, @@ -13,31 +13,47 @@ export parse_asp, debug_asp, Aggregate, Elements, InclusionCondition, Constraint, LeftBound, RightBound, Choice, RestrictedChoice, Choices, - Disjunction, Body, Rule, Restriction, WeakRestriction, Annotation, + Disjunction, Head, Body, Rule, Restriction, WeakRestriction, Annotation, Query, Program + + +abstract type Node end +Base.:(==)(n1::Node, n2::Node) = (typeof(n1) == typeof(n2)) && (n1.args == n2.args) + +pstring(x::Any, level=0) = repr(x) +abstract type Terminal <: Node end macro terminal(lang) return quote - struct $lang <: Node end + struct $lang <: Terminal end end end +pstring(x::Terminal, level=0) = "$(" "^level)$(typeof(x))" +abstract type NonTerminal <: Node end macro variable(lang) return quote - struct $lang <: Node + struct $lang <: NonTerminal args end end end +function pstring(x::NonTerminal, level=0) + if typeof(x.args) <: AbstractVector + pargs = x.args .|> (z -> pstring(z, level + 2)) + "\n$(" "^level)$(typeof(x))($(join(pargs, ","))\n$(" "^level))" + else + pargs = join(pstring.(x.args), ",") + "\n$(" "^level)$(typeof(x))($pargs) - $(typeof(x.args))" + end +end + using ParserCombinator #= DATA STRUCTURES =# -abstract type Node end -Base.:(==)(n1::Node, n2::Node) = (typeof(n1) == typeof(n2)) && (n1.args == n2.args) - @variable Variable @variable StringConstant @variable SymbolicConstant @@ -92,6 +108,7 @@ Base.:(==)(n1::Node, n2::Node) = (typeof(n1) == typeof(n2)) && (n1.args == n2.ar @variable Disjunction @variable Annotation @variable Body +@variable Head @variable Rule @variable Restriction @@ -316,7 +333,7 @@ statement = # strong restriction (E":-" + body + E"." > Restriction) | # rule - (head + Opt(annotation) + Opt(E":-" + body) + E"." |> Rule) | + ((head + Opt(annotation) |> Head) + Opt(E":-" + body) + E"." |> Rule) | # weak restriction (E":~" + Opt(body) + E"." + spc + E"[" + weight_at_level + E"]" |> WeakRestriction) statements = StarList(statement, E"") diff --git a/code/asplang/drafts.jl b/code/asplang/drafts.jl index 3622b0f..5ca020a 100644 --- a/code/asplang/drafts.jl +++ b/code/asplang/drafts.jl @@ -4,8 +4,7 @@ using .ASPLang function test_parse(source, grammar=asp_grammar) expr = parse_asp(source, grammar) - println("$source => $(expr).\n") - print(pstring(expr)) + println("$source\n$(pstring(expr))") end # test_parse("\"a\"", term_grammar) diff --git a/code/asplang/sbf.plp b/code/asplang/sbf.plp index ffa07cb..71c3522 100644 --- a/code/asplang/sbf.plp +++ b/code/asplang/sbf.plp @@ -1,2 +1,3 @@ a::"0.3". -b | c :- a. \ No newline at end of file +b | c ::"0.7" :- a. +:- not c. \ No newline at end of file diff --git a/pex2024/candidatura.md b/pex2024/candidatura.md index a64813c..a37c24a 100644 --- a/pex2024/candidatura.md +++ b/pex2024/candidatura.md @@ -1,4 +1,102 @@ -# Candidatura PeX - Zugzwang +# Candidatura PEx - Zugzwang + + +## 2024-01-05 - Next Research Lines + +> After the base-setting work of "_An Algebraic Approach to Stochastic ASP_" these are the next tasks to consider. Is summary: +> 1. **Logic Programming** - Stratified & Non-stratified programs +> 2. **Computer Science** - Inductive Logic Programming +> 3. **Software** - Integration with Potassco and other frameworks +> 4. **Applications** + +#### Line 1: Logic Programming - Stratified & Non-stratified programs + +##### Line 1a - Logic Programs Structure and Properties + +> _Stratified_ & _non-stratified_ programs are quoted in the "CREDAL" papers as important classes of logic programs. + +Minimal example of a **non-stratified program**. + +The following annotated LP, with clauses $c_1, c_2, c_3$ respectively, is non-stratified (because has a cycle with negated arcs) but no head is disjunctive: +```prolog +0.3::a. % c1 +b :- not c, not a. % c2 +c :- not b. % c3 +``` + +This program has three stable models: +$$ +\begin{aligned} +m_1 &= \set{ a, c } \cr +m_2 &= \set{ \neg a, b } \cr +m_3 &= \set{ \neg a, c } +\end{aligned} +$$ + +> We should **investigate** _What are stratified programs and why are they important?_ and how does our approach deals with such programs? + +##### Line 1b - Investigate the expressiveness of PASP + +Consider: + +- Recursion +- Variables, +- Functional symbols, + +##### Line 1c - The equivalence relation + +Consider the cases where only $s \subseteq e$ and $e \subseteq s$. Or other refinements. Also consider the inconsistent and independent events. + +##### Line 1d - Stability of the error function + +Consider alternative error functions. See statistics, Kullback-Leibler divergence + +#### Line 2: Computer Science - Inductive Logic Programming + +> Proceed from scoring programs to support genetic algorithms or other program space exploration methods. + +Scoring programs, as described in our paper, is just a step into **Inductive Logic Programming**. To go further, we need to explore algorithms that: + +1. Use **background knowledge**, expressed as a PLP. +2. Consult **positive examples** that should be _soft_ induced. +3. Consult **negative examples** that should be _soft_ excluded. +4. Generate **PLPs** that are scored. +5. Recombine the **best scored** into a new _population_, using recombination rules. + +> In order to do that, **PLPs must be expressed as data structures** to be manipulated. Also **recombination rules** must investigated before become formally expressed and supported with adequate methods. + +#### Line 3: Software - Integration with Potassco and other frameworks + +> Support annotated programs with zugzwang semantics. + +- Bayesian Networks (BII Alice) + - Generate an annotated asp program from a bayesian network and run it trough `clingo`. + - Recover the stable models from the previous ste and compute the respective probabilities. +- Program Manipulation + - Annotated ASP program _representation_ and a _parser_. + +#### Line 4: Applications + +> Apply zugzwang to a few showcases, besides the theoretic corner stones (non-stratified, disjunctive, bayes networks), preferably based in real world scenarios, with complex structure and large datasets. + +- (Stochastic) Plan Generation +- Yale-Shooting Problem +- (Stochastic) Situation Calculus +- Frame Problem +- Latent Facts - and core assumptions. +- Given a **Bayesian Network** (or a **Markov Networks**): + - Represent it. (**done** for BNs; MNs?) + - Solve the common probability tasks: join (**done**), marginals, conditionals, parameter learning, inferring unobserved variables, sample generation, _etc._ +- Given a _solved_ ASP specification: + - What is the marginal probability of the atom `a`? (**done**) + - What other probability queries are important to consider? +- Given an _unsolved_ ASP specification: + - What is the probability (distribution?) of the probabilistic fact `a`? + - What other questions are relevant? _E.g._ the distribution family of a fact? +- Given a _solved_ ASP specification and a set of _samples_: + - How do the probabilities inferred from the specification match the ones from the empiric distribution? (**done** might see alternative approaches) +- Given two _solved_ ASP specification and a set of _samples_: + - Which specification best describes the empiric distribution? (**done**) ## Tarefas diff --git a/pex2024/candidatura.pdf b/pex2024/candidatura.pdf new file mode 100644 index 0000000..19f4609 Binary files /dev/null and b/pex2024/candidatura.pdf differ diff --git a/projecto-NovaLINCS.gdlink b/projecto-NovaLINCS.gdlink deleted file mode 100644 index 9650490..0000000 --- a/projecto-NovaLINCS.gdlink +++ /dev/null @@ -1 +0,0 @@ -{"url": "https://drive.google.com/file/d/1liS-0PGFXZVVPtfiRZix2JXjXzshbNKw/view?usp=drivesdk", "file_id": "1liS-0PGFXZVVPtfiRZix2JXjXzshbNKw", "account_email": "mangon@gmail.com"} \ No newline at end of file -- libgit2 0.21.2