Harvard-MIT Division of Health Sciences and Technology HST.952: Computing for Biomedical Scientists Data and Knowledge Representation Lecture 2 Last Time We Talked About z Why is knowledge/data representation important z Propositional Logic z Operators z WFF z Truth table Today We Will Talk About z Boolean Algebra z Predicate Logic (First order logic) Exercise z Generate a truth table for ( a ∧ b ) ∨ ( a ∧ ¬b ) Boolean Algebra z Named in honor of George Boole z http://www.digitalcentury.com/encyclo/updat e/boole.html z Another way of reasoning with proposition logic z Is a form of equational reasoning Laws of Boolean Algebra Operations with Constants z a Λ False = False za V True = True z a Λ True = a z a V False = a Laws of Boolean Algebra Basic properties of Λ and V z a→aVb z aΛb→a z aΛa=a z z z z z aVa=a aΛb=bΛa aVb=bVa (a Λ b) Λ c = a Λ (b Λ c) (a V b) V c = a V (b V c) Note the difference between “→” and “=“ a→aVb a b aVb a→aVb 0 0 0 1 0 1 1 1 1 0 1 1 1 1 1 1 aΛb→a a b aΛb aΛb→a 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 1 Laws of Boolean Algebra Distributive and DeMorgan’s Laws z a Λ (b V c) = (a Λ b) V (a Λ c) z a V (b Λ c) = (a V b) Λ (a V c) z ¬ (a Λ b) = ¬ a V ¬b z ¬ (a V b) = ¬a Λ ¬b Laws of Boolean Algebra Laws on Negation z ¬True = False z ¬False = True z a Λ ¬a = False z a V ¬a = True z ¬(¬a) = a Laws of Boolean Algebra Laws on Implication z (a Λ (a → b)) → b z ((a → b) Λ ¬b) → ¬a z ((a V b) Λ ¬a) → b z ((a → b) Λ (b → c)) → (a → c) z ((a → b) Λ (c → d)) → ((a Λ c) → (b Λ d)) z ((a → b) → c) → (a → (b → c)) z ((a Λ b) → c) = (a → (b → c)) z a → b = ¬a V b z a → b = ¬b → ¬a z (a → b) Λ (a → ¬ b) = ¬a a→b = ¬aVb a b a→b ¬a ¬aVb a→b = ¬aVb 0 0 1 1 1 1 0 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 1 1 (a → b) Λ (a → ¬ b) = ¬a ( a → b ) ∧ ( a → ¬b ) = ( ¬ a ∨ b ) ∧ ( ¬a ∨ ¬b ) = ¬a ∨ (b ∧ ¬b) = ¬a ∨ False = ¬a Laws of Boolean Algebra Equivalence a ↔ b = (a → b) Λ (b → a) Examples z Please write a propositional logic WFF for the following eligibility criteria: “a women over 50-year old and not on hormonal therapy” w Λ old Λ ¬ (hrt) Need to define w, old, and hrt Examples z Please write a propositional logic WFF for the following guideline: “All women over 30 years old should have pap smear every year” w Λ Over30 → pap_yearly How to convey “all”? Predicate Logic z Extension to propositional logic z Augmented with variables, predicates and quantifiers Predicate zA predicate is a statement that an object x has certain property z E.g. F (x): F is the predicate and x is the variable F applies to z Any term in the form F(x), where F is a predicate name and x is a variable name, is a well-formed formula. Similarly, F(X1, X2………Xk) is a well-formed formula; this is a predicate containing k variables Examples z Women over 70 years old Women (x) Ξ x is female senior (x) Ξ x is over 70 years old Quantifiers z There are two quantifiers in predicate logic: z The universal quantification: z The existential quantification: ∀ ∃ Universal Quantification z If F(x) is a well-formed formula containing the variable x, then ∀ x . F ( x ) is a wellformed called a universal quantification. For all x in the universe, the predicate F(x) holds. In other words: every x has the property F. z ∀x. F ( x) = F ( x ) ∧ F ( x ) ∧ F ( x ) K ∧ F ( x ) 1 2 2 n Existential Quantification z If F(x) is a well-formed formula containing the variable x, then ∃x. F ( x) is a wellformed called a existential quantification. For one or more x in the universe, the predicate F(x) holds. In other words: some x has the property F. ∃x. F ( x) = F ( x1 ) ∨ F ( x2 ) ∨ F ( x2 ) K ∨ F ( xn ) Universe of Discourse z Also called universe or U z A set of possible values that the variables can have z Let U be all female, C (x, “xx”) mean x has XX chromosomes, then ∀x C ( x, " xx" ) is true z Let U be all patients, C (x, “xx”) mean x has XX chromosomes, then ∀x C ( x, " xx" ) is false Scope of Variables Bindings z Quantifiers bind variables by assigning them values from a universe z This formula ∀x. F ( x) ∨ E ( x) Can be interpreted as (∀x. F ( x)) ∨ E ( x) Or ∀x. ( F ( x) ∨ E ( x)) z Use parentheses if not clear Translation A ≡ a patient is female B ≡ a patient is pregnant C ≡ a pregnancy test is positive What does B → A mean? What does A Λ C → B mean? But is C a test the patient in A took? Translation A( x) ≡ x is female B( x) ≡ x is pregnant C ( x, y ) ≡ x is a pregnancy test of y D( x) ≡ x is positive What does ∀x. A( x) → B( x) mean? What does ∀x.∃y.A(x) ∧ C( y, x) ∧ D( y) → B(x) mean? Can we say some pregnant female does not have positive pregnancy test results? Algebraic Laws of Predicate Logic ∀x. f ( x) → f (c) f (c) → ∃x. f ( x) • x is any element in the universe. • The element c is any fixed element of the universe. Algebraic Laws of Predicate Logic ∀ x . ¬ f ( x ) = ¬∃ x . f ( x ) ∃ x . ¬ f ( x ) = ¬∀ x . f ( x ) ∀ x . f ( x ) ∧ q = ∀ x .( f ( x ) ∧ q ) ∀ x . f ( x ) ∨ q = ∀ x .( f ( x ) ∨ q ) ∃ x . f ( x ) ∧ q = ∃ x .( f ( x ) ∧ q ) ∃ x . f ( x ) ∨ q = ∃ x .( f ( x ) ∨ q ) • q is a proposition that does not contain x Algebraic Laws of Predicate Logic ∀x. f ( x) ∧ ∀x.g ( x) = ∀x.( f ( x) ∧ g ( x)) ∀x. f ( x) ∨ ∀x.g ( x) → ∀x.( f ( x) ∨ g ( x)) ∃x.( f ( x) ∨ g ( x)) → ∃x. f ( x) ∨ ∃g ( x) ∃x. f ( x) ∨ ∃x.g ( x) = ∃x.( f ( x) ∨ g ( x)) • Please note the difference between “→” and “=“ Equational Reasoning z Showing two values are the same by building up chains of equalities z Substitute equals for equals Example ( False ∧ P) ∨ Q = ( P ∧ False) ∨ Q = False ∨ Q = Q ∨ False =Q Example Prove ¬∃x.( f ( x) → g ( x)) ∧ ∀x.¬f ( x) = False ¬∃x.( f ( x) → g ( x)) ∧ ∀x.¬f ( x) = ∀x.¬( f ( x) → g ( x)) ∧ ∀x.¬f ( x) = ∀x.(¬( f ( x) → g ( x)) ∧ ¬f ( x)) = ∀x.(¬(¬f ( x) ∨ g ( x)) ∧ ¬f ( x)) = ∀x.(¬(¬f ( x)) ∧ ¬g ( x) ∧ ¬f ( x)) = ∀x.( f ( x) ∧ ¬g ( x) ∧ ¬f ( x)) = ∀x.((¬g ( x) ∧ f ( x)) ∧ ¬f ( x)) = ∀x.(¬g ( x) ∧ ( f ( x) ∧ ¬f ( x))) = ∀x.(¬g ( x) ∧ False) = False Exercise z Prove PΛ¬(QVP) = False P ∧ ¬(Q ∨ P) = P ∧ ( ¬ Q ∧ ¬P ) = P ∧ ( ¬ P ∧ ¬Q ) = ( P ∧ ¬ P ) ∧ ¬Q = False ∧ ¬Q = False Exercise z Prove ∀x.( f ( x) ∧ ¬g ( x)) = ∀x. f ( x) ∧ ¬∃x.g ( x) ∀x.( f ( x) ∧¬g( x)) = ∀x. f (x) ∧ (∀x.¬g(x)) = ∀x. f (x) ∧¬∃x.g(x) Exercise z Translate Logic: z Some the following into Predicate patients only speak Spanish. z All doctors speak English, while some can also speak Spanish. z Spanish speaking doctors should be assigned to patients who only speak Spanish Alternatives in Modeling zX has Diabetes: z Diabetes (x) z Has_Diagnosis (x, “Diabetes”) z Has (x, “Diagnosis”, “Diabetes”) z Trade off between efficiency and expressiveness z Has (x, y, “Diabetes”) Relationship to OO model z Representing patient X has Diabetes in OO model: z Diabetes (x) z z Has_Diagnosis (x, “Diabetes”) z z Object x has an attribute called Diabetes Object x has an attribute called Has_Diagnosis which can have value “Diabetes” Has (x, “Diagnosis”, “Diabetes”) z Object x has an attribute called Has which can have value observation, which is an object with attributes observation type “Diagnosis” and observation value “Diabetes” Relationship to DB z Representing patient X has Diabetes in a table: z Diabetes (x) z z Has_Diagnosis (x, “Diabetes”) z z A table called Diabetes with column (s) identifying patient x and a column of the value of Diabetes (x) A table called Diagnosis with column (s) identifying patient x, and diagnosis y and a column of the value of Has_Diagnosis (x, y) Has (x, “Diagnosis”, “Diabetes”) z A table called observation with column (s) identifying patient x, observation type y and observation value z and a column of the value of Has (x, y, z) Different Representation of FirstOrder Logic z Conceptual Graph (CG) z Knowledge Interchange Format (KIF) z Conceptual Graph Interchange Format (CDIF) z ……….. Examples of Medical Knowledge z z z z z Nitrates are a safe and effective treatment that can be used in patients with angina and left ventricular systolic dysfunction. On the basis of currently published evidence, amlodipine is the calcium channel antagonist that it is safest to use in patients with heart failure and left ventricular systolic dysfunction. Coronary artery bypass grafting may be indicated, in some, for relief of angina All patients with heart failure and angina should be referred for specialist assessment. Patients with angina and mild to moderately symptomatically severe heart failure that is well controlled, and who have no other contraindications to major surgery, should be considered for coronary artery bypass grafting on prognostic (as well as symptomatic) grounds. Limitation z Real world sometimes can not be represented using logic z Induction and deduction model z Uncertainty and probability z Context and exception Alternatives z Case-based z Fuzzy reasoning (Analogy) logic z Nonmonotonic logic Extra Reading z Aho’s book chapter 14 z Sowa’s book p467-488