All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cdc.applic.proofs.Prover Maven / Gradle / Ivy

The newest version!
package cdc.applic.proofs;

import cdc.applic.dictionaries.handles.DictionaryHandle;
import cdc.applic.expressions.ApplicException;
import cdc.applic.expressions.Expression;
import cdc.applic.expressions.ast.Node;

/**
 * Interface of higher level proofs.
 *
 * 

Notation

* An expression X can be interpreted as a condition expressed with properties * Pi:
* X = X(P1, P2, ...)
* X is satisfiable when it is possible to allocate one value vito * each property Pi, such as X evaluates to {@code true}.
* Such an allocation is a tuple v = (v1, v2, ...)
* vi ∈ Ti = Ti(Pi) = {vi1, ..., viN}, * the type of Pi. *

* v ∈ V(X) = T1×T2×... *

* Let VSAT(X) = {v|X(v)≡true} and * VUNSAT(X) = {v|X(v)≡false}
* So, V(X) = VSAT(X) ∪ VUNSAT(X)
* We have VUNSAT(X) = VSAT(¬X) *

* These formulas are equivalent: *

    *
  • SAT(X) ≡ VSAT(X) ≠ ∅ *
  • !SAT(X) ≡ VSAT(X) = ∅ *
  • UNSAT(X) ≡ VUNSAT(X) ≠ ∅ ≡ SAT(¬X) ≠ ∅ *
  • !UNSAT(X) ≡ VUNSAT(X) = ∅ ≡ SAT(¬X) = ∅ *
* *

Simple positive formulas

*
    *
  • X is sometimes true, ST(X), when VSAT(X) ≠ ∅, that * is SAT(X) *
  • X is never true, NT(X), when VSAT(X) = ∅, that is * !SAT(X)
    * VUNSAT(X) = V(X), which can be empty. *
  • X is always true, AT(X), when * VSAT(X) ≠ ∅ ∧ VUNSAT(X) = ∅,
    * which can also expressed as VSAT(X) ≠ ∅ ∧ VSAT(¬X) = ∅,
    * or AT(X) = ST(X) ∧ NT(¬X) = SAT(X) ∧ ¬SAT(¬X),
    * or VSAT(X) = V(X) ≠ ∅ *
* *

Simple negative formulas

*
    *
  • X is sometimes false, SF(X), when VSAT(¬X) ≠ ∅ *
  • X is never false, NF(X), when VSAT(¬X) = ∅ *
  • X is always false, AF(X), when * VSAT(¬X) ≠ ∅ ∧ VUNSAT(¬X) = ∅,
    * which can also expressed as VSAT(¬X) ≠ ∅ ∧ VSAT(X) = ∅,
    * or AF(X) = SF(X) ∧ NF(¬X) *
* *

Warning

*
    *
  • AT(X) → NF(X), but the opposite is false.
    * Always true and never false are different. *
  • AF(X) → NT(X), but the opposite is false.
    * Always false and never true are different. *
* It is generally meaningless to say anything on things that don't exist. All assertions can be proved to be true in that case.
* Therefore, NT(X) and NF(X) should always be used in conjunction with a formula that proves existence of * something. * *

Elaborated formulas

*
    *
  • X ∩ Y ≡ ST(X ∧ Y) ≡ SAT(X ∧ Y) *
  • X ⊂ Y ≡ X ∩ ¬Y = ∅ ≡ !SAT(X ∧ ¬Y) *
  • X ⊂ Y ∧ X ≠ ∅ ≡ !SAT(X ∧ ¬Y) ∧ SAT(X) *
  • ... *
* * @author Damien Carbonne */ public interface Prover { /** * @return The context used by this Prover. */ public DictionaryHandle getDictionaryHandle(); /** * @return The features used by this Prover. */ public ProverFeatures getFeatures(); /** * Returns {@code true} when a Node is never satisfiable. *

* This is equivalent to: *

    *
  • {@code !isSometimesTrue(node)}. *
* Note: result depends on features.
* Note: this invokes once {@code SatSystemSolver.isSatisfiable(SatSystem)}. *

* is never true * * @param node The Node. * @return {@code true} when {@code node} is never satisfiable. * @throws IllegalArgumentException When {@code node} is {@code null}. * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean isNeverTrue(Node node); /** * Returns {@code true} when an Expression is never satisfiable. *

* This is equivalent to: *

    *
  • {@code !isSometimesTrue(expression)}. *
  • {@code isNeverTrue(expression.getRootNode())}. *
* Note: result depends on features.
* Note: this invokes once {@code SatSystemSolver.isSatisfiable(SatSystem)}. *

* is never true * * @param expression The Expression. * @return {@code true} when {@code expression} is never satisfiable. * @throws IllegalArgumentException When {@code expression} is {@code null}. * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean isNeverTrue(Expression expression); /** * Returns {@code true} when a Node is sometimes (at least one solution) satisfiable. *

* Note: result depends on features.
* Note: this invokes once {@code SatSystemSolver.isSatisfiable(SatSystem)}. *

* Warning: this does not imply that the node is sometimes false, it may be always true. *

* is sometimes true * * @param node The Node. * @return {@code true} when {@code node} is sometimes satisfiable. * @throws IllegalArgumentException When {@code node} is {@code null}. * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean isSometimesTrue(Node node); /** * Returns {@code true} when an Expression is sometimes (at least one solution) satisfiable. *

* This is equivalent to: *

    *
  • {@code isSometimesTrue(expression.getRootNode())}. *
* Note: result depends on features.
* Note: this invokes once {@code SatSystemSolver.isSatisfiable(SatSystem)}. *

* Warning: this does not imply that the node is sometimes false, it may be always true. *

* is sometimes true * * @param expression The Expression. * @return {@code true} when {@code expression} is sometimes satisfiable. * @throws IllegalArgumentException When {@code expression} is {@code null}. * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean isSometimesTrue(Expression expression); /** * Returns {@code true} when a Node is always satisfiable. *

* This is equivalent to: *

    *
  • {@code isSometimesTrue(node) && isNeverTrue(!node)}. *
  • {@code isSometimesTrue(node) && !isSometimesTrue(!node)}. *
*

* Note: result depends on features.
* Note: this invokes once {@code SatSystemSolver.isSatisfiable(SatSystem)}. *

* WARNING: This must NOT be used when the tree contains {@code AtomVarNode}s. *

* is always true * * @param node The Node. * @return {@code true} when {@code node} is always satisfiable. * @throws IllegalArgumentException When {@code node} is {@code null}, * or contains an {@code AtomVarNode}. * * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean isAlwaysTrue(Node node); /** * Returns {@code true} when an Expression is always satisfiable. *

* This is equivalent to: *

    *
  • {@code isSometimesTrue(expression) && isNeverTrue(!expression)}. *
  • {@code isSometimesTrue(expression) && !isSometimesTrue(!expression)}. *
  • {@code isAlwaysTrue(expression.getRootNode())}. *
*

* Note: result depends on features.
* Note: this invokes twice {@code SatSystemSolver.isSatisfiable(SatSystem)}. *

* is always true * * @param expression The Expression. * @return {@code true} when {@code expression} is always satisfiable. * @throws IllegalArgumentException When {@code expression} is {@code null}. * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean isAlwaysTrue(Expression expression); /** * Returns {@code true} when the negation of a Node is never satisfiable. *

* This is equivalent to: *

    *
  • {@code !isSometimesFalse(node)}. *
  • {@code !isSometimesTrue(!node)}. *
* Note: result depends on features.
* Note: this invokes once {@code SatSystemSolver.isSatisfiable(SatSystem)}. *

* is never false * * @param node The Node. * @return {@code true} when {@code !node} is never satisfiable. * @throws IllegalArgumentException When {@code node} is {@code null}. * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean isNeverFalse(Node node); /** * Returns {@code true} when the negation of an Expression is never satisfiable. *

* This is equivalent to: *

    *
  • {@code isNeverTrue(!node)}. *
  • {@code !isSometimesTrue(!node)}. *
  • {@code !isSometimesFalse(node)}. *
* Note: result depends on features.
* Note: this invokes once {@code SatSystemSolver.isSatisfiable(SatSystem)}. *

* is never false * * @param expression The Expression. * @return {@code true} when {@code !expression} is never satisfiable. * @throws IllegalArgumentException When {@code expression} is {@code null}. * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean isNeverFalse(Expression expression); /** * Returns {@code true} when the negation of a Node is sometimes (at least one solution) satisfiable. *

* This is equivalent to: *

    *
  • {@code isSometimesTrue(!node)}. *
* Note: result depends on features.
* Note: this invokes once {@code SatSystemSolver.isSatisfiable(SatSystem)}. *

* Warning: this does not imply that the node is sometimes true, it may be always false. *

* is sometimes false * * @param node The Node. * @return {@code true} when {@code !node} is sometimes satisfiable. * @throws IllegalArgumentException When {@code node} is {@code null}. * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean isSometimesFalse(Node node); /** * Returns {@code true} when the negation of an Expression is sometimes (at least one solution) satisfiable. *

* This is equivalent to: *

    *
  • {@code isSometimesTrue(!expression)}. *
* Note: result depends on features.
* Note: this invokes once {@code SatSystemSolver.isSatisfiable(SatSystem)}. *

* Warning: this does not imply that the node is sometimes true, it may be always false. *

* is sometimes false * * @param expression The Expression. * @return {@code true} when {@code !expression} is sometimes satisfiable. * @throws IllegalArgumentException When {@code expression} is {@code null}. * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean isSometimesFalse(Expression expression); /** * Returns {@code true} when the negation of a Node is always satisfiable. *

* This is equivalent to: *

    *
  • {@code isAlwaysTrue(!node)}. *
  • {@code isSometimesTrue(!node) && isNeverTrue(node)}. *
  • {@code isSometimesTrue(!node) && !isSometimesTrue(node)}. *
  • {@code isSometimesFalse(node) && isNeverFalse(!node)}. *
  • {@code isSometimesFalse(node) && !isSometimesFalse(!node)}. *
*

* Note: result depends on features.
* Note: this invokes twice {@code SatSystemSolver.isSatisfiable(SatSystem)}. *

* WARNING: This must NOT be used when the tree contains {@code AtomVarNode}s. *

* is always false * * @param node The Node. * * @return {@code true} when {@code !node} is always satisfiable. * @throws IllegalArgumentException When {@code node} is {@code null}, * or contains an {@code AtomVarNode}. * * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean isAlwaysFalse(Node node); /** * Returns {@code true} when the negation of an Expression is always satisfiable. *

* This is equivalent to: *

    *
  • {@code isAlwaysTrue(!expression)}. *
  • {@code isSometimesTrue(!expression) && isNeverTrue(expression)}. *
  • {@code isSometimesTrue(!expression) && !isSometimesTrue(expression)}. *
  • {@code isSometimesFalse(expression) && isNeverFalse(!expression)}. *
  • {@code isSometimesFalse(expression) && !isSometimesFalse(!expression)}. *
*

* Note: result depends on features.
* Note: this invokes twice {@code SatSystemSolver.isSatisfiable(SatSystem)}. *

* WARNING: This must NOT be used when the tree contains {@code AtomVarNode}s. *

* is always false * * @param expression The Expression. * @return {@code true} when {@code !expression} is always satisfiable. * @throws IllegalArgumentException When {@code expression} is {@code null}, * or contains an {@code AtomVarNode}. * * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean isAlwaysFalse(Expression expression); /** * Returns {@code true} when 2 Nodes are always equivalent. * This is equivalent to: *

    *
  • {@code isAlwaysTrue(alpha <-> beta)}. *
* are always equivalent * * @param alpha The alpha condition. * @param beta The beta condition. * @return {@code true} when {@code alpha} and {@code beta} are always equivalent. */ public boolean areAlwaysEquivalent(Node alpha, Node beta); /** * Returns {@code true} when 2 Expressions are always equivalent. * This is equivalent to: *
    *
  • {@code isAlwaysTrue(alpha <-> beta)}. *
* are always equivalent * * @param alpha The alpha condition. * @param beta The beta condition. * @return {@code true} when {@code alpha} and {@code beta} are always equivalent. */ public boolean areAlwaysEquivalent(Expression alpha, Expression beta); /** * Returns {@code true} when it is {@code true} that an alpha condition intersects with a beta condition. *

* When {@code alpha} or {@code beta} condition is {@code false}, returns {@code false}. * This is equivalent to: *

    *
  • {@code isSometimesTrue(alpha & beta)}. *
* intersects * * @param alpha The alpha condition. * @param beta The beta condition. * @return {@code true} when it is {@code true} that a {@code alpha} condition intersects with {@code beta} condition. */ public boolean intersects(Node alpha, Node beta); /** * Returns {@code true} when it is {@code true} that an alpha condition intersects with a beta condition. *

* When {@code alpha} or {@code beta} condition is {@code false}, returns {@code false}. * This is equivalent to: *

    *
  • {@code isSometimesTrue(alpha & beta)}. *
* intersects * * @param alpha The alpha condition. * @param beta The beta condition. * @return {@code true} when it is {@code true} that a {@code alpha} condition intersects with {@code beta} condition. */ public boolean intersects(Expression alpha, Expression beta); /** * Returns {@code true} when it is {@code true} that an outer condition contains an inner condition. *

* When {@code inner} condition is false, answer is {@code true}. * This is equivalent to: *

    *
  • {@code !isSometimesTrue(!outer & inner)}. *
  • {@code isNeverTrue(!outer & inner)}. *
  • {@code isContained(inner, outer)}. *
* contains * * @param outer The outer condition. * @param inner The inner condition. * @return {@code true} when it is {@code true} that a {@code outer} condition contains {@code inner} condition. */ public boolean contains(Node outer, Node inner); /** * Returns {@code true} when it is {@code true} that an outer condition contains an inner condition. *

* When {@code inner} condition is false, answer is {@code true}. * This is equivalent to: *

    *
  • {@code !isSometimesTrue(!outer & inner)}. *
  • {@code isNeverTrue(!inner & outer)}. *
  • {@code isContained(inner, outer)}. *
* contains * * @param outer The outer condition. * @param inner The inner condition. * @return {@code true} when it is {@code true} that a {@code outer} condition contains {@code inner} condition. */ public boolean contains(Expression outer, Expression inner); /** * Returns {@code true} when it is {@code always true} that an outer condition contains an inner condition, * and the inner condition is not {@code false}. *

* This is equivalent to: *

    *
  • {@code isNeverTrue(!inner & outer) & isSometimesTrue(inner)}. *
  • {@code isNonEmptyContained(inner, outer)}. *
* contains non empty * * @param outer The outer condition. * @param inner The inner condition. * @return {@code true} when it is {@code always true} that {@code outer} condition contains {@code inner} condition * and {@code inner} is not {@code false}. */ public boolean containsNonEmpty(Node outer, Node inner); /** * Returns {@code true} when it is {@code always true} that an outer condition contains an inner condition, * and the inner condition is not {@code false}. *

* This is equivalent to: *

    *
  • {@code isNeverTrue(!inner & outer) & isSometimesTrue(inner)}. *
  • {@code isNonEmptyContained(inner, outer)}. *
* contains non empty * * @param outer The outer condition. * @param inner The inner condition. * @return {@code true} when it is {@code always true} that {@code outer} condition contains {@code inner} condition * and {@code inner} is not {@code false}. */ public boolean containsNonEmpty(Expression outer, Expression inner); /** * Returns {@code true} when it is {@code true} that an inner condition is contained in an outer condition. *

* When {@code inner} condition is false, answer is {@code true}. * This is equivalent to: *

    *
  • {@code !isSometimesTrue(!outer & inner)}. *
  • {@code isNeverTrue(!inner & outer)}. *
  • {@code contains(outer, inner)}. *
* * @param inner The inner condition. * @param outer The outer condition. * @return {@code true} when it is {@code true} that {@code inner} condition is contained in {@code outer} condition. */ public boolean isContained(Node inner, Node outer); /** * Returns {@code true} when it is {@code true} that an inner condition is contained in an outer condition. *

* When {@code inner} condition is false, answer is {@code true}. * This is equivalent to: *

    *
  • {@code !isSometimesTrue(!outer & inner)}. *
  • {@code isNeverTrue(!inner & outer)}. *
  • {@code contains(outer, inner)}. *
* * @param inner The inner condition. * @param outer The outer condition. * @return {@code true} when it is {@code true} that {@code inner} condition is contained in {@code outer} condition. */ public boolean isContained(Expression inner, Expression outer); /** * Returns {@code true} when it is {@code always true} that an inner condition is not {@code false} and is * contained in an outer condition. *

* This is equivalent to: *

    *
  • {@code isNeverTrue(!inner & outer) & isSometimesTrue(inner)}. *
  • {@code containsNonEmpy(outer, inner)}. *
* * @param inner The inner condition. * @param outer The outer condition. * @return {@code true} when it is {@code always true} that {@code inner} condition is not {@code false}, * and is contained in {@code outer} condition. */ public boolean isNonEmptyContained(Node inner, Node outer); /** * Returns {@code true} when it is {@code always true} that an inner condition is not {@code false} and is * contained in an outer condition. *

* This is equivalent to: *

    *
  • {@code isNeverTrue(!inner & outer) & isSometimesTrue(inner)}. *
  • {@code containsNonEmpy(outer, inner)}. *
* * @param inner The inner condition. * @param outer The outer condition. * @return {@code true} when it is {@code always true} that {@code inner} condition is not {@code false}, * and is contained in {@code outer} condition. */ public boolean isNonEmptyContained(Expression inner, Expression outer); /** * Returns {@code true} when it is {@code always true} that {@code at least one} condition is {@code true}. *

* This is equivalent to: *

    *
  • {@code isAlwaysTrue(atLeastOne(nodes))}. *
* * @param nodes The conditions. * @return {@code true} when it is {@code always true} that {@code at least one} of {@code nodes} is {@code true}. * @throws IllegalArgumentException When {@code nodes} is {@code null} or empty. * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean alwaysAtLeastOne(Node... nodes); /** * Returns {@code true} when it is {@code always true} that {@code at least one} condition is {@code true}. *

* This is equivalent to: *

    *
  • {@code isAlwaysTrue(atLeastOne(expressions))}. *
* * @param expressions The conditions. * @return {@code true} when it is {@code always true} that {@code at least one} of {@code expressions} is {@code true}. * @throws IllegalArgumentException When {@code expressions} is {@code null} or empty. * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean alwaysAtLeastOne(Expression... expressions); /** * Returns {@code true} when it is {@code always true} that {@code at most one} condition is {@code true}. *

* This is equivalent to: *

    *
  • {@code isAlwaysTrue(atMostOne(nodes))}. *
* * @param nodes The conditions. * @return {@code true} when it is {@code always true} that {@code at most one} of {@code nodes} is {@code true}. * @throws IllegalArgumentException When {@code nodes} is {@code null}. * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean alwaysAtMostOne(Node... nodes); /** * Returns {@code true} when it is {@code always true} that {@code at most one} condition is {@code true}. *

* This is equivalent to: *

    *
  • {@code isAlwaysTrue(atMostOne(nodes))}. *
* * @param expressions The conditions. * @return {@code true} when it is {@code always true} that {@code at most one} of {@code expressions} is {@code true}. * @throws IllegalArgumentException When {@code nodes} is {@code null}. * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean alwaysAtMostOne(Expression... expressions); /** * Returns {@code true} when it is {@code always true} that {@code exactly one} condition is {@code true}. *

* This is equivalent to: *

    *
  • {@code isAlwaysTrue(exactlyOne(nodes))}. *
* * @param nodes The conditions. * @return {@code true} when it is {@code always true} that {@code exactly one} of {@code nodes} is {@code true}. * @throws IllegalArgumentException When {@code nodes} is {@code null} or empty. * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean alwaysExactlyOne(Node... nodes); /** * Returns {@code true} when it is {@code always true} that {@code exactly one} condition is {@code true}. *

* This is equivalent to: *

    *
  • {@code isAlwaysTrue(exactlyOne(expressions))}. *
* * @param expressions The conditions. * @return {@code true} when it is {@code always true} that {@code exactly one} of {@code expressions} is {@code true}. * @throws IllegalArgumentException When {@code nodes} is {@code null} or empty. * @throws ApplicException When there is a semantic or SatSolver problem. */ public boolean alwaysExactlyOne(Expression... expressions); public boolean alwaysAtLeastOneInContext(Node context, Node... nodes); public boolean alwaysAtLeastOneInContext(Expression context, Expression... expressions); public boolean alwaysAtMostOneInContext(Node context, Node... nodes); public boolean alwaysAtMostOneInContext(Expression context, Expression... expressions); public boolean alwaysExactlyOneInContext(Node context, Node... nodes); public boolean alwaysExactlyOneInContext(Expression context, Expression... expressions); public ProverMatching getMatching(Node node); public ProverMatching getMatching(Expression expression); public ProverMatching getProjectedMatching(Node domain, Node on); public ProverMatching getProjectedMatching(Expression domain, Expression on); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy