Giter Club home page Giter Club logo

anthem's Issues

Add logic for parsing user guides

A user guide should not contain any annotated formulas other than

role: assumption
direction: universal

Otherwise an error should be thrown.

If any function constants other than placeholders occur in the formulas of a user guide, specification, or proof outline, a warning should be issued.

Let `anthem translate` optionally read from stdin

anthem translate should read its input from stdin if <INPUT> is not given as an argument. This allows constructions like anthem translate --with tau-star <INPUT> | anthem translate --with gamma.

Standard preamble revisions

Symbolic constants should be of type "symbol" not "object"
Add a "symbol" custom type to preamble rather than relying on native $i sort

Add Theory node to FOL AST

From "Verifying Tight Logic Programs with Anthem and Vampire":
"A program is a finite set of rules."
"For any program Π, τ ∗Π stands for the set of formulas τ ∗R for all rules R of Π."
And a collection of closed logical formulae is a theory, so an ASP Program node should translate to a FOL Theory node.

Proper formatting of placeholders in TPTP

Placeholders are syntactically indistinguishable from symbolic constants, but semantically they behave like free variables. Since TPTP requires type-casting for comparisons, e.g.

$lesseq(a, n)

is forbidden if a is a function constant but n is an integer placeholder, this makes formatting them correctly in TPTP very inconvenient. Currently using a temporary rename-and-replace strategy with regexes as a post-processing step in zach/dev.

One option is to make placeholders part of the fol AST: general-sorted placeholders are treated similarly to symbolic constants and integer-sorted placeholders are treated similarly to integer terms. So, rather than replacing them with variables of the appropriate sort, we could replace them with zero-arity functions of the appropriate sort.

Ultimately, I'm not sure there is a perfect way to do this. Parsing and formatting should be context-independent, but the presence of a user guide affects whether n is treated as a symbolic constant, a free-valued integer function, or a free valued general function.

Convenient naming for integer-sorted variables

VL requested (Feb 2, 2024) that the convention of writing "N$i" to denote an integer variable named N be converted to just "N$".

A way to write variables with sort information is:

N$g is understood as a general-sorted variable named N
N is understood as a general-sorted variable named N

N$i is understood as a integer-sorted variable named N
N$ is understood as a integer-sorted variable named N

For any other sort s, N$s denotes an s-sorted variable named N

Support second mini-gringo dialect and tau* variant with absolute value and modified division

Clingo's definition of division/modulo differs from mathematical definition presented in "Verifying Tight Logic Programs with ANTHEM and VAMPIRE" in the case of negative divisors (uses truncation to zero instead of floor).

Up-to-date definitions are in Jorge & Vladimir's "Omega-Completeness..." draft, which adds absolute value as a function to mini-GRINGO and the two-sorted target language.

So do we want to make anthem clingo-compliant and add this?
omega.pdf

Quality of Life: Variable Names

The formula

exists I J ( forall I ( p(I) -> q(J) ) & q(I) )

is correct. But it would be easier to read if it were

exists I J ( forall I1 ( p(I1) -> q(J) ) & q(I) )

Another parsing bug

The FOL parser is unable to parse atoms that begin with "g" for unknown reasons.

For example, "not g" does not parse correctly. In zach/tau_star_v1 branch, see the parse_formula tests in src/parsing/fol/pest.rs for an example, and the tau_star_test16 in tau_star.rs for another example (note that it differs from tau_star_test15 in exactly one character, "g" vs "t" in the atom).

Allow cascading translation in `anthem translate`

I should be possible to cascade multiple translations in anthem translate, e.g.

anthem translate --with tau-star, gamma <INPUT>.

This issue is difficult as it requires some kind of dynamic typing with the command line.

Parsing bug

The parser is unable to parse the rule

p :- a != b.

Since a is recognized as a predicate before being recognized as a term within a comparison.

Fix tau* in master

Throw unreachable! errors instead of handling SymbolicTerm::Variables in tau*

Parsing bug: comparisons between symbolic constants and integers.

Currently the parser fails the following test case, and throws an error when attempting to parse "n > 1" as a FOL formula.
(
"n > 1",
Formula::AtomicFormula(AtomicFormula::Comparison(Comparison {
term: GeneralTerm::Symbol("n".to_string()),
guards: vec![Guard {
relation: Relation::Greater,
term: GeneralTerm::IntegerTerm(IntegerTerm::BasicIntegerTerm(
BasicIntegerTerm::Numeral(1),
)),
}],
})),
)

Improve parsing error messages

Currently, the parser doesn't pinpoint where the error actually occurs, and gives a somewhat cryptic "expected EOI" error message for a line containing a syntax error. For example:

      Error: could not parse file `test.lp`
      
      Caused by:
           --> 2:1
            |
          2 | composite(I*J) :- sqrt_b(M), I = 2..M, J = 2..b. 
            | ^---
            |
            = expected EOI

In this case, the parsing error was caused by the "_" in sqrt_b, but the error message doesn't help a user pinpoint that.

Spec parsing

Currently the FOL grammar supports parsing and formatting everything up to and including theories. But we still need annotations for these formulas when we parse Anthem specifications or Anthem-P2P user guides. The following grammar rules should be added:

predicate_signature = @{ predicate_symbol ~ "/" ~ (("0") | (ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*)) }

statement = { assumption | axiom | spec | lemma | input | output }
assumption = { "assume:" ~ formula ~ "." }
axiom = { "axiom:" ~ formula ~ "." }
spec = { "spec:" ~ formula ~ "." }
lemma = { "lemma:" ~ formula ~ "." }
input = { "input:" ~ (placeholder | predicate_signature) ~ ("," ~ (placeholder | predicate_signature))* ~ "." }
output = { "output:" ~ (predicate_signature) ~ ("," ~ (predicate_signature))* ~ "." }

specification = _{ SOI ~ statement* ~ EOI }

Add sort to TPTP variable printing

The spec language lets users write formulas like

forall X exists X$i q(X, X$i)

which in TPTP would currently be formatted ambiguously as

![X : $object] ( ?[X : $int]: ( q(X, X) ) )

which Vampire views as a syntax error. Instead, when formatting a variable named X with sort s in TPTP we should print Xs:

![Xg : $object] ( ?[Xi : $int]: ( q(Xg, Xi) ) )

Add a `--format` argument to `anthem translate`

It should be possible to specify the used formatter in anthem translate, e.g.

  • anthem translate --with tau-star --format default
  • anthem translate --with tau-star --format tptp
  • anthem translate --with tau-star --format debug

Ideas on the project structure

*analysing
    tightness

command_line

convenience
    apply
    unbox

formatting      -> Format structs
    asp
        default
    fol
        default
        tptp

parsing         -> Parser trait
    asp
        pest
    fol
        pest

*verifying
    task        -> Task trait
    problem     -> Problem struct
    proof

simplifiying
    fol
        ht
        *classic

syntax_tree     -> Node trait
    asp
    fol

translating
    gamma
    tau_star
    *completion

Modules marked with an * do not yet exist.
The module problem_building should be renamed into verifying/problem.

Release version 0.1

We should schedule a group meeting with all Anthem group members to discuss three related issues:

  1. Project scope. Should the potassco/anthem software project be a comprehensive toolkit for ASP verification, or a library supporting verification?
  2. Project name. Based on the scope, is this project named Anthem, Anthem-Next, or ASPCtk?
  3. Time to prepare a release to crates.io supporting (at minimum, tau* and a CLI).

Changing the spec language

Vladimir requested (Oct 19, 2023) the following modification to the parsing/formatting of integer/general variables:

"I like this. But it may be even better to adopt different conventions for variable names of two kinds: those that begin with I, J, K, L, M, N and those that begin with other letters. A variable of the first kind is integer unless it ends with $g; a variable of the second kind is general unless it ends with $i."

Add TRUE as a logical primitive to target language

TRUE should be a logical primitive analogous to FALSE. Furthermore, empty conjunctions (empty disjunctions) should be simplified to TRUE (FALSE). Especially within the tau* translation, the treatment of a fact "p" is better understood as an empty conjunction of tau^B applied to body literals, which simplifies to "true -> p" rather than just translating it as "p"

Unique name assumption

Function constants that occur within a program (but are not specified as placeholders) need a unique name axiom added to Vampire problem files. For example, Patrick's code adds

tff(symbolic_constant_order, axiom, p__less__(a, b)).

to the problem file generated by the problem

( {p :- a != b}, {spec: p.} )

Unnamed inductive lemmas are not TPTP compliant

An unnamed inductive lemma is named "inductive-lemma" by default, but TPTP forbids the "-" symbol in formula names. We should probably change the parsing and formatting of the inductive lemma role to "inductive_lemma"

Renaming predicates in program-to-program verification

Currently, predicate renaming always occurs (but it doesn't have to). We need to settle on cases when renaming isn't necessary with the goal of making lemma writing easier (e.g. don't have to name a predicate p as p_1 or p_2 when writing lemmas).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.