Inroducion o Sofware Tesing Chaper 3.6 Disjuncive Normal Form Crieria Paul Ammann & Jeff Offu hp://www.cs.gmu.edu/~offu/sofwarees/
Disjuncive Normal Form Common Represenaion for Boolean Funcions Slighly Differen Noaion for Operaors Slighly Differen Terminology Basics: A lieral is a clause or he negaion (oversrike) of a clause Examples: a, a A erm is a se of lierals conneced by logical and and is denoed by adjacency insead of Examples: ab, ab, ab for a b, a b, a b A (disjuncive normal form) predicae is a se of erms conneced by or or is denoed by + insead of Examples: abc + ab + ac Terms are also called implicans If a erm is rue, ha implies he predicae is rue Inroducion o Sofware Tesing (Ch 3) Ammann & Offu 2
Implican Coverage Obvious coverage idea: Make each implican evaluae o rue. Problem: Only ess rue cases for he predicae. Soluion: Include DNF represenaions for negaion. Implican Coverage (IC) : Given DNF represenaions of a predicae f and is negaion f,, for each implican in f and f,, TR conains he requiremen ha he implican evaluae o rue. Example: f = ab + bc f = b + ac Implicans: { ab, bc, b, ac } Possible es se: {TTF, FFT} Observaion: IC is relaively weak Inroducion o Sofware Tesing (Ch 3) Ammann & Offu 3
Improving on Implican Coverage Addiional Definiions: A proper suberm is a erm wih one or more clauses removed Example: abc has 6 proper suberms: a, b, c, ab, ac, bc A prime implican is an implican such ha no proper suberm is also an implican. Example: f = ab + abc Implican ab is a prime implican Implican abc is no a prime implican (due o proper suberm ac) A redundan implican is an implican ha can be removed wihou changing he value of he predicae Example: f = ab + ac + bc ab is redundan Predicae can be wrien: ac + bc Inroducion o Sofware Tesing (Ch 3) Ammann & Offu 4
Unique True Poins A minimal DNF represenaion is one wih only prime, nonredundan implicans. A unique rue poin wih respec o a given implican is an assignmen of ruh values so ha he given implican is rue, and all oher implicans are false Hence a unique rue poin es focuses on jus one implican A minimal represenaion guaranees he exisence of a leas one unique rue poin for each implican Unique True Poin Coverage (UTPC) : Given minimal DNF represenaions of a predicae f and is negaion f,, TR conains a unique rue poin for each implican in f and f. Inroducion o Sofware Tesing (Ch 3) Ammann & Offu 5
Unique True Poin Example Consider again: f = ab + bc f = b + ac Implicans: { ab, bc, b, ac } Each of hese implicans is prime None of hese implicans is redundan Unique rue poins: ab: {TTT} bc: {FTF} b: {FFF, TFF, TFT} ac: {FTT} Noe ha here are hree possible (minimal) ess saisfying UTPC UTPC is fairly powerful Exponenial in general, bu reasonable cos for many common funcions No subsumpion relaion wr any of he ACC or ICC Crieria Inroducion o Sofware Tesing (Ch 3) Ammann & Offu 6
Near False Poins A near false poin wih respec o a clause c in implican i is an assignmen of ruh values such ha f is false, bu if c is negaed (and all oher clauses lef as is), i (and hence f) evaluaes o rue. Relaion o deerminaion: a a near false poin, c deermines f Hence we should expec relaionship o ACC crieria Unique True Poin and Near False Poin Pair Coverage (CUTPNFP) : Given a minimal DNF represenaion of a predicae f,, for each clause c in each implican i,, TR conains a unique rue poin for i and a near false poin for c such ha he poins differ only in he ruh value of c. Noe ha definiion only menions f, and no f. Clearly, CUTPNFP subsumes RACC Inroducion o Sofware Tesing (Ch 3) Ammann & Offu 7
Consider f = ab + cd CUTPNFP Example For implican ab, we have 3 unique rue poins: {TTFF, TTFT, TTTF} For clause a, we can pair unique rue poin TTFF wih near false poin FTFF For clause b, we can pair unique rue poin TTFF wih near false poin TFFF For implican cd, we have 3 unique rue poins: {FFTT, FTTT, TFTT} For clause c, we can pair unique rue poin FFTT wih near false poin FFFT For clause d, we can pair unique rue poin FFTT wih near false poin FFTF CUTPNFP se: {TTFF, FFTT, TFFF, FTFF, FFTF, FFFT} Firs wo ess are unique rue poins; ohers are near false poins Rough number of ess required: # implicans * # lierals Inroducion o Sofware Tesing (Ch 3) Ammann & Offu 8
DNF Faul Classes ENF: Expression Negaion Faul f = ab+c f = ab+c TNF: Term Negaion Faul f = ab+c f = ab+c TOF: Term Omission Faul f = ab+c f = ab LNF: Lieral Negaion Faul f = ab+c f = ab+c LRF: Lieral Reference Faul f = ab + bcd f = ad + bcd LOF: Lieral Omission Faul f = ab + c f = a + c LIF: Lieral Inserion Faul f = ab + c f = ab + bc ORF+: Operaor Reference Faul f = ab + c f = abc ORF*: Operaor Reference Faul f = ab + c f = a + b + c Key idea is ha faul classes are relaed wih respec o esing: Tes ses guaraneed o deec cerain fauls are also guaraneed o deec addiional fauls. Inroducion o Sofware Tesing (Ch 3) Ammann & Offu 9
Faul Deecion Relaionships Lieral Inserion Faul LIF Term Omission Faul TOF Operaor Reference Faul ORF+ Lieral Reference Faul LRF Lieral Negaion Faul LNF Term Negaion Faul TNF Lieral Omission Faul LOF Operaor Reference Faul ORF* Expression Negaion Faul ENF Inroducion o Sofware Tesing (Ch 3) Ammann & Offu
Undersanding The Deecion Relaionships Consider he TOF (Term Omission Faul) class UTPC requires a unique rue poin for every implican (erm) Hence UTPC deecs all TOF fauls From he diagram, UTPC also deecs: All LNF fauls (Unique rue poin for implican now false) All TNF fauls (All rue poins for implican are now false poins) All ORF+ fauls (Unique rue poins for joined erms now false) All ENF fauls (Any single es deecs his ) Alhough CUTPNFP does no subsume UTPC, CUTPNFP deecs all faul classes ha UTPC deecs (Converse is false) Consider wha his says abou he noions of subsumpion vs. faul deecion Lieraure has many more powerful (and more expensive) DNF crieria In paricular, possible o deec enire faul hierarchy (MUMCUT) Inroducion o Sofware Tesing (Ch 3) Ammann & Offu
Karnaugh Maps for Tesing Logic Expressions Fair Warning We use, raher han presen, Karnaugh Maps Newcomer o Karnaugh Maps probably needs a uorial Suggesion: Google Karnaugh Map Tuorial Our goal: Apply Karnaugh Maps o conceps used o es logic expressions Idenify when a clause deermines a predicae Idenify he negaion of a predicae Idenify prime implicans and redundan implicans Idenify unique rue poins Idenify unique rue poin / near false poin pairs No new maerial here on esing Jus fas shorcus for conceps already presened Inroducion o Sofware Tesing (Ch 3) Ammann & Offu 12
K-Map: A clause deermines a predicae Consider he predicae: f = b + ac + ac Suppose we wan o idenify when b deermines f The dashed line highlighs where b changes value If wo cells joined by he dashed line have differen values for f, hen b deermines f for hose wo cells. b deermines f: ac + ac (bu NOT a ac or ac) Repea for clauses a and c c ab 00 01 0 1 Inroducion o Sofware Tesing (Ch 3) Ammann & Offu 13
K-Map: Negaion of a predicae Consider he predicae: f = ab + bc Draw he Karnaugh Map for he negaion Idenify groups Wrie down negaion: f = b + a c c ab 00 01 c ab 00 01 0 0 1 1 Inroducion o Sofware Tesing (Ch 3) Ammann & Offu 14
K-Map: Prime and redundan implicans Consider he predicae: f = abc + abd + abcd + abcd + acd Draw he Karnaugh Map Implicans ha are no prime: abd, abcd, abcd, acd Redundan implican: abd Prime implicans ab Three: ad, bcd, abc 00 01 cd The las is redundan Minimal DNF represenaion 00 f = ad + bcd 01 Inroducion o Sofware Tesing (Ch 3) Ammann & Offu 15
K-Map: Unique True Poins Consider he predicae: f = ab + cd Three unique rue poins for ab TTFF, TTFT, TTTF TTTT is a rue poin, bu no a unique rue poin Three unique rue poins for cd FFTT, FTTT, TFTT Unique rue poins for f ab cd 00 01 f = ac + bc + ad + bd 00 FTFT,TFFT, FTTF, TFTF Possible UTPC es se 01 f: {TTFT, FFTT} f: {FTFT, TFFT, FTTF, TFTF} Inroducion o Sofware Tesing (Ch 3) Ammann & Offu 16
K-Map: Unique True Poin/ Near False Poin Pairs Consider he predicae: f = ab + cd For implican ab For a, choose UTP, NFP pair TTFF, FTFF For b, choose UTP, NFP pair TTFT, TFFT For implican cd For c, choose UTP, NFP pair FFTT, FFFT For d, choose UTP, NFP pair FFTT, FFTF Possible CUTPNFP es se {TTFF, TTFT, FFTT //UTPs FTFF, TFFT, FFFT, FFTF} //NFPs ab cd 00 00 01 01 Inroducion o Sofware Tesing (Ch 3) Ammann & Offu 17