




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
LogicinComputerScience
YongmeiLiu
ymliu@
Dept,ofComputerScience
SunYat-senUniversity
December14,2009
Y.LiuLogicinComputerScience1/41
Introductionandoutline
FocusonapplicationsoflogicincomputerScience
JSATsolversandapplications
JProgramverification
」Modelchecking
口Cognitiverobotics
Y.LiuLogicinComputerScience2/41
Amotivatingexample
WewouldliketoselectpeoplefromAnn,Bob,CarolandDanfora
certainjob.Thefollowingconstraintsmustbesatisfied:
■BoborCarolshouldbeselected
aAnnandDancannotbebothselected
aIfBobisselected,Danshouldalsobeselected
Howshouldweselectthepeople?
(6Vc)A(-»QV「d)AVd)
{B,D}
Whatifwehavemanypeopleandmanyconstraints?
Y.LiuLogicinComputerScience3/41
WhatisSAT?
aAliteralisanatomorthenegationofanatom
aAclauseisadisjunctionofliterals
aAformulaisinConjunctiveNormalForm(CNF)ifitisa
conjunctionofclauses
aExample:(5Vc)A(->aV->d)A(T)Vd)
flSAT:GivenapropositionalformulainCNF,decideifthere
existsatruthassignmentthatsatisfiestheformula
Y.LiuLogicinComputerScience4/41
Timecomplexityofalgorithms
Expressedintermsofthenumberofoperationsused
aDecideifatruthassignmentsatisfiesaCNFformula:O(m)
aNaivealgorithmtosolveSAT:O^2nm)
n-thenumberofatoms,m-thelengthoftheformula
Thecomputertimeusedbyalgorithms
ProblemSizeBitOperationsUsed
nnnlog/7n12”
103X10-9s10-8s3XIO-8sKT?5|o-6§
IO27x10-9$10-7§7x)0"7sIO_5s4X10"yr
1031(0X10%IO-6s1X10-5sICT?§*
IO4l(3XIO-8sIO-s1X10-%10Ts*
IO5l(7xIO-8sIO_4s2XIO_3s10s♦
IO62x10-8$10-3$2X10-%17min*
*:morethanIO100years
Y.LiuLogicinComputerScience5/41
Pvs.NP
aP:theclassofproblemsforwhichthereexistsaprocedure
thatrunsinpolynomialtime
aExample:decideifatruthassignmentsatisfiesaformula
flNP:theclassofproblemswherewearesearchingforanitem
inalargespaceofpossibilities,butwherewecantestifa
candidateitemisasolutioninpolynomialtime
aExample:decideifapropositionalformulaissatisfiable
■P=NP?OneofthesevenMillenniumPrizeProblems
selectedbytheClayMathematicsInstitutetocarryaUS$
1,000,000prizeforthefirstcorrectsolution.
aItisgenerallyacceptedthatP*NP
Y.LiuLogicinComputerScience6/41
NPCompleteness
aAproblemisNP-completeifitisinNPandanyproblemin
NPcanbereducedtoitinpolynomialtime
aifanyNP-completeproblemisinP,thenP=NP
aSATisaclassicalNP-completeproblem,soanyproblemin
NPcanbereducedtoSATinpolytime
aTherearethousandsofcomputationalproblemsofeconomic
significancethatareknowntobeinNP
aStephenCookreceivedthe1982Turingawardforhisworkon
NP-completeness
Y.LiuLogicinComputerScience7/41
TheDPLLprocedure
NamedaftertheauthorsDavis,Putnam,Logemann,andLoveland
dpll(F):
JIfthesetofclausesFisempty,return1
JIfFcontainsanemptyclause,return0
JIfFcontainsaunitclauseMtreturndpl(M,F)
asimplifyFusingM,getG,returndpll(G)
hJChooseanatomA
Jreturndpl(A,F)Vdpl(->A,F)
Example:(feVc)A(->QV->d)A(-Vd)
CompleteSATsolver
Y.LiuLogicinComputerScience8/41
TheGSATprocedure
aWestartwitharandomtruthassignmenttoallatoms,
aandthenstartchangingthetruthofcertainatomsuntil
aweeitherobtainasatisfyingassignmentorgiveupandtry
again(uptoamaximum)
aGSAToftenoutperformsdpll
aIncompleteSATsolver
Y.LiuLogicinComputerScience9/41
ProgressofSATsolvers
a1960-2010,about50yearshistory
■1995-2010,significantgrowthandsuccessinSATsolver,
researchbasedonDPLL
aThenumberofvariables:10—>106
aManypracticalapplicationsemerged,pushsolverstotheir
limits,andmotivatemoreefficientalgorithm
aNewtechniquesforSATsolversemergeoneaftertheother
aGRASP(1996):thepioneerof2ndgenerationofSATsolver
aCHAFF(2001):carefulengineeringallaspectsofthesearch
Y.LiuLogicinComputerScience10/41
TheN-queensproblem
GivenNqueensandanNxNchessboard,
findawayofplacingthosequeensinsuch
awaythatnoneofthemcanattackanyof
theothers.
eachqueenmustbe
onitsown
,row
•column
,leftdiagonal\
•rightdiagonal/
Y.LiuLogicinComputerScience11/41
EncodingtheN-queensinSAT
Weillustratethecasewheren=8
Introduce8x8atomsp»jsaying
"thereisaqueenatrowiandcolumnj”
aThereisatleast1queenoneveryrow
AL1Vj=lPij
aThereisatmost1queenoneveryrow
Ai=lAj=lAfc=J+lVrpik)
aThereisatleast1queenoneverycolumn
aThereisatmost1queenoneverycolumn
aThereisatmost1queenoneveryleftdiagonal
aThereisatmost1queenoneveryrightdiagonal
Y.LiuLogicinComputerScience12/41
RunningtheN-queens
Ingeneral,theprocedureweuseisthis:
1.wereadtheprobleminput(inthiscase,justn)
2.weconstructtheclausalformulaF
3.wecallaSATsolver
4.wetranslatethesatisfyingtruthassignment
backintothedesiredproblemoutput
Allbutstep(3)shouldbedoneinpolynomialtime.
FortheN-queens,ifwerunaSATsolverforn=8,we
willgetbackatruthassignmentwithexactly8ofthe
64atomstrue.
onesuchisthefollowing:
Pll'P25,P3*P46'P53'P72'PM
(thisisthefirstsolutioninleft-to-rightorder)
Fornlargerthan20or30,dpssrunsintodifficulties
Butgsatcansolvetheseforninthethousands.
Y.LiuLogicinComputerScience13/41
SudokupuzzlerrFn
Givenapartiallyfilled9x9
gridT,fillTwithdigitss.t.L7—LLi
I1ri
aeachcolumn,4
aeachrow,L_j
aeachofthenine3x3Kr
sub-grids28
containsallofthedigitsfromLLL6j
1to9.
Y.LiuLogicinComputerScience14/41
EncodingSudokuinSAT
Introduce9x9atoms:sxyzdenotesfilling(x,y)withdigitz
a(x,y)hasbeenfilledwithz:sxyz
aEachgridcanbefilledwithatmostonedigit
Ax=lA?;=1Az=lAc=z+1(「SsyzVF"如)
aEachdigitappearsatleastonceineachcolumn
A:=lAz=lVx=lSxyz
aEachdigitappearsatleastonceineachrow
Ax=l及Z=\V;=lSXyz
aEachdigitappearsatleastonceineach3x3sub-grid
/\i=0A/=0/\x=lAy=lVz=:lS(3e+i)(3j+g)z
□►《闫
室><考,
Y.LiuLogicinComputerScience15/41
Outline
iJSATsolversandapplications
hJProgramverification
,JModelchecking
hJCognitiverobotics
Y.LiuLogicinComputerScience16/41
Amotivatingexample
Socomputestheintegerdivisionofxandy
1.a:=0;
2.b:=x;
3.while(b>=y)do
4.b:=b-y;
5.a:=a+1;
6.od
Howtoensureourselvesthattheprogramiscorrect?
Y.LiuLogicinComputerScience17/41
Hoarelogic
aIn1969,Hoareintroducedanaxiomaticmethodofproving
programcorrectness
aHoareintroducedthenotationof{p}S{(/}(calledHoare
triples),whereSisaprogram,andp,qareformulasina
first-orderlanguage.
aTheintuitivemeaningof{p}S{(/}:ifpholdsbeforethe
executionofSandtheexecutionofSterminates,thenq
holdsafterwards.
Y.LiuLogicinComputerScience18/41
Aproofsystem
」AssignmentAxiom
{pQ/。}立:=t{p},
JCompositionRule
{p}Si{r},{r}S2{q}
{p}5i;52{<?}'
■if-then-elseRule
{p八e}Si{q},{pAf}S?{q}
{p}ifethenS\elseS?fi{q}
.JwhileRule
_______{pAe}S{p}_______
{p}whileedoSod{pA-»e}
hlConsequenceRule
PTPl,{Pl}S{qi},qiTq
{0}S{q},
Y.LiuLogicinComputerScience19/41
Anexampleproof
Wewanttoprove{x>0A>0}S(){Q-y+b=x/\0<b<y}
ByComp,itsufficestoprovethefollowing:
(1){x>Q/\y>0}a:=0]b:=x{a-y+b=x/\0<b}
Cons(3,6)
(3)rr>0A7/>0—>0-?/+rr=3rA0<:r
(4){0①}a:=0{a-y+x=xf\0<x}Assn
(5){a•yx=x/\0<x}b:=x{ayb=x/\0<b}Assn
(6){0•y+1=①A0W①}a:=0]b:=x{a-y-\-b=x/\0<b}
Comp(4r5)
(2){a-y+b=x/\0<b}whileloop{a-y+b=x/\0<b<y}
Thekeyistofindtheloopinvarianta-yb=x/\0<b
Y.LiuLogicinComputerScience20/41
Anexampleproof(2)
Wenowprove
(2){ayb=x/\0<b}whileloop{a-y-\-b=x/\0<b<y}
ByWhile,itsufficestoprove
(7){a-y-^-b=x/\0<b/\b>y}
b:=b—y;a:=a+1{a-yh=xf\0<h}Cons(8,ll)
(8)a-y+b=x/\0<b/\b>y—>(a^iyy+b—y=x/\b-y>0
(9){(a+l)-y+6—y=a:A5—y>0}b:=b—y
{(a+l).g+b=i八吐0}Assn
(10){(a+l)-y+b=xA6>0}a:=a+l
{a-y-\-b=x/\b>0}Assn
(11){(a+l)-y+b—y=x/\b-y>0}b:=b—y;a:=a+1
{a'yb=x/\b>0}Comp(9,10)
Y.LiuLogicinComputerScience21/41
Outline
iJSATsolversandapplications
」Programverification
」Modelchecking
hJCognitiverobotics
Y.LiuLogicinComputerScience22/41
Amotivatingexample
aWhenconcurrentprocessessharearesource,wemayneedto
ensurethattheydonothaveaccesstoitatthesametime.
aForexample,wedonotwantseveralprocessestoeditthe
samefileatthesametime.
aWeidentifycertaincriticalsectionsofeachprocess*code,and
ensurethatonlyoneprocesscanbeinitscriticalsectionata
time.
aWewanttofindaprotocolfordeterminingwhichprocessis
allowedtoenteritscriticalsectionatwhichtime.
Y.LiuLogicinComputerScience23/41
Desiredpropertiesoftheprotocol
」Safety:onlyoneprocessisinitscriticalsectionatanytime.
」Liveness:wheneveranyprocessrequeststoenteritscritical
section,itwilleventuallybepermittedtodoso.
」Non-blocking:aprocesscanalwaysrequesttoenterits
criticalsection.
」Nostrictsequencing:processesneednotentertheircritical
sectioninstrictsequence.
Y.LiuLogicinComputerScience24/41
Threecomponentsofaformalverificationtechnique
」Aframeworkformodelingsystems
QAspecificationlanguagefordescribingsystemproperties
」Anautomaticverificationmethodtoestablishwhetherthe
systemmodelsatisfiesthespecification
Y.LiuLogicinComputerScience25/41
Amodelformutualexclusion
Eachprocesshas3states:n(non-criticalstate),
t(tryingtoentercriticalstate),c(criticalstate)
Y.LiuLogicinComputerScience26/41
AtransitionsystemM=(S,—L)
■asetofstatesS
■atransitionrelation—>(abinaryrelationonS)
■foreverys£Shassomes'eSwiths—>s'
■alabelingfunctionL:StP(Atoms)
1OQC
Y.LiuLogicinComputerScience27/41
Unwindingatransitionsystemtoaninfinitetree
Linear-timetemporallogic
a0::=p|-|0|0A欧|X,|F(j)|G(j)|0U欧
apisanypropositionalatom
aXmeans4neXtstate,
aFmeans'someFuturestate1
■Gmeans"allfuturestates(Globally)^
aUmeans'until'
Y.LiuLogicinComputerScience29/41
Branching-timelogic:CTL
.0::=p|w0A@|AX(j)IEX6IAF(I)IEF@\
AG。|EG@|A[(j)U^]|司型
aAmeans4forAllpaths'
aEmeans*thereExistsonepath,
0><&)><复*<建>>W)AC
Y.LiuLogicinComputerScience30/41
Representingthepropertiesintemporallogic
」Safety:onlyoneprocessisinitscriticalsectionatanytime.
AC2)
口Liveness:wheneveranyprocessrequeststoenteritscritical
section,itwilleventuallybepermittedtodoso.
G(ti—>Fei)AG&2tFC2)
」Non-blocking:Aprocesscanalwaysrequeststoenterits
criticalsection.
4Gdi-EXti)A4Gs2-EXt2)
」Nostrictsequencing:processesneednotentertheircritical
sectioninstrictsequence.
EF©A(->5AE[->C2(7CI])])
Y.LiuLogicinComputerScience31/41
Verifyingtheproperties
9G-|(C1AC2),TfCi)AG2TFc2)
aAG(mtEXti)AAG{n2tEXg)
aEF(c\AE[ciU(-*ciAE[-iC2Uci])]]
Y.LiuLogicinComputerScience32/41
Modelcheckingalgorithms
aCheckwhetheragiventransitionsystemsatisfiesagiven
temporalformula
aLTLandCTLmodelcheckingcanbedoneintime。⑹,
wherenisthesizeofthetransitionsystem
aThestateexplosionproblem:thesizeofthetransitionsystem
isexponentialinthenumberofstatevariables
aApproacheshavebeendevelopedtocombattheproblem
asymbolicmodelchecking
aboundedmodelchecking
aClarke,Emerson,andSifakissharedthe2007TuringAward
fortheirworkonmodelchecking.
Y.LiuLogicinComputerScience33/41
Outline
iJSATsolversandapplications
」Programverification
,JModelchecking
JCognitiverobotics
Y.LiuLogicinComputerScience34/41
Roboticsvs.cognitiverobotics
aRoboticshastraditionallyemphasizedlow-levelsensingand
controltasksincludingsensoryprocessing,pathplanning,and
manipulatordesignandcontrol.
aCognitiveroboticsisconcernedwithendowingrobotsand
softwareagentswithhigherlevelcognitivefunctionsthat
enablethemtoreason,actandperceiveinchanging,
incompletelyknown,andunpredictableenvironments.
aSuchrobotsmust,forexample,beabletoreasonaboutgoals,
actions,whentoperceiveandwhattolookfor,thecognitive
statesofotheragents,etc.
Y.LiuLogicinComputerScience35/41
Cognitiverobotics
aThestudyofknowledgerepresentationandreasoning
problemsfacedbyanautonomousrobot(oragent)ina
dynamicandincompletelyknownworld.
aCentraltothiseffortistodevelopanunderstandingofthe
relationshipbetweentheknowledge,theperception,andthe
actionofsucharobot.
aThegoalishigh-levelroboticcontrol:developasystemthatis
capableofgeneratingactionsintheworldthatareappropriate
asafunctionofsomecurrentsetofbeliefsanddesires.
Y.LiuLogicinComputerScience36/41
Representingadynamicworld:situationcalculus
aActions:puton(x、y)andputonTable(x)
aSituations:S。,do{puton(C,A),So),
aFluents:on(C,D,So),A,do(puton(C^A),So))
aActionpreconditionaxioms:
Poss(puton(x、y),s)=clear(x)Aclear(y\
aSuccessorStateAxioms:
O7z(c,y,do(a,s))三Q=puton(x,y)V
y、s)A->a=putonTable(x)A~^(3z)a=pn,t(m(x,z),
Y.LiuLogicinComputerScience37/41
Twobasicreasoningtasks
LJTh
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- Brand KPIs for online betting:22Bet in Germany-英文培训课件2025.5
- DeepSeek+辅导教育应用场景规划方案
- 让学生走出自卑、秀出自己的教育案例分析
- 向华为公司学习绩效管理(一)12P
- 现代设计史试题及答案
- 物理模拟试题及答案
- 2025年河南省南阳市桐柏县中考三模数学试题(含答案)
- (期末培优卷)期末常考易错培优卷-2024-2025学年五年级下学期数学(含解析)
- 2025年购车贷款合同模板示例
- 构建有效的工程设计质量控制体系
- 2014国家电缆桥架标准
- 临床常见检验指标
- 标准物质管理与应用
- 【图文】做个受欢迎的人
- 面试成绩通知单(上下联式)
- 2009吉林省职称评审表(共4页)
- 最新小学生成长记录(课堂PPT)
- LNG饱和曲线图
- 地质灾害治理工程施工记录用表(最新整理
- 水池满水试验记录表(自动计算)
- 山洪灾害防御
评论
0/150
提交评论