• No results found

Predicate logic Proofs Artificial intelligence. Predicate logic. SET07106 Mathematics for Software Engineering

N/A
N/A
Protected

Academic year: 2021

Share "Predicate logic Proofs Artificial intelligence. Predicate logic. SET07106 Mathematics for Software Engineering"

Copied!
26
0
0

Loading.... (view fulltext now)

Full text

(1)

Predicate logic

SET07106 Mathematics for Software Engineering

School of Computing Edinburgh Napier University

Module Leader: Uta Priss

2010

(2)

Outline

Predicate logic Proofs

Artificial intelligence

(3)

Predicate logic

Propositional logic: “and, or, not” and variables.

Propositional logic does not have quantifiers:

“Allpoodles are dogs.”

“There isat least oneblack swan.”

“Onlysupervisors are allowed to fill in the form.”

“Noperson can solve this problem.”

These sentences cannot be expressed in propositional logic.

(4)

Predicate logic

Quantifiers: all, at least one

First order logic: quantifiers for individuals.

“All squirrels eat nuts.”

Second order logic: quantifiers for predicates.

S = “squirrels eat nuts”

“All S involves chewing.”

Third order logic: ...

(5)

Syntax and semantics

Predicate logic is a formal language (like a programming language) with rules for

syntax (i.e. how to write expressions) and

semantics (i.e. how to formalise the meaning of expressions).

(6)

Syntax: well-formed formulas

I logical symbols: and, or, not, all, at least one, brackets, variables, equality (=), true, false

I predicate and function symbols (for example, Cat(x) for “x is a Cat”)

I term: variables and functions (for example, Cat(x))

I formula: any combination of terms and logical symbols (for example, “Cat(x) and Sleeps(x)”)

I sentence: formulas without free variables (for example, “All x: Cat(x) and Sleeps(x)”)

(7)

Semantics: meaning

The meaning of a term or formula is a set of elements. The meaning of a sentence is a truth value.

The function that maps a formula into a set of elements is called an interpretation.

An interpretation maps

an intensional description (formula/sentence) into an extensional description (set or truth value).

(8)

Validity

A sentence is ...

I satisfiable if it is true under at least one interpretation.

I valid if it is true under all interpretations.

I invalid if it is false under some interpretation.

I contradictory if it is false under all interpretations.

Example: “All x: Cat(x) and Sleeps(x)”

If this is interpreted on an island which only has one cat that always sleeps, this is satisfiable.

Since not all cats in all interpretations always sleep, the sentence is not valid.

(9)

Exercises

Are these sentences satisfiable, valid, invalid or contradictory? If a sentence is satisfiable or invalid, provide an interpretation which makes it true (or false).

I 1 + 1 = 1

I A ∩ B = not(not A ∪ not B)

I All x: ToBe(x) or not ToBe(x)

(10)

Axioms

Mathematical theories distinguish between axioms and theorems.

Axioms cannot be proven, but are accepted as facts.

Theorems can be proven from axioms by using logical inference.

(11)

An example of using axioms

A Boolean logic is a set with operators: and (∧), or (∨), not (A), the elements “true” and “false” and the axioms:

associativity A ∧ (B ∧ C ) = (A ∧ B) ∧ C A ∨ (B ∨ C ) = (A ∨ B) ∨ C commutativity A ∧ B = B ∧ A A ∨ B = B ∨ A

absorption A ∨ (A ∧ B) = A A ∧ (A ∨ B) = A

distributivity A ∨ (B ∧ C ) = (A ∨ B) ∧ (A ∨ C ) A ∧ (B ∨ C ) = (A ∧ B) ∨ (A ∧ C )

complements A ∨ A = 1 A ∧ A = 0

De Morgan’s law is a theorem which can be proven from the axioms.

(12)

Proving de Morgan’s law

A ∨ B = (A ∨ B) ∧ 1

= (A ∨ B) ∧ ((A ∧ B) ∨ A ∧ B)

= (A ∧ A ∧ B) ∨ (A ∧ A ∧ B) ∨ (B ∧ A ∧ B) ∨ (B ∧ A ∧ B)

= 0 ∨ (A ∧ A ∧ B) ∨ 0 ∨ (B ∧ A ∧ B)

= (A ∧ A ∧ B) ∨ (B ∧ A ∧ B)

= ((A ∨ B) ∧ A ∧ B)

= ((A ∨ B) ∧ A ∧ B) ∨ 0

= ((A ∨ B) ∧ A ∧ B) ∨ (A ∧ B ∧ A ∧ B)

= A ∧ B ∧ ((A ∨ B) ∨ (A ∧ B))

= A ∧ B ∧ ((A ∨ B) ∨ (A ∧ B) ∨ (A ∧ B))

= A ∧ B ∧ (((A ∨ (A ∧ B)) ∨ (B ∨ (A ∧ B)))

= A ∧ B ∧ (A ∨ B ∨ B ∨ A)

= A ∧ B ∧ 1 = A ∧ B

(13)

Syllogisms

The ancient Greek philosopher Aristotle introduced logical syllogisms.

Premise 1: All humans are mortal.

Premise 2: Socrates is a human.

Conclusion: Therefore, Socrates is mortal.

(14)

Logical inference

I Law of excluded middle: either P is true or (not P) is true

I Principle of contradiction: P and (not P) cannot both be true Examples:

? Either you are currently sitting in this class room or not.

? The gender of the baby is either male or female or unknown.

? Either you are wearing shoes or sandals.

? Are you wearing a shirt or a t-shirt? Could be both.

(15)

Logical inference

I Modus ponens: (P implies Q) and P is true =⇒ Q is true

I Modus tollens: (P implies Q) and Q is false =⇒ P is false

I Contradiction: P implies (Q is true and false) =⇒ P is false

I Contraposition: (not Q implies not P) =⇒ (P implies Q) Other types of proofs used in mathematics:

mathematical induction, construction, exhaustion, visual proof, ...

(16)

Exercise: which of these inferences are valid?

The days are becoming longer.

The nights are becoming shorter if the days are becoming longer.

Hence, the nights are becoming shorter.

The earth is spherical implies that the moon is spherical.

The earth is not spherical.

Hence, the moon is not spherical.

The new people in the neighbourhood have a beautiful boat.

They also have a nice car.

Hence, they must be nice people.

All dogs are carnivorous.

Some animals are dogs.

(17)

Reasoning (Charles Sanders Peirce)

Induction: Every dog I know has ears. =⇒ Dogs have ears.

(from specific examples to general)

Deduction: Dogs bark. Bobby is a dog. =⇒ Bobby barks.

(from general to specific)

Abduction: Sherlock Holmes: the murderer was left-handed.

Smith is left-handed. =⇒ Smith is the murderer.

(based on shared attributes)

(18)

Predicate logic Proofs Artificial intelligence

Exercises: induction, deduction or abduction?

Birds fly. Penguins are birds.

Hence, penguins fly.

All swans on this lake are white.

Hence, all swans are white.

Some dogs are animals.

Some cats are animals.

Hence, some cats are dogs.

Induction and abduction always need to be treated with caution.

(19)

Exercises: induction, deduction or abduction?

Birds fly. Penguins are birds.

Hence, penguins fly.

All swans on this lake are white.

Hence, all swans are white.

Some dogs are animals.

Some cats are animals.

Hence, some cats are dogs.

Using deduction in unclear domains can lead to false results.

Induction and abduction always need to be treated with caution.

(20)

Artificial intelligence

I The term “artificial intelligence” was coined in 1956 by John McCarthy.

I An attempt to build computer software which has reasoning capabilities similar to humans.

I Processing of natural language.

I Understanding and modelling of spatial, temporal and social situations.

I Knowledge representation and problem solving.

I Many approaches: neural networks, evolutionary algorithms, robots, distributed devices, ...

(21)

Knowledge representation

Uses formal languages to represent knowledge.

I Conceptual structures

I Ontologies

I Knowledge bases

I Expert systems

(22)

Tasks for knowledge representation systems

I Acquisition: new information is integrated into the system

I Retrieval: existing information is retrieved, query answering

I Reasoning: logical inferences

(23)

Reasoning

I Is this concept an element of this class?

I Are concepts, relations and assertions satisfiable/valid?

I Is the knowledge base consistent (i.e. free of contradictions)?

Complexity: the reasoning tasks must not take too much time or computing resources.

(24)

Predicate logic Proofs Artificial intelligence

Natural language can be ambiguous

They drank two cups of tea because they were warm.

They drank two cups of tea because they were cold.

Fruit flies like a banana. (Groucho Marx)

=⇒ It is difficult to write software that extracts information from natural language or that translates between different languages.

(25)

Natural language can be ambiguous

They drank two cups of tea because they were warm.

They drank two cups of tea because they were cold.

Time flies like an arrow.

Fruit flies like a banana. (Groucho Marx)

=⇒ It is difficult to write software that extracts information from natural language or that translates between different languages.

(26)

Programming with logic

I Prolog: declarative, logic programming language

I Lisp: favourite language for artificial intelligence programming

I Smalltalk: object-oriented, dynamically typed, reflective language

I Description logics: knowledge representation languages

I OWL: web ontology language

References

Related documents

Maybe you’d like to sell your product for five dollars, so you can sell it to as many people as possible – but that’s not going to fly if the product costs six dollars to make..

distance to a health facility into consideration, it is still worth reviewing how distance to health facilities impacts the quality of delivery utilization and neonatal mortality,

4 Emotion recognition rates of the BESR and MESR systems based on the PNCC feature in both clean and noisy conditions for different SNR values obtained as mean values among

Recent palaeoaltimetry results from the Linzizong Group in southern Tibet imply that the central Lhasa Block have achieved high elevations (~4.5 km), indicative of a thickened crust,

As part of the validation process following the recent im- plementation of an APP in the outpatient orthopaedic clinic at the Sacré-Coeur Hospital of Montreal, in Montreal, Canada,

I am sometimes very depressed and this impairs my ability to implement diabetes self- care behaviors including healthy eating, physical activity, blood glucose monitoring and

From a descriptive-empirical perspective it is clear that spirituality, spiritual and pastoral work, the faith- based community and faith-based organisations can make a

the rate at which inputs can be substituted keeping production constant equals the relative price of inputs allocative efficiency: Productive efficiency = Allocative efficiency