Title:
1??????
- semantics (???) ????????? method (??) ???????
- ??? (?) ????? method ?????????????
(??????????????) - ??? method ???????????
Specify ??????? illustrate ??????????
application ????????, ??
2????????
- semantics ?????????????????????
- ?????????????????????
- ? syntax ? semantics ????????????????
(???????????)
Represent ?? implementation ??, (??????)
analysis ??
3Syntax ? Semantics
- Syntax grammatical structure(??,??)
- parser ????????
- Semantics the meaning (??)
- ???????????????
Syntax analysis ????
4Semantics ?3????
- Operational semantics ???????
- Denotational semantics
- ?????????
- Axiomatic semantics
- ??????????????
Execute ???? Construct ?? (syntax
??????????) Effect ??, ?????
(????????????????????????) Statement ???
Sequence ??
5?
- z x x y y z
- (x ? y ????????????????)
Assign ???, ????, ????
6Operational semantics
- zx xy yz ???????????
- ? ???????????????????????
- ( ??????)
A variable followed by ? (??) ????????????
zx ?? z ????????????????
7Structual operational semantics
- ????????????????????????(small-step semantics)
- ????????????????????????????
- ??????????? derivation sequence ??? (P3 ???)
Abstraction ?? abstract ??? derivation
?? Derivation sequence ???????
8Natural semantics
- ??????????state (??) ?????????????????????
- ???? state ????????????????????? (big-step
semantic) - ????? state ???????????????derivation tree
(???) ??? (P.3 ???)
abbreviation ??
9Denotational semantics
- ???????????????????????? (P.4 ?????)
- ????z x ??z ????????????????
- ??????????????????????
- ???????????????????????? (Chapter 5 ???????????)
Reason ???? functional composition ????
apply ????
10Denotational Operational
- ???????? (?) ????? Denotational semantics ???
- ??????? implement (??) ???? Operational
semantics ??? - Operational ? Denotational ????????????? ?
Chapter 4.3 ??????
Equivalent ??? be adapt to ?????
11Axiomatic semantics
- ????????????? Precondition (????) ?
Postcondition (????) ???????????? - precondition construct postcondition
- ?????
- ????????????????????????????(???????????)
Partial ??????????????????(???????)?????
(????) total ??????, ????????????????
12Pre ?? Post ??????
- ????????????
- ????2???????????????????????????????????????????
????a, b, c ?????????? - a ! 0, b2 - 4ac gt 0
- ?2???????????????????precondition ???
Partial correctness property (?????????????????)
??????
13Pre ?? Post ??????
- ??????????(?) ????????? x ??????? (????)
???????????????? Postcondition ???
???????????? assertion ?????(????????????)
????????????????????????????????????????????!???
?????????????????? ? ?????????????????????? Precon
dition ?? Postcondition ? (???? axiomatic
semantics ?) ?????????????? construct
??????????????????????assertion ??????????????
14????? Axiomatic
- ???????????????????????????? (P.6 ???)
- ???? ????????????????????????????????? (P.6
???) - Axiomatic semantics ???????????????????????????
Specification ??(?)
15?????
- 3?? semantics ? While ????????
- 3?? semantics ??????? While ???????????????
- While (????) ?????3????????????
- ????????????????????????????????
3?? semantics ?????????????????????????????
16While ??
BNF ??????????????????(???????)
?????? Syntactic category ???? cf.????
???????? ??? ?? ????? ?? Meta-variables ????
???????????????syntactic category ?????? ????
???? n, (?????????)???? str ??????? Range over
????, (??, ?????????) Numeral (syntactic
category ????) ? Arithmetic expressions ?????
(???) ??????? (?????) Boolean expressions
????????????? (?????) Statement ???
17While ??
- ????????????????????????????????? (syntax tree)
?????????? - ???????????? (?????????)
- ?????????????????? syntactic category
????????????? - ? () ?????????????
- ? ??????? - and or not ????????????????????
Primed ???????? subscripted ?????????
string (??????) ??? digit (??????) ??
Letter ?? (???????) Basis element ???? b ?
expression ???? b ??????? Composite element ????
b ? expression ???? b ?????
18While ??
- While ?? (??????????) ?????Semantic function
(????, ??) ????????? - Semantic function ???????????????
Entity ?? (syntax ?????????????) assume
???? Syntactic entity (syntax ??????????????)
argument ?? Assign ????????? Semantics
function ???? ????????P.7 ? syntax
??????????? (syntactic entity) ?????????????
(???????????????) ???????? (??????)
19???? Semantics
- ??!!
- ?????????numerals ?2???????
- ??????10???????????????2????????????????????????
???
Binary system 2??
20??????????
- P.9 ?????
- ? syntactic entity ? semantics (meaning)
????????????????? (????????????????) - ?????????????????????
Number (???????10???) ? Total function
??????????????????????? clause ? bracket
???? (???????, ??????????????????) Corresponding
(???1?1?) ???? application ?? Semantics
clause ???????????? P.10 ?????????????????? Equa
tion ???
21N ????????
- P.10 ??????
- P.9 ? numeral ??????????????
- ? ?????????? syntax ???
- (???? syntax ??????????????????)
- ? ???? semantics (meaning) ???????????????????
- ??????? syntactic entity ????? semantics ???
(?????????)
Compositional definition ???? Obtain ??
Subconstruct construct ???, ???
22N ? well-defined ?????
Well-defined ??????????? cf. ????? Induction
?????? Base case ????????????? Induction
step n ????????????n ???? ???? Hypothesis
?? Hold ?????, ???? Omit ?? ex. The case ?
is similar and we omit the details.
23Compositional definition
- syntactic category ? basis element ? composite
element ?????(???)????????? - syntactic category ???? element ?????semantic
clause ??????Composite element ???????????????????
??
Immediate constituents of the element Composite
element ??????????? syntactic category ???????
????????????? ????b ?????b1 b2 ? b1 ? b2 ????
24Compositional Definition
- composite element ?????????????? syntactic
category ???????? - ??????????????????????
- ? composite element ????????????????? basis
element ????????????! - ????????(?????)
Immediate constituents of the element Composite
element ??????????? syntactic category ???????
????????????? ????b ?????b1 b2 ? b1 ? b2 ????
25Structual Induction
- compositional definition ??????
- ???basis element ???????????????
- ???composite element ??immediate constituents
of the elements ?????????????? (induction
hypothesis) ?????????
Structual Induction ????? ? ????? numeral
???10?????
26Semantic function
- ????????(?)?????
- ? ????????????????????
Semantic function ????
27State
- ??????????????????
- ?? ???? (state ??????????)
- ?? s ??? x ??????????
- s x
- ???
- ??????????????????
State ??, ??
28???? A
- expression ? state ??????????
- ? expression ? state ????????????? (A) ?????
- p.9 ??????A ? AExp ?????state
??????????????????????state???????????????????? - ???? ? ?????????
Functionality ???, ?
29???? A
- ???? (??) ??? p.10 ???
- Compositional Definition ????????? A
???????????????? syntactic entity ???? (immediate
?) ?????? - ????????????????????????? semantic
???????????? (??????????)
Sum ? product ? difference ?