Full reference for SoleLogics.jl
Auto documentation for SoleLogics.jl.
SoleLogics.:¬
— Constantconst NEGATION = NamedConnective{:¬}()
const ¬ = NEGATION
-arity(::typeof(¬)) = 1
Logical negation (also referred to as complement). It can be typed by \neg<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.:→
— Constantconst IMPLICATION = NamedConnective{:→}()
+arity(::typeof(¬)) = 1
Logical negation (also referred to as complement). It can be typed by \neg<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.:→
— Constantconst IMPLICATION = NamedConnective{:→}()
const → = IMPLICATION
-arity(::typeof(→)) = 2
Logical implication. It can be typed by \to<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.:∧
— Constantconst CONJUNCTION = NamedConnective{:∧}()
+arity(::typeof(→)) = 2
Logical implication. It can be typed by \to<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.:∧
— Constantconst CONJUNCTION = NamedConnective{:∧}()
const ∧ = CONJUNCTION
-arity(::typeof(∧)) = 2
Logical conjunction. It can be typed by \wedge<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.:∨
— Constantconst DISJUNCTION = NamedConnective{:∨}()
+arity(::typeof(∧)) = 2
Logical conjunction. It can be typed by \wedge<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.:∨
— Constantconst DISJUNCTION = NamedConnective{:∨}()
const ∨ = DISJUNCTION
-arity(::typeof(∨)) = 2
Logical disjunction. It can be typed by \vee<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.BASE_OPERATORS
— Constantconst BASE_OPERATORS = [¬, ∧, ∨, →]
Basic logical operators.
See also NEGATION
, CONJUCTION
, DISJUNCTION
, IMPLICATION
, Connective
.
SoleLogics.BASE_PARSABLE_OPERATORS
— Constantconst BASE_PARSABLE_OPERATORS = SoleLogics.Syntactical[¬, ∧, ∨, →, ◊, □, ⟨G⟩, [G], ⟨=⟩, [=], ⊤, ⊥]
Vector of (standard) operators that are automatically taken care of when parsing.
See also parseformula
.
SoleLogics.BOT
— Constantstruct Bot <: Truth end
+arity(::typeof(∨)) = 2
Logical disjunction. It can be typed by \vee<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.BASE_OPERATORS
— Constantconst BASE_OPERATORS = [¬, ∧, ∨, →]
Basic logical operators.
See also NEGATION
, CONJUCTION
, DISJUNCTION
, IMPLICATION
, Connective
.
SoleLogics.BASE_PARSABLE_OPERATORS
— Constantconst BASE_PARSABLE_OPERATORS = SoleLogics.Syntactical[¬, ∧, ∨, →, ◊, □, ⟨G⟩, [G], ⟨=⟩, [=], ⊤, ⊥]
Vector of (standard) operators that are automatically taken care of when parsing.
See also parseformula
.
SoleLogics.BOT
— Constantstruct Bot <: Truth end
const BOT = Bot()
-const ⊥ = BOT
Canonical truth operator representing the value false
. It can be typed by \bot<tab>
.
SoleLogics.BOX
— Constantconst BOX = NamedConnective{:□}()
+const ⊥ = BOT
Canonical truth operator representing the value false
. It can be typed by \bot<tab>
.
SoleLogics.BOX
— Constantconst BOX = NamedConnective{:□}()
const □ = BOX
-arity(::typeof(□)) = 1
Logical box operator, typically interpreted as the modal universal quantifier. See here.
See also DIAMOND
, NamedConnective
, Connective
.
SoleLogics.CONJUNCTION
— Constantconst CONJUNCTION = NamedConnective{:∧}()
+arity(::typeof(□)) = 1
Logical box operator, typically interpreted as the modal universal quantifier. See here.
See also DIAMOND
, NamedConnective
, Connective
.
SoleLogics.CONJUNCTION
— Constantconst CONJUNCTION = NamedConnective{:∧}()
const ∧ = CONJUNCTION
-arity(::typeof(∧)) = 2
Logical conjunction. It can be typed by \wedge<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.DIAMOND
— Constantconst DIAMOND = NamedConnective{:◊}()
+arity(::typeof(∧)) = 2
Logical conjunction. It can be typed by \wedge<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.DIAMOND
— Constantconst DIAMOND = NamedConnective{:◊}()
const ◊ = DIAMOND
ismodal(::NamedConnective{:◊}) = true
-arity(::typeof(◊)) = 1
Logical diamond operator, typically interpreted as the modal existential quantifier. See here.
See also BOX
, NamedConnective
, Connective
.
SoleLogics.DISJUNCTION
— Constantconst DISJUNCTION = NamedConnective{:∨}()
+arity(::typeof(◊)) = 1
Logical diamond operator, typically interpreted as the modal existential quantifier. See here.
See also BOX
, NamedConnective
, Connective
.
SoleLogics.DISJUNCTION
— Constantconst DISJUNCTION = NamedConnective{:∨}()
const ∨ = DISJUNCTION
-arity(::typeof(∨)) = 2
Logical disjunction. It can be typed by \vee<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.IA3Relations
— Constantconst IA3Relations = [IA_I, IA_L, IA_Li]
Vector of 3 interval relations from a coarser version of Allen's interval algebra.
See also IARelations
, IA7Relations
, IntervalRelation
, GeometricalRelation
.
SoleLogics.IA7Relations
— Constantconst IA7Relations = [IA_AorO, IA_L, IA_DorBorE,
- IA_AiorOi, IA_Li, IA_DiorBiorEi]
Vector of 7 interval relations from a coarser version of Allen's interval algebra.
See also IARelations
, IA3Relations
, IntervalRelation
, GeometricalRelation
.
SoleLogics.IABase
— Typeconst IABase = Union{IntervalRelation,IdentityRel,GlobalRel}
+arity(::typeof(∨)) = 2
Logical disjunction. It can be typed by \vee<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.IA3Relations
— Constantconst IA3Relations = [IA_I, IA_L, IA_Li]
Vector of 3 interval relations from a coarser version of Allen's interval algebra.
See also IARelations
, IA7Relations
, IntervalRelation
, GeometricalRelation
.
SoleLogics.IA7Relations
— Constantconst IA7Relations = [IA_AorO, IA_L, IA_DorBorE,
+ IA_AiorOi, IA_Li, IA_DiorBiorEi]
Vector of 7 interval relations from a coarser version of Allen's interval algebra.
See also IARelations
, IA3Relations
, IntervalRelation
, GeometricalRelation
.
SoleLogics.IABase
— Typeconst IABase = Union{IntervalRelation,IdentityRel,GlobalRel}
struct RectangleRelation{R1<:IABase,R2<:IABase} <: GeometricalRelation
x :: R1
y :: R2
@@ -33,37 +33,37 @@
"A̅,E̅"
"B̅,E"
"E̅,D̅"
- "O̅,D"
See also Interval
, Interval2D
, IntervalRelation
, [[
GeometricalRelation`](@ref).
SoleLogics.IARelations
— Constantconst IARelations = [IA_A, IA_L, IA_B, IA_E, IA_D, IA_O,
- IA_Ai, IA_Li, IA_Bi, IA_Ei, IA_Di, IA_Oi]
Vector of the 12 interval relations from Allen's interval algebra.
See also IA7Relations
, IA3Relations
, IntervalRelation
, GeometricalRelation
.
SoleLogics.IMPLICATION
— Constantconst IMPLICATION = NamedConnective{:→}()
+ "O̅,D"
See also Interval
, Interval2D
, IntervalRelation
, [[
GeometricalRelation`](@ref).
SoleLogics.IARelations
— Constantconst IARelations = [IA_A, IA_L, IA_B, IA_E, IA_D, IA_O,
+ IA_Ai, IA_Li, IA_Bi, IA_Ei, IA_Di, IA_Oi]
Vector of the 12 interval relations from Allen's interval algebra.
See also IA7Relations
, IA3Relations
, IntervalRelation
, GeometricalRelation
.
SoleLogics.IMPLICATION
— Constantconst IMPLICATION = NamedConnective{:→}()
const → = IMPLICATION
-arity(::typeof(→)) = 2
Logical implication. It can be typed by \to<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.NEGATION
— Constantconst NEGATION = NamedConnective{:¬}()
+arity(::typeof(→)) = 2
Logical implication. It can be typed by \to<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.NEGATION
— Constantconst NEGATION = NamedConnective{:¬}()
const ¬ = NEGATION
-arity(::typeof(¬)) = 1
Logical negation (also referred to as complement). It can be typed by \neg<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.Operator
— Typeconst Operator = Union{Connective,Truth}
Union type for logical constants of any ariety (zero for Truth
values, non-zero for Connective
s).
See also Connective
, Truth
.
SoleLogics.Operator
— Method(op::Operator)(o::Any)
An Operator
can be used to compose syntax tokens (e.g., atoms), syntax trees and/or formulas.
Examples
¬(Atom(1)) ∨ Atom(1) ∧ ⊤
+arity(::typeof(¬)) = 1
Logical negation (also referred to as complement). It can be typed by \neg<tab>
.
See also NamedConnective
, Connective
.
SoleLogics.Operator
— Typeconst Operator = Union{Connective,Truth}
Union type for logical constants of any ariety (zero for Truth
values, non-zero for Connective
s).
See also Connective
, Truth
.
SoleLogics.Operator
— Method(op::Operator)(o::Any)
An Operator
can be used to compose syntax tokens (e.g., atoms), syntax trees and/or formulas.
Examples
¬(Atom(1)) ∨ Atom(1) ∧ ⊤
∧(⊤,⊤)
- ⊤()
SoleLogics.Point2DRelations
— ConstantVector of 8 cardinal relations from Compass logic: North, South, North-West, etc.
See also PointRelations
.
SoleLogics.PointRelations
— ConstantVector of 6 point relations: min, max, successor, predecessor, >, <.
See also Point2DRelations
.
SoleLogics.RCC5Relations
— Constantconst RCC5Relations = [Topo_DR, Topo_PO, Topo_PP, Topo_PPi]
Vector of the 4 relations from RCC5.
See also RCC5Relations
, GeometricalRelation
.
SoleLogics.RCC8Relations
— Constantconst RCC8Relations = [Topo_DC, Topo_EC, Topo_PO, Topo_TPP, Topo_TPPi, Topo_NTPP, Topo_NTPPi]
Vector of the 7 relations from RCC8.
See also RCC5Relations
, GeometricalRelation
.
SoleLogics.SyntaxToken
— Typeconst SyntaxToken = Union{Connective,SyntaxLeaf}
Union type for values wrapped in SyntaxTree
nodes.
See also SyntaxTree
, SyntaxLeaf
, Connective
.
SoleLogics.TOP
— Constantstruct Top <: Truth end
+ ⊤()
SoleLogics.Point2DRelations
— ConstantVector of 8 cardinal relations from Compass logic: North, South, North-West, etc.
See also PointRelations
.
SoleLogics.PointRelations
— ConstantVector of 6 point relations: min, max, successor, predecessor, >, <.
See also Point2DRelations
.
SoleLogics.RCC5Relations
— Constantconst RCC5Relations = [Topo_DR, Topo_PO, Topo_PP, Topo_PPi]
Vector of the 4 relations from RCC5.
See also RCC5Relations
, GeometricalRelation
.
SoleLogics.RCC8Relations
— Constantconst RCC8Relations = [Topo_DC, Topo_EC, Topo_PO, Topo_TPP, Topo_TPPi, Topo_NTPP, Topo_NTPPi]
Vector of the 7 relations from RCC8.
See also RCC5Relations
, GeometricalRelation
.
SoleLogics.SyntaxToken
— Typeconst SyntaxToken = Union{Connective,SyntaxLeaf}
Union type for values wrapped in SyntaxTree
nodes.
See also SyntaxTree
, SyntaxLeaf
, Connective
.
SoleLogics.TOP
— Constantstruct Top <: Truth end
const TOP = Top()
-const ⊤ = TOP
Canonical truth operator representing the value true
. It can be typed by \top<tab>
.
SoleLogics.globalrel
— Constantstruct GlobalRel <: AbstractRelation end;
+const ⊤ = TOP
Canonical truth operator representing the value true
. It can be typed by \top<tab>
.
SoleLogics.globalrel
— Constantstruct GlobalRel <: AbstractRelation end;
const globalrel = GlobalRel();
Singleton type for the global relation. This is a binary relation via which a world accesses every other world within the frame. The relation is also symmetric, reflexive and transitive.
Examples
julia> syntaxstring(SoleLogics.globalrel)
"G"
julia> SoleLogics.converse(globalrel)
-GlobalRel()
See also IdentityRel
, AbstractRelation
, AbstractWorld
, AbstractFrame
. AbstractKripkeStructure
,
SoleLogics.identityrel
— Constantstruct IdentityRel <: AbstractRelation end;
+GlobalRel()
See also IdentityRel
, AbstractRelation
, AbstractWorld
, AbstractFrame
. AbstractKripkeStructure
,
SoleLogics.identityrel
— Constantstruct IdentityRel <: AbstractRelation end;
const identityrel = IdentityRel();
Singleton type for the identity relation. This is a binary relation via which a world accesses itself. The relation is also symmetric, reflexive and transitive.
Examples
julia> syntaxstring(SoleLogics.identityrel)
"="
julia> SoleLogics.converse(identityrel)
-IdentityRel()
See also GlobalRel
, AbstractRelation
, AbstractWorld
, AbstractFrame
. AbstractKripkeStructure
,
SoleLogics.tocenterrel
— Constantstruct ToCenteredRel <: AbstractRelation end;
+IdentityRel()
See also GlobalRel
, AbstractRelation
, AbstractWorld
, AbstractFrame
. AbstractKripkeStructure
,
SoleLogics.tocenterrel
— Constantstruct ToCenteredRel <: AbstractRelation end;
const tocenterrel = ToCenteredRel();
Singleton type for a relation that leads to the world at the center of a frame. The relation is transitive.
Examples
julia> syntaxstring(SoleLogics.tocenterrel)
-"◉"
See also IdentityRel
, centralworld
, AbstractRelation
, AbstractWorld
, AbstractFrame
. AbstractKripkeStructure
,
SoleLogics.⊤
— Constantstruct Top <: Truth end
+"◉"
See also IdentityRel
, centralworld
, AbstractRelation
, AbstractWorld
, AbstractFrame
. AbstractKripkeStructure
,
SoleLogics.⊤
— Constantstruct Top <: Truth end
const TOP = Top()
-const ⊤ = TOP
Canonical truth operator representing the value true
. It can be typed by \top<tab>
.
SoleLogics.⊥
— Constantstruct Bot <: Truth end
+const ⊤ = TOP
Canonical truth operator representing the value true
. It can be typed by \top<tab>
.
SoleLogics.⊥
— Constantstruct Bot <: Truth end
const BOT = Bot()
-const ⊥ = BOT
Canonical truth operator representing the value false
. It can be typed by \bot<tab>
.
SoleLogics.□
— Constantconst BOX = NamedConnective{:□}()
+const ⊥ = BOT
Canonical truth operator representing the value false
. It can be typed by \bot<tab>
.
SoleLogics.□
— Constantconst BOX = NamedConnective{:□}()
const □ = BOX
-arity(::typeof(□)) = 1
Logical box operator, typically interpreted as the modal universal quantifier. See here.
See also DIAMOND
, NamedConnective
, Connective
.
SoleLogics.◊
— Constantconst DIAMOND = NamedConnective{:◊}()
+arity(::typeof(□)) = 1
Logical box operator, typically interpreted as the modal universal quantifier. See here.
See also DIAMOND
, NamedConnective
, Connective
.
SoleLogics.◊
— Constantconst DIAMOND = NamedConnective{:◊}()
const ◊ = DIAMOND
ismodal(::NamedConnective{:◊}) = true
-arity(::typeof(◊)) = 1
Logical diamond operator, typically interpreted as the modal existential quantifier. See here.
See also BOX
, NamedConnective
, Connective
.
SoleLogics.AbstractAlgebra
— Typeabstract type AbstractAlgebra{T<:Truth} end
Abstract type for representing algebras. Algebras are used for grounding the truth of atoms and the semantics of operators. They typically encode a lattice structure where two elements(or nodes) ⊤ and ⊥ are referred to as TOP (or maximum) and bot (or minimum). Each node in the lattice represents a truth value that an atom or a formula can have on an interpretation, and the semantics of operators is given in terms of operations between truth values.
Implementation
When implementing a new algebra type, the methods domain
, TOP
, and bot
should be implemented.
See also bot
, BooleanAlgebra
, Operator
, TOP
, collatetruth
, domain
, iscrisp
, truthtype
.
SoleLogics.AbstractAlphabet
— Typeabstract type AbstractAlphabet{V} end
Abstract type for representing an alphabet of atoms with values of type V
. An alphabet (or propositional alphabet) is a set of atoms (assumed to be countable).
Examples
julia> Atom(1) in ExplicitAlphabet(Atom.(1:10))
+arity(::typeof(◊)) = 1
Logical diamond operator, typically interpreted as the modal existential quantifier. See here.
See also BOX
, NamedConnective
, Connective
.
SoleLogics.AbstractAlgebra
— Typeabstract type AbstractAlgebra{T<:Truth} end
Abstract type for representing algebras. Algebras are used for grounding the truth of atoms and the semantics of operators. They typically encode a lattice structure where two elements(or nodes) ⊤ and ⊥ are referred to as TOP (or maximum) and bot (or minimum). Each node in the lattice represents a truth value that an atom or a formula can have on an interpretation, and the semantics of operators is given in terms of operations between truth values.
Implementation
When implementing a new algebra type, the methods domain
, TOP
, and bot
should be implemented.
See also bot
, BooleanAlgebra
, Operator
, TOP
, collatetruth
, domain
, iscrisp
, truthtype
.
SoleLogics.AbstractAlphabet
— Typeabstract type AbstractAlphabet{V} end
Abstract type for representing an alphabet of atoms with values of type V
. An alphabet (or propositional alphabet) is a set of atoms (assumed to be countable).
Examples
julia> Atom(1) in ExplicitAlphabet(Atom.(1:10))
true
julia> Atom(1) in ExplicitAlphabet(1:10)
@@ -80,17 +80,17 @@
└ @ SoleLogics ...
true
Implementation
When implementing a new alphabet type MyAlphabet
, you should provide a method for establishing whether an atom belongs to it or not; while, in general, this method should be:
function Base.in(p::Atom, a::MyAlphabet)::Bool
in the case of finite alphabets, it suffices to define a method:
function atoms(a::AbstractAlphabet)::AbstractVector{atomstype(a)}
By default, an alphabet is considered finite:
Base.isfinite(::Type{<:AbstractAlphabet}) = true
Base.isfinite(a::AbstractAlphabet) = Base.isfinite(typeof(a))
-Base.in(p::Atom, a::AbstractAlphabet) = Base.isfinite(a) ? Base.in(p, atoms(a)) : error(...)
See also AbstractGrammar
, AlphabetOfAny
, Atom
, ExplicitAlphabet
, atomstype
, valuetype
.
SoleLogics.AbstractAlphabet
— MethodAn alphabet of valuetype
V
can be used for instantiating atoms of valuetype V
.
SoleLogics.AbstractAssignment
— Typeabstract type AbstractAssignment <: AbstractInterpretation end
Abstract type for assigments, that is, interpretations of propositional logic, encoding mappings from Atom
s to Truth
values.
See also AbstractInterpretation
.
SoleLogics.AbstractDimensionalFrame
— Typeabstract type AbstractDimensionalFrame{
+Base.in(p::Atom, a::AbstractAlphabet) = Base.isfinite(a) ? Base.in(p, atoms(a)) : error(...)
See also AbstractGrammar
, AlphabetOfAny
, Atom
, ExplicitAlphabet
, atomstype
, valuetype
.
SoleLogics.AbstractAlphabet
— MethodAn alphabet of valuetype
V
can be used for instantiating atoms of valuetype V
.
SoleLogics.AbstractAssignment
— Typeabstract type AbstractAssignment <: AbstractInterpretation end
Abstract type for assigments, that is, interpretations of propositional logic, encoding mappings from Atom
s to Truth
values.
See also AbstractInterpretation
.
SoleLogics.AbstractDimensionalFrame
— Typeabstract type AbstractDimensionalFrame{
N,
W<:AbstractWorld,
-} <: AbstractMultiModalFrame{W} end
Abstract type for dimensional frames. Given a N
-dimensional array of size (X, Y, Z, ...) the corresponding dimensional frame is a graph where each vertex is an N
-hyperrectangle (e.g., an Interval/Interval2D) in the space (1:X, 1:Y, 1:Z, ...).
See also Interval
, Interval2D
, IntervalRelation
, AbstractDimensionalFrame
, AbstractMultiModalFrame
.
SoleLogics.AbstractFrame
— Typeabstract type AbstractFrame{W<:AbstractWorld} end
Abstract type for an accessibility graph (Kripke frame), that gives the structure to Kripke structures's).
See also truthtype
, worldtype
, allworlds
, nworlds
, AbstractKripkeStructure
, AbstractWorld
.
SoleLogics.AbstractGrammar
— Typeabstract type AbstractGrammar{V<:AbstractAlphabet,O<:Operator} end
Abstract type for representing a context-free grammar based on a single alphabet of type V
, and a set of operators that consists of all the (singleton) child types of O
. V context-free grammar is a simple structure for defining formulas inductively.
See also alphabet
, atomstype
, tokenstype
, operatorstype
, alphabettype
, AbstractAlphabet
, Operator
.
SoleLogics.AbstractInterpretation
— Typeabstract type AbstractInterpretation end
Abstract type for representing a logical interpretation. In the case of propositional logic, is essentially a map atom → truth value.
Properties expressed via logical formulas can be check
ed on logical interpretations.
See also check
, AbstractAssignment
, AbstractKripkeStructure
.
SoleLogics.AbstractInterpretationSet
— Typeabstract type AbstractInterpretationSet{M<:AbstractInterpretation} <: AbstractDataset end
Abstract type for ordered sets of interpretations. A set of interpretations, also referred to as a dataset in this context, is a collection of instances, each of which is an interpretation, and is identified by an index iinstance::Integer. These structures are especially useful when performing [model checking](https://en.wikipedia.org/wiki/Modelchecking).
See also valuetype
, truthtype
, InterpretationSet
.
SoleLogics.AbstractKripkeStructure
— Typeabstract type AbstractKripkeStructure <: AbstractInterpretation end
Abstract type for representing Kripke structures's). It comprehends a directed graph structure (Kripke frame), where nodes are referred to as worlds, and the binary relation between them is referred to as the accessibility relation. Additionally, each world is associated with a mapping from Atom
s to Truth
values.
See also frame
, worldtype
, accessibles
, AbstractInterpretation
.
SoleLogics.AbstractLogic
— Typeabstract type AbstractLogic{G<:AbstractGrammar,V<:AbstractAlgebra} end
Abstract type of a logic, which comprehends a context-free grammar (syntax) and an algebra (semantics).
Implementation
When implementing a new logic type, the methods grammar
and algebra
should be implemented.
See also AbstractAlgebra
, AbstractGrammar
.
SoleLogics.AbstractMultiModalFrame
— Typeabstract type AbstractMultiModalFrame{W<:AbstractWorld} <: AbstractFrame{W} end
A frame of a multi-modal logic, that is, a modal logic based on a set of accessibility relations.
Implementation
When implementing a new multi-modal frame type, the logical semantics for the frame should be defined via accessibles
methods; refer to the help for accessibles
.
See also AbstractUniModalFrame
, AbstractFrame
.
SoleLogics.AbstractRelation
— Typeabstract type AbstractRelation end
Abstract type for the relations of a multi-modal annotated accessibility graph (Kripke structure). Two noteworthy relations are identityrel
and globalrel
, which access the current world and all worlds, respectively.
Examples
julia> fr = SoleLogics.FullDimensionalFrame((10,),);
+} <: AbstractMultiModalFrame{W} end
Abstract type for dimensional frames. Given a N
-dimensional array of size (X, Y, Z, ...) the corresponding dimensional frame is a graph where each vertex is an N
-hyperrectangle (e.g., an Interval/Interval2D) in the space (1:X, 1:Y, 1:Z, ...).
See also Interval
, Interval2D
, IntervalRelation
, AbstractDimensionalFrame
, AbstractMultiModalFrame
.
SoleLogics.AbstractFrame
— Typeabstract type AbstractFrame{W<:AbstractWorld} end
Abstract type for an accessibility graph (Kripke frame), that gives the structure to Kripke structures's).
See also truthtype
, worldtype
, allworlds
, nworlds
, AbstractKripkeStructure
, AbstractWorld
.
SoleLogics.AbstractGrammar
— Typeabstract type AbstractGrammar{V<:AbstractAlphabet,O<:Operator} end
Abstract type for representing a context-free grammar based on a single alphabet of type V
, and a set of operators that consists of all the (singleton) child types of O
. V context-free grammar is a simple structure for defining formulas inductively.
See also alphabet
, atomstype
, tokenstype
, operatorstype
, alphabettype
, AbstractAlphabet
, Operator
.
SoleLogics.AbstractInterpretation
— Typeabstract type AbstractInterpretation end
Abstract type for representing a logical interpretation. In the case of propositional logic, is essentially a map atom → truth value.
Properties expressed via logical formulas can be check
ed on logical interpretations.
See also check
, AbstractAssignment
, AbstractKripkeStructure
.
SoleLogics.AbstractInterpretationSet
— Typeabstract type AbstractInterpretationSet{M<:AbstractInterpretation} <: AbstractDataset end
Abstract type for ordered sets of interpretations. A set of interpretations, also referred to as a dataset in this context, is a collection of instances, each of which is an interpretation, and is identified by an index iinstance::Integer. These structures are especially useful when performing [model checking](https://en.wikipedia.org/wiki/Modelchecking).
See also valuetype
, truthtype
, InterpretationSet
.
SoleLogics.AbstractKripkeStructure
— Typeabstract type AbstractKripkeStructure <: AbstractInterpretation end
Abstract type for representing Kripke structures's). It comprehends a directed graph structure (Kripke frame), where nodes are referred to as worlds, and the binary relation between them is referred to as the accessibility relation. Additionally, each world is associated with a mapping from Atom
s to Truth
values.
See also frame
, worldtype
, accessibles
, AbstractInterpretation
.
SoleLogics.AbstractLogic
— Typeabstract type AbstractLogic{G<:AbstractGrammar,V<:AbstractAlgebra} end
Abstract type of a logic, which comprehends a context-free grammar (syntax) and an algebra (semantics).
Implementation
When implementing a new logic type, the methods grammar
and algebra
should be implemented.
See also AbstractAlgebra
, AbstractGrammar
.
SoleLogics.AbstractMultiModalFrame
— Typeabstract type AbstractMultiModalFrame{W<:AbstractWorld} <: AbstractFrame{W} end
A frame of a multi-modal logic, that is, a modal logic based on a set of accessibility relations.
Implementation
When implementing a new multi-modal frame type, the logical semantics for the frame should be defined via accessibles
methods; refer to the help for accessibles
.
See also AbstractUniModalFrame
, AbstractFrame
.
SoleLogics.AbstractRelation
— Typeabstract type AbstractRelation end
Abstract type for the relations of a multi-modal annotated accessibility graph (Kripke structure). Two noteworthy relations are identityrel
and globalrel
, which access the current world and all worlds, respectively.
Examples
julia> fr = SoleLogics.FullDimensionalFrame((10,),);
julia> Interval(8,11) in (accessibles(fr, Interval(2,5), IA_L))
true
Implementation
When implementing a new relation type R
, please provide the methods:
arity(::R)::Int = ...
syntaxstring(::R; kwargs...)::String = ...
If the relation is symmetric, please specify its converse relation cr
with:
hasconverse(::R) = true
converse(::R) = cr
If the relation is many-to-one or one-to-one, please flag it with:
istoone(::R) = true
If the relation is reflexive or transitive, flag it with:
isreflexive(::R) = true
-istransitive(::R) = true
Most importantly, the logical semantics for R
should be defined via accessibles
methods; refer to the help for accessibles
.
See also issymmetric
, isreflexive
, istransitive
, isgrounding
, arity
, syntaxstring
, converse
, hasconverse
, istoone
, IdentityRel
, GlobalRel
, accessibles
, AbstractKripkeStructure
, AbstractFrame
, AbstractWorld
.
SoleLogics.AbstractRelationalOperator
— Typeabstract type AbstractRelationalOperator{R<:AbstractRelation} <: Connective end
Abstract type for relational logical operators. A relational operator allows for semantic quantification across relational structures (e.g., Krikpe structures). It has arity equal to the arity of its underlying relation minus one.
See, for example temporal modal logic.
See also DiamondRelationalOperator
, BoxRelationalOperator
, AbstractKripkeStructure
, AbstractFrame
.
SoleLogics.AbstractSyntaxStructure
— Typeabstract type AbstractSyntaxStructure <: Formula end
Abstract type for the purely-syntactic component of a logical formula (e.g., no fancy memoization structure associated). The typical representation is the SyntaxTree
, however, different implementations can cover specific syntactic forms (e.g., conjuctive/disjuctive normal forms).
See also Formula
, AbstractLogic
, SyntaxTree
, tree
.
SoleLogics.AbstractUniModalFrame
— Typeabstract type AbstractUniModalFrame{W<:AbstractWorld} <: AbstractFrame{W} end
A frame of a modal logic based on a single (implicit) accessibility relation.
See also AbstractMultiModalFrame
, AbstractFrame
.
SoleLogics.AbstractWorld
— Typeabstract type AbstractWorld end
Abstract type for the nodes of an annotated accessibility graph (Kripke structure). This is used, for example, in modal logic, where the truth of formulas is relativized to worlds, that is, nodes of a graph.
Implementing
When implementing a new world type, the logical semanticsu should be defined via accessibles
methods; refer to the help for accessibles
.
See also AbstractKripkeStructure
, AbstractFrame
.
SoleLogics.AbstractWorlds
— Typeconst AbstractWorlds{W} = AbstractVector{W} where {W<:AbstractWorld}
-const Worlds{W} = Vector{W} where {W<:AbstractWorld}
Useful aliases for dealing with worlds sets/arrays.
See also accessibles
, AbstractWorld
.
SoleLogics.AlphabetOfAny
— Typestruct AlphabetOfAny{V} <: AbstractAlphabet{V} end
An implicit, infinite alphabet that includes all atoms with values of a subtype of V.
See also AbstractAlphabet
.
SoleLogics.AnchoredFormula
— Typestruct AnchoredFormula{L<:AbstractLogic} <: Formula
+istransitive(::R) = true
Most importantly, the logical semantics for R
should be defined via accessibles
methods; refer to the help for accessibles
.
See also issymmetric
, isreflexive
, istransitive
, isgrounding
, arity
, syntaxstring
, converse
, hasconverse
, istoone
, IdentityRel
, GlobalRel
, accessibles
, AbstractKripkeStructure
, AbstractFrame
, AbstractWorld
.
SoleLogics.AbstractRelationalOperator
— Typeabstract type AbstractRelationalOperator{R<:AbstractRelation} <: Connective end
Abstract type for relational logical operators. A relational operator allows for semantic quantification across relational structures (e.g., Krikpe structures). It has arity equal to the arity of its underlying relation minus one.
See, for example temporal modal logic.
See also DiamondRelationalOperator
, BoxRelationalOperator
, AbstractKripkeStructure
, AbstractFrame
.
SoleLogics.AbstractSyntaxStructure
— Typeabstract type AbstractSyntaxStructure <: Formula end
Abstract type for the purely-syntactic component of a logical formula (e.g., no fancy memoization structure associated). The typical representation is the SyntaxTree
, however, different implementations can cover specific syntactic forms (e.g., conjuctive/disjuctive normal forms).
See also Formula
, AbstractLogic
, SyntaxTree
, tree
.
SoleLogics.AbstractUniModalFrame
— Typeabstract type AbstractUniModalFrame{W<:AbstractWorld} <: AbstractFrame{W} end
A frame of a modal logic based on a single (implicit) accessibility relation.
See also AbstractMultiModalFrame
, AbstractFrame
.
SoleLogics.AbstractWorld
— Typeabstract type AbstractWorld end
Abstract type for the nodes of an annotated accessibility graph (Kripke structure). This is used, for example, in modal logic, where the truth of formulas is relativized to worlds, that is, nodes of a graph.
Implementing
When implementing a new world type, the logical semanticsu should be defined via accessibles
methods; refer to the help for accessibles
.
See also AbstractKripkeStructure
, AbstractFrame
.
SoleLogics.AbstractWorlds
— Typeconst AbstractWorlds{W} = AbstractVector{W} where {W<:AbstractWorld}
+const Worlds{W} = Vector{W} where {W<:AbstractWorld}
Useful aliases for dealing with worlds sets/arrays.
See also accessibles
, AbstractWorld
.
SoleLogics.AlphabetOfAny
— Typestruct AlphabetOfAny{V} <: AbstractAlphabet{V} end
An implicit, infinite alphabet that includes all atoms with values of a subtype of V.
See also AbstractAlphabet
.
SoleLogics.AnchoredFormula
— Typestruct AnchoredFormula{L<:AbstractLogic} <: Formula
_logic::Base.RefValue{L}
synstruct::AbstractSyntaxStructure
end
A formula anchored to a logic of type L
, and wrapping a syntax structure. The structure encodes a formula belonging to the grammar of the logic, and the truth of the formula can be evaluated on interpretations of the same logic. Note that, here, the logic is represented by a reference.
Upon construction, the logic can be passed either directly, or via a RefValue. Additionally, the following keyword arguments may be specified:
check_atoms::Bool = false
: whether to perform or not a check that the atoms belong to the alphabet of the logic;check_tree::Bool = false
: whether to perform or not a check that the formula's syntactic structure honors the grammar (includes the check performed withcheck_atoms = true
);
Cool feature: a AnchoredFormula
can be used for instating other formulas of the same logic. See the examples.
Examples
julia> f = parsebaseformula("◊(p→q)");
@@ -108,14 +108,14 @@
julia> @assert ◊ in operators(logic(f2))
julia> @assert ◊ isa operatorstype(logic(f2))
-
See also AbstractLogic
, logic
, SyntaxToken
, SyntaxBranch
, tree
.
SoleLogics.Atom
— Typestruct Atom{V} <: SyntaxLeaf
+
See also AbstractLogic
, logic
, SyntaxToken
, SyntaxBranch
, tree
.
SoleLogics.Atom
— Typestruct Atom{V} <: SyntaxLeaf
value::V
-end
An atom, sometimes called an atomic proposition, propositional letter (or simply letter), of type Atom{V}
wraps a value::V
representing a fact which truth can be assessed on a logical interpretation.
Atoms are nullary tokens (i.e, they are at the leaves of a syntax tree); note that their atoms cannot be Atom
s.
See also AbstractInterpretation
, check
, SyntaxToken
.
SoleLogics.BaseLogic
— Typestruct BaseLogic{G<:AbstractGrammar,A<:AbstractAlgebra} <: AbstractLogic{G,A}
+end
An atom, sometimes called an atomic proposition, propositional letter (or simply letter), of type Atom{V}
wraps a value::V
representing a fact which truth can be assessed on a logical interpretation.
Atoms are nullary tokens (i.e, they are at the leaves of a syntax tree); note that their atoms cannot be Atom
s.
See also AbstractInterpretation
, check
, SyntaxToken
.
SoleLogics.BaseLogic
— Typestruct BaseLogic{G<:AbstractGrammar,A<:AbstractAlgebra} <: AbstractLogic{G,A}
grammar::G
algebra::A
-end
A basic logic based on a grammar and an algebra, where both the grammar and the algebra are instantiated.
See also grammar
, algebra
, AbstractGrammar
, AbstractAlgebra
, AbstractLogic
.
SoleLogics.BooleanAlgebra
— Typestruct BooleanAlgebra <: AbstractAlgebra{Bool} end
A boolean algebra, defined on the values Top (representing true
) and Bot (for bottom, representing false
). For this algebra, the basic operators negation, conjunction and disjunction (stylized as ¬, ∧, ∨) can be defined as the complement, minimum and maximum, of the integer cast of true
and false
, respectively.
See also Truth
.
SoleLogics.BooleanTruth
— Typeabstract type BooleanTruth <: Truth end
Supertype of Top
and Bot
, the two truth values of BooleanAlgebra
See also Bot
, Top
, BooleanAlgebra
.
SoleLogics.Bot
— Typestruct Bot <: Truth end
+end
A basic logic based on a grammar and an algebra, where both the grammar and the algebra are instantiated.
See also grammar
, algebra
, AbstractGrammar
, AbstractAlgebra
, AbstractLogic
.
SoleLogics.BooleanAlgebra
— Typestruct BooleanAlgebra <: AbstractAlgebra{Bool} end
A boolean algebra, defined on the values Top (representing true
) and Bot (for bottom, representing false
). For this algebra, the basic operators negation, conjunction and disjunction (stylized as ¬, ∧, ∨) can be defined as the complement, minimum and maximum, of the integer cast of true
and false
, respectively.
See also Truth
.
SoleLogics.BooleanTruth
— Typeabstract type BooleanTruth <: Truth end
Supertype of Top
and Bot
, the two truth values of BooleanAlgebra
See also Bot
, Top
, BooleanAlgebra
.
SoleLogics.Bot
— Typestruct Bot <: Truth end
const BOT = Bot()
-const ⊥ = BOT
Canonical truth operator representing the value false
. It can be typed by \bot<tab>
.
SoleLogics.CNF
— Typestruct LeftmostLinearForm{C<:Connective,SS<:AbstractSyntaxStructure} <: AbstractSyntaxStructure
+const ⊥ = BOT
Canonical truth operator representing the value false
. It can be typed by \bot<tab>
.
SoleLogics.CNF
— Typestruct LeftmostLinearForm{C<:Connective,SS<:AbstractSyntaxStructure} <: AbstractSyntaxStructure
children::Vector{<:SS}
end
A syntax structure representing the foldl
of a set of other syntax structure of type SS
by means of a connective C
. This structure enables a structured instantiation of formulas in conjuctive/disjunctive forms, and conjuctive normal form (CNF) or disjunctive normal form (DNF), defined as:
const LeftmostConjunctiveForm{SS<:AbstractSyntaxStructure} = LeftmostLinearForm{typeof(∧),SS}
const LeftmostDisjunctiveForm{SS<:AbstractSyntaxStructure} = LeftmostLinearForm{typeof(∨),SS}
@@ -135,10 +135,10 @@
julia> LeftmostDisjunctiveForm([LeftmostConjunctiveForm(parseformula.(["¬p", "q", "¬r"]))]) isa SoleLogics.DNF
true
-
SoleLogics.CompleteFlatGrammar
— Typestruct CompleteFlatGrammar{V<:AbstractAlphabet,O<:Operator} <: AbstractGrammar{V,O}
+
SoleLogics.CompleteFlatGrammar
— Typestruct CompleteFlatGrammar{V<:AbstractAlphabet,O<:Operator} <: AbstractGrammar{V,O}
alphabet::V
operators::Vector{<:O}
-end
V grammar of all well-formed formulas obtained by the arity-complying composition of atoms of an alphabet of type V
, and all operators in operators
. With n operators, this grammar has exactly n+1 production rules. For example, with operators = [∧,∨]
, the grammar (in Backus-Naur form) is:
φ ::= p | φ ∧ φ | φ ∨ φ
with p ∈ alphabet. Note: it is flat in the sense that all rules substitute the same (unique and starting) non-terminal symbol φ.
See also AbstractGrammar
, Operator
, alphabet
, formulas
, connectives
, operators
, leaves
.
SoleLogics.Connective
— Typeabstract type Connective <: Syntactical end
Abstract type for logical connectives, that are used to express non-atomic statements; for example, CONJUNCTION, DISJUNCTION and IMPLICATION (stylized as ∧, ∨ and →).
Implementation
When implementing a new type C
for a connective, please define its arity
. For example, with a binary operator (e.g., ∨ or ∧):
arity(::C) = 2
When implementing a new type C
for a commutative connective with arity higher than 1, please provide a method iscommutative(::C)
. This can speed up model checking operations.
When implementing a custom binary connective, one can override the default precedence
and associativity
(see https://docs.julialang.org/en/v1/manual/mathematical-operations/#Operator-Precedence-and-Associativity). If the custom connective is a NamedConnective
and renders as something considered as a math symbol
(for example, ⊙
, see https://stackoverflow.com/a/60321302/5646732), by the Julia parser, Base.operator_precedence
and Base.operator_associativity
are used to define these behaviors, and you might want to avoid providing these methods at all.
See also arity
, SyntaxBranch
, associativity
, precedence
, check
, iscommutative
, NamedConnective
, Syntactical
.
SoleLogics.DNF
— Typestruct LeftmostLinearForm{C<:Connective,SS<:AbstractSyntaxStructure} <: AbstractSyntaxStructure
+end
V grammar of all well-formed formulas obtained by the arity-complying composition of atoms of an alphabet of type V
, and all operators in operators
. With n operators, this grammar has exactly n+1 production rules. For example, with operators = [∧,∨]
, the grammar (in Backus-Naur form) is:
φ ::= p | φ ∧ φ | φ ∨ φ
with p ∈ alphabet. Note: it is flat in the sense that all rules substitute the same (unique and starting) non-terminal symbol φ.
See also AbstractGrammar
, Operator
, alphabet
, formulas
, connectives
, operators
, leaves
.
SoleLogics.Connective
— Typeabstract type Connective <: Syntactical end
Abstract type for logical connectives, that are used to express non-atomic statements; for example, CONJUNCTION, DISJUNCTION and IMPLICATION (stylized as ∧, ∨ and →).
Implementation
When implementing a new type C
for a connective, please define its arity
. For example, with a binary operator (e.g., ∨ or ∧):
arity(::C) = 2
When implementing a new type C
for a commutative connective with arity higher than 1, please provide a method iscommutative(::C)
. This can speed up model checking operations.
When implementing a custom binary connective, one can override the default precedence
and associativity
(see https://docs.julialang.org/en/v1/manual/mathematical-operations/#Operator-Precedence-and-Associativity). If the custom connective is a NamedConnective
and renders as something considered as a math symbol
(for example, ⊙
, see https://stackoverflow.com/a/60321302/5646732), by the Julia parser, Base.operator_precedence
and Base.operator_associativity
are used to define these behaviors, and you might want to avoid providing these methods at all.
See also arity
, SyntaxBranch
, associativity
, precedence
, check
, iscommutative
, NamedConnective
, Syntactical
.
SoleLogics.DNF
— Typestruct LeftmostLinearForm{C<:Connective,SS<:AbstractSyntaxStructure} <: AbstractSyntaxStructure
children::Vector{<:SS}
end
A syntax structure representing the foldl
of a set of other syntax structure of type SS
by means of a connective C
. This structure enables a structured instantiation of formulas in conjuctive/disjunctive forms, and conjuctive normal form (CNF) or disjunctive normal form (DNF), defined as:
const LeftmostConjunctiveForm{SS<:AbstractSyntaxStructure} = LeftmostLinearForm{typeof(∧),SS}
const LeftmostDisjunctiveForm{SS<:AbstractSyntaxStructure} = LeftmostLinearForm{typeof(∨),SS}
@@ -158,7 +158,7 @@
julia> LeftmostDisjunctiveForm([LeftmostConjunctiveForm(parseformula.(["¬p", "q", "¬r"]))]) isa SoleLogics.DNF
true
-
SoleLogics.DefaultedTruthDict
— Typestruct DefaultedTruthDict{
+
SoleLogics.DefaultedTruthDict
— Typestruct DefaultedTruthDict{
D<:AbstractDict{A where A<:Atom,T where T<:Truth},
T<:Truth
} <: AbstractAssignment
@@ -178,7 +178,7 @@
julia> check(parseformula("1 ∧ 5"), t1)
false
-
See also TruthDict
, AbstractAssignment
, AbstractInterpretation
.
SoleLogics.DiamondRelationalOperator
— Typestruct DiamondRelationalOperator{R<:AbstractRelation} <: AbstractRelationalOperator{R} end
+
See also TruthDict
, AbstractAssignment
, AbstractInterpretation
.
SoleLogics.DiamondRelationalOperator
— Typestruct DiamondRelationalOperator{R<:AbstractRelation} <: AbstractRelationalOperator{R} end
struct BoxRelationalOperator{R<:AbstractRelation} <: AbstractRelationalOperator{R} end
Singleton types for relational operators, typically interpreted as the modal existential and universal quantifier, respectively.
Both operators can be easily instantiated with relation instances, such as DiamondRelationalOperator(rel)
, which is a shortcut for DiamondRelationalOperator{typeof(rel)}()
.
Examples
julia> syntaxstring(DiamondRelationalOperator(IA_A))
"⟨A⟩"
@@ -186,9 +186,9 @@
"[A]"
julia> @assert DiamondRelationalOperator(IA_A) == SoleLogics.dual(BoxRelationalOperator(IA_A))
-
See also DiamondRelationalOperator
, BoxRelationalOperator
, syntaxstring
, dual
, AbstractKripkeStructure
, AbstractFrame
.
SoleLogics.ExplicitAlphabet
— Typestruct ExplicitAlphabet{V} <: AbstractAlphabet{V}
+
See also DiamondRelationalOperator
, BoxRelationalOperator
, syntaxstring
, dual
, AbstractKripkeStructure
, AbstractFrame
.
SoleLogics.ExplicitAlphabet
— Typestruct ExplicitAlphabet{V} <: AbstractAlphabet{V}
atoms::Vector{Atom{V}}
-end
An alphabet wrapping atoms in a (finite) Vector
.
See also AbstractAlphabet
, atoms
.
SoleLogics.ExplicitCrispUniModalFrame
— TypeTODO
SoleLogics.Formula
— Typeabstract type Formula <: Syntactical end
Abstract type for logical formulas. Examples of Formula
s are SyntaxLeaf
s (for example, Atom
s and Truth
values), AbstractSyntaxStructure
s (for example, SyntaxTree
s and LeftmostLinearForm
s) and TruthTable
s ( enriched representation, which associates a syntactic structure with additional memoization structures, which can save computational time upon model checking).
Any formula can be converted into its SyntaxTree
representation via tree
; its height
can be computed, and it can be queried for its syntax tokens
, atoms
, etc... It can be parsed from its syntaxstring
representation via parseformula
.
See also tree
, AbstractSyntaxStructure
, SyntaxLeaf
.
SoleLogics.FullDimensionalFrame
— Typestruct FullDimensionalFrame{N,W<:AbstractWorld} <: AbstractDimensionalFrame{N,W}
+end
An alphabet wrapping atoms in a (finite) Vector
.
See also AbstractAlphabet
, atoms
.
SoleLogics.ExplicitCrispUniModalFrame
— TypeTODO
SoleLogics.Formula
— Typeabstract type Formula <: Syntactical end
Abstract type for logical formulas. Examples of Formula
s are SyntaxLeaf
s (for example, Atom
s and Truth
values), AbstractSyntaxStructure
s (for example, SyntaxTree
s and LeftmostLinearForm
s) and TruthTable
s ( enriched representation, which associates a syntactic structure with additional memoization structures, which can save computational time upon model checking).
Any formula can be converted into its SyntaxTree
representation via tree
; its height
can be computed, and it can be queried for its syntax tokens
, atoms
, etc... It can be parsed from its syntaxstring
representation via parseformula
.
See also tree
, AbstractSyntaxStructure
, SyntaxLeaf
.
SoleLogics.FullDimensionalFrame
— Typestruct FullDimensionalFrame{N,W<:AbstractWorld} <: AbstractDimensionalFrame{N,W}
channelsize::NTuple{N,Int}
end
Abstract type for full dimensional frames. Given a N
-dimensional array of size (X, Y, Z, ...) the corresponding full dimensional frame is a graph where there is exactly one vertex for each M-hyperrectangle in the space (1:X, 1:Y, 1:Z, ...), with M ≤ N
.
Here, the M
-hyperrectangle can be either a Point
, or a N
-tuple of intervals (e.g., Interval
or Interval2D
), where each interval is a pair of natural numbers (x,y) where: i) x > 0; ii) y > 0; iii) x < y.
The current implementation can handle N ∈ {0,1,2}.
Examples
julia> SoleLogics.allworlds(SoleLogics.FullDimensionalFrame((),))
1-element Vector{OneWorld}:
@@ -205,19 +205,19 @@
((4−5)×(5−6))
((4−6)×(5−6))
((5−6)×(5−6))
-
See also OneWorld
, Interval
, Interval2D
, IntervalRelation
, IntervalRelation2D
, accessibles
, AbstractDimensionalFrame
, AbstractMultiModalFrame
.
SoleLogics.GeometricalRelation
— Typeabstract type GeometricalWorld <: AbstractRelation end
Abstract type for relations with a geometrical interpretation.
See also istopological
, IntervalRelation
, RectangleRelation
, RCCRelation
, AbstractRelation
.
SoleLogics.GeometricalWorld
— Typeabstract type GeometricalWorld <: AbstractWorld end
Abstract type for worlds with a geometrical interpretation.
See also Point
, Interval
, Interval2D
, AbstractWorld
.
SoleLogics.GlobalRel
— Typestruct GlobalRel <: AbstractRelation end;
+
See also OneWorld
, Interval
, Interval2D
, IntervalRelation
, IntervalRelation2D
, accessibles
, AbstractDimensionalFrame
, AbstractMultiModalFrame
.
SoleLogics.GeometricalRelation
— Typeabstract type GeometricalWorld <: AbstractRelation end
Abstract type for relations with a geometrical interpretation.
See also istopological
, IntervalRelation
, RectangleRelation
, RCCRelation
, AbstractRelation
.
SoleLogics.GeometricalWorld
— Typeabstract type GeometricalWorld <: AbstractWorld end
Abstract type for worlds with a geometrical interpretation.
See also Point
, Interval
, Interval2D
, AbstractWorld
.
SoleLogics.GlobalRel
— Typestruct GlobalRel <: AbstractRelation end;
const globalrel = GlobalRel();
Singleton type for the global relation. This is a binary relation via which a world accesses every other world within the frame. The relation is also symmetric, reflexive and transitive.
Examples
julia> syntaxstring(SoleLogics.globalrel)
"G"
julia> SoleLogics.converse(globalrel)
-GlobalRel()
See also IdentityRel
, AbstractRelation
, AbstractWorld
, AbstractFrame
. AbstractKripkeStructure
,
SoleLogics.IdentityRel
— Typestruct IdentityRel <: AbstractRelation end;
+GlobalRel()
See also IdentityRel
, AbstractRelation
, AbstractWorld
, AbstractFrame
. AbstractKripkeStructure
,
SoleLogics.IdentityRel
— Typestruct IdentityRel <: AbstractRelation end;
const identityrel = IdentityRel();
Singleton type for the identity relation. This is a binary relation via which a world accesses itself. The relation is also symmetric, reflexive and transitive.
Examples
julia> syntaxstring(SoleLogics.identityrel)
"="
julia> SoleLogics.converse(identityrel)
-IdentityRel()
See also GlobalRel
, AbstractRelation
, AbstractWorld
, AbstractFrame
. AbstractKripkeStructure
,
SoleLogics.InterpretationSet
— Typestruct InterpretationSet{M<:AbstractInterpretation} <: AbstractInterpretationSet{M}
+IdentityRel()
See also GlobalRel
, AbstractRelation
, AbstractWorld
, AbstractFrame
. AbstractKripkeStructure
,
SoleLogics.InterpretationSet
— Typestruct InterpretationSet{M<:AbstractInterpretation} <: AbstractInterpretationSet{M}
instances::Vector{M}
-end
A dataset of interpretations instantiated as a vector.
SoleLogics.Interval
— Typestruct Interval{T} <: GeometricalWorld
+end
A dataset of interpretations instantiated as a vector.
SoleLogics.Interval
— Typestruct Interval{T} <: GeometricalWorld
x :: T
y :: T
end
An interval in a 1-dimensional space, with coordinates of type T
.
Examples
julia> SoleLogics.goeswithdim(SoleLogics.Interval(1,2),1)
@@ -235,7 +235,7 @@
(4−6)
(5−6)
-
See also goeswithdim
, accessibles
, FullDimensionalFrame
, Point
, Interval2D
, GeometricalWorld
, AbstractWorld
.
SoleLogics.Interval2D
— Typestruct Interval2D{T} <: GeometricalWorld
+
See also goeswithdim
, accessibles
, FullDimensionalFrame
, Point
, Interval2D
, GeometricalWorld
, AbstractWorld
.
SoleLogics.Interval2D
— Typestruct Interval2D{T} <: GeometricalWorld
x :: Interval{T}
y :: Interval{T}
end
A orthogonal rectangle in a 2-dimensional space, with coordinates of type T
. This is the 2-dimensional Interval
counterpart, that is, the combination of two orthogonal Interval
s.
Examples
julia> SoleLogics.goeswithdim(SoleLogics.Interval2D((1,2),(3,4)),1)
@@ -249,7 +249,7 @@
((4−5)×(5−6))
((4−6)×(5−6))
((5−6)×(5−6))
-
See also goeswithdim
, accessibles
, FullDimensionalFrame
, Point
, Interval
, GeometricalWorld
, AbstractWorld
.
SoleLogics.IntervalRelation
— Typeabstract type IntervalRelation <: GeometricalRelation end
Abstract type for interval binary relations. Originally defined by Allen in 1983, interval algebra comprehends 12 directional relations between intervals, plus the identity (i.e., identityrel
).
The 12 relations are the 6 relations after
, later
, begins
, ends
, during
, overlaps
, and their inverses.
If we consider a reference interval (x,y)
, we can graphically represent the 6 base relations by providing an example of a world (z,t)
that is accessible via each of them:
RELATION ABBR. x y PROPERTY |–––––––––-| . . . z t y = z After (A) . |––––| . . . . z t y < z Later (L) . . |––––-| . . z t . x = z, t < y Begins (B) |––-| . . . . z t y = t, x < z Ends (E) . |––-| . . . z t . x < z, t < y During (D) . |––––| . . . . z . t x < z < y < t Overlaps (O) . |––––––|
Coarser relations can be defined by union of these 12 relations.
Examples
julia> IARelations
+
See also goeswithdim
, accessibles
, FullDimensionalFrame
, Point
, Interval
, GeometricalWorld
, AbstractWorld
.
SoleLogics.IntervalRelation
— Typeabstract type IntervalRelation <: GeometricalRelation end
Abstract type for interval binary relations. Originally defined by Allen in 1983, interval algebra comprehends 12 directional relations between intervals, plus the identity (i.e., identityrel
).
The 12 relations are the 6 relations after
, later
, begins
, ends
, during
, overlaps
, and their inverses.
If we consider a reference interval (x,y)
, we can graphically represent the 6 base relations by providing an example of a world (z,t)
that is accessible via each of them:
RELATION ABBR. x y PROPERTY |–––––––––-| . . . z t y = z After (A) . |––––| . . . . z t y < z Later (L) . . |––––-| . . z t . x = z, t < y Begins (B) |––-| . . . . z t y = t, x < z Ends (E) . |––-| . . . z t . x < z, t < y During (D) . |––––| . . . . z . t x < z < y < t Overlaps (O) . |––––––|
Coarser relations can be defined by union of these 12 relations.
Examples
julia> IARelations
12-element Vector{IntervalRelation}:
_IA_A()
_IA_L()
@@ -315,13 +315,13 @@
"I"
"L"
"L̅"
-
See also IARelations
, IA7Relations
, IA3Relations
, Interval
, GeometricalRelation
.
SoleLogics.KripkeStructure
— Typestruct KripkeStructure{
+
See also IARelations
, IA7Relations
, IA3Relations
, Interval
, GeometricalRelation
.
SoleLogics.KripkeStructure
— Typestruct KripkeStructure{
FR<:AbstractFrame,
MAS<:AbstractDict
} <: AbstractKripkeStructure
frame::FR
assignment::AS
-end
Type for representing Kripke structures's). explicitly; it wraps a frame
, and an abstract dictionary that assigns an interpretation to each world.
SoleLogics.LeftmostConjunctiveForm
— Typestruct LeftmostLinearForm{C<:Connective,SS<:AbstractSyntaxStructure} <: AbstractSyntaxStructure
+end
Type for representing Kripke structures's). explicitly; it wraps a frame
, and an abstract dictionary that assigns an interpretation to each world.
SoleLogics.LeftmostConjunctiveForm
— Typestruct LeftmostLinearForm{C<:Connective,SS<:AbstractSyntaxStructure} <: AbstractSyntaxStructure
children::Vector{<:SS}
end
A syntax structure representing the foldl
of a set of other syntax structure of type SS
by means of a connective C
. This structure enables a structured instantiation of formulas in conjuctive/disjunctive forms, and conjuctive normal form (CNF) or disjunctive normal form (DNF), defined as:
const LeftmostConjunctiveForm{SS<:AbstractSyntaxStructure} = LeftmostLinearForm{typeof(∧),SS}
const LeftmostDisjunctiveForm{SS<:AbstractSyntaxStructure} = LeftmostLinearForm{typeof(∨),SS}
@@ -341,7 +341,7 @@
julia> LeftmostDisjunctiveForm([LeftmostConjunctiveForm(parseformula.(["¬p", "q", "¬r"]))]) isa SoleLogics.DNF
true
-
SoleLogics.LeftmostDisjunctiveForm
— Typestruct LeftmostLinearForm{C<:Connective,SS<:AbstractSyntaxStructure} <: AbstractSyntaxStructure
+
SoleLogics.LeftmostDisjunctiveForm
— Typestruct LeftmostLinearForm{C<:Connective,SS<:AbstractSyntaxStructure} <: AbstractSyntaxStructure
children::Vector{<:SS}
end
A syntax structure representing the foldl
of a set of other syntax structure of type SS
by means of a connective C
. This structure enables a structured instantiation of formulas in conjuctive/disjunctive forms, and conjuctive normal form (CNF) or disjunctive normal form (DNF), defined as:
const LeftmostConjunctiveForm{SS<:AbstractSyntaxStructure} = LeftmostLinearForm{typeof(∧),SS}
const LeftmostDisjunctiveForm{SS<:AbstractSyntaxStructure} = LeftmostLinearForm{typeof(∨),SS}
@@ -361,7 +361,7 @@
julia> LeftmostDisjunctiveForm([LeftmostConjunctiveForm(parseformula.(["¬p", "q", "¬r"]))]) isa SoleLogics.DNF
true
-
SoleLogics.LeftmostLinearForm
— Typestruct LeftmostLinearForm{C<:Connective,SS<:AbstractSyntaxStructure} <: AbstractSyntaxStructure
+
SoleLogics.LeftmostLinearForm
— Typestruct LeftmostLinearForm{C<:Connective,SS<:AbstractSyntaxStructure} <: AbstractSyntaxStructure
children::Vector{<:SS}
end
A syntax structure representing the foldl
of a set of other syntax structure of type SS
by means of a connective C
. This structure enables a structured instantiation of formulas in conjuctive/disjunctive forms, and conjuctive normal form (CNF) or disjunctive normal form (DNF), defined as:
const LeftmostConjunctiveForm{SS<:AbstractSyntaxStructure} = LeftmostLinearForm{typeof(∧),SS}
const LeftmostDisjunctiveForm{SS<:AbstractSyntaxStructure} = LeftmostLinearForm{typeof(∨),SS}
@@ -381,21 +381,21 @@
julia> LeftmostDisjunctiveForm([LeftmostConjunctiveForm(parseformula.(["¬p", "q", "¬r"]))]) isa SoleLogics.DNF
true
-
See also AbstractSyntaxStructure
, SyntaxTree
, LeftmostConjunctiveForm
, LeftmostDisjunctiveForm
, Literal
.
SoleLogics.Literal
— Typestruct Literal{T<:SyntaxToken} <: AbstractSyntaxStructure
+
See also AbstractSyntaxStructure
, SyntaxTree
, LeftmostConjunctiveForm
, LeftmostDisjunctiveForm
, Literal
.
SoleLogics.Literal
— Typestruct Literal{T<:SyntaxToken} <: AbstractSyntaxStructure
ispos::Bool
prop::T
-end
An atom, or its negation.
See also CNF
, DNF
, AbstractSyntaxStructure
.
SoleLogics.LogicalInstance
— TypeTODO explain. In general, one may not be able to extract a single logical instance from a set, thus we represent it as a tuple of dataset + instance id (i_instance).
SoleLogics.NamedConnective
— Typestruct NamedConnective{Symbol} <: Connective end
A singleton type for representing connectives defined by a name or a symbol.
Examples
The AND connective (logical conjuction) is defined as the subtype:
const CONJUNCTION = NamedConnective{:∧}()
+end
An atom, or its negation.
See also CNF
, DNF
, AbstractSyntaxStructure
.
SoleLogics.LogicalInstance
— TypeTODO explain. In general, one may not be able to extract a single logical instance from a set, thus we represent it as a tuple of dataset + instance id (i_instance).
SoleLogics.NamedConnective
— Typestruct NamedConnective{Symbol} <: Connective end
A singleton type for representing connectives defined by a name or a symbol.
Examples
The AND connective (logical conjuction) is defined as the subtype:
const CONJUNCTION = NamedConnective{:∧}()
const ∧ = CONJUNCTION
-arity(::typeof(∧)) = 2
See also NEGATION
, CONJUNCTION
, DISJUNCTION
, IMPLICATION
, Connective
.
SoleLogics.NamedRelation
— Typestruct NamedRelation{T} <: AbstractRelation
+arity(::typeof(∧)) = 2
See also NEGATION
, CONJUNCTION
, DISJUNCTION
, IMPLICATION
, Connective
.
SoleLogics.NamedRelation
— Typestruct NamedRelation{T} <: AbstractRelation
name::T
-end
Type for relations that are solely defined by their name.
See also AbstractRelation
, AbstractWorld
, AbstractFrame
. AbstractKripkeStructure
,
SoleLogics.OneWorld
— Typestruct OneWorld <: AbstractWorld end
A singleton world to be used in modal frames with a single, unique world. This usage effectively simulates a propositional context. Note that it is compatible with 0-dimensional datasets.
See also Interval
, Interval2D
, goeswithdim
, AbstractWorld
.
SoleLogics.Point
— Typestruct Point{N,T} <: GeometricalWorld
+end
Type for relations that are solely defined by their name.
See also AbstractRelation
, AbstractWorld
, AbstractFrame
. AbstractKripkeStructure
,
SoleLogics.OneWorld
— Typestruct OneWorld <: AbstractWorld end
A singleton world to be used in modal frames with a single, unique world. This usage effectively simulates a propositional context. Note that it is compatible with 0-dimensional datasets.
See also Interval
, Interval2D
, goeswithdim
, AbstractWorld
.
SoleLogics.Point
— Typestruct Point{N,T} <: GeometricalWorld
xyz :: NTuple{N,T}
end
A point in an N
-dimensional space, with integer coordinates.
Examples
julia> SoleLogics.goeswithdim(SoleLogics.Point(1,2,3),3)
true
julia> SoleLogics.goeswithdim(SoleLogics.Point(1,2,3),2)
false
-
See also goeswithdim
, Interval
, Interval2D
, GeometricalWorld
, AbstractWorld
.
SoleLogics.Point2DRelation
— Type2D Point relations (see Compass logic)
SoleLogics.PointRelation
— Type1D Point relations
SoleLogics.RCCRelation
— Typeabstract type RCCRelation <: GeometricalRelation end
Topological binary relations from Region Connection Calculus. Region Connection Calculus (RCC) is most famous for RCC8, a set of 8 topological relations, which comprehends the identity relation (i.e., `identityrel'), and the following 7 relations:
- Externally connected
- Partially overlapping
- Tangential proper part
- Tangential proper part inverse
- Non-tangential proper part
- Non-tangential proper part inverse
If we consider a reference interval (x,y)
, we can graphically represent the 7 relations by providing an example of a world (z,t)
that is accessible via each of them:
x y
RELATION ABBR. |–––––––––-| . . . . z t Disconnected (DC) . . |––––| . . . z t Externally connected (EC) . |––––-| . . . z t Partially overlapping (PO) . |––-| . . . z t Tangential proper part (TPP) . |––-| . . z . t Tangential proper part inverse (T̅P̅P̅) |––––––––––––-| . . . z . Non-tangential proper part (NTPP) . |––-| . . . z . . t Non-tangential proper part inverse (N̅T̅P̅P̅) |–––––––––––-|
Methods for RCC8 relations and Interval2D's can be obtained by combining their 1D versions, according to the following composition rules:
.-------------------------------------------------------.
+
See also goeswithdim
, Interval
, Interval2D
, GeometricalWorld
, AbstractWorld
.
SoleLogics.Point2DRelation
— Type2D Point relations (see Compass logic)
SoleLogics.PointRelation
— Type1D Point relations
SoleLogics.RCCRelation
— Typeabstract type RCCRelation <: GeometricalRelation end
Topological binary relations from Region Connection Calculus. Region Connection Calculus (RCC) is most famous for RCC8, a set of 8 topological relations, which comprehends the identity relation (i.e., `identityrel'), and the following 7 relations:
- Externally connected
- Partially overlapping
- Tangential proper part
- Tangential proper part inverse
- Non-tangential proper part
- Non-tangential proper part inverse
If we consider a reference interval (x,y)
, we can graphically represent the 7 relations by providing an example of a world (z,t)
that is accessible via each of them:
x y
RELATION ABBR. |–––––––––-| . . . . z t Disconnected (DC) . . |––––| . . . z t Externally connected (EC) . |––––-| . . . z t Partially overlapping (PO) . |––-| . . . z t Tangential proper part (TPP) . |––-| . . z . t Tangential proper part inverse (T̅P̅P̅) |––––––––––––-| . . . z . Non-tangential proper part (NTPP) . |––-| . . . z . . t Non-tangential proper part inverse (N̅T̅P̅P̅) |–––––––––––-|
Methods for RCC8 relations and Interval2D's can be obtained by combining their 1D versions, according to the following composition rules:
.-------------------------------------------------------.
| DC EC PO TPP T̅P̅P̅ NTPP N̅T̅P̅P̅ Id |
|-------------------------------------------------------|
| DC | DC | DC | DC | DC | DC | DC | DC | DC |
@@ -444,7 +444,7 @@
_Topo_DR()
_Topo_PO()
_Topo_PP()
- _Topo_PPi()
See also RCC8Relations
, RCC5Relations
, Interval
, IntervalRelation
, GeometricalRelation
.
SoleLogics.RectangleRelation
— Typeconst IABase = Union{IntervalRelation,IdentityRel,GlobalRel}
+ _Topo_PPi()
See also RCC8Relations
, RCC5Relations
, Interval
, IntervalRelation
, GeometricalRelation
.
SoleLogics.RectangleRelation
— Typeconst IABase = Union{IntervalRelation,IdentityRel,GlobalRel}
struct RectangleRelation{R1<:IABase,R2<:IABase} <: GeometricalRelation
x :: R1
y :: R2
@@ -458,14 +458,14 @@
"A̅,E̅"
"B̅,E"
"E̅,D̅"
- "O̅,D"
See also Interval
, Interval2D
, IntervalRelation
, [[
GeometricalRelation`](@ref).
SoleLogics.Syntactical
— Typeabstract type Syntactical end
Master abstract type for all syntactical objects (e.g., formulas, connectives).
See also Formula
, Connective
.
SoleLogics.SyntaxBranch
— Typestruct SyntaxBranch{T<:Connective} <: SyntaxTree
+ "O̅,D"
See also Interval
, Interval2D
, IntervalRelation
, [[
GeometricalRelation`](@ref).
SoleLogics.Syntactical
— Typeabstract type Syntactical end
Master abstract type for all syntactical objects (e.g., formulas, connectives).
See also Formula
, Connective
.
SoleLogics.SyntaxBranch
— Typestruct SyntaxBranch{T<:Connective} <: SyntaxTree
token::T
children::NTuple{N,SyntaxTree} where {N}
-end
An internal node of a syntax tree encoding a logical formula. Such a node holds a syntax token
(a Connective
, and has as many children as the arity
of the token.
This implementation is arity-compliant, in that, upon construction, the arity of the token is checked against the number of children provided.
See also token
, children
, arity
, Connective
, height
, atoms
, natoms
, atomstype
, operators
, noperators
, operatorstype
, tokens
, ntokens
, tokenstype
,
SoleLogics.SyntaxLeaf
— Typeabstract type SyntaxLeaf <: AbstractSyntaxStructure end
An atomic logical element, like a Truth
value or an Atom
. SyntaxLeaf
s have arity
equal to zero, meaning that they are not allowed to have children in tree-like syntactic structures.
See also AbstractSyntaxStructure
, arity
, SyntaxBranch
.
SoleLogics.SyntaxTree
— Typeabstract type SyntaxTree <: AbstractSyntaxStructure end
Abstract type for syntax leaves (see SyntaxLeaf
, such as Truth
values and Atom
s), and their composition via Connective
s (i.e., SyntaxBranch
).
See also SyntaxLeaf
, SyntaxBranch
, AbstractSyntaxStructure
, Formula
.
SoleLogics.ToCenteredRel
— Typestruct ToCenteredRel <: AbstractRelation end;
+end
An internal node of a syntax tree encoding a logical formula. Such a node holds a syntax token
(a Connective
, and has as many children as the arity
of the token.
This implementation is arity-compliant, in that, upon construction, the arity of the token is checked against the number of children provided.
See also token
, children
, arity
, Connective
, height
, atoms
, natoms
, atomstype
, operators
, noperators
, operatorstype
, tokens
, ntokens
, tokenstype
,
SoleLogics.SyntaxLeaf
— Typeabstract type SyntaxLeaf <: AbstractSyntaxStructure end
An atomic logical element, like a Truth
value or an Atom
. SyntaxLeaf
s have arity
equal to zero, meaning that they are not allowed to have children in tree-like syntactic structures.
See also AbstractSyntaxStructure
, arity
, SyntaxBranch
.
SoleLogics.SyntaxTree
— Typeabstract type SyntaxTree <: AbstractSyntaxStructure end
Abstract type for syntax leaves (see SyntaxLeaf
, such as Truth
values and Atom
s), and their composition via Connective
s (i.e., SyntaxBranch
).
See also SyntaxLeaf
, SyntaxBranch
, AbstractSyntaxStructure
, Formula
.
SoleLogics.ToCenteredRel
— Typestruct ToCenteredRel <: AbstractRelation end;
const tocenterrel = ToCenteredRel();
Singleton type for a relation that leads to the world at the center of a frame. The relation is transitive.
Examples
julia> syntaxstring(SoleLogics.tocenterrel)
-"◉"
See also IdentityRel
, centralworld
, AbstractRelation
, AbstractWorld
, AbstractFrame
. AbstractKripkeStructure
,
SoleLogics.Top
— Typestruct Top <: Truth end
+"◉"
See also IdentityRel
, centralworld
, AbstractRelation
, AbstractWorld
, AbstractFrame
. AbstractKripkeStructure
,
SoleLogics.Top
— Typestruct Top <: Truth end
const TOP = Top()
-const ⊤ = TOP
Canonical truth operator representing the value true
. It can be typed by \top<tab>
.
SoleLogics.Truth
— Typeabstract type Truth <: SyntaxLeaf end
Abstract type for syntax leaves representing values of a lattice algebra. In Boolean logic, the two BooleanTruth
values Top
and Bot
are tused.
Implementation
When implementing a custom Truth
subtype, provide istop, isbot... TODO: write the interface to be implemented here, with an example.
See also Top
, Bot
, BooleanTruth
, arity
;
SoleLogics.TruthDict
— Typestruct TruthDict{D<:AbstractDict{A where A<:Atom,T where T<:Truth}} <: AbstractAssignment
+const ⊤ = TOP
Canonical truth operator representing the value true
. It can be typed by \top<tab>
.
SoleLogics.Truth
— Typeabstract type Truth <: SyntaxLeaf end
Abstract type for syntax leaves representing values of a lattice algebra. In Boolean logic, the two BooleanTruth
values Top
and Bot
are tused.
Implementation
When implementing a custom Truth
subtype, provide istop, isbot... TODO: write the interface to be implemented here, with an example.
See also Top
, Bot
, BooleanTruth
, arity
;
SoleLogics.TruthDict
— Typestruct TruthDict{D<:AbstractDict{A where A<:Atom,T where T<:Truth}} <: AbstractAssignment
truth::D
end
A logical interpretation instantiated as a dictionary, explicitly assigning truth values to a finite set of atoms.
Examples
julia> TruthDict(1:4)
TruthDict with values:
@@ -497,21 +497,21 @@
julia> check(parseformula("a ∨ b"), t2)
true
-
If prompted for the value of an unknown atom, this throws an error. If boolean, integer, or float values are specified, they are converted to Truth
values. If the structure is initialized as empty, BooleanTruth
values are assumed.
See also DefaultedTruthDict
, AbstractAssignment
, AbstractInterpretation
.
SoleLogics.TruthTable
— Typestruct TruthTable{A,T<:Truth}
Dictionary which associates an AbstractAssignment
s to the truth value of the assignment itself on a AbstractSyntaxStructure
.
See also AbstractAssignment
, AbstractSyntaxStructure
, Truth
.
SoleLogics.World
— Typestruct World{T} <: AbstractWorld
+
If prompted for the value of an unknown atom, this throws an error. If boolean, integer, or float values are specified, they are converted to Truth
values. If the structure is initialized as empty, BooleanTruth
values are assumed.
See also DefaultedTruthDict
, AbstractAssignment
, AbstractInterpretation
.
SoleLogics.TruthTable
— Typestruct TruthTable{A,T<:Truth}
Dictionary which associates an AbstractAssignment
s to the truth value of the assignment itself on a AbstractSyntaxStructure
.
See also AbstractAssignment
, AbstractSyntaxStructure
, Truth
.
SoleLogics.World
— Typestruct World{T} <: AbstractWorld
name::T
-end
A world that is solely identified by its name
. This can be useful when instantiating the underlying graph of a modal frame in an explicit way.
See also OneWorld
, AbstractWorld
.
SoleLogics.Worlds
— Typeconst AbstractWorlds{W} = AbstractVector{W} where {W<:AbstractWorld}
-const Worlds{W} = Vector{W} where {W<:AbstractWorld}
Useful aliases for dealing with worlds sets/arrays.
See also accessibles
, AbstractWorld
.
SoleLogics.WrapperMultiModalFrame
— Typestruct WrapperMultiModalFrame{
+end
A world that is solely identified by its name
. This can be useful when instantiating the underlying graph of a modal frame in an explicit way.
See also OneWorld
, AbstractWorld
.
SoleLogics.Worlds
— Typeconst AbstractWorlds{W} = AbstractVector{W} where {W<:AbstractWorld}
+const Worlds{W} = Vector{W} where {W<:AbstractWorld}
Useful aliases for dealing with worlds sets/arrays.
See also accessibles
, AbstractWorld
.
SoleLogics.WrapperMultiModalFrame
— Typestruct WrapperMultiModalFrame{
W<:AbstractWorld,
D<:AbstractDict{<:AbstractRelation,<:AbstractUniModalFrame{W}}
} <: AbstractMultiModalFrame{W}
frames::D
-end
A multi-modal frame that is the superposition of many uni-modal frames. It uses a single AbstractUniModalFrame
for each of relations.
See also AbstractRelation
, AbstractUniModalFrame
.
AbstractTrees.children
— MethodAbstractTrees.children
— MethodBase.haskey
— MethodBase.haskey(i::AbstractAssignment, ::Atom)::Bool
Return whether an assigment has a truth value for a given atom.
See also AbstractInterpretation
.
Base.in
— MethodBase.in(p::Atom, a::AbstractAlphabet)::Bool
Return whether an atom belongs to an alphabet.
See also AbstractAlphabet
, Atom
.
Base.in
— MethodBase.in(tok::SyntaxToken, φ::Formula)::Bool
Return whether a syntax token appears in a formula.
See also Formula
, SyntaxToken
.
Base.in
— MethodBase.in(φ::SyntaxTree, g::AbstractGrammar)::Bool
Return whether a SyntaxTree
, belongs to a grammar.
See also AbstractGrammar
, SyntaxTree
.
Base.iterate
— MethodBase.iterate(a::AbstractAlphabet)
-Base.iterate(a::AbstractAlphabet, state)
Return an iterator to the next element in an alhabet.
See also AbstractAlphabet
, SyntaxBranch
.
Base.length
— MethodBase.length(a::AbstractAlphabet)::Bool
Return the alphabet length, if it is finite.
See also AbstractAlphabet
, SyntaxBranch
.
Base.rand
— MethodBase.rand(
+end
A multi-modal frame that is the superposition of many uni-modal frames. It uses a single AbstractUniModalFrame
for each of relations.
See also AbstractRelation
, AbstractUniModalFrame
.
AbstractTrees.children
— MethodAbstractTrees.children
— MethodBase.haskey
— MethodBase.haskey(i::AbstractAssignment, ::Atom)::Bool
Return whether an assigment has a truth value for a given atom.
See also AbstractInterpretation
.
Base.in
— MethodBase.in(p::Atom, a::AbstractAlphabet)::Bool
Return whether an atom belongs to an alphabet.
See also AbstractAlphabet
, Atom
.
Base.in
— MethodBase.in(tok::SyntaxToken, φ::Formula)::Bool
Return whether a syntax token appears in a formula.
See also Formula
, SyntaxToken
.
Base.in
— MethodBase.in(φ::SyntaxTree, g::AbstractGrammar)::Bool
Return whether a SyntaxTree
, belongs to a grammar.
See also AbstractGrammar
, SyntaxTree
.
Base.iterate
— MethodBase.iterate(a::AbstractAlphabet)
+Base.iterate(a::AbstractAlphabet, state)
Return an iterator to the next element in an alhabet.
See also AbstractAlphabet
, SyntaxBranch
.
Base.length
— MethodBase.length(a::AbstractAlphabet)::Bool
Return the alphabet length, if it is finite.
See also AbstractAlphabet
, SyntaxBranch
.
Base.rand
— MethodBase.rand(
[rng::AbstractRNG = Random.GLOBAL_RNG, ]
alphabet,
args...;
kwargs...
-)::Atom
Randomly sample an atom from an alphabet
, according to a uniform distribution.
Implementation
If the alphabet
is finite, the function defaults to rand(rng, atoms(alphabet))
; otherwise, it must be implemented, and additional keyword arguments should be provided in order to limit the (otherwise infinite) sampling domain.
See also isfinite
, `AbstractAlphabet'.
SoleLogics.accessibles
— Methodaccessibles(
+)::Atom
Randomly sample an atom from an alphabet
, according to a uniform distribution.
Implementation
If the alphabet
is finite, the function defaults to rand(rng, atoms(alphabet))
; otherwise, it must be implemented, and additional keyword arguments should be provided in order to limit the (otherwise infinite) sampling domain.
See also isfinite
, `AbstractAlphabet'.
SoleLogics.accessibles
— Methodaccessibles(
fr::AbstractMultiModalFrame{W},
w::W,
r::AbstractRelation
@@ -560,9 +560,9 @@
r::GlobalRel,
) where {W<:AbstractWorld}
allworlds(fr)
-end
In general, it should be true that collect(accessibles(fr, w, r)) isa AbstractWorlds{W}
.
See also AbstractWorld
, AbstractRelation
, AbstractMultiModalFrame
.
SoleLogics.accessibles
— Methodaccessibles(fr::AbstractUniModalFrame{W}, w::W)::Worlds{W} where {W<:AbstractWorld}
Return the worlds in frame fr
that are accessible from world w
.
See also AbstractWorld
, AbstractUniModalFrame
.
SoleLogics.algebra
— Methodalgebra(l::AbstractLogic{G,V})::V where {G,V}
Return the algebra
of a given logic.
See also AbstractAlgebra
, AbstractLogic
.
SoleLogics.allworlds
— Methodallworlds(fr::AbstractFrame{W})::AbstractVector{<:W} where {W<:AbstractWorld}
Return all worlds within the frame.
See also nworlds
, AbstractFrame
.
SoleLogics.alphabet
— Methodalphabet(g::AbstractGrammar{V} where {V})::V
Return the propositional alphabet of a grammar.
See also AbstractAlphabet
, AbstractGrammar
.
SoleLogics.arity
— MethodSoleLogics.arity
— Methodarity(tok::Connective)::Integer
-arity(φ::SyntaxLeaf)::Integer # TODO extend to SyntaxTree SyntaxBranch
Return the arity
of a Connective
or an SyntaxLeaf
. The arity
is an integer representing the number of allowed children in a SyntaxBranch
. Connective
s with arity
equal to 0, 1 or 2 are called nullary
, unary
and binary
, respectively. SyntaxLeaf
s (Atom
s and Truth
values) are always nullary.
See also SyntaxLeaf
, Connective
, SyntaxBranch
.
SoleLogics.arity
— Methodarity(tok::Connective)::Integer
-arity(φ::SyntaxLeaf)::Integer # TODO extend to SyntaxTree SyntaxBranch
Return the arity
of a Connective
or an SyntaxLeaf
. The arity
is an integer representing the number of allowed children in a SyntaxBranch
. Connective
s with arity
equal to 0, 1 or 2 are called nullary
, unary
and binary
, respectively. SyntaxLeaf
s (Atom
s and Truth
values) are always nullary.
See also SyntaxLeaf
, Connective
, SyntaxBranch
.
SoleLogics.associativity
— Methodassociativity(::Connective)
Return whether a (binary) connective is right-associative.
When using infix notation, and in the absence of parentheses, associativity establishes how binary connectives of the same
precedenceare interpreted. This affects how formulas are shown (via
syntaxstring) and parsed (via
parseformula`).
By default, the value for a NamedConnective
is derived from the Base.operator_precedence
of its symbol (name
); thus, for example, most connectives are left-associative (e.g., ∧
and ∨
), while →
is right-associative. Because of this, when dealing with a custom connective ⊙
, it will be the case that parseformula("p ⊙ q ∧ r") == (@synexpr p ⊙ q ∧ r)
.
Examples
julia> associativity(∧)
+end
In general, it should be true that collect(accessibles(fr, w, r)) isa AbstractWorlds{W}
.
See also AbstractWorld
, AbstractRelation
, AbstractMultiModalFrame
.
SoleLogics.accessibles
— Methodaccessibles(fr::AbstractUniModalFrame{W}, w::W)::Worlds{W} where {W<:AbstractWorld}
Return the worlds in frame fr
that are accessible from world w
.
See also AbstractWorld
, AbstractUniModalFrame
.
SoleLogics.algebra
— Methodalgebra(l::AbstractLogic{G,V})::V where {G,V}
Return the algebra
of a given logic.
See also AbstractAlgebra
, AbstractLogic
.
SoleLogics.allworlds
— Methodallworlds(fr::AbstractFrame{W})::AbstractVector{<:W} where {W<:AbstractWorld}
Return all worlds within the frame.
See also nworlds
, AbstractFrame
.
SoleLogics.alphabet
— Methodalphabet(g::AbstractGrammar{V} where {V})::V
Return the propositional alphabet of a grammar.
See also AbstractAlphabet
, AbstractGrammar
.
SoleLogics.arity
— MethodSoleLogics.arity
— Methodarity(tok::Connective)::Integer
+arity(φ::SyntaxLeaf)::Integer # TODO extend to SyntaxTree SyntaxBranch
Return the arity
of a Connective
or an SyntaxLeaf
. The arity
is an integer representing the number of allowed children in a SyntaxBranch
. Connective
s with arity
equal to 0, 1 or 2 are called nullary
, unary
and binary
, respectively. SyntaxLeaf
s (Atom
s and Truth
values) are always nullary.
See also SyntaxLeaf
, Connective
, SyntaxBranch
.
SoleLogics.arity
— Methodarity(tok::Connective)::Integer
+arity(φ::SyntaxLeaf)::Integer # TODO extend to SyntaxTree SyntaxBranch
Return the arity
of a Connective
or an SyntaxLeaf
. The arity
is an integer representing the number of allowed children in a SyntaxBranch
. Connective
s with arity
equal to 0, 1 or 2 are called nullary
, unary
and binary
, respectively. SyntaxLeaf
s (Atom
s and Truth
values) are always nullary.
See also SyntaxLeaf
, Connective
, SyntaxBranch
.
SoleLogics.associativity
— Methodassociativity(::Connective)
Return whether a (binary) connective is right-associative.
When using infix notation, and in the absence of parentheses, associativity establishes how binary connectives of the same
precedenceare interpreted. This affects how formulas are shown (via
syntaxstring) and parsed (via
parseformula`).
By default, the value for a NamedConnective
is derived from the Base.operator_precedence
of its symbol (name
); thus, for example, most connectives are left-associative (e.g., ∧
and ∨
), while →
is right-associative. Because of this, when dealing with a custom connective ⊙
, it will be the case that parseformula("p ⊙ q ∧ r") == (@synexpr p ⊙ q ∧ r)
.
Examples
julia> associativity(∧)
:left
julia> associativity(→)
@@ -572,7 +572,7 @@
"p → (q → r)"
julia> syntaxstring(parseformula("p ∧ q ∨ r"); remove_redundant_parentheses = false)
-"(p ∧ q) ∨ r"
See also Connective
, parseformula
, precedence
, syntaxstring
.
SoleLogics.atoms
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
+"(p ∧ q) ∨ r"
See also Connective
, parseformula
, precedence
, syntaxstring
.
SoleLogics.atoms
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
atoms(φ::Formula)::AbstractVector{<:Atom}
truths(φ::Formula)::AbstractVector{<:Truth}
leaves(φ::Formula)::AbstractVector{<:SyntaxLeaf}
@@ -583,7 +583,7 @@
ntruths(φ::Formula)::Integer
nleaves(φ::Formula)::Integer
nconnectives(φ::Formula)::Integer
-noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.atoms
— Methodatoms(a::AbstractAlphabet)::AbstractVector{atomstype(a)}
List the atoms of a finite alphabet.
See also AbstractAlphabet
, Base.isfinite
.
SoleLogics.baseformula
— Methodfunction baseformula(
+noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.atoms
— Methodatoms(a::AbstractAlphabet)::AbstractVector{atomstype(a)}
List the atoms of a finite alphabet.
See also AbstractAlphabet
, Base.isfinite
.
SoleLogics.baseformula
— Methodfunction baseformula(
φ::Formula;
infer_logic = true,
additional_operators::Union{Nothing,Vector{<:Operator}} = nothing,
@@ -603,7 +603,7 @@
∨
→
◊
- □
SoleLogics.bot
— MethodSoleLogics.box
— MethodTODO document
SoleLogics.centralworld
— MethodReturn the world at the center of the frame; note that this does not always exist.
SoleLogics.check
— Functionfunction check(
+ □
SoleLogics.bot
— MethodSoleLogics.box
— MethodTODO document
SoleLogics.centralworld
— MethodReturn the world at the center of the frame; note that this does not always exist.
SoleLogics.check
— Functionfunction check(
φ::SyntaxTree,
i::AbstractKripkeStructure,
w::Union{Nothing,<:AbstractWorld} = nothing;
@@ -646,7 +646,7 @@
SoleLogics.World{Int64}(2) => 1
SoleLogics.World{Int64}(3) => 1
SoleLogics.World{Int64}(4) => 0
- SoleLogics.World{Int64}(5) => 0
See also SyntaxTree
, AbstractWorld
, KripkeStructure
.
SoleLogics.check
— Methodcheck(
+ SoleLogics.World{Int64}(5) => 0
See also SyntaxTree
, AbstractWorld
, KripkeStructure
.
SoleLogics.check
— Methodcheck(
φ::Formula,
i::AbstractInterpretation,
args...;
@@ -666,25 +666,25 @@
└────────┴────────┘
julia> check(CONJUNCTION(p,q), td)
-false
See also interpret
, Formula
, AbstractInterpretation
, TruthDict
.
SoleLogics.check
— Methodcheck(
+false
See also interpret
, Formula
, AbstractInterpretation
, TruthDict
.
SoleLogics.check
— Methodcheck(
φ::Formula,
s::AbstractInterpretationSet,
i_instance::Integer,
args...;
kwargs...
-)::Bool
Check a formula on the $i$-th instance of an AbstractInterpretationSet
.
See also AbstractInterpretationSet
, Formula
.
SoleLogics.check
— Methodcheck(
+)::Bool
Check a formula on the $i$-th instance of an AbstractInterpretationSet
.
See also AbstractInterpretationSet
, Formula
.
SoleLogics.check
— Methodcheck(
φ::Formula,
s::AbstractInterpretationSet,
args...;
kwargs...
-)::Vector{Bool}
Check a formula on all instances of an AbstractInterpretationSet
.
See also AbstractInterpretationSet
, Formula
.
SoleLogics.collatetruth
— Methodcollatetruth(
+)::Vector{Bool}
Check a formula on all instances of an AbstractInterpretationSet
.
See also AbstractInterpretationSet
, Formula
.
SoleLogics.collatetruth
— Methodcollatetruth(
c::Connective,
ts::NTuple{N,T},
-)::T where {N,T<:Truth}
Return the truth value for a composed formula c(φ1, ..., φN), given the N
truth values for its immediate sub-formulas.
See also AbstractAlgebra
Connective
, Truth
.
SoleLogics.collateworlds
— Methodcollateworlds(
+)::T where {N,T<:Truth}
Return the truth value for a composed formula c(φ1, ..., φN), given the N
truth values for its immediate sub-formulas.
See also AbstractAlgebra
Connective
, Truth
.
SoleLogics.collateworlds
— Methodcollateworlds(
fr::AbstractFrame{W},
op::Operator,
t::NTuple{N,WS},
-)::AbstractVector{<:W} where {N,W<:AbstractWorld,WS<:AbstractWorlds}
For a given crisp frame (truthtype == Bool
), return the set of worlds where a composed formula op(φ1, ..., φN) is true, given the N
sets of worlds where the each immediate sub-formula is true.
See also check
, iscrisp
, Operator
, AbstractFrame
.
SoleLogics.composeformulas
— Methodcomposeformulas(c::Connective, φs::NTuple{N,F})::F where {N,F<:Formula}
Return a new formula of type F
by composing N
formulas of the same type via a connective c
. This function allows one to use connectives for flexibly composing formulas (see Implementation section).
Examples
julia> f = parseformula("◊(p→q)");
+)::AbstractVector{<:W} where {N,W<:AbstractWorld,WS<:AbstractWorlds}
For a given crisp frame (truthtype == Bool
), return the set of worlds where a composed formula op(φ1, ..., φN) is true, given the N
sets of worlds where the each immediate sub-formula is true.
See also check
, iscrisp
, Operator
, AbstractFrame
.
SoleLogics.composeformulas
— Methodcomposeformulas(c::Connective, φs::NTuple{N,F})::F where {N,F<:Formula}
Return a new formula of type F
by composing N
formulas of the same type via a connective c
. This function allows one to use connectives for flexibly composing formulas (see Implementation section).
Examples
julia> f = parseformula("◊(p→q)");
julia> p = Atom("p");
@@ -712,7 +712,7 @@
cs::Formula...
)
return ∨(c1, ∨(c2, c3, cs...))
-end
To allow for the composition of Formula
s of different types, promotion rules should be provided.
See also Formula
, Connective
.
SoleLogics.connectives
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
+end
To allow for the composition of Formula
s of different types, promotion rules should be provided.
See also Formula
, Connective
.
SoleLogics.connectives
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
atoms(φ::Formula)::AbstractVector{<:Atom}
truths(φ::Formula)::AbstractVector{<:Truth}
leaves(φ::Formula)::AbstractVector{<:SyntaxLeaf}
@@ -723,16 +723,16 @@
ntruths(φ::Formula)::Integer
nleaves(φ::Formula)::Integer
nconnectives(φ::Formula)::Integer
-noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.connectives
— Methodconnectives(g::AbstractGrammar)
List all connectives appearing in a grammar.
See also Connective
, nconnectives
.
SoleLogics.converse
— Methodconverse(r::AbstractRelation)::AbstractRelation
If the relation hasconverse
, return the converse relation (type) of a given relation (type).
See also issymmetric
, isreflexive
, istransitive
, AbstractRelation
.
SoleLogics.diamond
— MethodTODO document
SoleLogics.domain
— Methoddomain(a::AbstractAlgebra)
Return an iterator to the values in the domain
of a given algebra.
See also AbstractAlgebra
.
SoleLogics.dual
— Methoddual(op::SyntaxToken)
Return the dual
of an Operator
. Given an operator op
of arity n
, the dual dop
is such that, on a boolean algebra, op(ch_1, ..., ch_n)
≡ ¬dop(¬ch_1, ..., ¬ch_n)
.
Duality can be used to perform syntactic simplifications on formulas. For example, since ∧
and ∨
are dual
s, ¬(¬p ∧ ¬q)
can be simplified to (p ∧ q)
. Duality also applies to Truth
values (⊤
/⊥
), with existential/universal semantics (◊
/□
), and Atom
s.
Implementation
When providing a dual
for an operator of type O
, please also provide:
hasdual(::O) = true
The dual of an Atom
(that is, the atom with inverted semantics) is defined as:
dual(p::Atom{V}) where {V} = Atom(dual(value(p)))
As such, hasdual(::V)
and dual(::V)
should be defined when wrapping objects of type A
.
See also normalize
, SyntaxToken
.
SoleLogics.emptyworld
— MethodReturn an empty world (e.g., Interval(-1,0)
).
SoleLogics.formulas
— Methodformulas(
+noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.connectives
— Methodconnectives(g::AbstractGrammar)
List all connectives appearing in a grammar.
See also Connective
, nconnectives
.
SoleLogics.converse
— Methodconverse(r::AbstractRelation)::AbstractRelation
If the relation hasconverse
, return the converse relation (type) of a given relation (type).
See also issymmetric
, isreflexive
, istransitive
, AbstractRelation
.
SoleLogics.diamond
— MethodTODO document
SoleLogics.domain
— Methoddomain(a::AbstractAlgebra)
Return an iterator to the values in the domain
of a given algebra.
See also AbstractAlgebra
.
SoleLogics.dual
— Methoddual(op::SyntaxToken)
Return the dual
of an Operator
. Given an operator op
of arity n
, the dual dop
is such that, on a boolean algebra, op(ch_1, ..., ch_n)
≡ ¬dop(¬ch_1, ..., ¬ch_n)
.
Duality can be used to perform syntactic simplifications on formulas. For example, since ∧
and ∨
are dual
s, ¬(¬p ∧ ¬q)
can be simplified to (p ∧ q)
. Duality also applies to Truth
values (⊤
/⊥
), with existential/universal semantics (◊
/□
), and Atom
s.
Implementation
When providing a dual
for an operator of type O
, please also provide:
hasdual(::O) = true
The dual of an Atom
(that is, the atom with inverted semantics) is defined as:
dual(p::Atom{V}) where {V} = Atom(dual(value(p)))
As such, hasdual(::V)
and dual(::V)
should be defined when wrapping objects of type A
.
See also normalize
, SyntaxToken
.
SoleLogics.emptyworld
— MethodReturn an empty world (e.g., Interval(-1,0)
).
SoleLogics.formulas
— Methodformulas(
g::AbstractGrammar;
maxdepth::Integer,
nformulas::Union{Nothing,Integer} = nothing,
args...
-)::Vector{<:SyntaxBranch}
Enumerate the formulas produced by a given grammar with a finite and iterable alphabet.
Implementation
Additional args
can be used to model the function's behavior. At least these two arguments should be covered:
- a
nformulas
argument can be used to limit the size of the returnedVector
; - a
maxdepth
argument can be used to limit the syntactic component, represented as a syntax tree,
to a given maximum depth;
See also AbstractGrammar
, SyntaxBranch
.
SoleLogics.formulas
— Methodformulas(
+)::Vector{<:SyntaxBranch}
Enumerate the formulas produced by a given grammar with a finite and iterable alphabet.
Implementation
Additional args
can be used to model the function's behavior. At least these two arguments should be covered:
- a
nformulas
argument can be used to limit the size of the returnedVector
; - a
maxdepth
argument can be used to limit the syntactic component, represented as a syntax tree,
to a given maximum depth;
See also AbstractGrammar
, SyntaxBranch
.
SoleLogics.formulas
— Methodformulas(
g::CompleteFlatGrammar{V,O} where {V,O};
maxdepth::Integer,
nformulas::Union{Nothing,Integer} = nothing
-)::Vector{SyntaxBranch}
Generate all formulas whose SyntaxBranch
s that are not taller than a given maxdepth
.
See also AbstractGrammar
, SyntaxBranch
.
SoleLogics.goeswithdim
— MethodSome worlds (dimensional worlds) can be interpreted on dimensional data, that is, n-dimensional arrays. The compatibility of a given world with respect of a structure of a given dimensionality must be specified via the following trait:
goeswithdim(w::AbstractWorld, d) = goeswithdim(typeof(w), d)
+)::Vector{SyntaxBranch}
Generate all formulas whose SyntaxBranch
s that are not taller than a given maxdepth
.
See also AbstractGrammar
, SyntaxBranch
.
SoleLogics.goeswithdim
— MethodSome worlds (dimensional worlds) can be interpreted on dimensional data, that is, n-dimensional arrays. The compatibility of a given world with respect of a structure of a given dimensionality must be specified via the following trait:
goeswithdim(w::AbstractWorld, d) = goeswithdim(typeof(w), d)
goeswithdim(W::Type{<:AbstractWorld}, d::Integer) = goeswithdim(W, Val(d))
goeswithdim(::Type{<:AbstractWorld}, ::Val) = false
Examples
julia> SoleLogics.goeswithdim(OneWorld, 0)
true
@@ -748,7 +748,7 @@
julia> all([SoleLogics.goeswithdim.(SoleLogics.Point{N}, N) for N in 1:10])
true
-
See also OneWorld
, World
, Interval
, Interval2D
, GeometricalWorld
, AbstractWorld
.
SoleLogics.grammar
— Methodgrammar(l::AbstractLogic{G})::G where {G<:AbstractGrammar}
Return the grammar
of a given logic.
See also AbstractGrammar
, AbstractLogic
, algebra
, alphabet
, formulas
, grammar
, operators
, truthtype
.
SoleLogics.hasconverse
— Methodconverse(r::AbstractRelation)::AbstractRelation
If the relation hasconverse
, return the converse relation (type) of a given relation (type).
See also issymmetric
, isreflexive
, istransitive
, AbstractRelation
.
SoleLogics.hasdual
— Methoddual(op::SyntaxToken)
Return the dual
of an Operator
. Given an operator op
of arity n
, the dual dop
is such that, on a boolean algebra, op(ch_1, ..., ch_n)
≡ ¬dop(¬ch_1, ..., ¬ch_n)
.
Duality can be used to perform syntactic simplifications on formulas. For example, since ∧
and ∨
are dual
s, ¬(¬p ∧ ¬q)
can be simplified to (p ∧ q)
. Duality also applies to Truth
values (⊤
/⊥
), with existential/universal semantics (◊
/□
), and Atom
s.
Implementation
When providing a dual
for an operator of type O
, please also provide:
hasdual(::O) = true
The dual of an Atom
(that is, the atom with inverted semantics) is defined as:
dual(p::Atom{V}) where {V} = Atom(dual(value(p)))
As such, hasdual(::V)
and dual(::V)
should be defined when wrapping objects of type A
.
See also normalize
, SyntaxToken
.
SoleLogics.height
— Methodheight(φ::Formula)::Integer
Return the height of a formula in its syntax tree representation.
See also SyntaxTree
.
SoleLogics.interpret
— Methodinterpret(
+
See also OneWorld
, World
, Interval
, Interval2D
, GeometricalWorld
, AbstractWorld
.
SoleLogics.grammar
— Methodgrammar(l::AbstractLogic{G})::G where {G<:AbstractGrammar}
Return the grammar
of a given logic.
See also AbstractGrammar
, AbstractLogic
, algebra
, alphabet
, formulas
, grammar
, operators
, truthtype
.
SoleLogics.hasconverse
— Methodconverse(r::AbstractRelation)::AbstractRelation
If the relation hasconverse
, return the converse relation (type) of a given relation (type).
See also issymmetric
, isreflexive
, istransitive
, AbstractRelation
.
SoleLogics.hasdual
— Methoddual(op::SyntaxToken)
Return the dual
of an Operator
. Given an operator op
of arity n
, the dual dop
is such that, on a boolean algebra, op(ch_1, ..., ch_n)
≡ ¬dop(¬ch_1, ..., ¬ch_n)
.
Duality can be used to perform syntactic simplifications on formulas. For example, since ∧
and ∨
are dual
s, ¬(¬p ∧ ¬q)
can be simplified to (p ∧ q)
. Duality also applies to Truth
values (⊤
/⊥
), with existential/universal semantics (◊
/□
), and Atom
s.
Implementation
When providing a dual
for an operator of type O
, please also provide:
hasdual(::O) = true
The dual of an Atom
(that is, the atom with inverted semantics) is defined as:
dual(p::Atom{V}) where {V} = Atom(dual(value(p)))
As such, hasdual(::V)
and dual(::V)
should be defined when wrapping objects of type A
.
See also normalize
, SyntaxToken
.
SoleLogics.height
— Methodheight(φ::Formula)::Integer
Return the height of a formula in its syntax tree representation.
See also SyntaxTree
.
SoleLogics.interpret
— Methodinterpret(
φ::Formula,
i::AbstractInterpretation,
args...;
@@ -768,7 +768,7 @@
└────────┴────────┘
julia> interpret(CONJUNCTION(p,q), td)
-⊥
See also check
, Formula
, AbstractInterpretation
, AbstractAlgebra
.
SoleLogics.isbot
— Methodisbot(::Truth)::Bool
Return true if the Truth
value is the bottom of its algebra. For example, in the crisp case, with Bool
truth values, it is:
isbot(t::Bool)::Bool = (t == false)
SoleLogics.isbox
— Methodisbox(::Type{<:Connective})::Bool = false
+⊥
See also check
, Formula
, AbstractInterpretation
, AbstractAlgebra
.
SoleLogics.isbot
— Methodisbot(::Truth)::Bool
Return true if the Truth
value is the bottom of its algebra. For example, in the crisp case, with Bool
truth values, it is:
isbot(t::Bool)::Bool = (t == false)
SoleLogics.isbox
— Methodisbox(::Type{<:Connective})::Bool = false
isbox(c::Connective)::Bool = isbox(typeof(c))
Return whether it is known that an Connective
is a box (i.e., universal) operator.
Examples
julia> SoleLogics.isbox(◊)
false
@@ -776,22 +776,22 @@
false
julia> SoleLogics.isbox(□)
-true
SoleLogics.iscommutative
— Methodiscommutative(c::Connective)
Return whether a connective is known to be commutative.
Examples
julia> iscommutative(∧)
+true
SoleLogics.iscommutative
— Methodiscommutative(c::Connective)
Return whether a connective is known to be commutative.
Examples
julia> iscommutative(∧)
true
julia> iscommutative(→)
-false
Note that nullary and unary connectives are considered commutative.
See also Connective
.
Implementation
When implementing a new type for a commutative connective C
with arity higher than 1, please provide a method iscommutative(::C)
. This can help model checking operations.
See also Connective
.
SoleLogics.iscrisp
— Methodiscrisp(a::AbstractAlgebra) = iscrisp(typeof(a))
An algebra is crisp (or boolean) when its domain only has two values, namely, the top and the bottom. The antonym of crisp is fuzzy.
See also AbstractAlgebra
.
SoleLogics.isgrounded
— Methodisgrounded(f::Formula)::Bool
Return true
if the formula is grounded, that is, if it can be inferred from its syntactic structure that, given any frame-based model, the truth value of the formula is the same on every world.
Examples
julia> f = parseformula("⟨G⟩p → [G]q");
+false
Note that nullary and unary connectives are considered commutative.
See also Connective
.
Implementation
When implementing a new type for a commutative connective C
with arity higher than 1, please provide a method iscommutative(::C)
. This can help model checking operations.
See also Connective
.
SoleLogics.iscrisp
— Methodiscrisp(a::AbstractAlgebra) = iscrisp(typeof(a))
An algebra is crisp (or boolean) when its domain only has two values, namely, the top and the bottom. The antonym of crisp is fuzzy.
See also AbstractAlgebra
.
SoleLogics.isgrounded
— Methodisgrounded(f::Formula)::Bool
Return true
if the formula is grounded, that is, if it can be inferred from its syntactic structure that, given any frame-based model, the truth value of the formula is the same on every world.
Examples
julia> f = parseformula("⟨G⟩p → [G]q");
julia> syntaxstring(f)
"(⟨G⟩p) → ([G]q)"
julia> SoleLogics.isgrounded(f)
-true
See also isgrounding
), SyntaxTree
), Formula
.
SoleLogics.isgrounding
— Methodisgrounding(::AbstractRelation)
Return whether it is known that a relation is grounding. A relation R
is grounding if ∀x,y R(x,y) ⇔ R(z,y).
See also isreflexive
, issymmetric
, istransitive
, AbstractRelation
.
SoleLogics.ismodal
— Methodismodal(::Type{<:Connective})::Bool = false
+true
See also isgrounding
), SyntaxTree
), Formula
.
SoleLogics.isgrounding
— Methodisgrounding(::AbstractRelation)
Return whether it is known that a relation is grounding. A relation R
is grounding if ∀x,y R(x,y) ⇔ R(z,y).
See also isreflexive
, issymmetric
, istransitive
, AbstractRelation
.
SoleLogics.ismodal
— Methodismodal(::Type{<:Connective})::Bool = false
ismodal(c::Connective)::Bool = ismodal(typeof(c))
Return whether it is known that an Connective
is modal.
Examples
julia> ismodal(◊)
true
julia> ismodal(∧)
-false
SoleLogics.isreflexive
— Methodisreflexive(::AbstractRelation)
Return whether it is known that a relation is reflexive.
See also issymmetric
, istransitive
, isgrounding
, AbstractRelation
.
SoleLogics.issymmetric
— Methodissymmetric(r::AbstractRelation) = hasconverse(r) ? converse(r) == r : false
Return whether it is known that a relation is symmetric.
See also hasconverse
, converse
, isreflexive
, istransitive
, isgrounding
, AbstractRelation
.
SoleLogics.istoone
— Methodistoone(r::AbstractRelation) = false
Return whether it is known that a relation is istoone.
See also hasconverse
, converse
, issymmetric
, istransitive
, isgrounding
, AbstractRelation
.
SoleLogics.istop
— Methodistop(::Truth)::Bool
Return true if the Truth
value is the top of its algebra. For example, in the crisp case, with Bool
truth values, it is:
istop(t::Bool)::Bool = (t == true)
SoleLogics.istopological
— Methodistopological(r::GeometricalRelation)
Return whether it is known that a given geometrical relation is topological (i.e., invariant under homeomorphisms, see here)
See also GeometricalRelation
.
SoleLogics.istransitive
— Methodistransitive(::AbstractRelation)
Return whether it is known that a relation is transitive.
See also istoone
, issymmetric
, isgrounding
, AbstractRelation
.
SoleLogics.leaves
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
+false
SoleLogics.isreflexive
— Methodisreflexive(::AbstractRelation)
Return whether it is known that a relation is reflexive.
See also issymmetric
, istransitive
, isgrounding
, AbstractRelation
.
SoleLogics.issymmetric
— Methodissymmetric(r::AbstractRelation) = hasconverse(r) ? converse(r) == r : false
Return whether it is known that a relation is symmetric.
See also hasconverse
, converse
, isreflexive
, istransitive
, isgrounding
, AbstractRelation
.
SoleLogics.istoone
— Methodistoone(r::AbstractRelation) = false
Return whether it is known that a relation is istoone.
See also hasconverse
, converse
, issymmetric
, istransitive
, isgrounding
, AbstractRelation
.
SoleLogics.istop
— Methodistop(::Truth)::Bool
Return true if the Truth
value is the top of its algebra. For example, in the crisp case, with Bool
truth values, it is:
istop(t::Bool)::Bool = (t == true)
SoleLogics.istopological
— Methodistopological(r::GeometricalRelation)
Return whether it is known that a given geometrical relation is topological (i.e., invariant under homeomorphisms, see here)
See also GeometricalRelation
.
SoleLogics.istransitive
— Methodistransitive(::AbstractRelation)
Return whether it is known that a relation is transitive.
See also istoone
, issymmetric
, isgrounding
, AbstractRelation
.
SoleLogics.leaves
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
atoms(φ::Formula)::AbstractVector{<:Atom}
truths(φ::Formula)::AbstractVector{<:Truth}
leaves(φ::Formula)::AbstractVector{<:SyntaxLeaf}
@@ -802,7 +802,7 @@
ntruths(φ::Formula)::Integer
nleaves(φ::Formula)::Integer
nconnectives(φ::Formula)::Integer
-noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.leaves
— MethodSoleLogics.modallogic
— Methodmodallogic(;
+noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.leaves
— MethodSoleLogics.modallogic
— Methodmodallogic(;
alphabet = AlphabetOfAny{String}(),
operators = [⊤, ⊥, ¬, ∧, ∨, →, ◊, □],
grammar = CompleteFlatGrammar(AlphabetOfAny{String}(), [⊤, ⊥, ¬, ∧, ∨, →, ◊, □]),
@@ -821,7 +821,7 @@
julia> modallogic(; alphabet = ["p", "q"]);
julia> modallogic(; alphabet = ExplicitAlphabet([Atom("p"), Atom("q")]));
-
See also propositionallogic
, AbstractAlphabet
, AbstractAlgebra
.
SoleLogics.natoms
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
+
See also propositionallogic
, AbstractAlphabet
, AbstractAlgebra
.
SoleLogics.natoms
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
atoms(φ::Formula)::AbstractVector{<:Atom}
truths(φ::Formula)::AbstractVector{<:Truth}
leaves(φ::Formula)::AbstractVector{<:SyntaxLeaf}
@@ -832,7 +832,7 @@
ntruths(φ::Formula)::Integer
nleaves(φ::Formula)::Integer
nconnectives(φ::Formula)::Integer
-noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.nconnectives
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
+noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.nconnectives
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
atoms(φ::Formula)::AbstractVector{<:Atom}
truths(φ::Formula)::AbstractVector{<:Truth}
leaves(φ::Formula)::AbstractVector{<:SyntaxLeaf}
@@ -843,7 +843,7 @@
ntruths(φ::Formula)::Integer
nleaves(φ::Formula)::Integer
nconnectives(φ::Formula)::Integer
-noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.nleaves
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
+noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.nleaves
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
atoms(φ::Formula)::AbstractVector{<:Atom}
truths(φ::Formula)::AbstractVector{<:Truth}
leaves(φ::Formula)::AbstractVector{<:SyntaxLeaf}
@@ -854,7 +854,7 @@
ntruths(φ::Formula)::Integer
nleaves(φ::Formula)::Integer
nconnectives(φ::Formula)::Integer
-noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.noperators
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
+noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.noperators
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
atoms(φ::Formula)::AbstractVector{<:Atom}
truths(φ::Formula)::AbstractVector{<:Truth}
leaves(φ::Formula)::AbstractVector{<:SyntaxLeaf}
@@ -865,7 +865,7 @@
ntruths(φ::Formula)::Integer
nleaves(φ::Formula)::Integer
nconnectives(φ::Formula)::Integer
-noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.normalize
— Methodnormalize(
+noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.normalize
— Methodnormalize(
f::Formula;
remove_boxes = true,
reduce_negations = true,
@@ -879,7 +879,7 @@
"¬◊(q ∨ ¬p ∨ r)"
julia> syntaxstring(SoleLogics.normalize(f; profile = :readability, allow_atom_flipping = false))
-"□(¬r ∧ p ∧ ¬q)"
See also SyntaxTree
), Formula
.
SoleLogics.ntokens
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
+"□(¬r ∧ p ∧ ¬q)"
See also SyntaxTree
), Formula
.
SoleLogics.ntokens
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
atoms(φ::Formula)::AbstractVector{<:Atom}
truths(φ::Formula)::AbstractVector{<:Truth}
leaves(φ::Formula)::AbstractVector{<:SyntaxLeaf}
@@ -890,7 +890,7 @@
ntruths(φ::Formula)::Integer
nleaves(φ::Formula)::Integer
nconnectives(φ::Formula)::Integer
-noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.ntruths
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
+noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.ntruths
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
atoms(φ::Formula)::AbstractVector{<:Atom}
truths(φ::Formula)::AbstractVector{<:Truth}
leaves(φ::Formula)::AbstractVector{<:SyntaxLeaf}
@@ -901,7 +901,7 @@
ntruths(φ::Formula)::Integer
nleaves(φ::Formula)::Integer
nconnectives(φ::Formula)::Integer
-noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.nworlds
— Methodnworlds(fr::AbstractFrame)::Integer
Return the number of worlds within the frame.
See also nworlds
, AbstractFrame
.
SoleLogics.operators
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
+noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.nworlds
— Methodnworlds(fr::AbstractFrame)::Integer
Return the number of worlds within the frame.
See also nworlds
, AbstractFrame
.
SoleLogics.operators
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
atoms(φ::Formula)::AbstractVector{<:Atom}
truths(φ::Formula)::AbstractVector{<:Truth}
leaves(φ::Formula)::AbstractVector{<:SyntaxLeaf}
@@ -912,14 +912,14 @@
ntruths(φ::Formula)::Integer
nleaves(φ::Formula)::Integer
nconnectives(φ::Formula)::Integer
-noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.parsebaseformula
— Methodparsebaseformula(
+noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.parsebaseformula
— Methodparsebaseformula(
expression::String,
additional_operators::Union{Nothing,Vector{<:Operator}} = nothing;
operators::Union{Nothing,Vector{<:Operator}},
grammar::Union{Nothing,AbstractGrammar} = nothing,
algebra::Union{Nothing,AbstractAlgebra} = nothing,
kwargs...
-)::AnchoredFormula
Return a AnchoredFormula
which is the result of parsing expression
via the Shunting yard algorithm. By default, this function is only able to parse operators in SoleLogics.BASE_PARSABLE_OPERATORS
; additional operators may be provided as a second argument.
The grammar
and algebra
of the associated logic is inferred using the baseformula
function from the operators encountered in the expression, and those in additional_operators
.
See parseformula
, baseformula
.
SoleLogics.parseformula
— Methodparseformula(expr::String, additional_operators = nothing; kwargs...)
+)::AnchoredFormula
Return a AnchoredFormula
which is the result of parsing expression
via the Shunting yard algorithm. By default, this function is only able to parse operators in SoleLogics.BASE_PARSABLE_OPERATORS
; additional operators may be provided as a second argument.
The grammar
and algebra
of the associated logic is inferred using the baseformula
function from the operators encountered in the expression, and those in additional_operators
.
See parseformula
, baseformula
.
SoleLogics.parseformula
— Methodparseformula(expr::String, additional_operators = nothing; kwargs...)
parseformula(F::Type{<:Formula}, expr::String, additional_operators = nothing; kwargs...)
Parse a formula of type F
from a string expression (its syntaxstring
). When F
is not specified, it defaults to SyntaxTree
.
By default, this function is only able to parse operators in SoleLogics.BASE_PARSABLE_OPERATORS
(e.g., ¬, ∧, ∨, →); additional, non-standard operators may be provided as a vector additional_operators
, and their syntaxstring
's will be used for parsing them. Note that, in case of clashing syntaxstring
's, the provided additional operators will override the standard ones.
When parsing SyntaxTree
s, the Shunting yard algorithm is used, and the method allows the following keywords arguments.
Keyword Arguments
function_notation::Bool = false
: if set totrue
, the expression is considered in function notation (e.g.,"⨁(arg1, arg2)"
); otherwise, it is considered in infix notation (e.g.,"arg1 ⨁ arg2"
);atom_parser::Base.Callable = Atom{String}
: a callable to be used for parsing atoms, once they are recognized in the expression. It must return the atom, or theAtom
itself;additional_whitespaces::Vector{Char} = Char[]
: characters to be stripped out from each syntax token. For example, if'@' in additional_whitespaces
, "¬@p@" is parsed just as "¬p".opening_parenthesis::String = "("
: the string signaling the opening of an expression block;closing_parenthesis::String = ")"
: the string signaling the closing of an expression block;arg_delim::String = ","
: whenfunction_notation = true
, the string that delimits the different arguments of a function call.
For a proper functioning, the syntaxstring
of any syntax token cannot be prefixed/suffixed by whitespaces. For example, for any operator ⨁
, it should hold that syntaxstring(⨁) == strip(syntaxstring(⨁))
. Also, syntaxstring
s cannot contain special symbols (opening_parenthesis
, closing_parenthesis
, and arg_delim
) as substrings.
Examples
julia> syntaxstring(parseformula("¬p∧q∧(¬s∧¬z)"))
"¬p ∧ q ∧ ¬s ∧ ¬z"
@@ -927,7 +927,7 @@
"¬p ∧ q ∧ ¬s ∧ ¬z"
julia> syntaxstring(parseformula("¬1→0"; atom_parser = (x -> Atom{Float64}(parse(Float64, x)))))
-"(¬1.0) → 0.0"
For any Formula
type F
, this function should be the inverse of syntaxstring
; that is, if φ::F
then the following should hold, for at least some args
, and for every kwargs
allowing correct parsing: φ == parseformula(F, syntaxstring(φ, args...; kwargs...), args...; kwargs...)
.
See also SyntaxTree
, syntaxstring
.
SoleLogics.precedence
— Methodprecedence(c::Connective)
Return the precedence of a binary connective.
When using infix notation, and in the absence of parentheses, precedence
establishes how binary connectives are interpreted. A precedence value is a standard integer, and connectives with high precedence take precedence over connectives with lower precedences. This affects how formulas are shown (via syntaxstring
) and parsed (via parseformula
).
By default, the value for a NamedConnective
is derived from the Base.operator_precedence
of its symbol (name
); there are some exceptions (e.g., ¬). Because of this, when dealing with a custom connective ⊙
, it will be the case that parseformula("p ⊙ q ∧ r") == (@synexpr p ⊙ q ∧ r)
.
It is possible to assign a specific precedence to a connective type C
by providing a method Base.operator_precedence(::C)
.
Examples
julia> precedence(∧) == Base.operator_precedence(:∧)
+"(¬1.0) → 0.0"
For any Formula
type F
, this function should be the inverse of syntaxstring
; that is, if φ::F
then the following should hold, for at least some args
, and for every kwargs
allowing correct parsing: φ == parseformula(F, syntaxstring(φ, args...; kwargs...), args...; kwargs...)
.
See also SyntaxTree
, syntaxstring
.
SoleLogics.precedence
— Methodprecedence(c::Connective)
Return the precedence of a binary connective.
When using infix notation, and in the absence of parentheses, precedence
establishes how binary connectives are interpreted. A precedence value is a standard integer, and connectives with high precedence take precedence over connectives with lower precedences. This affects how formulas are shown (via syntaxstring
) and parsed (via parseformula
).
By default, the value for a NamedConnective
is derived from the Base.operator_precedence
of its symbol (name
); there are some exceptions (e.g., ¬). Because of this, when dealing with a custom connective ⊙
, it will be the case that parseformula("p ⊙ q ∧ r") == (@synexpr p ⊙ q ∧ r)
.
It is possible to assign a specific precedence to a connective type C
by providing a method Base.operator_precedence(::C)
.
Examples
julia> precedence(∧) == Base.operator_precedence(:∧)
true
julia> precedence(∧), precedence(∨), precedence(→)
@@ -940,7 +940,7 @@
"(¬a) → (b ∧ c)"
julia> syntaxstring(parseformula("a ∧ b → c ∧ d"))
-"(a ∧ b) → (c ∧ d)"
See also associativity
, Connective
.
SoleLogics.propositionallogic
— Methodpropositionallogic(;
+"(a ∧ b) → (c ∧ d)"
See also associativity
, Connective
.
SoleLogics.propositionallogic
— Methodpropositionallogic(;
alphabet = AlphabetOfAny{String}(),
operators = NamedConnective[¬, ∧, ∨, →],
grammar = CompleteFlatGrammar(AlphabetOfAny{String}(), NamedConnective[¬, ∧, ∨, →]),
@@ -954,7 +954,7 @@
julia> propositionallogic(; alphabet = ["p", "q"]);
julia> propositionallogic(; alphabet = ExplicitAlphabet([Atom("p"), Atom("q")]));
-
See also modallogic
, AbstractAlphabet
, AbstractAlgebra
.
SoleLogics.randbaseformula
— Methodrandformula(
+
See also modallogic
, AbstractAlphabet
, AbstractAlgebra
.
SoleLogics.randbaseformula
— Methodrandformula(
height::Integer,
alphabet,
operators::AbstractVector;
@@ -967,7 +967,7 @@
g::AbstractGrammar;
rng::Union{Integer,AbstractRNG} = Random.GLOBAL_RNG
)::SyntaxTree
Return a pseudo-randomic SyntaxBranch
.
Arguments
height::Integer
: height of the generated structure;alphabet::AbstractAlphabet
: collection from which atoms are chosen randomly;operators::AbstractVector
: vector from which legal operators are chosen;g::AbstractGrammar
: alternative to passing alphabet and operators separately. (TODO explain?)
Keyword Arguments
rng::Union{Intger,AbstractRNG} = Random.GLOBAL_RNG
: random number generator;atompicker::Function
= method used to pick a random element. For example, this could be Base.rand or StatsBase.sample.opweights::AbstractWeights
= weight vector over the set of operators (seeStatsBase
).
Examples
julia> syntaxstring(randformula(4, ExplicitAlphabet([1,2]), [NEGATION, CONJUNCTION, IMPLICATION]))
-"¬((¬(¬(2))) → ((1 → 2) → (1 → 2)))"
See also AbstractAlphabet
, SyntaxBranch
.
SoleLogics.randformula
— Methodrandformula(
+"¬((¬(¬(2))) → ((1 → 2) → (1 → 2)))"
See also AbstractAlphabet
, SyntaxBranch
.
SoleLogics.randformula
— Methodrandformula(
height::Integer,
alphabet,
operators::AbstractVector;
@@ -980,16 +980,16 @@
g::AbstractGrammar;
rng::Union{Integer,AbstractRNG} = Random.GLOBAL_RNG
)::SyntaxTree
Return a pseudo-randomic SyntaxBranch
.
Arguments
height::Integer
: height of the generated structure;alphabet::AbstractAlphabet
: collection from which atoms are chosen randomly;operators::AbstractVector
: vector from which legal operators are chosen;g::AbstractGrammar
: alternative to passing alphabet and operators separately. (TODO explain?)
Keyword Arguments
rng::Union{Intger,AbstractRNG} = Random.GLOBAL_RNG
: random number generator;atompicker::Function
= method used to pick a random element. For example, this could be Base.rand or StatsBase.sample.opweights::AbstractWeights
= weight vector over the set of operators (seeStatsBase
).
Examples
julia> syntaxstring(randformula(4, ExplicitAlphabet([1,2]), [NEGATION, CONJUNCTION, IMPLICATION]))
-"¬((¬(¬(2))) → ((1 → 2) → (1 → 2)))"
See also AbstractAlphabet
, SyntaxBranch
.
SoleLogics.relation
— Methodrelationtype(::AbstractRelationalOperator{R}) where {R<:AbstractRelation} = R
-relation(op::AbstractRelationalOperator) = relationtype(op)()
Return the underlying relation (and relation type) of the relational operator.
See also AbstractFrame
.
SoleLogics.relationtype
— Methodrelationtype(::AbstractRelationalOperator{R}) where {R<:AbstractRelation} = R
-relation(op::AbstractRelationalOperator) = relationtype(op)()
Return the underlying relation (and relation type) of the relational operator.
See also AbstractFrame
.
SoleLogics.subformulas
— Methodsubformulas(f::Formula; sorted=true)
Return all sub-formulas (sorted by size when sorted=true
) of a given formula.
Examples
julia> syntaxstring.(SoleLogics.subformulas(parseformula("◊((p∧q)→r)")))
+"¬((¬(¬(2))) → ((1 → 2) → (1 → 2)))"
See also AbstractAlphabet
, SyntaxBranch
.
SoleLogics.relation
— Methodrelationtype(::AbstractRelationalOperator{R}) where {R<:AbstractRelation} = R
+relation(op::AbstractRelationalOperator) = relationtype(op)()
Return the underlying relation (and relation type) of the relational operator.
See also AbstractFrame
.
SoleLogics.relationtype
— Methodrelationtype(::AbstractRelationalOperator{R}) where {R<:AbstractRelation} = R
+relation(op::AbstractRelationalOperator) = relationtype(op)()
Return the underlying relation (and relation type) of the relational operator.
See also AbstractFrame
.
SoleLogics.subformulas
— Methodsubformulas(f::Formula; sorted=true)
Return all sub-formulas (sorted by size when sorted=true
) of a given formula.
Examples
julia> syntaxstring.(SoleLogics.subformulas(parseformula("◊((p∧q)→r)")))
6-element Vector{String}:
"p"
"q"
"r"
"p ∧ q"
"◊(p ∧ q)"
- "(◊(p ∧ q)) → r"
See also SyntaxTree
), Formula
.
SoleLogics.syntaxstring
— Methodsyntaxstring(s::Syntactical; kwargs...)::String
Return the string representation of any syntactic object (e.g., Formula
, SyntaxTree
, SyntaxToken
, Atom
, Truth
, etc). Note that this representation may introduce redundant parentheses. kwargs
can be used to specify how to display syntax tokens/trees under some specific conditions.
The following kwargs
are currently supported:
function_notation = false::Bool
: when set totrue
, it forces the use of function notation for binary operators (see here).remove_redundant_parentheses = true::Bool
: when set tofalse
, it prints a syntaxstring where each syntactical element is wrapped in parentheses.parenthesize_atoms = !remove_redundant_parentheses::Bool
: when set totrue
, it forces the atoms (which are the leaves of a formula's tree structure) to be wrapped in parentheses.
Examples
julia> syntaxstring(parseformula("p∧q∧r∧s∧t"))
+ "(◊(p ∧ q)) → r"
See also SyntaxTree
), Formula
.
SoleLogics.syntaxstring
— Methodsyntaxstring(s::Syntactical; kwargs...)::String
Return the string representation of any syntactic object (e.g., Formula
, SyntaxTree
, SyntaxToken
, Atom
, Truth
, etc). Note that this representation may introduce redundant parentheses. kwargs
can be used to specify how to display syntax tokens/trees under some specific conditions.
The following kwargs
are currently supported:
function_notation = false::Bool
: when set totrue
, it forces the use of function notation for binary operators (see here).remove_redundant_parentheses = true::Bool
: when set tofalse
, it prints a syntaxstring where each syntactical element is wrapped in parentheses.parenthesize_atoms = !remove_redundant_parentheses::Bool
: when set totrue
, it forces the atoms (which are the leaves of a formula's tree structure) to be wrapped in parentheses.
Examples
julia> syntaxstring(parseformula("p∧q∧r∧s∧t"))
"p ∧ q ∧ r ∧ s ∧ t"
julia> syntaxstring(parseformula("p∧q∧r∧s∧t"), function_notation=true)
@@ -1005,7 +1005,7 @@
"◊((p ∧ s) → q)"
julia> syntaxstring(parseformula("◊((p∧s)→q)"); function_notation = true)
-"◊(→(∧(p, s), q))"
See also parseformula
, SyntaxBranch
, SyntaxToken
.
Implementation
In the case of a syntax tree, syntaxstring
is a recursive function that calls itself on the syntax children of each node. For a correct functioning, the syntaxstring
must be defined (including kwargs...
) for every newly defined SyntaxToken
(e.g., SyntaxLeaf
s, that is, Atom
s and Truth
values, and Operator
s), in a way that it produces a unique string representation, since Base.hash
and Base.isequal
, at least for SyntaxBranch
s, rely on it.
In particular, for the case of Atom
s, the function calls itself on the wrapped value:
syntaxstring(a::Atom; kwargs...) = syntaxstring(value(a); kwargs...)
The syntaxstring
for any value defaults to its string
representation, but it can be defined by defining the appropriate syntaxstring
method.
The syntaxstring
for syntax tokens (e.g., atoms, operators) should not be prefixed/suffixed by whitespaces, as this may cause ambiguities upon parsing. For similar reasons, syntaxstring
s should not contain parentheses ('('
, ')'
), and, when parsing in function notation, commas (','
).
See also SyntaxLeaf
, Operator
, parseformula
.
SoleLogics.token
— Methodtoken(φ::SyntaxTree)::SyntaxToken
Getter for the token wrapped in a SyntaxTree
.
See also SyntaxBranch
, SyntaxTree
.
SoleLogics.token
— Methodtoken(φ::SyntaxTree)::SyntaxToken
Getter for the token wrapped in a SyntaxTree
.
See also SyntaxBranch
, SyntaxTree
.
SoleLogics.tokens
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
+"◊(→(∧(p, s), q))"
See also parseformula
, SyntaxBranch
, SyntaxToken
.
Implementation
In the case of a syntax tree, syntaxstring
is a recursive function that calls itself on the syntax children of each node. For a correct functioning, the syntaxstring
must be defined (including kwargs...
) for every newly defined SyntaxToken
(e.g., SyntaxLeaf
s, that is, Atom
s and Truth
values, and Operator
s), in a way that it produces a unique string representation, since Base.hash
and Base.isequal
, at least for SyntaxBranch
s, rely on it.
In particular, for the case of Atom
s, the function calls itself on the wrapped value:
syntaxstring(a::Atom; kwargs...) = syntaxstring(value(a); kwargs...)
The syntaxstring
for any value defaults to its string
representation, but it can be defined by defining the appropriate syntaxstring
method.
The syntaxstring
for syntax tokens (e.g., atoms, operators) should not be prefixed/suffixed by whitespaces, as this may cause ambiguities upon parsing. For similar reasons, syntaxstring
s should not contain parentheses ('('
, ')'
), and, when parsing in function notation, commas (','
).
See also SyntaxLeaf
, Operator
, parseformula
.
SoleLogics.token
— Methodtoken(φ::SyntaxTree)::SyntaxToken
Getter for the token wrapped in a SyntaxTree
.
See also SyntaxBranch
, SyntaxTree
.
SoleLogics.token
— Methodtoken(φ::SyntaxTree)::SyntaxToken
Getter for the token wrapped in a SyntaxTree
.
See also SyntaxBranch
, SyntaxTree
.
SoleLogics.tokens
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
atoms(φ::Formula)::AbstractVector{<:Atom}
truths(φ::Formula)::AbstractVector{<:Truth}
leaves(φ::Formula)::AbstractVector{<:SyntaxLeaf}
@@ -1016,7 +1016,7 @@
ntruths(φ::Formula)::Integer
nleaves(φ::Formula)::Integer
nconnectives(φ::Formula)::Integer
-noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.top
— MethodSoleLogics.tree
— Methodtree(φ::Formula)::SyntaxTree
Return the SyntaxTree
representation of a formula; note that this is equivalent to Base.convert(SyntaxTree, φ)
.
See also Formula
, SyntaxTree
.
SoleLogics.treewalk
— Methodtreewalk(
+noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.top
— MethodSoleLogics.tree
— Methodtree(φ::Formula)::SyntaxTree
Return the SyntaxTree
representation of a formula; note that this is equivalent to Base.convert(SyntaxTree, φ)
.
See also Formula
, SyntaxTree
.
SoleLogics.treewalk
— Methodtreewalk(
st::SyntaxTree,
args...;
rng::AbstractRNG = Random.GLOBAL_RNG,
@@ -1024,7 +1024,7 @@
toleaf::Bool = true,
returnnode::Bool = false,
transformnode::Function = nothing,
-)::SyntaxTree
Return a subtree of syntax tree, by following these options:
criterion
: function used to calculate the probability of stopping at a random node;returnnode
: true if only the subtree is to be returned;transformnode
: function that will be applied to the chosen subtree.
TODO explain better TODO is this available in AbstractTrees?
SoleLogics.truths
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
+)::SyntaxTree
Return a subtree of syntax tree, by following these options:
criterion
: function used to calculate the probability of stopping at a random node;returnnode
: true if only the subtree is to be returned;transformnode
: function that will be applied to the chosen subtree.
TODO explain better TODO is this available in AbstractTrees?
SoleLogics.truths
— Methodtokens(φ::Formula)::AbstractVector{<:SyntaxToken}
atoms(φ::Formula)::AbstractVector{<:Atom}
truths(φ::Formula)::AbstractVector{<:Truth}
leaves(φ::Formula)::AbstractVector{<:SyntaxLeaf}
@@ -1035,15 +1035,15 @@
ntruths(φ::Formula)::Integer
nleaves(φ::Formula)::Integer
nconnectives(φ::Formula)::Integer
-noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.truthsupertype
— Methodtruthsupertype(T::Type{<:Truth})::Type
Return the supertype of a Truth
type that includes all values of the same algebra.
SoleLogics.truthtype
— Methodtruthtype(::Type{<:AbstractAlgebra{T}}) where {T<:Truth} = T
-truthtype(a::AbstractAlgebra) = truthtype(typeof(a))
The Julia type for representing truth values of the algebra.
See also AbstractAlgebra
.
SoleLogics.worldtype
— Methodworldtype(fr::AbstractFrame)
-worldtype(i::AbstractKripkeStructure)
Return the world type of the Kripke frame/structure.
See also AbstractFrame
.
StatsBase.sample
— FunctionStatsBase.sample(
+noperators(φ::Formula)::Integer
Return the list/number of (non-unique) SyntaxToken
s, Atoms
s, etc... appearing in a formula.
See also Formula
, SyntaxToken
.
SoleLogics.truthsupertype
— Methodtruthsupertype(T::Type{<:Truth})::Type
Return the supertype of a Truth
type that includes all values of the same algebra.
SoleLogics.truthtype
— Methodtruthtype(::Type{<:AbstractAlgebra{T}}) where {T<:Truth} = T
+truthtype(a::AbstractAlgebra) = truthtype(typeof(a))
The Julia type for representing truth values of the algebra.
See also AbstractAlgebra
.
SoleLogics.worldtype
— Methodworldtype(fr::AbstractFrame)
+worldtype(i::AbstractKripkeStructure)
Return the world type of the Kripke frame/structure.
See also AbstractFrame
.
StatsBase.sample
— FunctionStatsBase.sample(
[rng::AbstractRNG = Random.GLOBAL_RNG, ]
g::AbstractGrammar,
height::Integer,
args...;
kwargs...
-)::Formula
Randomly sample a logic formula of given height
from a grammar g
.
Implementation
This method for must be implemented, and additional keyword arguments should be provided in order to limit the (otherwise infinite) sampling domain.
See also `AbstractAlphabet'.
SoleLogics.@atoms
— Macro@atoms(ps...)
Instantiate a collection of Atom
s and return them as a vector.
Atoms instantiated with this macro are defined in the global scope as constants.
Examples
julia> SoleLogics.@atoms String p q r s
+)::Formula
Randomly sample a logic formula of given height
from a grammar g
.
Implementation
This method for must be implemented, and additional keyword arguments should be provided in order to limit the (otherwise infinite) sampling domain.
See also `AbstractAlphabet'.
SoleLogics.@atoms
— Macro@atoms(ps...)
Instantiate a collection of Atom
s and return them as a vector.
Atoms instantiated with this macro are defined in the global scope as constants.
Examples
julia> SoleLogics.@atoms String p q r s
4-element Vector{Atom{String}}:
Atom{String}("p")
Atom{String}("q")
@@ -1051,11 +1051,11 @@
Atom{String}("s")
julia> p
-Atom{String}("p")
SoleLogics.@synexpr
— Macro@synexpr(expression)
Return an expression after automatically instantiating undefined Atom
s.
Every identified atom is of type Atom{String}
.
Examples
julia> @synexpr x = p # Atom{String}("p") is assigned to the global variable x
+Atom{String}("p")
SoleLogics.@synexpr
— Macro@synexpr(expression)
Return an expression after automatically instantiating undefined Atom
s.
Every identified atom is of type Atom{String}
.
Examples
julia> @synexpr x = p # Atom{String}("p") is assigned to the global variable x
Atom{String}("p")
julia> @synexpr st = p ∧ q → r
(p ∧ q) → r
julia> typeof(st)
-SyntaxBranch{SoleLogics.NamedConnective{:→}}