Logic

Aus FernFH MediaWiki
Zur Navigation springen Zur Suche springen

Logic

Mathematical logic

Mathematical logic is the study of logic in mathematics.

Propositional logic

Propositional logic deals with logical statements, which are directly decidable. For example the logical statement is .

Logical operators

The mathematical logical operators are listed as

  • Negation
  • Conjunction
  • Disjunction
  • Implication
  • Double implication

The logical operators are also called as logical connectives.

Negation as logical operator has only one argument, i.e. it concerns only one statement. Negation of a statement is if the statement is . Negation is also called as NOT operator and it is denoted in mathematical logic as . For example if stands for a statement then is whenever is and vice versa.

Th conjunction and disjunction as logical operators have two arguments. Conjunction is also known as AND operator and denoted by . Disjunction is also known as OR operator and denoted by .

Implication as logical operator has two arguments. It is also known as conditional operator and it is denoted by . Implication (e.g. ) is if truth of first argument () implies truth of second argument () or the first argument () is .

Double implication as logical operator has two arguments. It is also known as biconditional operator and it is denoted by . is either if both and are or if both are . is to be read as iff or if and only if .

Truth tables

Logical operators can be also given by their truth tables specifying the logical value ( or ) of the operator for each possible combinations of the logical values of the arguments of the operator.

The truth table of logical negation is given by Table 3.

Logical negation
     
True     False  
False     True  


The truth tables for logical conjunction (and) and for logical disjunction (or) are given below by Tables [tab:log_and] and 5.

Logical conjunction
        
True     True     True  
True     False     False  
False     True     False  
False     False     False  


Logical disjunction
        
True     True     True  
True     False     True  
False     True     True  
False     False     False  


The truth table for logical implication and logical double implication is shown in Table [tab:log_impl] and 7, respectively.

Logical implication
        
True     True     True  
True     False     False  
False     True     True  
False     False     True  


Logical double implication
        
True     True     True  
True     False     False  
False     True     False  
False     False     True  


Logic formulas

Logical operators satisfy several laws, which can be formulated as logic formula. They can be proven either directly based on the interpretations of the arising logical operators or by using the truth tables of the arising logical operators.

Below is a list of the fundamental logic formulas. Here stands for the equivalence relation.

  • Double negation law
  • Identity laws
  • Domination laws
  • Idempotent laws
  • Commutative laws
  • Associative laws
  • De Morgan laws
  • Absorption laws
  • Negation laws

Examples

Example 1

Given the statement : The USA is a democratic country. The negation of : The USA is not a democratic country.
Example 2

Given the statement : . Is the statement or  ?
If then is also . So the statement is .

Predicate logic in mathematics

Propositional logic deals with statements, whose logical value or is directly decidable. More interesting are the statements, whose logical value depends on variables. Predicate logic deals with logical statements over a set of variables.

The elements of predicate logic are given as

  • Predicate
  • Variable domain
  • Quantifier

Predicate

A predicate is a logical statement whose logical value ( or ) depends on one or more variables. Thus formally a predicate is a function with codomain and with any set as domain. For predicates tipically a function like notation is used with uppercase letter, like e.g. , where is the variable it depends on. The predicate is defined by giving a statement involving the variables. For example the predicate can be defined as " is the statement: x can be divided by 3". Then is while is . Just like functions, predicates can also depend on more variables. For example for the predicate "defined as " is , since .

Variable domain

Besides of involving variables, the definition of a predicate, just like in case of functions, must involve also the domains of the involved variables. So the definition of predicate can be completed as

Quantifier

Often rather a kind of aggregation of the predicate’s truth values is interesting, instead of the concrete logical value of a predicate for a specific value. For example "every negative real number satisfies the inequality " is not a statement for one specific value of , but rather about all possible values of negative -s.

Such aggregations of the predicate’s truth values are represented by the quantifier of a variable. Thus the quantifier modifies the statement of the predicate by specifying the way of interpretation of the variable, to which the quantifier refers to. The two types of quantifiers are called as

  • Existential quantifier,
  • Universal quantifier

Existential quantifier
The existential quantifier specifies the interpretation of the variable by the concept "there exist an element in the domain of the variable which fulfils the given predicate". The existential quantifier is denoted by .
Example The statement is to be interpreted as "there exists an integer number x which is less than zero" . This statement is , since for example for holds that .

The formalism can be also interpreted as an abbreviation for a big OR, which runs over every possible values for in the set and tests , in other words

In Python there is an in-built function any() which realizes the existential quantifier. For example

would return , due to the string ’Friday’.

Universal quantifier
The universal quantifier represents the concept "every element in the domain of the variable fulfils the given predicate". The existential quantifier is denoted by .
Example The statement is to be interpreted as "every integer number x is less than zero" . This statement is , since for example for does not hold that .

The formalism can be also interpreted as an abbreviation for a big AND, which runs over every possible values for in the set and tests , in other words

In Python there is an in-built function also for all() which realizes the universal quantifier. For example, for the previously defined list of strings one can test as

would return , since the fourth letter of all the three strings in the list is ’d’.

Formula and sentence

The general formula in the predicate logic is built up from the following elements

  • predicates (including the domains of the involved variables)
  • propositional operators , , , and
  • the existential and universal quantifiers

A variable is quantified if there is a quantifier referring to it. A sentence is a special case of formula, in which all variables are quantified. The quantified and unquantified variables are also referred as bound and free variables, respectively.

For example the formula

is not a sentence, since the variable is not quantified. After quantifying also we get the sentence

Valid places for comma for arising in predicate formulas are given as

  • separating variables in the same quantification,
  • immediatly after the quantification and
  • seperating arguments in predicate function.

An example for a predicate formula built up from all the three types of elements is given as

Simplification rules

Taking a negation of a statement is very common in practice. However usually it is not easy to interpret and understand negation of formulas. In this case simplification rules can be applied in order to push the negation to right. Below is a list of useful simplification rules with negation.

  • Double negation law
  • De Morgan laws
  • Negation rules for and
  • Negation rules for quantifiers

First-order logic

First-order logic, also called predicate logic, is used not only in mathematics, but also in philosophy, linguistics and computer science. First-order logic allows sentences containing quantified variables. In first-order logic sentences are formulated by means of predicate, like e.g. "For every x, if x has a son, then x is parent".

Description of first-order formulas

In this subsection we give a brief overview on the description of the first-order logic. The description of first-order logic requires the introduction of infinite sets like terms and formulas, which are defined inductively.

Elements of first-order logic

The elements of first-order formulas are given as

  • Variables, like x,y, representing any objects, i.e. whose meaning is determined by the semantic.
  • Functions, where function with arguments are called -ary functions.
  • Predicates, where predicates with arguments are called -ary predicates.
  • Equality
  • Logical operators or logical connectives

Terms

The infinite set of terms is defined by applying the following rules

  • Variables. Any variable symbol itself is a term.
  • Functions. If is a n-ary function and are terms then applying to these terms, is also a term.

Terms are only the expressions, which can be obtained by finite many application of rules and are terms.

Formulas

The infinite set of formulas is defined by applying the following rules

  • Predicate. If is a n-ary predicate and are terms then applying to these terms, is a formula
  • Equality. If and are terms then the equality symbol applied to them, is a formula.
  • Negation. If is a formula then is also a formula.
  • Binary logical operators. If and are formulas then any binary logical functions of them (like e.g. , , etc. ) is also a formula.
  • Quantifiers. If is a formula and x is a variable then and are also formulas.

The expressions obtained by finite many applications of only rules and are called atomic formulas. Formulas are only the expressions, which can be obtained by finite many applications of the rules - .

Precedence of the logical operators

Precedence of the logical operators enables to interpret a formula without placing any parentheses into it. The precedence of the logical operators in decreasing order is given by

  • Negation
  • Disjunction and conjunction
  • Quantifiers
  • Implication

Nevertheless extra parentheses can be inserted into formulas.

Formal description of first-order logic

Description of first-order logic as language is completely formal. The terms and formulas are strings of symbols, the symbols together forms the alphabet of the language.

Alphabet

The alphabet of symbols can be divided into the following two groups:

  • Logical symbols
  • Non-logical symbols

The logical symbols include the infinite set of variables, the logical operators, the quantifier symbols, parenthesis, brackets and other punctuation sybols as well as the equality symbol.

The non-logical symbols include the infinite set of n-ary predicate symbols (like e.g. , for binary predicate symbols) and the infinite set of n-ary function symbols (like e.g. , for ternary function symbols)

Language of syntactically valid first-order formulas

Based on the alphabet, the inductive definition of terms, atomic formulas and formulas the language of syntactically valid first-order formulas can be defined as a cntext-free grammar. This can be seen in Backus-Naur form in Figure 15.

Figure 15: Language of syntactically valid first order logic formulas as context-free grammar in BNF

Semantics

Semantic meaning of a first-order language is determined by its interpretation. This interpretation - assigns a way of interpretation to each non-logical symbol in that language and - determines the domains of variables.

Deductive systems

Deductive system is to show on syntactic level, that one formula logically follows from another formula.

The deductive system is sound if every formula which can be derived in the system is logically valid. On the other hand a deductive system is complete if every logically valid formula can be derived in it.

An important property of the deductive systems that they are completely syntactic, so no any interpretation is utilized for the derivations in such system. This means that if the deductive system is sound, than it holds in every possible interpretation of the language describing the system.

Rule of inference

The rule of inference represents the concept that from a given formula (set of formulas) another formula (set of formulas) can be derived as a conclusion.

One commonly used rule of inference is the rule of substitution. Let and be a term and a formula containing the variable respectively. Then replacing all free instances of by in the formula is denoted by . The rule of substitutions states that for any and it can be concluded that , given the condition that no free variable of becomes bound during the substitution process.

Formula identities

Besides of the simplification rules provided in [simpl_rules] several further useful formula identities are listed below.

  • Commutativity of the same quantifier
  • Quantifier with disjunction and conjunction - distributivity
  • Quantifier with disjunction and conjunction - exchangeability

Applications of first-order logic

First-order logic has applications in different scientific fields. Some of them are given below.

  • In mathematics it is used for formalizing and provides proof techniques for mathematical theorems.
  • In computer science it is used for logical reasoning and verifying computer programs.
  • In linguistic it is used for formalizing simple quantifier construction in natural language, which serves a basis for knowledge representation languages.