constraint-handling-rules

Defining CHR constraints at runtime

五迷三道 提交于 2021-02-07 14:51:13
问题 I'm trying to write a program that generates new constraints at runtime in SWI-Prolog. is_true([A,means,B]) is intended to generate another constraint at runtime: :- use_module(library(chr)). :- chr_constraint is_true/1. is_true([A,means,B]) ==> (is_true(A) ==> is_true(B),writeln('asserted')). is_true([[A,is,true],means,[A,is,not,false]]). is_true([something,is,true]). But when I type these queries, the is_true constraint seems to have no effect. is_true([something, is, not, false]) does not

Defining CHR constraints at runtime

空扰寡人 提交于 2021-02-07 14:50:09
问题 I'm trying to write a program that generates new constraints at runtime in SWI-Prolog. is_true([A,means,B]) is intended to generate another constraint at runtime: :- use_module(library(chr)). :- chr_constraint is_true/1. is_true([A,means,B]) ==> (is_true(A) ==> is_true(B),writeln('asserted')). is_true([[A,is,true],means,[A,is,not,false]]). is_true([something,is,true]). But when I type these queries, the is_true constraint seems to have no effect. is_true([something, is, not, false]) does not

Representing logical disjunctions in Constraint Handling Rules

夙愿已清 提交于 2019-12-25 06:26:49
问题 I am writing a constraint solver in Prolog that implements a simple logical formula: "(alive(A) and animal(A)) iff (awake(A) or asleep(A))" . I found one way to implement it in Constraint Handling Rules, but it is much more verbose than the original formula: :- use_module(library(chr)). :- chr_constraint is_true/1. is_true(A) \ is_true(A) <=> true. is_true(alive(A)),is_true(animal(A)) ==> is_true(awake(A));is_true(asleep(A)). is_true(awake(A)) ==> is_true(animal(A)),is_true(alive(A)). is_true