This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 1 11/21/06 Copyright N. Ramsey & others. DPL10: Logic Programming How to use Logic as a Programming Language Example Languages: Prolog Goedel (adds types) Mercury (adds functional programming) another variant adds constraints, another objects, etc… It was supposed to be the language for the 5th generation project in Japan in the 1980s. It is (often) used to implement rulebased systems. 11/21/06 Copyright N. Ramsey & others. DPL10: Logic Programming How to use Logic as a Programming Language It is based on ideas from Propositional Logic (where we can only determine truth and falsity, and which is thus not very interesting) Predicate Calculus also known as First Order Logic, which can be used as the basis for programming languages. Material in the lectures is, variously, from Ruth E. Davis "Truth Deduction and Computation", from lecture notes by Stuart Shieber, and from lectures by Gerald Sachs, and other sources. 11/21/06 Copyright N. Ramsey & others. DPL10: Logic Programming Semantics of Propositional Calculus Grammar : P ::= V  ¬ P  P → P  ( P ) V ::= p  q  r  s Valuation Function : [[*]] relative to the interpretation φ , where φ : variables → {truth, falsity}. More speci¡cally: {truth, falsity} φ → {truth, falsity} Variables V Propositions P Semantic Domains Syntactic Domains 11/21/06 Copyright N. Ramsey & others. DPL10: Logic Programming Semantics of Propositional Calculus V ranges over variables, P , P 1 , P 2 , Q range over propositions V [[ V ]] φ = φ ( V ) P [[ V ]] φ = V [[ V ]] φ P [[ ¬ P ]] φ "not" P [[ P 1 → P 2 ]] φ "implies" P [[( P )]] φ = P [[ P ]] φ = " # $ truth if P [[ P ]] φ = falsity falsity if P [[ P ]] φ = truth = " # $ % $ truth if P [[ P 2 ]] φ = truth truth if P [[ P 1 ]] φ = falsity falsity otherwise 11/21/06 Copyright N. Ramsey & others. DPL10: Logic Programming Semantics of Propositional Calculus Syntactic Sugar: ( P → Q ) ∧ ( Q → P ) "equivalent to" P ↔ Q (( ¬ P ) → Q ) "or" P ∨ Q ¬ ( P → ( ¬ Q )) "and" P ∧ Q Expansion Called Abbreviation 11/21/06 Copyright N. Ramsey & others. DPL10: Logic Programming More Semantics of Propositional Calculus We add some abbreviations to the language, and we give denotational de¡nitions. Claim : ∧ really means "and". P [[ P ∧ Q ]] φ ≡ P [[ ¬ ( P → ( ¬ Q ))]] φ by ¬ by → by ¬ = " # $ falsity if P [[ P → ( ¬ Q )]] φ = truth truth if P [[ P → ( ¬ Q )]] φ = falsity = " # $ % $ falsity if P [[ ¬ Q ]] φ = truth falsity if P [[ P ]] φ = falsity truth otherwise ( P [[ P ]] φ = truth and P [[ ¬ Q ]] φ = falsity) = " # $ % $ falsity if P [[ Q ]] φ = falsity falsity if P [[ P ]] φ = falsity truth otherwise ( P [[ P ]] φ = truth and P [[ Q ]] φ = truth) 2 11/21/06 Copyright N. Ramsey & others....
View
Full Document
 Fall '09
 Giam
 C Programming, Functional Programming, Firstorder logic, Logic Programming, Horn clause, N. Ramsey, Copyright N. Ramsey

Click to edit the document details