First Order Logic - PowerPoint PPT Presentation

About This Presentation
Title:

First Order Logic

Description:

First Order Logic Logic is a mathematical attempt to formalize the way we think. First-order predicate calculus was created in an attempt to mechanize reason. – PowerPoint PPT presentation

Number of Views:81
Avg rating:3.0/5.0
Slides: 19
Provided by: Danielle227
Category:

less

Transcript and Presenter's Notes

Title: First Order Logic


1
First Order Logic
  • Logic is a mathematical attempt to formalize the
    way we think.
  • First-order predicate calculus was created in an
    attempt to mechanize reason.

2
First Order Logical Representations
  • All zombies eat brains.
  • This assumption can be represented in
    propositional logic by the propositional variable
    p.
  • In first order logic, the expression can be
    broken down
  • ?X (zombie(X) ? eatsbrains(X))?
  • ?X (zombie(X) ? eats(X, brains))?
  • ?X ?Y (zombie(X) ? eats(X, Y) brains(Y))?
  • Some people with no heartbeats are zombies.
  • ?X (person(X) zombie(X) heartbeat(X))?

3
Natural Deductive Rules
  • Natural deductive rules are logical rules
    accepted as being intuitively true.
  • Universal Instantiation If a variable is
    assigned a value, it will always have that value.
  • If X joe, ?X (zombie(X) ? eatsbrains(X)) is the
    same as (zombie(joe) ? eatsbrains(joe))?
  • Modus Ponens For some pair of expressions p and
    q, p (p ?q) q.
  • If zombie(X), (zombie(X) ? eatsbrains(X)) becomes
    (eatsbrains(X))?

4
Truth Tables
  • Truth tables can be constructed from first order
    logic by transforming expressions into atomic
    formulas (something with value true or false).
  • Atomic formulas can be constructed from first
    order logic by either quantifying a formula or
    mapping it to a value (analogous to valuation).
  • Interpretations are analogous to truth tables.

5
Truth Tables
zombie(joe) zombie(X) eatsbrains(joe) eatsbrai
ns(X) ...
0 ? 0 ? 1 ? 0 ?
By mapping (valuation) of X to fred
zombie(joe) zombie(fred) eatsbrains(joe)
eatsbrains(fred)?
0 0 0 0 1 0 0 1
6
Brief Intro Herbrand Base
  • The Herbrand base is the set of ground atomic
    formulas.
  • In the previous example, this is the set
    zombie(joe), zombie(fred), eatsbrains(joe),
    eatsbrains(fred).
  • A model is satisfiable if and only if it has a
    Herbrand Interpretation (a valid truth assignment
    given its Herbrand base).

7
Function Symbols
  • Function symbols map an individual in the domain
    to another in the domain.
  • Everyone loves their mother.
  • In the expression ?X loves(X, mother(X)),
    mother(X) maps X to the element in the domain.
  • Peano's Axioms for Arithmetic
  • In the expression ?X (number(X) ? number(S(X)),
    the occurance of number in number(X) is a
    function symbol. In the second occurrence, number
    is a predicate and S(X) is a function symbol.

8
Relational Databases
  • Assume there is a relational database with a
    patient table, visit table, and a prescription
    table.
  • The patient table has fields ID, Date of Birth,
    and Gender.
  • The visit table has fields ID, Visit Date, and
    Diagnosis Code.
  • The prescription table has fields ID, Date, and
    Drug.

9
Relational Databases
Patient
Visit
Prescription
10
Relational Databases
  • In a relational database, the table can be
    represented by an atomic formula of a predicate
    objects composed of constants and/or function
    symbols. One such formula exists for each
    patient.
  • Patient table patient(id, date of birth,
    gender)?
  • Visit table visit(id, date, diagnosis code)?
  • Prescription table prescription(id, date, drug)?

11
Relational Databases
  • Any query can be represented as a formula.
  • To find all male patients with diagnosis code
    111, use the query formula ?P (interest(P)?patien
    t(P, B, male) visit(P, D, 111)?
  • The query result can define a new table
    containing the desired data.
  • Extensional Write out entries in a table.
  • Intensional Write out tables via formula

12
First Order Logical Inference-Datalog
  • Datalog is a syntactic variation on relational
    database queries. It forms an intensional
    representation to the query equivalent to those
    formed by relational algebra.
  • All quanitifiers are assumed universal and out
    front of the formula. All formulas are atomic or
    implications. No function symbols are used.
    (interest(P)?patient(P, B, male), visit(P, D,
    111)

13
Queries in Datalog
  • Datalog queries can be called with a
    goal. male-flu(P, D)?(patient(P, B, male),
    visit(P, D, 111)?
  • Goals can be satisfied by finding all bindings on
    the goal variables and using pattern matching.
  • The process of matching all atomic formulas by
    binding the variables to force matching is known
    as Unification.

14
Queries in Datalog
  • Unification is most frequently executed by
    running a backtracking search for proofs
    satisfying all subgoals.
  • Running unification on the male-flu example, if
    there exists patient(1, 1-1-01, male) and
    visit(1, 3-3-03, 111), there will be a new row
    binding in the resulting male-flu table with P1,
    D3-3-03.

15
Prolog
  • All formulas have the format atomic formula ?
    atomic formula , atomic formula(s)written in
    Prolog as atomic formula - atomic formula ,
    atomic formula(s).
  • Prolog uses only universally quantified
    variables.
  • Some arithmetic functions are allowed, such as
    W is XY
  • Specification of correct output is allowed.

16
Prolog Lists
  • cons(H, T) constructs the list with H as the head
    and T as the tail. This is equivalent to
    HT.1,2,312, 3123nilcons(1,
    cons(2, cons(3, nil))) where nil is the empty
    list.
  • All functions are evaluated based on unification.
  • Conventionally, arguments to a Prolog expression
    are given with inputs first, then outputs.
  • Prolog is Turing-complete so long as function
    symbols are allowed.

17
Defining Prolog Functions
  • Member function member(H, HT).member(H,
    ST) ? member(H,T).
  • Insertion Sortsort( , ).sort(HT, L) ?
    sort(T, T2), insert(H, T2, L).insert(H, AT,
    H,AT ? H lt A.insert(H, AT, AL) ? H gt
    A, insert(H, T, L).

18
Running Prolog
  • On CSL machines, Prolog is run via the yap
    interpreter.
  • To load a file into the interpreter ?-
    consult('filename').
  • Once a file has been loaded, definitions
    contained in that file may be executed. The code
    will then be run top down until a solution is
    found and then bound to the output. ?- sort(5,
    1, 10, 3, 9, X). Bind sorted list to X
Write a Comment
User Comments (0)
About PowerShow.com