Module Qcert.Data.OperatorsTyping.ForeignOperatorsTyping
Require
Import
Utils
.
Require
Import
DataModel
.
Require
Import
ForeignData
.
Require
Import
ForeignOperators
.
Require
Import
Types
.
Require
Import
ForeignDataTyping
.
Require
Import
TData
.
Section
ForeignOperatorsTyping
.
Class
foreign_operators_typing
{
fdata
:
foreign_data
}
{
foperators
:
foreign_operators
}
{
ftype
:
foreign_type
}
{
fdtyping
:
foreign_data_typing
}
{
model
:
brand_model
}
:
Type
:=
mk_foreign_operators_typing
{
foreign_operators_typing_unary_has_type
(
fu
:
foreign_operators_unary
)
(τ
in
τ
out
:
rtype
) :
Prop
;
foreign_operators_typing_unary_sound
{
fu
:
foreign_operators_unary
}
{τ
in
τ
out
:
rtype
}
(
optyp
:
foreign_operators_typing_unary_has_type
fu
τ
in
τ
out
)
{
din
:
data
}
(
dtin
:
din
▹ τ
in
) :
(
exists
dout
,
foreign_operators_unary_interp
brand_relation_brands
fu
din
=
Some
dout
/\
dout
▹ τ
out
)
;
foreign_operators_typing_unary_infer
(
fu
:
foreign_operators_unary
)
:
rtype
->
option
rtype
;
foreign_operators_typing_unary_infer_correct
{
fu
:
foreign_operators_unary
}
{τ₁ τ
out
} :
foreign_operators_typing_unary_infer
fu
τ₁ =
Some
τ
out
->
foreign_operators_typing_unary_has_type
fu
τ₁ τ
out
;
foreign_operators_typing_unary_infer_least
{
fu
:
foreign_operators_unary
}
{τ₁ τ
out
₁ τ
out
₂} :
foreign_operators_typing_unary_infer
fu
τ₁ =
Some
τ
out
₁ ->
foreign_operators_typing_unary_has_type
fu
τ₁ τ
out
₂ ->
τ
out
₁ ≤ τ
out
₂
;
foreign_operators_typing_unary_infer_complete
{
fu
:
foreign_operators_unary
}
{τ₁ τ
out
} :
foreign_operators_typing_unary_infer
fu
τ₁ =
None
->
~
foreign_operators_typing_unary_has_type
fu
τ₁ τ
out
;
foreign_operators_typing_unary_infer_sub
(
fu
:
foreign_operators_unary
)
:
rtype
->
option
(
rtype
*
rtype
)
;
foreign_operators_typing_binary_has_type
(
fb
:
foreign_operators_binary
)
(τ
in
₁ τ
in
₂ τ
out
:
rtype
) :
Prop
;
foreign_operators_typing_binary_sound
{
fb
:
foreign_operators_binary
}
{τ
in
₁ τ
in
₂ τ
out
:
rtype
}
(
optyp
:
foreign_operators_typing_binary_has_type
fb
τ
in
₁ τ
in
₂ τ
out
)
{
din
₁
din
₂:
data
}
(
dtin
:
din
₁ ▹ τ
in
₁)
(
dtin
:
din
₂ ▹ τ
in
₂) :
(
exists
dout
,
foreign_operators_binary_interp
brand_relation_brands
fb
din
₁
din
₂
=
Some
dout
/\
dout
▹ τ
out
)
;
foreign_operators_typing_binary_infer
(
fb
:
foreign_operators_binary
)
:
rtype
->
rtype
->
option
rtype
;
foreign_operators_typing_binary_infer_correct
{
fb
:
foreign_operators_binary
}
{τ₁ τ₂ τ
out
} :
foreign_operators_typing_binary_infer
fb
τ₁ τ₂ =
Some
τ
out
->
foreign_operators_typing_binary_has_type
fb
τ₁ τ₂ τ
out
;
foreign_operators_typing_binary_infer_least
{
fb
:
foreign_operators_binary
}
{τ₁ τ₂ τ
out
₁ τ
out
₂} :
foreign_operators_typing_binary_infer
fb
τ₁ τ₂ =
Some
τ
out
₁ ->
foreign_operators_typing_binary_has_type
fb
τ₁ τ₂ τ
out
₂ ->
τ
out
₁ ≤ τ
out
₂
;
foreign_operators_typing_binary_infer_complete
{
fb
:
foreign_operators_binary
}
{τ₁ τ₂ τ
out
} :
foreign_operators_typing_binary_infer
fb
τ₁ τ₂ =
None
->
~
foreign_operators_typing_binary_has_type
fb
τ₁ τ₂ τ
out
;
foreign_operators_typing_binary_infer_sub
(
fb
:
foreign_operators_binary
)
:
rtype
->
rtype
->
option
(
rtype
*
rtype
*
rtype
)
}.
End
ForeignOperatorsTyping
.