@@ -36,7 +36,6 @@ and enclose a *tree* of `AbstractModel`s (with `LeafModel`s at the leaves).
36
36
- `info(m::AbstractModel, [key, [defaultval]])`
37
37
- `info!(m::AbstractModel, key, value)`
38
38
- `hasinfo(m::AbstractModel, key)`
39
- - `AbstractTrees.children(m::AbstractModel)`
40
39
41
40
# Utility functions
42
41
- `apply(m::AbstractModel, i::AbstractInterpretationSet; kwargs...)`
@@ -111,95 +110,6 @@ function outputtype(m::AbstractModel)
111
110
iscomplete (m) ? outcometype (m) : Union{Nothing,outcometype (m)}
112
111
end
113
112
114
-
115
- """
116
- immediatesubmodels(m::AbstractModel)
117
-
118
- Return the list of immediate child models.
119
-
120
- !!! note
121
- If the model is a leaf model, then the returned list will be empty.
122
-
123
- # Examples
124
- ```julia-repl
125
- julia> using SoleLogics
126
-
127
- julia> branch = Branch(SoleLogics.parseformula("p∧q∨r"), "YES", "NO");
128
-
129
- julia> immediatesubmodels(branch)
130
- 2-element Vector{SoleModels.ConstantModel{String}}:
131
- SoleModels.ConstantModel{String}
132
- YES
133
-
134
- SoleModels.ConstantModel{String}
135
- NO
136
-
137
- julia> branch2 = Branch(SoleLogics.parseformula("s→p"), branch, 42);
138
-
139
-
140
- julia> printmodel.(immediatesubmodels(branch2));
141
- Branch
142
- ┐ p ∧ (q ∨ r)
143
- ├ ✔ YES
144
- └ ✘ NO
145
-
146
- ConstantModel
147
- 42
148
- ```
149
-
150
- See also [`AbstractModel`](@ref), [`LeafModel`](@ref), [`submodels`](@ref).
151
- """
152
- function immediatesubmodels (
153
- m:: AbstractModel{O}
154
- ):: Vector{<:{AbstractModel{<:O}}} where {O}
155
- return error (" Please, provide method immediatesubmodels(::$(typeof (m)) )." )
156
- end
157
-
158
- """
159
- nimmediatesubmodels(m::AbstractModel)
160
-
161
- Return the number of models returned by [`immediatesubmodels`](@ref).
162
-
163
- See also [`AbstractModel`](@ref), [`immediatesubmodels`](@ref).
164
- """
165
- function nimmediatesubmodels (m:: AbstractModel )
166
- return error (" Please, provide method nimmediatesubmodels(::$(typeof (m)) )." )
167
- end
168
-
169
- """
170
- listimmediaterules(m::AbstractModel{O} where {O})::Rule{<:O}
171
-
172
- List the immediate rules equivalent to a symbolic model.
173
-
174
- # Examples
175
- ```julia-repl
176
- julia> using SoleLogics
177
-
178
- julia> branch = Branch(SoleLogics.parseformula("p"), Branch(SoleLogics.parseformula("q"), "YES", "NO"), "NO")
179
- p
180
- ├✔ q
181
- │├✔ YES
182
- │└✘ NO
183
- └✘ NO
184
-
185
-
186
- julia> printmodel.(listimmediaterules(branch); tree_mode = true);
187
- ▣ p
188
- └✔ q
189
- ├✔ YES
190
- └✘ NO
191
-
192
- ▣ ¬(p)
193
- └✔ NO
194
- ```
195
-
196
- See also [`AbstractModel`](@ref), [`listrules`](@ref).
197
- """
198
- listimmediaterules (m:: AbstractModel{O} where {O}):: Rule{<:O} =
199
- error (" Please, provide method listimmediaterules(::$(typeof (m)) ) " *
200
- " ($(typeof (m)) is a symbolic model)." )
201
-
202
-
203
113
"""
204
114
apply(m::AbstractModel, i::AbstractInterpretation; kwargs...)::outputtype(m)
205
115
@@ -357,13 +267,93 @@ wrap(o::Any, FM::Type{<:AbstractModel}) = convert(FM, wrap(o))
357
267
wrap (m:: AbstractModel ) = m
358
268
# wrap(o::Any)::AbstractModel = error("Please, provide method wrap($(typeof(o))).")
359
269
270
+ """
271
+ immediatesubmodels(m::AbstractModel)
272
+
273
+ Return the list of immediate child models.
274
+
275
+ !!! note
276
+ If the model is a leaf model, then the returned list will be empty.
277
+
278
+ # Examples
279
+ ```julia-repl
280
+ julia> using SoleLogics
281
+
282
+ julia> branch = Branch(SoleLogics.parseformula("p∧q∨r"), "YES", "NO");
283
+
284
+ julia> immediatesubmodels(branch)
285
+ 2-element Vector{SoleModels.ConstantModel{String}}:
286
+ SoleModels.ConstantModel{String}
287
+ YES
288
+
289
+ SoleModels.ConstantModel{String}
290
+ NO
291
+
292
+ julia> branch2 = Branch(SoleLogics.parseformula("s→p"), branch, 42);
293
+
294
+
295
+ julia> printmodel.(immediatesubmodels(branch2));
296
+ Branch
297
+ ┐ p ∧ (q ∨ r)
298
+ ├ ✔ YES
299
+ └ ✘ NO
300
+
301
+ ConstantModel
302
+ 42
303
+ ```
304
+
305
+ See also [`AbstractModel`](@ref), [`LeafModel`](@ref), [`submodels`](@ref).
306
+ """
307
+ function immediatesubmodels (
308
+ m:: AbstractModel{O}
309
+ ):: Vector{<:{AbstractModel{<:O}}} where {O}
310
+ return error (" Please, provide method immediatesubmodels(::$(typeof (m)) )." )
311
+ end
312
+
313
+ """
314
+ nimmediatesubmodels(m::AbstractModel)
315
+
316
+ Return the number of models returned by [`immediatesubmodels`](@ref).
317
+
318
+ See also [`AbstractModel`](@ref), [`immediatesubmodels`](@ref).
319
+ """
320
+ function nimmediatesubmodels (m:: AbstractModel )
321
+ return error (" Please, provide method nimmediatesubmodels(::$(typeof (m)) )." )
322
+ end
323
+
324
+ """
325
+ listimmediaterules(m::AbstractModel{O} where {O})::Rule{<:O}
360
326
327
+ List the immediate rules equivalent to a symbolic model.
361
328
362
- # AbstracTrees interface
363
- using AbstractTrees
364
- import AbstractTrees: children
329
+ # Examples
330
+ ```julia-repl
331
+ julia> using SoleLogics
332
+
333
+ julia> branch = Branch(SoleLogics.parseformula("p"), Branch(SoleLogics.parseformula("q"), "YES", "NO"), "NO")
334
+ p
335
+ ├✔ q
336
+ │├✔ YES
337
+ │└✘ NO
338
+ └✘ NO
339
+
340
+
341
+ julia> printmodel.(listimmediaterules(branch); tree_mode = true);
342
+ ▣ p
343
+ └✔ q
344
+ ├✔ YES
345
+ └✘ NO
346
+
347
+ ▣ ¬(p)
348
+ └✔ NO
349
+ ```
350
+
351
+ See also [`AbstractModel`](@ref), [`listrules`](@ref).
352
+ """
353
+ listimmediaterules (m:: AbstractModel{O} where {O}):: Rule{<:O} =
354
+ error (" Please, provide method listimmediaterules(::$(typeof (m)) ) " *
355
+ " ($(typeof (m)) is a symbolic model)." )
365
356
366
- AbstractTrees. children (m:: AbstractModel ) = immediatesubmodels (m)
367
357
368
358
# ###########################################################################################
369
359
# #################################### LeafModel ############################################
0 commit comments