Proper code for $p\to q$ in GAP

60 Views Asked by At

I’d like to know if

gap> IsBool(not(p) or q)=true;

is the only code for checking the trueness of a conditional statement p->q or not? I couldn’t find the proper code (if it exists) in GAP.

Thanks for any hint!

1

There are 1 best solutions below

1
On BEST ANSWER

The code given in the question is not correct. IsBool checks the type of its argument, so we have

gap> IsBool(true); IsBool(false); IsBool(fail);
true
true
true

Therefore, IsBool(not(p) or q)=true will be equal to true for any p, q in [true,false].

The correct code is just

not p or q

(also note that there is no need in () around p):

gap> t:=Tuples([true,false],2);
[ [ true, true ], [ true, false ], [ false, true ], [ false, false ] ]
gap> for x in t do Print( x, " ", not x[1] or x[2],"\n");od;
[ true, true ] true
[ true, false ] false
[ false, true ] true
[ false, false ] true