> For the complete documentation index, see [llms.txt](https://manis-organization-2.gitbook.io/untitled-1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://manis-organization-2.gitbook.io/untitled-1/keywords/operators-in-x3/not.md).

# not

&#x20;X3 programming language, the keyword "not" serves as a logical operator for negation. Let's explore its functionality and usage:

#### Functionality:

The "not" keyword is a unary logical operator used to negate the value of a condition. It flips the logical value of the expression, converting true to false and false to true.

#### Usage:

```x3
var x = 5

# Using 'not' in an 'if' statement
if not x < 0 then
    show("x is not negative.")
end
```

#### Explanation:

* In this example, the "if" statement checks if `x` is not less than 0.
* If `x` is greater than or equal to 0, the condition `x < 0` evaluates to false, and then `not false` evaluates to true, so the statement inside the "if" block will be executed.

#### Example:

```x3
var isWeekend = true

# Using 'not' to check if it's not a weekend
if not isWeekend then
    show("It's not a weekend!")
end
```

#### Explanation:

* Here, the "if" statement checks if `isWeekend` is not true.
* If `isWeekend` is false, meaning it's not a weekend, the statement inside the "if" block will be executed.

#### De Morgan's Laws:

In Boolean algebra, De Morgan's laws state that `not (A or B)` is equivalent to `(not A) and (not B)`, and `not (A and B)` is equivalent to `(not A) or (not B)`. These laws can be applied when using the "not" keyword in complex logical expressions.

#### Example:

```x3
var x = 5
var y = 10

# Using De Morgan's laws
if not (x > 0 and y < 5) then
    show("Either x is non-positive or y is non-negative.")
end
```

#### Explanation:

* This example demonstrates applying De Morgan's laws to the expression `(x > 0 and y < 5)` by negating both conditions and changing "and" to "or".

By incorporating the "not" keyword as a logical operator in your X3 language, you enable users to express negated conditions, allowing for more versatile control flow and decision-making in their programs.
