日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

第五课 formal method 的课件和翻译,原来老师用latex打印的,pdf转成markdown,之后翻译的

發布時間:2025/3/18 编程问答 12 豆豆
生活随笔 收集整理的這篇文章主要介紹了 第五课 formal method 的课件和翻译,原来老师用latex打印的,pdf转成markdown,之后翻译的 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

COMP 313 - Formal Methods

Lecture 5 : FunctionsinZ

MartinZimmermann(UniversityofLiverpool)

Planfor theWeek

Monday:Sets Tuesday:Functions Whatisafunction? Whattypesoffunctionsexist? HowarefunctionsmanipulatedinZ? Wednesday:Schemas

Introduction

Likesets,theconceptoffunctionsisusedthroughout
mathematics.Intuitively,afunctionisarelationbetweentwo
setsT 1 andT 2 thatassignstoelementsinT 1 asingleelementin
T 2 .Thus,wecanunderstandelementsinT 1 asinputsand
elementsinT 2 asoutputs.

Examples

1. Everypersonhasadateofbirth. 2. Assigntoapersonthenameoftheirfirst-bornchild. 3. Aphonebookassignsphonenumberstopersons. 4. Thefunctionmappingarealnumberxto 2 x. 5. Thefunctionmappingarealnumberxtox^2.

ClassesofFunctions

Notethedifferentpropertiesofthesefunctions:

Everybodyhasadateofbirth,butnotnecessarilyachild. Manypersonssharethesamedateofbirth. Everyrealxyieldsaunique 2 x,but 12 =(? 1 )^2. Everyrealyisoftheformy= 2 xforsomex,butthereisno realxwithx^2 =? 1.

Therearevariousclassesoffunctionsthatcapturetheseproperties.

RepresentingFunctions

Asimplewaytorepresentafunctionistouseasetofpairs(x,y)
wherexistheinputandyistheoutput.

Example
ConsiderasimplephonebookfortheCSdepartmentwithentries

Name Number Louwe 4293 Toan 8858

Wecanrepresentthisfunctionastheset

PB=={(Louwe, 4293 ),(Toan, 8858 )}.

Withthisdefinition,wewrite

PB(Louwe)= 4293 and PB(Toan)= 8858.

APitfall

Noteverysuchsetofpairsinducesafunction!

Example
Considertheset

PB=={(Louwe, 4293 ),(Louwe, 4294 )}.

WhatisPB(Louwe)then?

Functionshaveauniquenessproperty:everypossibleinputtothe
functionmusthaveatmostoneassociatedoutput.Thus,no
elementcanappearasfirstentryintwodifferentpairs.

Aside
Thisdoesnotmeanthatonecannotdefineafunctionassigning
multiplephonenumberstopersons:But,onehastomappersons
tosetsofphonenumberstodoso.

PartialFunctions

Themostgeneralkindoffunctionweconsiderarepartial
functions.

Definition

ApartialfunctionfromasetT 1 toasetT 2 isasubset
f ?T 1 ×T 2 suchthattheuniquenesspropertyissatisfied:forall
(x,y)∈f and(x′,y′)∈f,ifx=x′thenalsoy=y′.
ThesetofallpartialfunctionsfromT 1 toT 2 isgivenbythe
expressionT 1 →% T 2.

Properties

Iff ∈(T 1 →% T 2 )thenf maybeundefinedforsomevaluein T 1 ,i.e.forallx∈T 1 thatarenotthefirstcomponentof somepairinf. ?∈(T 1 →% T 2 ),i.e.theemptysetisapartialfunction,which isundefinedforeveryx∈T 1.

Domain andRange

Therearetwoimportantsetsassociatedwithapartialfunction
fromT 1 toT 2 :

Domain:thesetrepresentingallinputvaluesforwhichthe functionisdefined,whichisasubsetofT 1. Range:thesetrepresentingalloutputsofthefunctionthat correspondtoadefinedinput,whichisasubsetofT 2.

Definition

Iff isapartialfunctionthen

domf

denotesthedomainoff and

ranf

denotesitsrange.

Domain andRange viaSetComprehension

Thedomainandrangeofapartialfunctionf fromT 1 toT 2 can
formallybedefinedviasetcomprehension:

domf=={x:T 1 |?y:T 2 ? ((x,y)∈f)}

and

ranf =={y:T 2 |?x:T 1 ? ((x,y)∈f)}

Nevertheless,itisconvenienttohavededicatednotationforthese
sets.

Domain andRange: Properties

Example
IfPB=={(Louwe, 4293 ),(Toan, 8858 )}then

domPB={Louwe,Toan} and ranPB={ 4293 , 8858 }.

Usefulproperties

#domf ≥ #ranf dom(f∪g) = (domf)∪(domg) ran(f∪g) = (ranf)∪(rang) dom(f∩g) ? (domf)∩(domg) ran(f∩g) ? (ranf)∩(rang) dom? = ? ran? = ?

TotalFunctions

Somepartialfunctionshavethepropertyofbeingdefinedforall
potentialinputvalues:thesearetotalfunctions.

Definition

Iff ∈T 1 →% T 2 anddomf =T 1 ,thenf issaidtobeatotal
functionfromT 1 toT 2 .ThesetoftotalfunctionsfromT 1 toT 2
isgivenbytheexpressionT 1 →T 2.

ThesetT 1 →T 2 oftotalfunctionsfromT 1 toT 2 canalsobe
definedusingsetcomprehension:

T 1 →T 2 == {f :T 1 →% T 2 |domf =T 1 }

Functions withMultipleArguments

Whathappensifafunctiontakesmorethanoneargument?

Thenwesaythatthefunctiontakesjustoneinput,fromthe
cartesianproductoftheinputargumenttypes.

ExampleThefunctionplustakestwointegersasinputs,adds
themtogetherandreturnstheresult,i.e.

plus:Z×Z→Z

Ingeneral,theexpressionf 😄 1 ×···×Dm→R 1 ×···×Rnwhich
specifiesthetypeofthefunctionf iscalledthesignatureoff.

Injections

Definition

Afunctionf isone-to-oneifandonlyifforall(x,y)∈f and
(x′,y′)∈f,ifx∕=xtheny∕=y′,i.e.,everyelementinthedomain
mapstoadifferentelementintherange.One-to-onefunctionsare
alsocalledinjections.

Example
Ourphonebook

{(Louwe, 4293 ),(Toan, 8858 )}

isaninjectionwhereasthefollowingfunctionisnot:

{(Louwe, 4293 ),(Toan, 4293 )}

Surjections

Definition

Afunctionf fromT 1 toT 2 isontoifandonlyifeverypossible
elementy∈T 2 hassomecorrespondingvaluex∈domf suchthat
f(x)=y.Functionsthatare‘onto’arealsocalledsurjections.

Example
SupposeT 1 =={a,b,c,d}andT 2 =={e,f,g}.Then,

f 1 =={(a,e),(b,f),(c,g)}

isasurjectionwhereasthefunction

f 2 =={(a,e),(b,f)}

isnotasurjection,asthereisnoinputx∈domf 2 suchthat
f 2 (x)=g.

Notation for Functions

Finally,ifafunctionisbothaninjectionandasurjection,thenitis
calledabijection.

NotationforthedifferentclassesoffunctionsinZ:

constructor class →% partialfunctions → totalfunctions ?→% partialinjections ?→ totalinjections →→% partialsurjections →→ totalsurjections ?→→% partialbijections ?→→ totalbijections

Duringspecificationwehavetopicktherighttypeoffunctionto
implementdatastructureswithdesiredproperties.

The MapletNotation

Amoreconvenientandgraphicwayofwritingthefunction

{(Louwe, 4293 ),(Toan, 8858 )}

istowrite

{Louwe%→ 4293 ,Toan%→ 8858 }.

Thesymbol%→iscalledthemapletarrow:theexpression
Louwe%→ 4293 iscalledamaplet.

InZ,themapletnotationisjustsyntacticsugar.

Manipulating Functions

Aswedidforsets,weneedtointroduceoperatorsthattransform
functions.

Asfunctionsarejustsets,wecanusetheapparatusofsettheory
tomanipulatethem,e.g.,theunionoffunctions,providedthe
intersectionoftheirdomainsisempty.

However,therearecertainoperationswedosooftenthatitis
usefultodefineoperatorsforthem.Theseinclude

domainandrangerestriction, domainandrangesubtraction,and functionoverriding.

Domain Restriction

GivenourfunctionPBwhichmapsapersoninthedepartmentto
theirphonenumber,supposewewantedtoextractanother
functionwhichjustcontainedthedetailsoftheverificationgroup.

?isthedomainrestrictionoperator.

Definition

Supposef:T 1 →% T 2 isafunctionandS:IPT 1 isaset.Then,
S?f denotesthefunctionobtainedfromf byremovingfromitall
mapletsx%→ysuchthatx∕∈S.

Example

Let

PB == {Dominik%→ 4252 , Louwe%→ 4293 , Toan%→ 8858 }

and

S 1 =={Dominik,Louwe} S 2 =={Toan}

then

S 1 ?PB={Dominik%→ 4252 ,Louwe%→ 4293 }and S 2 ?PB={Toan%→ 8858 }.

Properties

Domainrestrictionviasetcomprehension:

S?f=={x:T 1 ;y:T 2 |(x∈S)∧(x%→y)∈f?x%→y}

Someproperties

dom(S?f) = S∩domf S?f ? f ??f = ?

RangeRestriction

Justaswecanrestrictthedomainofafunction,sowecanrestrict
itsrange.

?istherangerestrictionoperator.

Definition

Supposef:T 1 →% T 2 isafunctionandS:IPT 2 isasetthen
f?Sdenotesthefunctionobtainedfromf byremovingfromitall
mapletsx%→ysuchthaty∕∈S.

Example

Let

PB == {Dominik%→ 4252 , Louwe%→ 4293 , Toan%→ 8858 }

and

S 1 =={ 4252 , 8858 } S 2 =={ 4293 }

then

PB?S 1 ={Dominik%→ 4252 ,Toan%→ 8858 }and PB?S 2 ={Louwe%→ 4293 }.

Domain Subtraction

SupposewewanttotakePBandremovefromitallmembersof
theverificationgroup.

??isthedomainsubtractionoperator.

Definition

Supposef:T 1 →% T 2 isafunctionandS:IPT 1 isasetthen
S??f denotesthefunctionobtainedfromf byremovingfromitall
mapletsx%→ysuchthatx∈S.

Inshort:S??f==(domf\S)?f.

Example

Let

PB == {Dominik%→ 4252 , Louwe%→ 4293 , Toan%→ 8858 }

and

S 1 =={Louwe} S 2 =={Toan}

then

S 1 ??PB={Dominik%→ 4252 ,Toan%→ 8858 }and S 2 ??PB={Dominik%→ 4252 ,Louwe%→ 4293 }.

RangeSubtraction

Finally,thereisalsoarangesubtractionoperator??.

Definition

Supposef:T 1 →% T 2 isafunctionandS:IPT 2 isasetthen
f??Sdenotesthefunctionobtainedfromf byremovingfromitall
mapletsx%→ysuchthaty∈S.

Inshort:f??S==f?(ranf\S).

Example

Let

PB == {Dominik%→ 4252 , Louwe%→ 4293 , Toan%→ 8858 }

and

S 1 =={ 4293 } S 2 =={ 8858 }

then

PB??S 1 ={Dominik%→ 4252 ,Toan%→ 8858 }and PB??S 2 ={Dominik%→ 4252 ,Louwe%→ 4293 }.

FunctionOverriding

SupposewehavethefunctionPBthatgivespeoplesphone
numbers,andsomeonechangestheirextensionnumber—thenwe
wanttoreflectthisbychangingPB.

GivenPBaspreviouslydefined;whatexpressioncanweuseto
changeLouwe’snumberto 1111?

(PB\{Louwe%→ 1234 }) ∪ {Louwe%→ 1111 }

Zprovidesthe⊕symbolforfunctionoverriding:

PB⊕{Louwe%→ 1111 } = {Dominik%→ 4252 , Louwe%→ 1111 , Toan%→ 8858 }

FunctionOverriding

Thegeneraldefinitionallowstooverwritemultiplevaluesatonce.

Definition

Iff 1 :T 1 →% T 2 andf 2 :T 1 →% T 2 arefunctions(bothfromT 1 to
T 2 )thenf 1 ⊕f 2 denotesthefunctionthatresultsfromoverwriting
f 1 withf 2 :

f 1 ⊕f 2 ==(dom(f 2 )??f 1 )∪f 2.

COMP 313 - 形式方法

講座5:Z中的函數

馬丁-齊默爾曼(利物浦大學)

##本周計劃

星期一:套裝 星期二:功能 什么是性功能? Whattypesofffunctionsexist? HowarefunctionsmanipulatedinZ? 周三:方案

##介紹

例如,函數的概念貫穿于整個過程中。
數學.直觀地說,函數是兩個函數之間的關系。
集T 1和T 2,使T 1中的元素作為一個元素在
因此,我們可以把T 1中的元素理解為輸入和。
T 2中的元素作為輸出。

例子

1. Everypersonhasadateofbirth. 2. Assigntoapersonthenameoftheirfirst-bornchild。 3. Aphonebookassignsphonenumberstopersons. 4. Thefunctionmappingarealnumberxto2x。 5. Thefunctionmappingarealnumberxtox^2.

##函數類

Notthedifferentpropertiesofthesefunctions。

每個人都有出生日期,但不一定是孩子。 每個人都有相同的出生日期。 Everyrealxyields aunique 2 x,but 12 =(- 1 )^2. Everyrealyisoftheformy=2xforsomex,butthatthereisno? Realxwithx^2 =- 1.

有各種不同的函數類來捕捉這些屬性。

##表示函數

作為一個簡單的方法來表示一個函數,使用一組對子(x,y)
其中存在輸入和輸出。

例子
考慮為CS部門提供一個簡單的電話簿,其中有條目。

名稱編號 Louwe 4293 Toan 8858

我們可以把這個功能表示為一組。

PB=={(Louwe,4293 ),(Toan,8858 )}。

根據這個定義,我們寫

PB(Louwe)=4293,PB(Toan)=8858。

##APitfall

請注意這樣的對子集會引起功能!

例子
考慮到這組

PB=={(Louwe,4293 ),(Louwe,4294 )}。

那么什么是PB(Louwe)呢?

函數具有唯一性屬性:每一個可能的輸入都會被輸入到這個函數中。
因此,沒有任何一個功能是可以實現的,但必須有一個相關的輸出。
elementcanappearasfirstentryintwodifferentpairs.

除了
這并不意味著我們不能定義功能分配的功能。
多重號碼停止鍵:但是,一個人必須有一個應用程序的兒子。
tosetsofphonenumberstodoso。

##部分函數

最一般的功能,我們認為是部分的。
職能。

定義

ApartialfunctionfromasetT 1 toasetT 2 isasasubset
f ?T 1 ×T 2 suchthattheuniquenesspropertyissatisfied:for all
(x,y)∈f和(x′,y′)∈f,如果x=x′則也=y′。
從T 1到T 2的全偶函數集是由
表達式T 1 →% T 2.

屬性

Iff∈(T 1 →% T 2 )nf也許undefinedforsomevaluein。 T 1 ,即對于所有x∈T 1,不是第一成分的 somepairinf。 ?∈(T 1 →% T 2 ),即empty set是一個partialfunction,它的作用是 isundefinedforeveryx∈T 1.

Domain andRange

與輔助功能相關的有兩個重要的集合。
從T 1到T 2 。

域:代表所有輸入值的集合,其中的 函數的定義,它是T 1的一個子集。 Range:表示函數所有輸出的集合,它是T 1的一個子集。 對應于一個定義的輸入,它是T 2的一個子集。

###定義

如果是partialfunction,那么

domf

命名為 "域關 "和

跑步

表示它的范圍。

Domain andRange viaSetComprehension。

從T 1到T 2的apartialf函數f的域和范圍可以是
正式定義的Vaset理解。

domf=={x:T 1 |?y:T 2 - ((x,y)∈f)}。

ranf =={y:T 2 |?x:T 1 - ((x,y)∈f)}。

然而,為這些項目設立專門的注解是很方便的。
套。

Domain和Range。屬性

例子
如果PB=={(Louwe, 4293 ),(Toan, 8858 )}那么。

domPB={Louwe,Toan}和ranPB={ 4293 , 8858 }。

有用的屬性

#domf ≥ #ranf dom(f∪g) = (domf)∪(domg) ran(f∪g) = (ranf)∪(rang) dom(f∩g) ?(domf)∩(domg) ran(f∩g)?(ranf)∩(rang) dom? =? ran? = ?

TotalFunctions

某個部分函數有一個特性,即可以為所有的函數定義
potentialinputvalues:這些都是總的功能。

定義

Iff∈T 1 →% T 2且domf=T 1,則說f是打敗了總的。
從T 1到T 2的函數.從T 1到T 2的總函數的集合。
isgivenby theexpressionT 1 →T 2.

ThesetT 1 →T 2 oftotalfunctionsfromT 1 toT 2 canalsobe。
界定了我們的理解力。

T 1 →T 2 == {f :T 1 →% T 2 |domf =T 1 }。

帶有多個參數的函數。

如果一個函數需要更多的輸入怎么辦?

那么我們可以說,函數只需要一個輸入,來自于
輸入參數類型的卡提斯產品。

例子函數plust取兩個整數作為輸入值,添加了
他們一起,并返回其結果,即

加:Z×Z→Z

一般來說,表達式f:D 1×–×Dm→R 1×–×Rnich。
指定函數的類型,稱為 “特征關閉”。

注入

###定義

Afunctionf是一對一的,如果只有ifforall(x,y)∈f和
(x′,y′)∈f,ifx∕=xtheny∕=y′,即在域內的每個元素都是
mapstoadifferentlementintherange.One-to-on-efunctions are not the matter of the same.
也稱為注入式。

例子
我們的電話簿

{(盧維, 4293 ), (圖安, 8858 )}。

isaninjectionwhereasthefollowingfunctionisnot:

{(Louwe, 4293 ), (Toan, 4293 )}。

拋物線

###定義

從T 1到T 2的Afunctionf是ontoifandlyifeverypossible
elementy∈T 2 hassomecorrespondingvaluex∈domf such that.
f(x)=y. "到 "的函數也被稱為求函數。

例子
假設T 1 =={a,b,c,d},T 2 =={e,f,g}.那么。

f 1 =={(a,e),(b,f),(c,g)}。

是作為一個urjection,其中asthefunction

f 2 =={(a,e),(b,f)}。

isnotasurjection,asthereisnoinputx∈domf 2 such that
f 2 (x)=g.

##函數符號

最后,如果一個功能既是注射又是噴射,那么是
稱為 “jection”。

Notation for thedifferentclassesoffunctionsinZ:

構造函數類 →% partialfunctions →總函數 ?→%部分注射。 ?→總注射量。 →→% partialsurjections →→ 總數投射 ?→→% partialbijections ?→→總噴射量。

我們必須選擇正確的功能類型,以滿足我們的需求。
實現了有欲望屬性的數據庫。

MapletNotation

一個更方便和圖形化的方式來寫功能。

{(盧維, 4293 ), (圖安, 8858 )}。

撰寫

{Louwe%→4293 ,Toan%→8858 }.

符號%→稱為小地圖箭頭:表達式。
Louwe%→4293被稱為amaplet。

在Z中,mapletnotation就是syntacticsugar。

##操縱函數

當我們開始工作時,我們需要引入操作者,將其轉換為
函數。

如果函數是公正的集合,我們可以用集合理論的方法來解決。
如果是這樣的話,就可以讓它們發揮更大的作用,如工會的職能。
三域的交叉點是空的。

然而,我們經常進行的一些操作,卻導致了以下情況的發生
我們可以為他們定義操作者,這些包括

域和蘭根限制。 領域和范圍的減法,以及 函數覆蓋。

域名限制

GivenourfunctionPBwhichmapsapersoninthedepartmentto
他們的電話號碼,如果我們想提取另一個
函數,它只是包含了驗證組的細節。

?是一個域限制操作器。

###定義

Supposef:T 1 →% T 2 isafunctionandS:IPT 1 isaset.Then,
S?f表示通過將其所有的功能去除而獲得的功能。
mapletsx%→ysuchthatx∕∈S。

##示例

PB == {Dominik%→4252 , Louwe%→ 4293 , Toan%→ 8858 }

S 1 =={Dominik,Louwe}。 S 2 =={Toan}

然后

S 1 ?PB={Dominik%→4252 ,Louwe%→4293}和。 S 2?PB={Toan%→8858 }。

##屬性

域名限制viasetcomprehension。

S?f=={x:T 1 ;y:T 2 |(x∈S)∧(x%→y)∈f-x%→y}。

某個屬性

dom(S?f) = S∩domf S?f ? f ??f = ?

RangeRestriction

就像我們限制功能領域一樣,我們也可以限制功能領域。
其范圍。

?是其他angerestrictionoperator。

###定義

Supposef:T 1 →% T 2是函數,S:IPT 2是aset,那么
f?Sdenotest thefunctionoblishedfromfromfremovingfromitall.
mapletsx%→ysuchthaty∕∈S。

##示例

PB == {Dominik%→4252 , Louwe%→ 4293 , Toan%→ 8858 }

S 1 =={ 4252 , 8858 } S 2 =={ 4293 }

然后

PB?S 1 ={Dominik%→4252 ,Toan%→8858 }和。 PB?S 2 ={Louwe%→ 4293 }.

##域減法

假設我們要把PB帶從所有的成員中移除。
驗證組。

-?isthedomainsubtractionoperator。

定義

Supposef:T 1 →% T 2 是函數,S:IPT 1 是aset,那么
S-?f表示通過將其所有的功能去除而獲得的功能。
mapletsx%→ysuchthatx∈S。

Inshort:S-?f==(domf/S)?f。

##例

PB == {Dominik%→4252 , Louwe%→ 4293 , Toan%→ 8858 }

S 1 =={Louwe} S 2 =={Toan}

然后

S 1 -?PB={Dominik%→4252 ,Toan%→8858}和。 S 2 -?PB={Dominik%→4252 ,Louwe%→4293 }.

##范圍減法

最后,還有一個跨度很大的減法運算器–?。

###定義

假設:T 1 →% T 2是函數,S:IPT 2是aset那么
f-?Sdenotest the functionobtainedfromfromremovingfromitall.
mapletsx%→ysuchthaty∈S。

Inshort:f-?S==f?(ranf/S)。

##例

PB == {Dominik%→4252 , Louwe%→ 4293 , Toan%→ 8858 }

S 1 =={ 4293 } S 2 =={ 8858 }

然后

PB-?S 1 ={Dominik%→4252 ,Toan%→8858}和。 PB-?S 2 ={Dominik%→4252 ,Louwe%→4293 }.

FunctionOverriding

假設我們有一個功能PB,給人們的手機。
數字,有人改變了他們的擴展號碼,那么我們。
想通過改變PB來反映這一點。

GivenPBaspreviouslydefined;whatexpressioncanweuseto
把Louwe的號碼改成1111?

(PB{Louwe%→1234 }) ∪{Louwe%→1111 }。

Z提供⊕符號用于函數覆蓋。

PB⊕{Louwe%→1111 } = {Dominik%→4252 , Louwe%→ 1111 , Toan%→ 8858 }

FunctionOverriding

一般定義允許覆蓋多個值。

##定義

Iff 1 :T 1 →% T 2 andf 2 :T 1 →% T 2 arefunctions(bothfromT 1 to)
T 2 )nf 1 ⊕f 2 表示函數的結果,從overwriting
F1與F2:

f 1 ⊕f 2 ==(dom(f 2 )-?f 1 )∪f 2.

總結

以上是生活随笔為你收集整理的第五课 formal method 的课件和翻译,原来老师用latex打印的,pdf转成markdown,之后翻译的的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。