# Hypothetical syllogisms as a method to secure information

by **Eugenia Bahit**

*This article is a sample of our technical and
scientific writing work.
It has been written for computer scientists, programmers, and
software engineers and versioned for the Web.*

## What are syllogisms?

A *syllogism* is a logical reasoning procedure. The more
classic types of syllogism are categorical and hypothetical
syllogism.

Both types have three components:

- The first statement, called the
*premise* - A second statement, called the
*proposition* - And a final statement, called the
*conclusion*.

Thehypothetical syllogismis a logical reasoning procedure where the premise is a conditional statement.

The difference between categorical and hypothetical syllogisms is the first statement, the premise. While the premise of a hypothetical syllogism is a conditional statement (also called the hypothetical statement), the premise of the first one is categorical. Hence, it is possible to define a hypothetical syllogism as a logical reasoning procedure where the premise (the first component) is a conditional statement.

In sciences, **the hypothetical syllogism** is an
essential reasoning procedure because it **is the base of the
hypothetico-deductive method**—also called the H-D
method

^{1}—used to construct the hypothesis of a scientific theory.

## The hypothetical syllogism and its logic rules

A conditional statement has the form: if `p`, then `q`, where `p`
is called the *antecedent* and `q`, the *consequent*.
In the following example, John is tall

is the antecedent and
Jane is short

, the consequent:

## Example

If John is tall, then Jane is short.

To form a hypothetical syllogism, it is necessary to have a
conditional statement followed by a categorical premise, and
finished by another categorical statement called the *conclusion*.
The categorical premise could be the antecedent or the denial of the
consequent. So that, in the previous example, the possibilities are:
John is tall, or Jane is not short.

This is because there are two rules or ways to form a hypothetical syllogism:

**Affirming the antecedent**, also called*modus ponens*.**Denying the consequent**, also called*modus tollens*.

When the antecedent is affirmed, the consequent *must* be
affirmed in the conclusion:

## Example

If John is tall, then Jane is short.

John **is** tall.

Then, Jane **is** short.

And when the consequent is denied, the antecedent *must* be
denied in the conclusion, such that:

## Example

If John is tall, then Jane is short.

Jane **is not** short.

Then, John **is not** tall.

## Avoiding fallacies

The evident question could be why it is not possible to deny the
antecedent or affirm the consequent in the proposition. The short
answer is to avoid fallacies. The more complex one, is that logic
and reasoning methods have rules, and in the logic sphere, rules are
necessary to prevent *reasoning errors*.

In psychology, reasoning errors are known as thinking errors. That
is because of the **difference between thinking and
reasoning**. While thinking involves everything a person can
think of (and foremost, can believe in), reasoning is limited. In that
sense, thinking is infinite while reasoning is finite. Even though it
is possible to use the conclusion of one argument as a premise for
another one, each reasoning needs a final. A logical argument always
must have a conclusion.

Thinking errors are generated by *cognitive biases*,
which are
beliefs that people have based on previous experiences, political
ideologies, and social and cultural aspects, among other factors.
**Cognitive biases interfere with the natural reasoning process**,
resulting in a thinking error.

Afallacyis a psychologically persuasive argument that uses general thinking as logical reasoning.

Precisely, a *fallacy* is a psychologically persuasive
argument that uses general thinking as logical reasoning.
Formally^{2}, there are two types of formal
fallacies regarding hypothetical syllogisms: denying the antecedent
(or fallacy of the inverse) and affirming the consequent (or fallacy
of the converse).

It should be simple to demonstrate the reasoning error with one example. When the cost of petroleum increases, it also tends to increase the price of public transport tickets, so that:

## Example

If the cost of petroleum increases, then the price of public transport tickets increases.

By reasoning **forgetting the rules**, it is possible to
**commit the following reasoning error**:

## Example

If the cost of petroleum increases, then the price of public
transport ticket increases too.

`ox` The cost of petroleum does not increase.

`ox` Then, the price of public transport tickets do not increase.

However, **what happens if the price of public transport tickets
increases but not the cost of petroleum?** The conclusion would be
false because the premise only affirms the *consequences* of
increasing the petroleum cost, but not the *causes* of the
increasing public transport tickets.

So that, the hypothetical syllogism is limited. It only allows to know two things:

- What consequences will have the fact the antecedent is true.
- What cause can be rejected when the (supposed) consequence is not true.

A general principle of logical reasoning is that **it is not
possible to affirm more than has been affirmed in the premise**.
So that, by following two simple rules (affirming the antecedent to
affirm the consequent and denying the consequent to deny the
antecedent), fallacies are avoided.

## The hypothetical syllogism in software security

These concepts (hypothetical syllogism and reasoning rules) are of interest to software security systems because doing categorical definitions of information makes it possible to establish a hypothesis on each of them to validate the data. For example, a categorical definition of a product price could be like that:

## Example

A price is a real number greater or equal than 0.01 and lower or equal than 9999.99.

The previous sentence is categorical because its form
(

) is. It has a subject (formally
called the subject term), followed by a "to be" verb (linguistically
called a linking verb), and finished by a predicate (formally called
the predicate term). There are four forms of categorical
propositions:`S` is `P`

(A) Every `S` is `P`.

(E) No `S` is `P`.

(I) Some `S` is `P`.

(O) Some `S` is not `P`.

Forms **A** and **E** are general forms, while forms I and O
are particular forms. **For software security, A-form is
chosen.**

A categorical definition can be formally described by using
mathematical logic. For example, for the sentence: A price is a
real number greater or equal than 0.01 and lower or equal than
9999.99

, the formal definition would be:

## Example

A price is a real number greater or equal than 0.01 and lower or
equal than 9999.99, such that
`((p in RR) ^^ ( p >= 0.01 ^^ p <= 9999.99 ))`, where `p`
is the price.

In this way, it is possible to establish a hypothesis on to
validate a variable by saying that if

.`p` is a valid
price, then `p` is a real number greater or equal than 0.01
and lower or equal than 9999.99

Symbols meaning | |

`p` | A variable to denotes a price. |

`in` | ...is an element of... |

`RR` | The real numbers set. |

`>=` | Greater or equal than. |

`<=` | Lower or equal than. |

`^^` | Logic AND. |

Future symbols (not used yet) | |
---|---|

`()` | Logic term. |

`neg` | Deny |

`=>` | Then |

`f` | A function. |

`->` | The output of a function. |

There are only two forms to validate `p`:

- Affirming that

, but this is a paradox because it is trying to validate p precisely.`p`is a valid price - Denying
that

. The unique feasible option.`p`is a real number greater or equal than 0.01 and lower or equal than 9999.99

So, by following the second rule, it is possible to infer that:

## Formal definition

`neg((p in RR) ^^ ( p >= 0.01 ^^ p <= 9999.99 )) => neg p`

In order to validate `p`, it is necessary to have a
function `f` of `p` that receives `p`,
validates `p`, and returns a Boolean value, which means a
*true* or *false*. This function would be the following
one:

## Formal definition

`f(p) -> neg((p in RR) ^^ ( p >= 0.01 ^^ p <= 9999.99 )) => neg p`

The above statement can be translated to source code in a literal way. Some examples are shown then.

## Python Code

def is_a_price(p): term_1 = (type(p) == float) statement = (term_1 and (p >= 0.01 and p <= 9999.99)) if not statement: return False return True

## PHP Code

function is_a_price($p) { $term_1 = (gettype($p) == 'double'); $statement = ($term_1 and ($p >= 0.01 and $p <= 9999.99)); if(!$statement) return False; return True; }

The output of the above function executed in the Python shell would look like:

## Python Output

>>> is_a_price(1) False >>> is_a_price(1.1) True >>> is_a_price('1.1') False >>> is_a_price({1.1}) False

The output of the above function executed in the PHP shell would show:

## PHP Output

php > print is_a_price(1); php > print is_a_price(1.1); 1 php > print is_a_price('1.1'); php > print is_a_price([1.1]);

It is possible to observe that when the variable `p` has
not a suitable data type, the AND statement is not entirely executed
because, in that case, it would throw an exception due to '1.1' (and
the set that contains the number 1.1) could not be managed as a
number. So the language has to obtain the data type to ensure the rest
of the conditional can be executed without risk.