Directly write logical rules

I’ve been tinkering around with julog and it has met a course requirement of an expert system. I will work out my problem set for the class with this package, but I want to continue the project after this class, and am having issues switching around generalizing over multiple value. I was wondering if there is there another way to write out logical statements in Julia that I’m missing that is native to julia?

clauses = @julog [
   query(Orderfrom,Time,Product,Cost)<<=
       depot(Name1,Onhand1,Time1,Cost1) &
       depot(Name2,Onhand2,Time2,Cost2) &
       (Cost1<Cost2) &
       (Onhand1>30) &
       is(Orderfrom,Name1) &
       is(Time,Time1) &
       is(Product, 30) &
       is(Cost,Cost1),
   ]
   facts = @julog [depot(us2,40,9,15)<<=true,depot(aus,50,9,40)<<=true]
   boolyn,answer=@time resolve(@julog(query(Orderfrom,Time,Product,Cost)),  [facts; clauses])

REPL output
0.000197 seconds (1.22 k allocations: 52.406 KiB)
Dict{Var, Term}[{Orderfrom => us2}]

something like this logic. I think “anding” everything together is a way… I like the idea of multi dispatch as a solution, but also don’t want to have to re-write each function either.

(state>30)->(function(input_y)==true)->(input_y+20)

Any advice is welcome.

Julia itself is not a CAS or SAT solver, nor an answer set system, if that’s what you’re asking. As I understand your description, you need to define the logical/symbolic variables in julog to use its solver, so that it is aware of what variables it has to think about internally.

Or are you referring to dynamically creating new logical constraints?

1 Like

Thank you for the response, and helping me zero in on the problem.

I think I am looking for a CAS/SAT solver, and yes to the ability to define new constraints.

V/R,

For now I’m sticking with Julog and I’ve figured out how to use it as a constraint planner. I believe it hits size limitations that I haven’t reached yet.

Would love some solid alternatives for something like this.