Skip to content

Commit

Permalink
Merge branch 'main' of github.com:aclai-lab/SoleLogics.jl into mergin…
Browse files Browse the repository at this point in the history
…g/mauro
  • Loading branch information
mauro-milella committed Jul 25, 2023
2 parents 5b3b674 + c136b3d commit ae9066d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SoleLogics"
uuid = "b002da8f-3cb3-4d91-bbe3-2953433912b5"
authors = ["Mauro MILELLA", "Giovanni PAGLIARINI", "Eduard I. STAN"]
version = "0.4.4"
version = "0.4.5"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Expand Down
12 changes: 6 additions & 6 deletions src/algebras/frames/full-dimensional-frame/Full1DFrame+RCC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# Refer to [`RCCRelation`](@ref).

# Enumerate accessible worlds from a single world
_accessibles(fr::Full1DFrame, w::Interval, r::RCC8RelationFromIA) = Iterators.flatten((_accessibles(fr, w, IA_r) for IA_r in topo2IARelations(r)))
# _accessibles(fr::Full1DFrame, w::Interval, ::_Topo_DC) = Iterators.flatten((_accessibles(fr, w, IA_L), _accessibles(fr, w, IA_Li)))
# _accessibles(fr::Full1DFrame, w::Interval, ::_Topo_EC) = Iterators.flatten((_accessibles(fr, w, IA_A), _accessibles(fr, w, IA_Ai)))
# _accessibles(fr::Full1DFrame, w::Interval, ::_Topo_PO) = Iterators.flatten((_accessibles(fr, w, IA_O), _accessibles(fr, w, IA_Oi)))
# _accessibles(fr::Full1DFrame, w::Interval, ::_Topo_TPP) = Iterators.flatten((_accessibles(fr, w, IA_B), _accessibles(fr, w, IA_E)))
# _accessibles(fr::Full1DFrame, w::Interval, ::_Topo_TPPi) = Iterators.flatten((_accessibles(fr, w, IA_Bi), _accessibles(fr, w, IA_Ei)))
# _accessibles(fr::Full1DFrame, w::Interval, r::RCC8RelationFromIA) = Iterators.flatten((_accessibles(fr, w, IA_r) for IA_r in topo2IARelations(r)))
_accessibles(fr::Full1DFrame, w::Interval, ::_Topo_DC) = Iterators.flatten((_accessibles(fr, w, IA_L), _accessibles(fr, w, IA_Li)))
_accessibles(fr::Full1DFrame, w::Interval, ::_Topo_EC) = Iterators.flatten((_accessibles(fr, w, IA_A), _accessibles(fr, w, IA_Ai)))
_accessibles(fr::Full1DFrame, w::Interval, ::_Topo_PO) = Iterators.flatten((_accessibles(fr, w, IA_O), _accessibles(fr, w, IA_Oi)))
_accessibles(fr::Full1DFrame, w::Interval, ::_Topo_TPP) = Iterators.flatten((_accessibles(fr, w, IA_B), _accessibles(fr, w, IA_E)))
_accessibles(fr::Full1DFrame, w::Interval, ::_Topo_TPPi) = Iterators.flatten((_accessibles(fr, w, IA_Bi), _accessibles(fr, w, IA_Ei)))
_accessibles(fr::Full1DFrame, w::Interval, ::_Topo_NTPP) = _accessibles(fr, w, IA_D)
_accessibles(fr::Full1DFrame, w::Interval, ::_Topo_NTPPi) = _accessibles(fr, w, IA_Di)

Expand Down
27 changes: 14 additions & 13 deletions src/general.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ where each syntactical element is wrapped in parentheses.
# Examples
```julia-repl
julia> syntaxstring((parsebaseformula("◊((p∧s)→q)")))
"◊(p ∧ s) → q"
"◊((p ∧ s) → q)"
julia> syntaxstring((parsebaseformula("◊((p∧s)→q)")); function_notation = true)
"◊(→(∧(p, s), q))"
Expand Down Expand Up @@ -657,21 +657,21 @@ function syntaxstring(
parentheses_at_propositions = parentheses_at_propositions,
))

function _binary_infix_syntaxstring(t::SyntaxTree, ch::SyntaxTree; relation::Symbol=:left, kwargs...)
function _binary_infix_syntaxstring(tok::AbstractSyntaxToken, ch::SyntaxTree; relation::Symbol=:left)
# syntaxstring triggered by a binary operator in infix notation
tok = token(t)
chtok = token(ch)
chtokstring = syntaxstring(ch; ch_kwargs...)
lpar, rpar = "", ""

if !remove_redundant_parentheses
lpar, rpar = "(", ")"
end

if arity(chtok) == 0
if parentheses_at_propositions
return "($(syntaxstring(ch; kwargs...)))"
if chtok isa Proposition && parentheses_at_propositions
return "($(chtokstring))"
else
return "$(lpar)$(syntaxstring(ch; kwargs...))$(rpar)"
return "$(lpar)$(chtokstring)$(rpar)"
end
end

Expand All @@ -696,26 +696,27 @@ function syntaxstring(
lpar, rpar = "(", ")"
end

return "$(lpar)$(syntaxstring(ch; kwargs...))$(rpar)"
return "$(lpar)$(chtokstring)$(rpar)"
end

tok = token(t)
tokstr = syntaxstring(tok; ch_kwargs...)
if arity(tok) == 0
if parentheses_at_propositions
return "($(syntaxstring(tok; ch_kwargs...)))"
if tok isa Proposition && parentheses_at_propositions
return "($(tokstr))"
else
return "$(syntaxstring(tok; ch_kwargs...))"
return tokstr
end
elseif arity(tok) == 2 && !function_notation
# Previous idea
# f = ch->arity(token(ch)) == 0 ?
# "$(syntaxstring(ch; ch_kwargs...))" :
# "$(lpar)$(syntaxstring(ch; ch_kwargs...))$(rpar)"
# "$(f(children(t)[1])) $(syntaxstring(tok; ch_kwargs...)) $(f(children(t)[2]))"
# "$(f(children(t)[1])) $(tokstr) $(f(children(t)[2]))"

# Infix notation for binary operator
"$(_binary_infix_syntaxstring(t, children(t)[1]; relation=:left, ch_kwargs...)) $(syntaxstring(tok; ch_kwargs...)) $(_binary_infix_syntaxstring(t, children(t)[2]; relation=:right, ch_kwargs...))"
else
"$(_binary_infix_syntaxstring(tok, children(t)[1]; relation=:left)) $tokstr $(_binary_infix_syntaxstring(tok, children(t)[2]; relation=:right))"
else # Function notation
lpar, rpar = "(", ")"
charity = arity(token(children(t)[1]))
if !function_notation && arity(tok) == 1 && charity <= 1
Expand Down

0 comments on commit ae9066d

Please sign in to comment.