Copyright | (c) 2017 2018 N Steenbergen |
---|---|
License | GPL-3 |
Maintainer | ns@slak.ws |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
A generic decision algorithm based on the method of analytic tableaux.
- data TableauSystem ext = TableauSystem {
- title :: String
- rules :: [RuleUninstantiated ext]
- assumptions' :: [Formula ext]
- data Constraint primitive ext
- = None
- | Bind (Ambiguous (Term ext)) (Terms primitive ext)
- | Choose [Constraint primitive ext]
- | Merge [Constraint primitive ext]
- data Compositor
- data Rule generator ext = Rule {
- name :: String
- consumptions :: [Marked (Formula ext)]
- productions :: [[Marked (Formula ext)]]
- generator :: generator
- constraint :: Constraint PrimitiveDynamicTerms ext
- compositor :: Compositor
- type RuleUninstantiated ext = Rule (Constraint PrimitiveStaticTerms ext) ext
- data PrimitiveDynamicTerms
- data PrimitiveStaticTerms
- = Root
- | Assumption
- data Terms primitive ext
- type DynamicTerms = Terms PrimitiveDynamicTerms
- type StaticTerms = Terms PrimitiveStaticTerms
- decide :: forall ext. Extension ext => TableauSystem ext -> Formula ext -> Result (Formula ext) (Tableau ext)
- initial :: forall ext. Extension ext => TableauSystem ext -> Formula ext -> (TableauSettings ext, Branch ext)
- data TableauSettings ext = TableauSettings {
- rulesC :: [RuleInstantiated ext]
- root :: Marked (Formula ext)
- assumptions :: [Formula ext]
- data Ref ref val = (:=) {}
- data Branch ext = Branch {
- rulesA :: Maybe (PointedList (RuleInstantiated ext))
- actives :: Maybe (PointedList (BranchFormula ext))
- inactives :: [BranchFormula ext]
- new :: [BranchFormula ext]
- counter :: Int
- type BranchFormula ext = Ref Int (Marked (Formula ext))
- type RuleInstantiated ext = Rule (PointedList (Substitution ext)) ext
- data Result input output
- data Tableau ext
- = Node [BranchFormula ext] (Tableau ext)
- | Application String [Int] [Tableau ext]
- | Closure [Int]
- shorten :: Tableau ext -> Tableau ext
- renumber :: Int -> Tableau ext -> Tableau ext
- rewrite :: Extension ext => Formula ext -> Tableau ext -> Tableau ext
- greedy :: Alternative f => [a] -> f a
- intersection :: Eq a => [[a]] -> [a]
- combinations :: [[a]] -> [[a]]
Input structures
data TableauSystem ext Source #
Before initialisation, the tableau system is read into this structure.
TableauSystem | |
|
Printable ext => Printable (TableauSystem ext) Source # | |
data Constraint primitive ext Source #
A constraint is placed on a tableau rule to restrict the values to which its variables can be bound. This means that some applications of the rule will be blocked; but also that any "free" or "generative" variables (that is, variables that occur in the rule's productions but not in its consumptions) can now be associated with a set of possible assignments, thereby making it possible to, essentially, generate a choice of multiple instantiations of a single rule.
None | |
Bind (Ambiguous (Term ext)) (Terms primitive ext) | Demand that the pattern occurs in a particular set of terms. |
Choose [Constraint primitive ext] | Constraint holds if one of the subconstraints hold. |
Merge [Constraint primitive ext] | Constraint holds if all subconstraints hold. |
data Compositor Source #
Indicates how to handle the situation where multiple rule instantiations are applicable to the same formula.
Due to their computational complexity, rules that do not take any consumptions are handled greedily regardless of the value of the compositor.
data Rule generator ext Source #
A rule describes which formulas it consumes and which it produces. In its
basic form, it can represent both instantiated and uninstantiated tableau
rules (see RuleInstantiated
and RuleUninstantiated
).
Rule | |
|
Printable ext => Printable (RuleUninstantiated ext) Source # | |
type RuleUninstantiated ext = Rule (Constraint PrimitiveStaticTerms ext) ext Source #
Before instantiation, a generator is described by a constraint. This constraint can only refer to static terms.
Term specification
data PrimitiveDynamicTerms Source #
Represent sets of primitive source formulas to be used in restrictive constraints.
Static PrimitiveStaticTerms | |
Processed | Active terms, currently not processed on the branch. |
Unprocessed | Inactive terms, currently processed on the branch. |
data PrimitiveStaticTerms Source #
Represent sets of primitive source formulas to be used in generators and restrictive constraints.
Root | Goal formula. |
Assumption | Assumption formulas or constant specification. |
Printable PrimitiveStaticTerms Source # | |
Printable ext => Printable (RuleUninstantiated ext) Source # | |
data Terms primitive ext Source #
Represent complex sets of source terms, to be turned into concrete terms at a point where it is known what they should refer to. Static terms are known at the start of the tableau procedure, whereas dynamic terms should be evaluated dynamically.
type DynamicTerms = Terms PrimitiveDynamicTerms Source #
Shorthand for a specification of complex dynamic terms.
type StaticTerms = Terms PrimitiveStaticTerms Source #
Shorthand for a specification of complex static terms.
Decision algorithm
decide :: forall ext. Extension ext => TableauSystem ext -> Formula ext -> Result (Formula ext) (Tableau ext) Source #
Decide the validity of the target formula within the given logical system.
A branch closes when it internally contradicts. A branch that is neither
closed nor expandable corresponds to a satisfying assignment of the negation
of the target formula, and constitutes a counter-model. Otherwise, we have
successfully shown the formula's validity and can return a Tableau
.
initial :: forall ext. Extension ext => TableauSystem ext -> Formula ext -> (TableauSettings ext, Branch ext) Source #
Construct the initial branch and settings for the decision algorithm.
Intermediate structures
data TableauSettings ext Source #
The global state of the tableau — settings that will remain static after initialisation.
TableauSettings | |
|
Relates values to their identifiers.
A Branch
keeps track of the leaf of a single branch of the tableau, and
all that came before.
Branch | |
|
type BranchFormula ext = Ref Int (Marked (Formula ext)) Source #
Formulas on the branch are decorated by their reference number and marks.
type RuleInstantiated ext = Rule (PointedList (Substitution ext)) ext Source #
After instantiation, a generator consists of all variable assignments that it allows.
Output structures
A proof in a tableau system is a rose tree, containing sets of formulas and the rule applications used to obtain them.
Node [BranchFormula ext] (Tableau ext) | |
Application String [Int] [Tableau ext] | |
Closure [Int] |
Postprocessors
shorten :: Tableau ext -> Tableau ext Source #
Eliminate rule applications that do not produce any formulas that are involved in closing any branch.
Note that this will not eliminate all unnecessary applications (let alone
find the shortest proof) — it will only remove rules that are not involved
in any closure. For example, for justification logic, if c:φ
and d:ψ
are in the CS but only d:ψ
has to be introduced via CSr, then this will
remove any redundant CSr application — but if a formula is introduced via
a restricted cut, it could do nothing because the cut-formula IS involved in
the closure of a branch, even though it was pointless to do the cut in the
first place. It would be nice to think of a stronger method.
renumber :: Int -> Tableau ext -> Tableau ext Source #
Make the reference numbers on the formulas heterogeneous, even if they
are on different branches. This is done in a single step at the end so that
we do not have the mental (and computational) burden of carrying a
State
monad everywhere.
rewrite :: Extension ext => Formula ext -> Tableau ext -> Tableau ext Source #
If the root formula is not exactly equal to the input formula, there was supposedly a rewriting step. Add this step to the tableau explicitly, to show what happened.
Auxiliaries
greedy :: Alternative f => [a] -> f a Source #
Take the first option from a list of options.
intersection :: Eq a => [[a]] -> [a] Source #
Take the intersection of all given lists.
combinations :: [[a]] -> [[a]] Source #
A variation on permutations: given a list that describes the possible
elements at each position, give all possible element combinations. In a
sense, this is a transpose
operation.
Example: [[1,2],[3,4]] -> [[1,3],[1,4],[2,3],[2,4]]