Skip to content

Commit

Permalink
Fix docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
giopaglia committed Nov 11, 2023
1 parent c8d8a68 commit 2fb5814
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/algebras/frames/full-dimensional-frame/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ See also
[`Interval`](@ref),
[`Interval2D`](@ref),
[`IntervalRelation`](@ref),
[`IntervalRelation2D`](@ref),
[`RectangleRelation`](@ref),
[`accessibles`](@ref),
[`AbstractDimensionalFrame`](@ref), [`AbstractMultiModalFrame`](@ref).
"""
Expand Down
52 changes: 34 additions & 18 deletions src/anchored-formula.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ See the examples.
# Examples
```julia-repl
julia> f = parsebaseformula("◊(p→q)");
julia> φ = parsebaseformula("◊(p→q)");
julia> f2 = f(parseformula("p"));
julia> f2 = φ(parseformula("p"));
julia> syntaxstring(f)
julia> syntaxstring(φ)
"◊(→(p, q))"
julia> syntaxstring(f2)
"p"
julia> @assert logic(f) == logic(f2)
julia> @assert logic(φ) == logic(f2)
julia> @assert ◊ in operators(logic(f2))
Expand Down Expand Up @@ -99,15 +99,31 @@ struct AnchoredFormula{L<:AbstractLogic} <: Formula
end
end

_logic(f::AnchoredFormula) = f._logic
logic(f::AnchoredFormula) = f._logic[]
synstruct(f::AnchoredFormula) = f.synstruct
tree(f::AnchoredFormula) = tree(f.synstruct)
_logic::AnchoredFormula) = φ._logic

function Base.show(io::IO, f::AnchoredFormula)
println(io, "AnchoredFormula: $(syntaxstring(f))")
"""
logic(φ::AnchoredFormula)::AbstractLogic
Return the logic of an anchored formula
See [`AnchoredFormula`](@ref).
"""
logic::AnchoredFormula) = φ._logic[]

"""
logic(φ::AnchoredFormula)::AbstractSyntaxStructure
Return the syntactic component of an anchored formula.
See [`AnchoredFormula`](@ref).
"""
synstruct::AnchoredFormula) = φ.synstruct
tree::AnchoredFormula) = tree.synstruct)

function Base.show(io::IO, φ::AnchoredFormula)
println(io, "AnchoredFormula: $(syntaxstring(φ))")
print(io, "Anchored to logic: ")
Base.show(io, logic(f))
Base.show(io, logic(φ))
end

# Note that, since `c` might not be in the logic of the child formulas,
Expand All @@ -124,7 +140,7 @@ function composeformulas(c::Connective, φs::NTuple{N,AnchoredFormula}) where {N
end

# When constructing a new formula from a syntax tree, the logic is passed by reference.
(f::AnchoredFormula)(t::AbstractSyntaxStructure, args...) = AnchoredFormula(_logic(f), t, args...)
(φ::AnchoredFormula)(t::AbstractSyntaxStructure, args...) = AnchoredFormula(_logic(φ), t, args...)

# A logic can be used to instantiate `AnchoredFormula`s out of syntax trees.
(l::AbstractLogic)(t::AbstractSyntaxStructure, args...) = AnchoredFormula(Base.RefValue(l), t; args...)
Expand All @@ -136,17 +152,17 @@ function Base._promote(x::AnchoredFormula, y::AbstractSyntaxStructure)
end
Base._promote(x::AbstractSyntaxStructure, y::AnchoredFormula) = reverse(Base._promote(y, x))

iscrisp(f::AnchoredFormula) = iscrisp(logic(f))
grammar(f::AnchoredFormula) = grammar(logic(f))
algebra(f::AnchoredFormula) = algebra(logic(f))
iscrisp(φ::AnchoredFormula) = iscrisp(logic(φ))
grammar(φ::AnchoredFormula) = grammar(logic(φ))
algebra(φ::AnchoredFormula) = algebra(logic(φ))

syntaxstring(f::AnchoredFormula; kwargs...) = syntaxstring(f.synstruct; kwargs...)
syntaxstring(φ::AnchoredFormula; kwargs...) = syntaxstring(φ.synstruct; kwargs...)

############################################################################################


subformulas(f::AnchoredFormula; kwargs...) = f.(subformulas(tree(f); kwargs...))
normalize(f::AnchoredFormula; kwargs...) = f(normalize(tree(f); kwargs...))
subformulas(φ::AnchoredFormula; kwargs...) = φ.(subformulas(tree(φ); kwargs...))
normalize(φ::AnchoredFormula; kwargs...) = φ(normalize(tree(φ); kwargs...))

"""
function baseformula(
Expand Down
2 changes: 1 addition & 1 deletion src/base-logic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ end
Basic logical operators.
See also [`NEGATION`](@ref),
[`CONJUCTION`](@ref),
[`CONJUNCTION`](@ref),
[`DISJUNCTION`](@ref),
[`IMPLICATION`](@ref),
[`Connective`](@ref).
Expand Down
6 changes: 3 additions & 3 deletions src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -734,9 +734,9 @@ See also
[`arity`](@ref),
[`Connective`](@ref),
[`height`](@ref),
[`atoms`](@ref), [`natoms`](@ref), [`atomstype`](@ref),
[`operators`](@ref), [`noperators`](@ref), [`operatorstype`](@ref),
[`tokens`](@ref), [`ntokens`](@ref), [`tokenstype`](@ref),
[`atoms`](@ref), [`natoms`](@ref),
[`operators`](@ref), [`noperators`](@ref),
[`tokens`](@ref), [`ntokens`](@ref),
"""
struct SyntaxBranch{T<:Connective} <: SyntaxTree

Expand Down
2 changes: 1 addition & 1 deletion src/interpretation-sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ identified by an index i_instance::Integer.
These structures are especially useful when performing
[model checking](https://en.wikipedia.org/wiki/Model_checking).
See also [`valuetype`](@ref), [`truthtype`](@ref),
See also[`truthtype`](@ref),
[`InterpretationVector`](@ref).
"""
abstract type AbstractInterpretationSet{M<:AbstractInterpretation} <: AbstractDataset end
Expand Down
6 changes: 2 additions & 4 deletions src/logics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ By default, an alphabet is considered finite:
Base.in(p::Atom, a::AbstractAlphabet) = Base.isfinite(a) ? Base.in(p, atoms(a)) : error(...)
See also [`AbstractGrammar`](@ref), [`AlphabetOfAny`](@ref), [`Atom`](@ref),
[`ExplicitAlphabet`](@ref), [`atomstype`](@ref), [`valuetype`](@ref).
[`ExplicitAlphabet`](@ref).
"""
abstract type AbstractAlphabet{V} end

Expand All @@ -76,7 +76,7 @@ Base.isfinite(a::AbstractAlphabet) = Base.isfinite(typeof(a))
List the atoms of a *finite* alphabet.
See also [`AbstractAlphabet`](@ref), [`Base.isfinite`](@ref).
See also [`AbstractAlphabet`](@ref).
"""
function atoms(a::AbstractAlphabet)::AbstractVector{atomstype(a)}
if Base.isfinite(a)
Expand Down Expand Up @@ -214,8 +214,6 @@ 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`](@ref),
[`atomstype`](@ref), [`tokenstype`](@ref),
[`operatorstype`](@ref), [`alphabettype`](@ref),
[`AbstractAlphabet`](@ref), [`Operator`](@ref).
"""
abstract type AbstractGrammar{V<:AbstractAlphabet,O<:Operator} end
Expand Down
7 changes: 7 additions & 0 deletions src/modal-logic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,13 @@ function interpret(
return error("Please, provide method interpret(::$(typeof(φ)), ::$(typeof(i)), ::$(typeof(w))).")
end

"""
frame(i::AbstractKripkeStructure)::AbstractFrame
Return the frame of a Kripke structure.
See also [`AbstractFrame`](@ref), [`AbstractKripkeStructure`](@ref).
"""
function frame(i::AbstractKripkeStructure)::AbstractFrame
return error("Please, provide method frame(i::$(typeof(i))).")
end
Expand Down
1 change: 0 additions & 1 deletion src/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ otherwise, it must be implemented, and additional keyword arguments should be pr
in order to limit the (otherwise infinite) sampling domain.
See also
[`isfinite`](@ref),
[`AbstractAlphabet'](@ref).
"""
function Base.rand(alphabet::AbstractAlphabet, args...; kwargs...)
Expand Down

0 comments on commit 2fb5814

Please sign in to comment.