Propositional logic First order logic Alexander Clark Autumn 2014
Formal Logic Logical arguments are valid because of their form. Formal languages are devised to express exactly that relevant form and to disregard all the rest. We will consider 2 formal languages Sentential Logic (also known as Propositional Logic) First-order Predicate Logic.
Motivations (Meta)-mathematics: Hilbert s program Linguistics Computer science There is in my opinion no important theoretical difference between natural languages and the artificial languages of logicians; indeed, I consider it possible to comprehend the syntax and semantics of both kinds of language within a single natural and mathematically precise theory. On this point I differ from a number of philosophers, but agree, I believe, with Chomsky and his associates. (Montague, 1970)
Deductive validity in these languages can be defined in terms of truth-preservation and in terms of formal deduction or proof. We formalize truth -consequence by means of a semantics. We formalize formal deductive -consequence by means of a syntactic calculus Soundness: all formal deductive-consequences are truth-consequences. Completeness: all truth-consequences are formal deductive-consequences.
Defining a Logic involves: 1. Defining a language an alphabet, the primitive symbols of the language, a syntax, giving the well-formed formulas of the language. 2. Defining a semantics for the language, an interpretation of the well-formed formulas (and, sometimes, an interpretation of the primitive symbols)
Generally, the set of well-formed formulas of a language and its semantics are inductively defined. An inductive definition typically has three parts: 1. a basic step in which certain objects are explicitly defined to be of the desired kind, 2. one or more inductive steps defining complex objects to be of the desired kind, given that the component objects have already been defined, 3. a concluding step determining that nothing that cannot be defined by a finite number of basic and inductive steps is an object of the desired kind.
Sentential Logic The Language of Sentential Logic. The primitive symbols of the language (the alphabet) consist of 1. a countably infinite set L of sentence symbols, A 1,...., A n,..., A 10 15,.... (we will also use the symbols A, B, C, D,... Z for the first 26 sentence symbols.) 2. five propositional/boolean connectives,,,,, called the negation, conjunction, disjunction, conditional and the biconditional symbol respectively, 3. a left parenthesis, (, and a right parenthesis, ).
An L-string is a finite sequence of connectives, parentheses, and sentence symbols from L. Example The string of symbols )A 1 ( A 4. 1 2 3 4 5 6 7 It has 7 symbols: ) A 1 ( A 4
L-formulas, or well-formed formulas, (wffs), are Lstrings constructed according to the following rules: 1. A string consisting of a single occurrence of a sentence symbol is an L-formula. 2. If β is an L-formula then ( β) is an L-formula. 3. If β and γ are L-formulas then (β γ) is an L-formula. (β γ) is an L-formula. (β γ) is an L-formula. (β γ) is an L-formula. 4. Nothing else is an L-formula.
Examples of wff A 1 ( B) ( ( B)) (A 1 A 17 ) ((A B) C) ((( A) B) (A B)) (( A) A)
Expressions that are not wff AB A B (A B (A B(( ((A B))
Construction tree ((A B) (B ( A))) (A B) (B ( A)) A B B ( A) A
Inductive proof How do you prove that all wffs have some property? Prove that all sentence symbols have the desired property (Base case) Prove that the formula construction methods preserve that property (Inductive step) We have then proven that all wffs have the desired property. If you define something inductively, then typically it is easiest to use inductive proofs.
Notation We will use α, β as variables that range over wff.
Show by induction on the construction of α. In every wff there occur only a finite number of sentence symbols. Every wff has as many left as right parentheses. A proper initial segment of a wff contains an excess of left-parentheses. So no such segment can be a wff.
Unique readability Theorem Every wff is constructed in a unique way from the sentence symbols and the formula construction operations. That is, every wff can be associated with a unique construction tree.
Without parentheses A B B A A B B A A B B A A B B A A B B A B B A A B A A
Natural language ambiguities You can have tempura and udon or sushi. The chicken is ready to eat I saw the man on the hill with the telescope Volunteers needed to help torture victims Everybody in this room speaks two languages.
A truth assignment for a set of sentence symbols L is a function v v : L {T, F} That is, if A is a sentence symbol from L then v(a) {T, F} (T stands for true and F stands for false.) For n different sentence symbols from L, there are 2 n different truth valuations. Have I used a symbol that is unfamiliar?
Suppose v(a) = T, v(b) = F, v(c) = F,... α = ((A B) (B ( A))) Intuitively the truth assignment of α is computed from: ((T F) (F ( T)))
Given a truth assignment v we define by recursion the unique function v mapping all wffs over L to {T, F} by 1. v(α) = v(α) if α L { T if v(α) = F 2. v(( α)) = F if v(α) = T { T if v(α) = T and v(β) = T 3. v((α β)) = F otherwise { F if v(α) = F and v(β) = F 4. v((α β)) = T otherwise { F if v(α) = T and v(β) = F 5. v((α β)) = T otherwise
((A B) (B ( A))) (A B) (B ( A)) A B B ( A) A
A B B A
v(a) v(b) v(b) T F F T F F F v(a) T T T T F T F T T F F F T F F F T F F F T T T
Homomorphic extensions Suppose we want to define a function from the set of wff to natural numbers. Example Number of symbols in a wff: the length n(a) = 1 n(( A)) = 4 etc Homomorphic property If x, y are two expressions, and x y is the result of concatenating them: n(x y) = n(x) + n(y) (Monoid-homomorphism from strings under concatenation to numbers under addition.)
Alternative way of defining this Define n on the individual symbols: n(a) = 1, n( ) = 1,... Extend it to a function on strings of symbols n If u is a string of length 1, then n(u) = n(u) Otherwise u = v w, and n(u) = n(v) + n(w) (unique homomorphic extension of n as a monoid homomorphism)
Alternative way of defining this Define n on the sentence symbols: n(a) = 1 Extend it to a function on wff n If α is a sentence symbol then n(α) = n(α) = 1 Otherwise If α = ( β) then n(α) = n(β) + 3 If α = (β γ) then n(α) = n(β) + n(γ) + 3
Satisfiability Definitions If v(α) = T then truth assignment v satisfies α. If Φ is a set of wffs, then truth assignment v satisfies Φ if v satisfies every element of Φ. A set Φ is satisfiable if there is a truth assignment v satisfying Φ. Φ is unsatisfiable if it is not satisfiable.
Examples {( A), (A B)} is satisfiable. {( A), ( B), (A B)} is unsatisfiable.
Comments We write Φ; α for Φ {α}. Every set Φ of sentence symbols is satisfiable. So every unsatisfiable set must have at least one complex wff. No set containing α and ( α) is satisfiable. If Φ is satisfiable, and α is a wff, then either Φ; α is satisfiable or Φ; ( α) is satisfiable.
Logical consequence Semantic entailment α is a tautological consequence of Φ, written Φ α if every truth assignment satisfying Φ also satisfies α Examples {A, (A B)} B {A, ( A)} B {A, B} B {A, (B A)} B
Tautologies α is a tautology if it is a tautological consequence of the empty set: α also written as α In other words it is true for every truth assignment. Example (A ( A))
Monotonicity If Σ α then Σ Φ α. Note that we normally reason in a way that violates this condition. Birds can fly and X is a bird implies X can fly. Birds can fly and X is a bird and X is a penguin implies that X cannot fly.
Some facts: {α 1,..., α n } β if and only if {α 1,..., α n 1 } α n β Φ; α β if and only if Φ (α β) {α} β if and only if (α β) Φ α if and only if Φ; ( α) is unsatisfiable.
Truth tables Take a wff α Take the set of all wff that are subformula of α; (substrings of α that are wffs) Construct a table whose columns are the subformula; ordered by length. Add 2 n rows corresponding to the possible truth assignments.
Truth tables A T F ( A) F T A B (A B) T T T T F F F T T F F T A B (A B) T T T T F F F T F F F T
A B (A B) T T T T F T F T T F F F A B (A B) T T T T F F F T F F F F
((A B) (B ( A))) (A B) (B ( A)) A B B ( A) A
The method of truth tables Example ((A B) (B ( A))) A B ( A) (A B) (B ( A)) ((A B) (B ( A))) T T F T F F T F F F T T F T T T T T F F T T T T
Tautologies in truth tables Example ((A B) (B A)) is a tautology. A B (A B) (B A) ((A B) (B A)) T T T T T T F F F T F T F F T F F F F T
Entailment Example {A, (A B)} B A B (A B) Satisfies A and A B T T T yes T F F no F T T no F F T no
Effective procedures Informal definition Exact set of instructions Not requiring any originality or inspiration Terminates after a finite sequence of steps and returns an answer The Church-Turing thesis. An abstraction of a computer program Unbounded memory Unbounded time No errors
Decidability Definition A set Σ of expressions is decidable iff there is an effective procedure that given an expression α will decide whether or not α Σ. In other words, it will return true if α Σ and will return false if α Σ Examples: The set of all wffs is decidable. Any finite set of expressions is decidable There are some non decidable sets of expressions
Effective enumerability A slightly weaker property. Definition A set Σ of expressions is effectively enumerable iff there is an effective procedure that given an expression α will return true iff α Σ. Alternative definition iff there is an effective procedure that lists in some order the elements of Σ
Finiteness Lemma Finiteness Lemma If two truth assignments agree on all sentence symbols in wff α then they agree on α We have proven already that every wff uses only a finite number of sentence symbols. So if α has n sentence symbols, then there are, essentially, only 2 n different truth valuations. So the differences between the truth assignments on the infinite number of sentence symbols not occurring in α are irrelevant. We prove the finiteness lemma by induction on the construction of α
We will see that this lemma makes Truth-Tables an effective decision procedure. A Truth Table analyzes the truth value of a wff α in terms of only the truth values of its subformulas (the segments of the string α that are themselves wffs).
Test for satisfiability and tautological consequence If Φ is a finite set of wffs, then whether α is a tautological consequence of Φ and whether Φ; α is satisfiable can be effectively tested. Construct a truth table from all subformula of all wff in Φ or Φ; α Because is a finite set, it can be effectively tested whether a wff α is a tautology or not.
Testing satisfiability If there are n sentence symbols involved in the wff of Φ, then satisfiability can be tested by a truth-table with 2 n rows. Φ is satisfiable iff there is some row in the truth table assigning T to all elements of Φ.
Example Is Φ = {A, (A B), (B ( A))} satisfiable? A B ( A) (A B) (B ( A)) T T F T F T F F F T F T T T T F F T T T Not satisfiable!
Testing consequence If there are n sentence symbols involved in the wff of Φ; α, then tautological consequence can be tested by a truth-table T with 2 n rows. Φ α iff every row in T that assigns T to all elements of Φ assigns T to α. Iff Φ; ( α) is unsatisfiable. Theorem If Φ is a finite set of wff, then the set of tautological consequences of Φ is decidable.
Size of truth tables Suppose Σ is a finite set of clauses with n distinct sentence symbols. There are 2 n rows in the truth table. n rows 1 2 10 1024 100 1.27 10 30 1000 1.07 10 301 Are there better algorithms than truth tables?
Fortnow, 2009 As we solve larger and more complex problems with greater computational power and cleverer algorithms, the problems we cannot tackle begin to stand out. The theory of NP-completeness helps us understand these limitations and the P versus NP problem begins to loom large not just as an interesting theoretical question in computer science, but as a basic principle that permeates all the sciences.
SAT Definition SAT is the problem of determining whether a finite set of boolean formula is satisfiable and finding a satisfying assignment if one exists. Computationally, this is an NP-complete problem (the first one) Given an assignment v we can check easily if v satisfies all the formulas of Σ It is as hard as any other NP-problem to find such a v if one exists.
1-SAT Definition A literal is a formula which is either a sentence symbol, or the negation of a sentence symbol. A 1, ( A 3 ), A 5,... Suppose every element of Σ is a literal. Can we solve SAT easily in this case?
2-SAT vs 3-SAT 2-SAT Suppose every element of Σ is a disjunction of two literals. E.g. Σ = {(A B), (B C),... }. Can we solve this efficiently? Yes in linear time. 3-SAT Suppose every element of Σ is a disjunction of at most three literals. This is NP-complete.
Functional Completeness An n-ary truth function is a function Z of the form 2 0-ary truth functions (?), 4 1-ary truth functions Z (T) = T, Z (F) = T Z (T) = T, Z (F) = F Z (T) = F, Z (F) = T Z (T) = F, Z (F) = F Z : {T, F} n {T, F}
16 2-ary truth functions Z (T, T) = T, Z (T, F) = T,Z (F, T) = T,Z (F, F) = T Z (T, T) = T, Z (T, F) = T,Z (F, T) = T,Z (F, F) = F Z (T, T) = T, Z (T, F) = T,Z (F, T) = F,Z (F, F) = T... These are just the 16 possible ways of filling in a column in a truth table with n sentence symbols. A B Z T T? T F? F T? F F?
Functional Completeness If Z is an n-ary truth function, then there is a wff α in the sentence symbols A 1,..., A n such that for every truth assignment v: Z (v(a 1 ),..., v(a n )) = v(α) Proof: By the finiteness lemma, there are only 2 n essentially different truth assignments: v 1, v 2,..., v 2n. For any sequence of arguments s to Z there is exactly one truth assignment v i such that s = v i (A 1 ),... v i (A n ). These valuations correspond to the 2 n rows in a truth table for a formula with n sentence symbols. The desired wff α will be constructed from these symbols.
β i j = { A j ( A j ) if v i (A j ) = T otherwise Define α i = (β i 1 βi n). α i just codes one row of the truth table. Finally, pick just those rows α i such that Z (v i (A 1 ),..., v i (A n )) = T, and call these α 1,..., α k Then the required formula is: α = (α 1 α k )
Example A B C Z T T T T T T F F T F T T T F F F F T T F F T F F F F T F F F F T (A B C) (A B C) ( A B C)
Disjunctive normal form A set of connectives if functionally complete if we can express any truth function using them. We have just proved that {,, } is a functional complete set of connectives. {, } is also functionally complete as: (α β) ( (( α) ( β))) {, } is also functionally complete as: (α β) ( (( α) ( β))) {, } is also functionally complete as: (α β) ( (α ( β)))