> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# De Morgan's Laws

#### Sourcery refactoring id: `de-morgan`

#### Description:

Simplifies conditional logic using De Morgan's laws

#### Before:

```python
if not not p:
    a = 1
```

```python
if not a is b:
    a = 1
```

```python
if not (p == 1 and q == 2):
    a = 1
```

#### After:

```python
if p:
    a = 1
```

```python
if a is not b:
    a = 1
```

```python
if p != 1 or q != 2:
    a = 1
```

#### Explanation:

When reading logical statements it is important for them to be as simple as
possible. This proposal applies De Morgan's laws to simplify code by removing
double negatives or pushing negations deeper into statements.
