negation

Logical Negation in Prolog

那年仲夏 提交于 2019-12-01 15:21:43
I've read quite a bit about Prolog's Negation by Failure where Prolog in order to prove that \+Goal holds tries to prove that Goal fails. This is highly connected with CWA (close world assumption) where for example if we query \+P(a) (where P is a predicate of arity 1) and we have no clues that lead to prove P(a) Prolog assumes (due to CWA) that not P(a) holds so \+P(a) succeeds. From what I've searched this is a way to solve classical logic weakness where if we had no clue about P(a) then we could not answer whether \+P(a) holds. What described above was the way of introducing non-monotonic

Logical Negation in Prolog

家住魔仙堡 提交于 2019-12-01 14:06:05
问题 I've read quite a bit about Prolog's Negation by Failure where Prolog in order to prove that \+Goal holds tries to prove that Goal fails. This is highly connected with CWA (close world assumption) where for example if we query \+P(a) (where P is a predicate of arity 1) and we have no clues that lead to prove P(a) Prolog assumes (due to CWA) that not P(a) holds so \+P(a) succeeds. From what I've searched this is a way to solve classical logic weakness where if we had no clue about P(a) then we

Can I use the not operator in C++ on int values?

雨燕双飞 提交于 2019-12-01 02:36:45
Strange question, but someone showed me this, I was wondering can you use the not ! operator for int in C++? (its strange to me). #include <iostream> using namespace std; int main() { int a=5, b=4, c=4, d; d = !( a > b && b <= c) || a > c && !b; cout << d; system ("pause"); return 0; } Yes. For integral types, ! returns true if the operand is zero, and false otherwise. So !b here just means b == 0 . This is a particular case where a value is converted to a bool . The !b can be viewed as !((bool)b) so the question is what is the "truthness" of b . In C++, arithmetic types, pointer types and

Exclamation mark in front of variable - clarification needed

╄→尐↘猪︶ㄣ 提交于 2019-11-30 09:07:45
I've been working with PHP for quite a while now, but this was always a mystery to me, the correct use of the exclamation mark (negative sign) in front of variables. What does !$var indicate? Is var false , empty, not set etc.? Here are some examples that I need to learn... Example 1: $string = 'hello'; $hello = (!empty($string)) ? $string : ''; if (!$hello) { die('Variable hello is empty'); } Is this example valid? Would the if statement really work if $string was empty? Example 2: $int = 5; $count = (!empty($int)) ? $int : 0; // Note the positive check here if ($count) { die('Variable count

Exclamation mark in front of variable - clarification needed

柔情痞子 提交于 2019-11-29 12:38:42
问题 I've been working with PHP for quite a while now, but this was always a mystery to me, the correct use of the exclamation mark (negative sign) in front of variables. What does !$var indicate? Is var false , empty, not set etc.? Here are some examples that I need to learn... Example 1: $string = 'hello'; $hello = (!empty($string)) ? $string : ''; if (!$hello) { die('Variable hello is empty'); } Is this example valid? Would the if statement really work if $string was empty? Example 2: $int = 5;

Negation of %in% in R [duplicate]

独自空忆成欢 提交于 2019-11-29 05:31:44
This question already has an answer here: Opposite of %in% 8 answers Is there a short negation of %in% in R like !%in% or %!in% ? Of course I can negate c("A", "B") %in% c("B", "C") by !(c("A", "B") %in% c("B", "C")) (cf. this question ) but I would prefere a more straight forward approach and save a pair of brackets (alike presumably most people would prefer c("A", "B") != c("B", "C") over !(c("A", "B") == c("B", "C")) ). No, there isn't a built in function to do that, but you could easily code it yourself with `%nin%` = Negate(`%in%`) Or `%!in%` = Negate(`%in%`) See this thread and followup

how to pass a not like operator in a sqlalchemy ORM query

你说的曾经没有我的故事 提交于 2019-11-28 22:18:42
I've got a query: MyModel.query.filter(Mymodel.name.contains('a_string')) I need to do the same query but with the negation (a not like operator) but didn't find any operator matching my need in the SQLAlchemy documentation . Is there any way to do it without using the sql part of SQLAlchemy??? Just negate the filter: MyModel.query.filter(sqlalchemy.not_(Mymodel.name.contains('a_string'))) 来源: https://stackoverflow.com/questions/5018694/how-to-pass-a-not-like-operator-in-a-sqlalchemy-orm-query

Why does `not (some-width: Xem)` media query never fire?

你。 提交于 2019-11-28 14:20:54
I'm trying to negate the max-device-width media query (the reason for this is I don't won't both (max-device-width: X) and (min-device-width: X) to fire if the device has precisely that width). Unfortunately, the not (min-or-max-some-width: X) media queries never fire. Here's a small fiddle . I expect two yellow lines on the desktop and two red lines on mobile. What I get is only one yellow line on the desktop (the last one) and only one red line on mobile (the first one). What am I doing wrong? When Media Queries was first introduced, it required the not keyword to be followed by a media type

String negation using regular expressions

痞子三分冷 提交于 2019-11-28 06:45:43
Is it possible to do string negation in regular expressions? I need to match all strings that do not contain the string ".." . I know you can use ^[^\.]*$ to match all strings that do not contain "." but I need to match more than one character. I know I could simply match a string containing ".." and then negate the return value of the match to achieve the same result but I just wondered if it was possible. You can use negative lookaheads: ^(?!.*\.\.).*$ That causes the expression to not match if it can find a sequence of two periods anywhere in the string. ^(?:(?!\.\.).)*$ will only match if

How does the NEG instruction affect the flags on x86?

天大地大妈咪最大 提交于 2019-11-28 01:10:27
The Intel Software Development Manual says this about the neg instruction: The CF flag set to 0 if the source operand is 0; otherwise it is set to 1. The OF, SF, ZF, AF, and PF flags are set according to the result. I thought that AF and CF would be set as if neg %eax were replaced by, not %eax # bitwise negation add $1, %eax But that's not the case, negating 0x6ffffef5 on a real CPU sets AF and CF. neg sets all flags identically to what you'd get with a sub from 0. This sequence of instructions sets all flags (including AF and CF) identically to neg %eax : xor %ecx, %ecx sub %eax, %ecx # ecx