prolog and translating propositional logic -


my ultimate goal load set of propositional formulas in prolog file in order deduce facts. suppose have propositional formula:

p implies not(q). 

in prolog be:

not(q) :- p 

prolog not seem not operator in head of rule. following error:

 '$record_clause'/2: no permission redefine built-in predicate `not/1'         use :- redefine_system_predicate(+head) if redefinition intended 

i know 2 ways rewrite general formula p implies q. first, use fact contrapositive logically equivalent.

p implies q iff not(q) implies not(p)

second, use fact p implies q logically equivalent not(p) or q (the truth tables same).

the first method leads me current problem. second method conjunction or disjunction. cannot write conjunctions , disjunctions in prolog not facts or rules.

  1. what best way around problem can express p implies not(q)?
  2. is possible write propositional formulas in prolog?

edit: wish connect results other propositional formulae. suppose have following rule:

something :- formula(p, q).

how connect? if enter formula(false, true) (which evaluates true) interpreter, not automatically make something true. want.

p => ~q  ===  ~p \/ ~q  === ~( p /\ q ) 

so can try model prolog program,

formula(p,q) :- p, q, !, fail. formula(_,_). 

or can use built-in \+ i.e. "not", define formula(p,q) :- \+( (p, q) ).

this checks compliance of passed values formula. if combine domain generation first, can "deduce" i.e. generate compliant values:

13 ?- member(q,[true, false]), formula(true, q).  %// true => ~q, q? q = false.  14 ?- member(q,[true, false]), formula(false, q). %// false => ~q, q? q = true ; q = false. 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -