40 likes | 76 Views
First-Order Logic (Predicate Calculus). Some statements encode axioms from which other statements can be proven E.g., natural(0) and x natural(x) → natural(successor(x)) Different constructs make up first-order-logic Constants like 0 or 1 (usually numbers or names)
E N D
First-Order Logic (Predicate Calculus) • Some statements encode axioms from which other statements can be proven • E.g., natural(0) and x natural(x)→ natural(successor(x)) • Different constructs make up first-order-logic • Constants like 0 or 1 (usually numbers or names) • Variables like x whose possible values are sets of constants • Predicates like natural that return true or false • Functions like successor that return a constant or variable • Connectives like and, or, not, , and • Quantifiers like and that also introduce bound variables • Punctuation symbols like parentheses, commas, periods • Inference rules can produce new (proven) statements • E.g., (a b) and (b c) allows us to assert(a c)
Execution Order • Resolution in Prolog uses a depth-first search strategy • Replaces goals left-to-right • Works through database top-to-bottom • Sub-goals are considered as soon as possible • Whenever failure occurs, Prolog backtracks to continue • Can exploit this behavior to cause iteration • E.g., to do repetitive searches, show all answers, etc. • Built-in predicate fail forces backtracking • Watch out for unbounded recursion • E.g., need to be sure search will progress to termination
Some Problems with Logic Programming • Occur-check problem • A unification algorithm does not check whether a term that is being unified with a variable contains that variable itself • Can lead to non-progressing iteration (which does not halt) • Negation as failure (and vice versa) • Absence of proof is not proof of absence (but negation can make it appear that way), backtracking may release bindings • Expressive power of Horn clauses is limited • E.g., cannot express existential quantification as in x p(x) • Problems involving control information • Order of clauses (and statements) affects evaluation order • In terms of pure logic this does not matter • For logic programming this impacts progress, termination
Today’s Studio Exercises • We’ll continue looking at Horn clauses • Building on the parsing examples from last time • Translating from FOL format to a structured list format • In lab 3 we’ll use both unification and resolution (in C++) • Today’s exercises are again all in Scheme • Extracting variables and constants, forming lists (of lists) • Translating lists back into string representations in a file • When done, please email your answers to the studio exercises to the cse425@seas.wustl.edu course account, with subject “Logic Programming Studio II”