Questions tagged [negation]

Negation is the logic operation that inverses a value, also seen as a NOT operation. Functions in specific languages may operate with negation to specific uses. For questions specific to the use of complement patterns in regular expressions, use [regex-negation] instead.

Negation is the logic operation that inverses a value, also seen as a NOT operation. Negation may be implemented by specific languages to provide functions capable of operating with values for specific uses.

Read also the wikipedia article on Negation.

248 questions
5
votes
3 answers

Why is Prolog's failure by negation not considered logical negation?

In many Prolog guides the following code is used to illustrate "negation by failure" in Prolog. not(Goal) :- call(Goal), !, fail. not(Goal). However, those same tutorials and texts warn that this is not "logical negation". Question: What is the…
Penelope
  • 291
  • 6
5
votes
5 answers

Prolog Negation

I am trying to solve a simple query in Prolog that uses negation but I can't crack it. The query is "Find the categories that have never been sold". The knowledge base is as follows: category(stationery, 30, 200, 10, 2). category(books, 10, 30, 3,…
crazywizard
  • 59
  • 1
  • 2
5
votes
1 answer

Double boolean negation operator

I came across this piece of code from the Microsoft implementation of GSL (the C++ Guideline Support Library): #if defined(__clang__) || defined(__GNUC__) #define GSL_LIKELY(x) __builtin_expect(!!(x), 1) #define GSL_UNLIKELY(x)…
Nick
  • 10,309
  • 21
  • 97
  • 201
5
votes
2 answers

Does MiniKanren have the "not" operator?

Does MiniKanren have the "not" operator? For example, how would one represent Prolog's a :- b, not(c) a is true if b is true and c is not (Prolog uses negation as failure, i.e. not(c) is considered proven if c can not be proven) Prolog's not also…
MWB
  • 11,740
  • 6
  • 46
  • 91
5
votes
1 answer

Negation operation in TCL

I have not managed to find out how to negate booleans in TCL... I tried: set x true puts !$x #prints '!true' puts ![$x] #prints ! puts [!$x] #prints no event matches "true" puts !{$x} #prints !{true} puts {!$x} #prints !$x
Draif Kroneg
  • 743
  • 13
  • 34
5
votes
1 answer

Proof by counterexample in Coq

After proving tens of lemmas in propositional and predicate calculus (some more challenging than others but generally still provable on an intro-apply-destruct autopilot) I hit one starting w/ ~forall and was immediately snagged. Clearly, my…
jaam
  • 900
  • 4
  • 23
5
votes
2 answers

Flip bits using XOR 0xffffffff or ~ in C++?

If I want to flip some bits, I was wondering which way is better. Should I flip them using XOR 0xffffffff or by using ~? I'm afraid that there will be some cases where I might need to pad bits onto the end in one of these ways and not the other,…
Programmer_D
  • 601
  • 2
  • 15
  • 27
4
votes
3 answers

Why doesn't this CSS :not() declaration filter down?

I want to select spans that are not the descendants of a specific class, let's call it "no". Here's my CSS: div:not(.no) span{background-color:#00f;} Here's the HTML
yes 1
no…
Stephanie Hobson
  • 357
  • 4
  • 15
4
votes
2 answers

Is logical negation of zero (!0) compiler dependent in C?

I came across an article which mentioned that the result of !0 is compiler dependent. The result can be either 1 or FF or FFFF and so on. As for C99 standard 6.5.3.3 Unary arithmetic operators, The result of the logical negation operator ! is 0 if…
user1020828
  • 99
  • 1
  • 5
4
votes
3 answers

How to find if a string has a character which isn't in another string

For example I can have the string 'acagtcas' and I want to find if the string has any characters that aren't a, c, g or t. I've tried using not but I haven't been able to make it work. How can I implement this?
Miguens
  • 49
  • 1
4
votes
1 answer

Is There a Way to Just Evaluate the Argument to a Functor?

Given foo which is a vector I want to evaluate it's contents with all_of. But all I'm really trying to check is that each element evaluates to true. I can do this by using logical_not and none_of but I would rather not use double negatives, and it…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
4
votes
1 answer

Split and drop grouping variable

I am trying to split a data frame into a list. This question was helpful, but I also want to drop the column used for grouping, since it will mess up future steps. The drop argument for split only applies to unused levels. The data frame is as…
Matt
  • 954
  • 1
  • 9
  • 24
4
votes
3 answers

Negating multiple conditions in Bash

I realize this is a simple question, but I am finding a hard time getting an answer due to the finnicky syntax requirements in bash. I have the following script: if ! [ [ -z "$1" ] || [ -z "$2" ] ]; then echo "both arguments are set!" fi I get…
Jake
  • 7,565
  • 6
  • 55
  • 68
4
votes
1 answer

C# Byte Handling

I'm experiencing a bit of an issue while trying to convert some VB6 logic into C#. In one of the VB6 functions, it has the following statement: w = Not CByte(w) Where w is a long. In an example, after this line evaluates in VB6, I can see the…
Siyual
  • 16,415
  • 8
  • 44
  • 58
3
votes
1 answer

Is negation to prefer in conditions?

I have XML files that hold recordsets where a certain quantity sometimes equals 0. Now those recordsets I have to get rid of. I did the following.
Peter
  • 1,786
  • 4
  • 21
  • 40
1 2
3
16 17