Sunteți pe pagina 1din 17

Ren Witte

Chapter 9 Introduction
Logic

Introduction to Formal Specification Problems with Natural


Language Specifications
Paradoxes
Requirements Specification & Documentation (IV) Different Logics
Informal, Semi-Formal, and
Formal

SOEN 6481, Winter 2015/16 Propositional Logic


Introduction
Syntax
Semantics
Logical Equivalences
Tautologies and
Contradictions
Derivation Rules

Predicate Logic
Motivation
Predicates
Quantifiers
Translating NL into
Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Ren Witte Proof Procedures in
Predicate Logic
Department of Computer Science Automated Reasoning

and Software Engineering Conclusions

Concordia University Notes and Further


Reading
9.1

Outline Ren Witte

Introduction
Logic

1 Introduction Problems with Natural


Language Specifications
Paradoxes
Different Logics

2 Propositional Logic Informal, Semi-Formal, and


Formal

Propositional Logic
Introduction

3 Predicate Logic Syntax


Semantics
Logical Equivalences
Tautologies and

4 Proof Procedures Contradictions


Derivation Rules

Predicate Logic

5 Conclusions
Motivation
Predicates
Quantifiers
Translating NL into
Predicate Logic
6 Notes and Further Reading Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.2

Requirements Specification & Documentation Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Different Logics
Informal, Semi-Formal, and
Formal

Propositional Logic
Introduction
Syntax
Semantics
Logical Equivalences
Tautologies and
Contradictions
Derivation Rules

Predicate Logic
Motivation
Predicates
Quantifiers
Translating NL into
Predicate Logic
Negation

Proof Procedures
Copyright 2009 by John Wiley & Sons Ltd, [vL09] Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.3
Logic Ren Witte

Introduction
Logic
Logic as a Tool Problems with Natural
Language Specifications
Paradoxes
Boolean circuits: foundation of modern digital design Different Logics
Informal, Semi-Formal, and
Combinatorial explosion: logic served as a tool to formalize the theory of Formal

Propositional Logic
NP-completeness capturing the notion of combinatorial explosion Introduction
Syntax
SQL (Structured Query Language) in databases is essentially a syntactic Semantics

variant of first-order logic Logical Equivalences


Tautologies and
Contradictions
Semantics: to make sure that different implementations of programming Derivation Rules

languages yield the same results Predicate Logic


Motivation

Design validation and verification: the famous Intel bug of 1995, involving faulty Predicates
Quantifiers

floating point divisions, caused a cost of US$ 500 million Translating NL into
Predicate Logic

AI: mechanized reasoning and expert systems Negation

Proof Procedures
Security: trust of algorithms; do guarantees exist? Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.4

Problems with Natural Language Specifications Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes

Defects in NL Specifications Different Logics


Informal, Semi-Formal, and

Problems with natural language: Formal

Propositional Logic
ambiguous Introduction
Syntax

might depend on emphasis, culture, domain, fashion, etc. Semantics


Logical Equivalences

Remember the train control example with and/or causing different Tautologies and
Contradictions

interpretations: Derivation Rules

Predicate Logic
Full braking shall be activated by any train that receives an outdated Motivation

acceleration command or that enters a station block at speed higher than X Predicates
Quantifiers

m.p.h. and for which the preceding train is closer than Y yards. Translating NL into
Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.5

Paradoxes Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Different Logics
Another problem: Paradoxes Informal, Semi-Formal, and
Formal

The Liars Paradox: This sentence is a lie Propositional Logic


Introduction

Another Paradox: Syntax


Semantics

A student is sued for his tuition by the school that educated him. He argues that Logical Equivalences
Tautologies and
he must win, since, if he loses, the school didnt educate him well enough, and Contradictions
Derivation Rules
doesnt deserve the money. The school argues that he must lose, since if he Predicate Logic
wins, he was educated well enough and therefore should pay it. Motivation
Predicates

All these problems led to the effort to formulate logic in a symbolic language.
Quantifiers
Translating NL into
Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.6
Different Logics Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Different Logics
Types of Logics Informal, Semi-Formal, and
Formal
Various logics have been proposed: Propositional Logic

Propositional Logic Introduction


Syntax

Predicate Logic
Semantics
Logical Equivalences
Tautologies and
Temporal Logics Contradictions
Derivation Rules

Description Logics Predicate Logic


Motivation
... Predicates
Quantifiers

Differ in expressiveness and inference procedures. Translating NL into


Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.7

Informal, Semi-Formal, and Formal Ren Witte

Introduction
Informal Specifications Logic
Problems with Natural

Unrestricted natural language (NL) specifications Language Specifications


Paradoxes
Different Logics
Informal, Semi-Formal, and
Formal
Semi-Formal Specifications Propositional Logic
Some formal syntax, but essential descriptive and prescriptive statements in Introduction
Syntax
informal (NL) notation Semantics
Logical Equivalences

Decision Tables Tautologies and


Contradictions

Use Cases, UML


Derivation Rules

Predicate Logic
Motivation
Predicates
Formal Specifications Quantifiers
Translating NL into
Formal syntax and semantics. Predicate Logic
Negation

Different logics, algebraic specification, etc. Proof Procedures


Proof Procedures in
Machine-processable (automated theorem proving, etc.) Propositional Logic
Proof Procedures in

Better support for automatic requirements validation and verification. Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.8

Outline Ren Witte

1 Introduction Introduction
Logic
Problems with Natural

2 Propositional Logic Language Specifications


Paradoxes

Introduction Different Logics


Informal, Semi-Formal, and
Syntax Formal

Semantics Propositional Logic


Introduction

Logical Equivalences Syntax


Semantics
Tautologies and Contradictions Logical Equivalences

Derivation Rules
Tautologies and
Contradictions
Derivation Rules

Predicate Logic

3 Predicate Logic Motivation


Predicates
Quantifiers
Translating NL into

4 Proof Procedures Predicate Logic


Negation

Proof Procedures
Proof Procedures in
5 Conclusions Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

6 Notes and Further Reading Conclusions

Notes and Further


Reading
9.9
Propositional Logic Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Different Logics
Propositional Logic (0th-Order Logic) Informal, Semi-Formal, and
Formal

Propositional logic is a simple and well known language for representing knowledge Propositional Logic
Introduction
Syntax
Parts Semantics
Logical Equivalences

Syntax: how to represent a requirement in propositional logic Tautologies and


Contradictions

Semantics: how to interpret a requirement in propositional logic Derivation Rules

Predicate Logic
Proof procedures: (inference mechanisms) how to automatically create or prove Motivation
Predicates
new propositions Quantifiers
Translating NL into
Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.10

Statements (Propositions) Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Definition Different Logics
Informal, Semi-Formal, and
A statement (also known as a proposition) is a declarative sentence that is either Formal

true or false, but not both. Propositional Logic


Introduction
Syntax

Examples of statements Semantics


Logical Equivalences
Tautologies and
7 is odd. Contradictions
Derivation Rules

1+1=4 Predicate Logic


Motivation
If it is raining, then the ground is wet. Predicates
Quantifiers

Our professor is from Mars. Translating NL into


Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.11

Propositional Logic Basics Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Different Logics

The five logical connectives Informal, Semi-Formal, and


Formal

Propositional Logic
Name Symbol Introduction
Syntax
and (conjunction) Semantics

or (disjunction) Logical Equivalences


Tautologies and

not (negation) Contradictions


Derivation Rules

implies (if . . . then, conditional) Predicate Logic

if and only if (iff, biconditional) Motivation


Predicates
Quantifiers
Translating NL into
Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.12
Syntax of Propositional Logic Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Rules Different Logics

Syntax of propositional logic can be recursively defined by two rules: Informal, Semi-Formal, and
Formal

Propositional Logic

<atomicProposition> ::= true | false | <propositionalSymbol> Introduction


Syntax

<statement> ::= <atomicProposition> Semantics


Logical Equivalences
| ( <statement>) Tautologies and
Contradictions
| (<statement> <statement>) Derivation Rules

| (<statement> <statement>) Predicate Logic


Motivation
| (<statement> <statement>) Predicates

| (<statement> <statement>)
Quantifiers
Translating NL into
Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.13

Translating English to Propositional Logic Ren Witte

Introduction
Logic
Problems with Natural
Example Text Language Specifications
Paradoxes
Translate into propositional logic: Different Logics
Informal, Semi-Formal, and

If I am clever then I will pass, Formal

Propositional Logic
If I will pass then I am clever, Introduction

I am clever or I will pass, Syntax


Semantics

therefore Logical Equivalences


Tautologies and
I am clever and I will pass Contradictions
Derivation Rules

Predicate Logic
Motivation
Translation Predicates

Let p be i am clever and q be i will pass: Quantifiers


Translating NL into
Predicate Logic
Negation
((p q) (q p) (p q)) (p q) Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.14

Semantics Ren Witte

Introduction
Interpretation Logic
Problems with Natural

Semantic Rules define how to evaluate the meaning of a statement. Language Specifications
Paradoxes

Interpretation: Assignment I of truth values (T , F ) to all atomic symbols (one line in


Different Logics
Informal, Semi-Formal, and

a truth table)
Formal

Propositional Logic
Truth Value: The meaning valI (p) of a statement p under a given interpretation I Introduction
Syntax
Semantics
Logical Equivalences

Example Tautologies and


Contradictions

Given the requirements statement Derivation Rules

Predicate Logic
trainMoving doorsClosed Motivation
Predicates

and an interpretation I with Quantifiers


Translating NL into

valI (trainMoving) = F and valI (doorsClosed) = F


Predicate Logic
Negation

the semantic of our statement is Proof Procedures


Proof Procedures in
Propositional Logic
valI (trainMoving doorsClosed) = T Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.15
Truth tables for , , and Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications

p p Paradoxes
Different Logics

T F Informal, Semi-Formal, and


Formal

F T Propositional Logic
Introduction
Syntax
Semantics
Logical Equivalences
Tautologies and

p q pq p q pq Contradictions
Derivation Rules

T T T T T T Predicate Logic

T F F T F T Motivation
Predicates

F T F F T T Quantifiers
Translating NL into
F F F F F F Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.16

Truth tables for and Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Different Logics
Informal, Semi-Formal, and
Formal

p q pq p q pq Propositional Logic
Introduction
T T T T T T Syntax

T F F T F F
Semantics
Logical Equivalences

F T F F T T Tautologies and
Contradictions

F F T F F T Derivation Rules

Predicate Logic
Motivation
Predicates
Quantifiers
Translating NL into
Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.17

Logical Equivalences Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Different Logics
Informal, Semi-Formal, and
Formal

Propositional Logic
Introduction
Definition Syntax

Two statements are logically equivalent if they have the same T/F values for all
Semantics
Logical Equivalences

cases, that is, if they have the same truth tables. Tautologies and
Contradictions
Derivation Rules

Predicate Logic
Motivation
Predicates
Quantifiers
Translating NL into
Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.18
Using truth tables to (dis)proof logical equivalences Ren Witte

Contrapositive Introduction
p q is logically equivalent to q p: Logic
Problems with Natural
Language Specifications

p q pq
Paradoxes
q p q p Different Logics

T T T F F T Informal, Semi-Formal, and


Formal

T F F T F F Propositional Logic

F T T F T T
Introduction
Syntax

F F T T T T Semantics
Logical Equivalences
Tautologies and
Contradictions
Derivation Rules

Converse Predicate Logic


Motivation
q p is not logically equivalent to p q: Predicates
Quantifiers
Translating NL into
p q qp pq Predicate Logic
Negation
T T T T Proof Procedures
T F T F Proof Procedures in
Propositional Logic

F T F T Proof Procedures in
Predicate Logic

F F T T Automated Reasoning

Conclusions

Notes and Further


Reading
9.19

Tautologies Ren Witte

Introduction
Logic

Example Problems with Natural


Language Specifications

Example: (p q) p is always true: Paradoxes


Different Logics
Informal, Semi-Formal, and

p q pq (p q) p Formal

Propositional Logic
T T T T Introduction

T F F T Syntax
Semantics

F T F T Logical Equivalences
Tautologies and
F F F T Contradictions
Derivation Rules

Predicate Logic
Motivation

Definition Predicates
Quantifiers

A statement that is true under any interpretation I is called a tautology. Notation: Translating NL into
Predicate Logic
Negation

|= (p q) p Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.20

Example: modus ponens Ren Witte

Introduction
Logic
Problems with Natural
Prove Language Specifications
Paradoxes

 Different Logics

p Informal, Semi-Formal, and

q Formal

pq Propositional Logic
Introduction
Syntax
Semantics

Proof Logical Equivalences


Tautologies and
Contradictions

p q pq p (p q) [p (p q)] q Derivation Rules

Predicate Logic
T T T T T Motivation

T F F F T Predicates
Quantifiers

F T T F T Translating NL into
Predicate Logic

F F T F T Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.21
Contradictions Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Different Logics
Informal, Semi-Formal, and
Formal

Definition Propositional Logic


Statements that are never true are called contradictions. For example: Introduction
Syntax
Semantics

p p p p Logical Equivalences
Tautologies and
T F F Contradictions
Derivation Rules
F T F Predicate Logic
Motivation
Predicates
Quantifiers
Translating NL into
Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.22

Equivalence Rules Ren Witte

Introduction
Logic

Examples Problems with Natural


Language Specifications
Paradoxes

Equivalence Rule Name Different Logics


Informal, Semi-Formal, and
Formal
p p double negation Propositional Logic
p q p q implication Introduction
Syntax
(p q) p q De Morgans laws Semantics
Logical Equivalences
(p q) p q Tautologies and
Contradictions
pq qp commutativity Derivation Rules

pq qp Predicate Logic
Motivation
p (q r ) (p q) (p r ) distributivity Predicates

p (q r ) (p q) (p r ) Quantifiers
Translating NL into

p (q r ) (p q) r associativity
Predicate Logic
Negation

p (q r ) (p q) r Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.23

Inference Rules Ren Witte

Deriving new knowledge


Inference rules (derivation rules) allow us to obtain new statements from existing Introduction
Logic
ones. Problems with Natural
Language Specifications
Paradoxes

Example Rules Different Logics


Informal, Semi-Formal, and
Formal

Inference Rule Name Propositional Logic


 Introduction
p Syntax
pq conjunction Semantics
q  Logical Equivalences

p Tautologies and
Contradictions
q modus ponens
pq  Derivation Rules

Predicate Logic
q Motivation
p modus tollens
p q Predicates
Quantifiers

pq Translating NL into

pr chaining Predicate Logic

qr  Negation

Proof Procedures
pq
qr resolution Proof Procedures in

p r
Propositional Logic
Proof Procedures in
Predicate Logic
pq p simplification Automated Reasoning

p pq addition Conclusions

Notes and Further


Reading
9.24
Satisfiability and Validity Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes

Satisfiability Different Logics


Informal, Semi-Formal, and

A propositional formula p is satisfiable if there is some interpretation I such that


Formal

Propositional Logic
valI (p) = T . The satisfying interpretation I is called a model of p, written I |= p Introduction
Syntax
Semantics
Validity Logical Equivalences
Tautologies and
A formula p is valid, written |= p, if it is true (T ) in all interpretations (i.e., p is a Contradictions
Derivation Rules
tautology). Predicate Logic
Motivation

Unsatisfiability Predicates
Quantifiers

A formula p is unsatisfiable (or contradictory) if it is false (F ) in all interpretations. Translating NL into


Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.25

Outline Ren Witte

1 Introduction Introduction
Logic
Problems with Natural
Language Specifications
2 Propositional Logic Paradoxes
Different Logics
Informal, Semi-Formal, and
Formal

3 Predicate Logic Propositional Logic

Motivation Introduction
Syntax

Predicates Semantics
Logical Equivalences
Quantifiers Tautologies and
Contradictions
Translating NL into Predicate Logic Derivation Rules

Negation Predicate Logic


Motivation
Predicates
Quantifiers
4 Proof Procedures Translating NL into
Predicate Logic
Negation

Proof Procedures
5 Conclusions Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic

6 Notes and Further Reading Automated Reasoning

Conclusions

Notes and Further


Reading
9.26

Problems with Propositional Logic Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Good enough for RE? Paradoxes
Different Logics
Some limitations of propositional logic Informal, Semi-Formal, and
Formal

We can just state sentences with P, Q, R, etc. Propositional Logic


Introduction
Consider that P denotes the sentence Syntax

It rained on Sunday
Semantics
Logical Equivalences
Tautologies and
Can we access parts of the sentence? Contradictions
Derivation Rules

No components of proposition P Predicate Logic


Motivation
Q denotes Bill jogged on Sunday Predicates
Quantifiers
What about P Q? Translating NL into
Predicate Logic

Can we find out from P Q that both propositions refer to the same day? Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.27
Predicate Logic Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Different Logics
Informal, Semi-Formal, and
Predicates Formal

Predicate logic offers a solution Propositional Logic


Introduction

The sentence It rained on Sunday is denoted as weather( sunday, rain ) Syntax


Semantics

describes relationship weather between sunday and rain Logical Equivalences


Tautologies and
Contradictions
The sentence Bill jogged on Sunday is denoted as jogged(bill, sunday) or Derivation Rules

activity(bill, jogging, sunday) or . . . Predicate Logic


Motivation

Now we can formally find out that sunday is mentioned in both formulas. Predicates
Quantifiers
Translating NL into
Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.28

Predicates Ren Witte

Introduction
Logic

Definition Problems with Natural


Language Specifications

A predicate is a declarative sentence whose T/F value depends on one or more Paradoxes
Different Logics

variables. In other words, a predicate is a declarative sentence with variables, and Informal, Semi-Formal, and
Formal

after those variables have been given specific values, the sentence becomes a Propositional Logic

statement. Introduction
Syntax
Semantics

Example
Logical Equivalences
Tautologies and
Contradictions
Derivation Rules

Predicate Logic

P(x) = x is even Motivation


Predicates

Q(x, y ) = x is heavier than y


Quantifiers
Translating NL into
Predicate Logic
Negation

are predicates. The statement P(8) is true, while the statement Q(feather, brick) is Proof Procedures
false. Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.29

Quantifiers Ren Witte

Introduction

Universal and Existential Quantifier Logic


Problems with Natural

A quantifier modifies a predicate by describing whether some or all elements of the Language Specifications
Paradoxes

domain satisfy the predicate. Different Logics


Informal, Semi-Formal, and
Formal
Universal quantifier: Propositional Logic

Existential quantifier:
Introduction
Syntax
Semantics

The statement Logical Equivalences


Tautologies and
( x)P(x) Contradictions
Derivation Rules

says that P(x) is true for all x in the domain. Predicate Logic
Motivation
Predicates

The statement
Quantifiers
Translating NL into
Predicate Logic
( x)P(x) Negation

Proof Procedures
says that there exists an element x of the domain such that P(x) is true; in other Proof Procedures in
Propositional Logic
words, P(x) is true for some x in the domain. Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.30
Order matters Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Different Logics
Informal, Semi-Formal, and
Note Formal

In general, Propositional Logic


Introduction
( y )( x)G(x, y ) Syntax
Semantics

is different from Logical Equivalences


Tautologies and

( x)( y )G(x, y ). Contradictions


Derivation Rules

Predicate Logic
Motivation

For example, G(x, y ) = x > y . Predicates


Quantifiers
Translating NL into
Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.31

Translating NL into Predicate Logic Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Two common constructions Paradoxes
Different Logics

1 All hobjectsi are hsomethingi. translates as Informal, Semi-Formal, and


Formal

Propositional Logic

( x)(P(x) Q(x)). Introduction


Syntax
Semantics

For example, all baseball players are rich Logical Equivalences


Tautologies and
Contradictions
Derivation Rules
2 There is a hobjecti that is hsomethingi. translates as Predicate Logic
Motivation

( x)(P(x) Q(x)). Predicates


Quantifiers
Translating NL into
Predicate Logic
For example, some oysters taste funny Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.32

Example Ren Witte

Introduction
Logic

Domain = all cars. Problems with Natural


Language Specifications

With Paradoxes
Different Logics
Informal, Semi-Formal, and

P(x) x gets good mileage.


Formal
= Propositional Logic

Q(x) = x is large. Introduction


Syntax
Semantics

( x)(Q(x) P(x)) translates as Logical Equivalences


Tautologies and
Contradictions

For all cars x, if x is large, then x does not get good mileage. Derivation Rules

Predicate Logic

or Motivation
Predicates

All large cars get bad mileage. Quantifiers


Translating NL into
Predicate Logic

or Negation

Proof Procedures
There arent any large cars that get good mileage. Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.33
Negation rules for predicate logic Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Different Logics
Informal, Semi-Formal, and
Formal

Propositional Logic

Equivalence Name Introduction


Syntax

[( x)P(x)] ( x)(P(x)) universal negation Semantics


Logical Equivalences

[( x)P(x)] ( x)(P(x)) existential negation Tautologies and


Contradictions
Derivation Rules

Predicate Logic
Motivation
Predicates
Quantifiers
Translating NL into
Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.34

Example: Domain = all cars, revisited. Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes

P(x) = x gets good mileage. Different Logics


Informal, Semi-Formal, and

Q(x) = x is large. Formal

Propositional Logic
Introduction

Negate the statement All large cars get bad mileage. Syntax
Semantics
Logical Equivalences

Statements Reasons Tautologies and


Contradictions

1. [( x)(Q(x) P(x))] given Derivation Rules

2. ( x)(Q(x) P(x)) universal negation Predicate Logic


Motivation

3. ( x)(Q(x) P(x)) implication Predicates


Quantifiers
4. ( x)((Q(x)) (P(x))) De Morgans law Translating NL into
Predicate Logic
5. ( x)(Q(x) P(x)) double negation Negation

6. ( x)(P(x) Q(x)) commutativity Proof Procedures


Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.35

Outline Ren Witte

Introduction
1 Introduction Logic
Problems with Natural
Language Specifications
Paradoxes
2 Propositional Logic Different Logics
Informal, Semi-Formal, and
Formal

Propositional Logic
3 Predicate Logic Introduction
Syntax
Semantics

4 Proof Procedures
Logical Equivalences
Tautologies and

Proof Procedures in Propositional Logic Contradictions


Derivation Rules

Proof Procedures in Predicate Logic Predicate Logic

Automated Reasoning Motivation


Predicates
Quantifiers
Translating NL into
Predicate Logic
5 Conclusions Negation

Proof Procedures
Proof Procedures in

6 Notes and Further Reading Propositional Logic


Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.36
Proof Procedures Ren Witte

Introduction

Proof Procedure Logic


Problems with Natural

A Proof Procedure is a combination of Language Specifications


Paradoxes

an inference rule, and Different Logics


Informal, Semi-Formal, and
Formal
an algorithm for applying the rule to a set of expressions Propositional Logic
Introduction
Syntax

Examples Semantics
Logical Equivalences
Tautologies and
Direct Proof: We have the facts F1 , F2 , . . . , Fn and want to show that G is a logical Contradictions
Derivation Rules
consequence. Prove by showing that (F1 F2 . . . Fn ) G is a Predicate Logic
tautology: Motivation
Predicates
Quantifiers

|= (F1 F2 . . . Fn ) G Translating NL into


Predicate Logic
Negation

Refutation Proof: Prove by showing that adding the negation of G to the facts: Proof Procedures
Proof Procedures in
(F1 F2 . . . Fn G) leads to an inconsistency Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.37

Inference in Propositional Logic Ren Witte

Soundness and Completeness Introduction

Inference Rule: formal way of generating new expressions from (a set of) existing
Logic
Problems with Natural

propositional calculus expressions S


Language Specifications
Paradoxes
Different Logics
but we only want to generate expressions that logically follow from a given Informal, Semi-Formal, and
Formal
expression S Propositional Logic

if our inference rules only generates such expressions, it is sound Introduction


Syntax

and if we can generate all expressions that logically follow from a set S, it is
Semantics
Logical Equivalences

called complete Tautologies and


Contradictions
Derivation Rules

Predicate Logic
Notation Motivation

Given an inference rule r and a set of expressions S, if we can derive a new


Predicates
Quantifiers

expression from S using r , we write Translating NL into


Predicate Logic
Negation

S `r Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
This is also called the turnstyle symbol. It is a syntactic operation. Mind the Predicate Logic
Automated Reasoning
difference to the semantic operation |=. Conclusions

Notes and Further


Reading
9.38

Proof Methods Ren Witte

Introduction
Truth Table Logic
Problems with Natural
exhaustive proof method Language Specifications
Paradoxes

becomes intractable for large number of variables Different Logics


Informal, Semi-Formal, and
For n variables, O(2n ) combinations Formal

Propositional Logic
NP-Complete (Boolean Satisfiability problem) Introduction
Syntax
Semantics

Resolution Logical Equivalences


Tautologies and

Proof by contradiction Contradictions


Derivation Rules

Convert all statements to conjunctive normal form (CNF) Predicate Logic


Motivation

Add the negation of the desired conclusion (in CNF) Predicates


Quantifiers

Apply resolution rule: from , produce Translating NL into


Predicate Logic

until you arrive at the empty clause (showing a contradiction and thus the validity of Negation

Proof Procedures
the original goal). Proof Procedures in

or you cannot apply any more axioms (i.e. goal cannot be proven from the Propositional Logic
Proof Procedures in
statements) Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.39
Proof Procedures in Predicate Logic Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Example: Modus Ponens Different Logics
Informal, Semi-Formal, and
Modus ponens is a sound (but not complete!) inference rule for predicate calculus: Formal

Propositional Logic
If we have P and P Q, then we can infer (add to our knowledge base) Q Introduction
Syntax
Example: Semantics
Logical Equivalences

Fact: Socrates is a man: man(socrates) Tautologies and


Contradictions

Rule: All men are mortal: X (man(X ) mortal(X )). Derivation Rules

Predicate Logic
We can now deduce: mortal(socrates) Motivation
Predicates

Note that we substituted socrates for X . Quantifiers


Translating NL into

This step is called unification. Predicate Logic


Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.40

Decidability Ren Witte

Introduction
Logic
Problems with Natural
Mathematical foundation: Gdels completeness theorem (1930-31) Language Specifications
Paradoxes
Different Logics
For first-order logic: any sentence that logically follows from another set of Informal, Semi-Formal, and
Formal
sentences can be proved from that set Propositional Logic

Thus, we can find a complete proof procedure R Introduction


Syntax

if KB |= , then KB `R Semantics
Logical Equivalences

But he only showed that R must exist he did not provide it Tautologies and
Contradictions
Derivation Rules
This was done by Robinson (1965): resolution algorithm Predicate Logic

Note: the theorem says that if it follows, then it can be proved. But we dont Motivation
Predicates

know that until we proved it! Quantifiers


Translating NL into
Predicate Logic
And worse: if it doesnt, we cant always show that first-order logic is Negation

semidecidable Proof Procedures


Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.41

Automated Reasoning Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Applications of Automated Theorem Proving Different Logics
Informal, Semi-Formal, and
Automated Reasoning (Automated Theorem Proving) is an important foundation for Formal

many tasks: Propositional Logic


Introduction

Reasoning in natural languages Syntax


Semantics

Automated proving of mathematical theorems


Logical Equivalences
Tautologies and
Contradictions
Expert System Shells Derivation Rules

Predicate Logic
Requirements Verification & Validation Motivation
Predicates
Formal Software Verification Quantifiers
Translating NL into
Semantic Web Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.42
Outline Ren Witte

Introduction
Logic

1 Introduction Problems with Natural


Language Specifications
Paradoxes
Different Logics

2 Propositional Logic Informal, Semi-Formal, and


Formal

Propositional Logic
Introduction

3 Predicate Logic Syntax


Semantics
Logical Equivalences
Tautologies and

4 Proof Procedures Contradictions


Derivation Rules

Predicate Logic

5 Conclusions
Motivation
Predicates
Quantifiers
Translating NL into
Predicate Logic
6 Notes and Further Reading Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.43

Formal Requirements Specifications Ren Witte

Introduction
Logic
Problems with Natural
General Idea Language Specifications
Paradoxes

Elicit and evaluate requirements as before Different Logics


Informal, Semi-Formal, and
Formal
Translate requirements into a formal system (here: propositional and predicate
Propositional Logic
logic) Introduction
Syntax
Then, we can use tools (automated theorem provers) to Semantics
Logical Equivalences
Check internal consistency (no contradictions) Tautologies and
Contradictions
Derive new facts (verify with stakeholders!) Derivation Rules

Test for assertions: e.g., does a given invariant such as doorsOpen trainStopped Predicate Logic

logically follow from the requirements (knowledge base)? Motivation


Predicates

(more on this in the QA lecture) Quantifiers


Translating NL into
Predicate Logic
Predicate logic is also widely used for specifying pre- and postconditions (e.g., Negation

in Use Case specifications) Proof Procedures


Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.44

Soundness, Completeness, Decidability Ren Witte

Introduction
Logic
Problems with Natural

Syntax vs. Semantics Language Specifications


Paradoxes
Different Logics

Entailment models define the semantics Informal, Semi-Formal, and


Formal

entailment is a semantic notion Propositional Logic


Introduction
Inferences inference is a syntactic notion Syntax
Semantics
Logical Equivalences
Tautologies and
Quality measures for computing inferences Contradictions
Derivation Rules

Soundness something can be inferred only if it is entailed by the knowledge base Predicate Logic
Motivation

(KB) Predicates
Quantifiers

Completeness anything that is entailed by a KB can be inferred Translating NL into


Predicate Logic
Negation
Decidability sound and complete and terminating Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.45
Logics weve seen so far Ren Witte

Propositional Logic
Introduction
Logic
simple (not very expressive) Problems with Natural
Language Specifications
sound, complete, decidable Paradoxes
Different Logics
Informal, Semi-Formal, and
Formal

Predicate Logic Propositional Logic


Introduction

very expressive Syntax


Semantics
sound, complete, but only semi-decidable Logical Equivalences
Tautologies and
Contradictions
Derivation Rules

Compromise? Predicate Logic


Motivation
More expressive than propositional logic, yet decidable? Predicates
Quantifiers
Description Logics (DL) Translating NL into
Predicate Logic
Formal basis for (Semantic Web) Ontologies Negation

Web Ontology Language (OWL), W3C standard Proof Procedures


Proof Procedures in

Subsets of predicate logic with efficient decidability procedures for automated Propositional Logic
Proof Procedures in

theorem proving Predicate Logic


Automated Reasoning

Can be used for e.g. domain modeling Conclusions

Notes and Further


Reading
9.46

Outline Ren Witte

Introduction
Logic

1 Introduction Problems with Natural


Language Specifications
Paradoxes
Different Logics

2 Propositional Logic Informal, Semi-Formal, and


Formal

Propositional Logic
Introduction

3 Predicate Logic Syntax


Semantics
Logical Equivalences
Tautologies and

4 Proof Procedures Contradictions


Derivation Rules

Predicate Logic

5 Conclusions
Motivation
Predicates
Quantifiers
Translating NL into
Predicate Logic
6 Notes and Further Reading Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.47

Reading Material Ren Witte

Introduction
Logic
Problems with Natural
Language Specifications
Paradoxes
Required Different Logics
Informal, Semi-Formal, and
Formal
[vL09, Chapters 4.44.4.1, 4.4.7, 4.5]
Propositional Logic
Introduction
Syntax

Supplemental Semantics
Logical Equivalences
Tautologies and
[Mey85] Contradictions
Derivation Rules

Predicate Logic
Motivation
Further Reading Predicates
Quantifiers

[GK13] Translating NL into


Predicate Logic
Negation

Proof Procedures
Proof Procedures in
Propositional Logic
Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.48
References Ren Witte

Introduction

[GK13] Michael Genesereth and Eric Kao.


Logic
Problems with Natural

Introduction to Logic.
Language Specifications
Paradoxes

Synthesis Lectures on Computer Science. Morgan&Claypool Publishers, Different Logics


Informal, Semi-Formal, and

second edition, 2013. Formal

Propositional Logic
http://www.morganclaypool.com/doi/abs/10.2200/ Introduction

S00518ED2V01Y201306CSL006. Syntax
Semantics
Logical Equivalences
[Mey85] Bertrand Meyer. Tautologies and
Contradictions
On Formalism in Specifications. Derivation Rules

IEEE Software, 2(1):626, 1985. Predicate Logic

http://se.ethz.ch/~meyer/publications/computer/formalism.pdf.
Motivation
Predicates
Quantifiers

[vL09] Axel van Lamsweerde. Translating NL into


Predicate Logic

Requirements Engineering: From System Goals to UML Models to Negation

Proof Procedures
Software Specifications. Proof Procedures in

John Wiley & Sons, 2009. Propositional Logic


Proof Procedures in
Predicate Logic
Automated Reasoning

Conclusions

Notes and Further


Reading
9.49

S-ar putea să vă placă și