Replies: 5 comments 12 replies
-
I'm afraid it's too simplistic to be useful. Maybe a solution is to have some sort of a database of predicate modes that are "safe", and then check against that spec: reif_goal_spec(length(_,_)).
reif_goal_spec(maplist(A,_)) :- callable(A).
reify_si_t(G_0, T) :-
reif_goal_spec(G_0) -> (G_0, T = true; \+ G_0, T = false); instantiation_error(reify_si_t/2). I didn't run that code, so it can have some bugs. Also maybe it is a good idea to disallow running arbitrary goals for a |
Beta Was this translation helpful? Give feedback.
-
For a sound groundness check, you can use |
Beta Was this translation helpful? Give feedback.
-
Solution with call_semidet(Goal) :-
( call_nth(Goal, 2) ->
error(mode_error(semidet,Goal),call_semidet/1)
; once(Goal)
).
reify_si_t(Goal, T) :-
( call_semidet(Goal) -> T = true ; T = false ). If both reify_si_t(Goal, T) :-
( acyclic_term(Goal) ->
( ground(Goal) ->
( call(Goal) ->
T = true
; T = false
)
; call_semidet(Goal) ->
T = true
; T = false
)
; type_error(term, Goal, reify_si_t)
). This is already getting a bit more complicated than I would like, but (if it is sound, which I'm still not sure) it's already very useful! |
Beta Was this translation helpful? Give feedback.
-
I have a question that is tangentially related to the OP. Is there a mathematical procedure to prove monotonicity of a predicate? For example if predicate |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I was thinking about a
reify_si_t/2
predicate that "does it's best" to safely reify a goal for use withlibrary(reif)
, because this would make a lot of predicates usable withif_/3
. This is the best I could come with:Is there any problem with this, and/or can this be actually be more general and not only for ground goals? I think this is fine, but I don't know if cutting the alternatives of a ground goal is sound here.
Beta Was this translation helpful? Give feedback.
All reactions