First Order Logic
Logic is the study of relationship between the truth of one statement and that of another. First order logic (FOL) is a form of precise and unambiguous language for representing knowledge in more detail.
Syntax of FOL
The syntax of a language describes the symbols and notations that are allowed to use in the language.
Lexicon of a first order language contains the following:
- Connectives and Parentheses:
- Quantifier:
- Variables: ranging over particulars (i.e., individual objects)
- Constant: representing specific elements
- Functions
- Relations: with an associated arity (i..e, unary, binary, etc. )
Definitions
A term is defined by two rules:
- Every variable and constant is a term
- If is a m-ary function and are terms, then is also a term.
An atomic formula is a formula that has the form or where are terms and is an n-ary relation.
A string of symbols is a formula of FOL if and only if it is constructed from atomic formulas by repeated applications of the following 3 rules:
- If is a formula then so is
- If and are formulas then so is
- If is a formula then so is for any variable x
A free variable of a formula is that variable occurring in that is not quantified. For instance, if , then y is the free variable because is it not bounded (quantified) by a quantifier (i.e., )
A sentence of FOL is a formula having no free variables.
Examples
Some examples of translation between natural languages and FOL:
- "Each animal is an organism", "all animals are organisms", "if it is an animal, then it is an organism":
- Aliens exist:
- There are books that are heavy, meaning at least one book is heavy:
- Each student must be registered for a degree programme: .
UML class models can also be converted into FOL as follows:
- UML classes can also be converted into unary predicates in FOL (e.g., )
- Associations can be translated into binary relations (e.g., )
- Multiplicity constraints (i.e., 1..*) can be translated into existential quantification.
For example, to model a that the class animal is associated with 4 objects of class limbs, FOL can be used as follows: .
To model subclass relationship, we do as follow:
To model disjoint, we need to show that the intersection is empty. This has the pattern where is the bottom concept, which is a unary predicate that is always false.
To model completeness, we do as follow:
Semantics of FOL
The truth of a FOL sentence depends on the underlying set and the interpretation of functions, constants, and relation symbols. The combination of the underlying set and the interpretation forms a structure. Given a sentence and a structure , models means that the sentence is true with respect to .
A vocabulary is a set of functions, relations, and constant symbols.
A -structure consists of a non-empty underlying set along with an interpretation of . An interpretation of assigns:
- An element of to each constant in
- A function to each n-ary function in ,
- A subset of to each n-ary relation in ,
is a structure if it is a -structure of some vocabulary .
Let be a vocabulary. A -formula is a formula in which every function, relation, and constant is in . Correspondingly, a -sentence is a -formula that is a sentence.
Model theory is about the interplay between M and a set of first-order sentences , which is called the theory of M, and its ``inverse'' from a set of sentences to a class of structures called models. In other words, structure-to-sentence interplay is theory. Sentence-to-structures is model.
For any -structure M (i.e., underlying set plus interpretation of a vocabulary ), the theory of M is the set of all -sentence that are true with respect to . This relation between a sentence and a model is denoted as . The theory of is denoted as .
For any set of -sentences , the model of this set is a -structure such as all sentences in are true with respect to the structure. The class of all models of is denoted by .
The following definitions apply the aforementioned concepts in the context of logic:
Let be a set of -sentences (i.e., sentences written in the vocabulary ). Then is a complete -theory if, for any -sentence , either OR is in and it is NOT the case that both AND are in .
A set of sentences is said to be consistent if no contradiction can be derived from .
A theory is a consistent set of sentences.
My understanding here is that a logical theory is a set of sentences that are true in their structure and contains no contradiction.
Examples
Consider the following conceptual data model:
- Each Student attends exactly one DegreeProgramme
- It is possible that more than one Student attends the same DegreeProgramme
Based on these, we have the following FOL sentences. As they do not contain any contradiction, they form a theory, and thus can be modelled with a model.
Vocabulary:
The structure is the mapping of an underlying set of objects, such as to the vocabulary. John and Mary would be instances of the Student, and CS and Biology would be instances of DegreeProgramme.
Logical Equivalences
Commutativity:
Associativity:
Idempotence:
Absorption: (This one can be proven by truth table)
Distributivity:
Double negation:
De Morgan:
Implication: (This one is important. I couldn't recall learning this one)
Tautology:
Unsatisfiability:
Negation:
Quantifiers: