Module ForeignOpsTyping
Section
ForeignOpsTyping
.
Require
Import
Utils
BasicRuntime
Types
.
Require
Import
ForeignDataTyping
TData
.
Class
foreign_unary_op_typing
{
fdata
:
foreign_data
}
{
fuop
:
foreign_unary_op
}
{
ftype
:
foreign_type
}
{
fdtyping
:
foreign_data_typing
}
{
model
:
brand_model
}
:
Type
:=
mk_foreign_unary_op_typing
{
foreign_unary_op_typing_has_type
(
fu
:
foreign_unary_op_type
)
(τ
in
τ
out
:
rtype
) :
Prop
;
foreign_unary_op_typing_sound
{
fu
:
foreign_unary_op_type
}
{τ
in
τ
out
:
rtype
}
(
optyp
:
foreign_unary_op_typing_has_type
fu
τ
in
τ
out
)
{
din
:
data
}
(
dtin
:
din
▹ τ
in
) :
(
exists
dout
,
foreign_unary_op_interp
brand_relation_brands
fu
din
=
Some
dout
/\
dout
▹ τ
out
)
;
foreign_unary_op_typing_infer
(
fu
:
foreign_unary_op_type
)
:
rtype
->
option
rtype
;
foreign_unary_op_typing_infer_correct
{
fu
:
foreign_unary_op_type
}
{τ₁ τ
out
} :
foreign_unary_op_typing_infer
fu
τ₁ =
Some
τ
out
->
foreign_unary_op_typing_has_type
fu
τ₁ τ
out
;
foreign_unary_op_typing_infer_least
{
fu
:
foreign_unary_op_type
}
{τ₁ τ
out
₁ τ
out
₂} :
foreign_unary_op_typing_infer
fu
τ₁ =
Some
τ
out
₁ ->
foreign_unary_op_typing_has_type
fu
τ₁ τ
out
₂ ->
τ
out
₁ ≤ τ
out
₂
;
foreign_unary_op_typing_infer_complete
{
fu
:
foreign_unary_op_type
}
{τ₁ τ
out
} :
foreign_unary_op_typing_infer
fu
τ₁ =
None
->
~
foreign_unary_op_typing_has_type
fu
τ₁ τ
out
;
foreign_unary_op_typing_infer_sub
(
fu
:
foreign_unary_op_type
)
:
rtype
->
option
(
rtype
*
rtype
)
}.
Class
foreign_binary_op_typing
{
fdata
:
foreign_data
}
{
fbop
:
foreign_binary_op
}
{
ftype
:
foreign_type
}
{
fdtyping
:
foreign_data_typing
}
{
model
:
brand_model
}
:
Type
:=
mk_foreign_binary_op_typing
{
foreign_binary_op_typing_has_type
(
fb
:
foreign_binary_op_type
)
(τ
in
₁ τ
in
₂ τ
out
:
rtype
) :
Prop
;
foreign_binary_op_typing_sound
{
fb
:
foreign_binary_op_type
}
{τ
in
₁ τ
in
₂ τ
out
:
rtype
}
(
optyp
:
foreign_binary_op_typing_has_type
fb
τ
in
₁ τ
in
₂ τ
out
)
{
din
₁
din
₂:
data
}
(
dtin
:
din
₁ ▹ τ
in
₁)
(
dtin
:
din
₂ ▹ τ
in
₂) :
(
exists
dout
,
foreign_binary_op_interp
brand_relation_brands
fb
din
₁
din
₂
=
Some
dout
/\
dout
▹ τ
out
)
;
foreign_binary_op_typing_infer
(
fb
:
foreign_binary_op_type
)
:
rtype
->
rtype
->
option
rtype
;
foreign_binary_op_typing_infer_correct
{
fb
:
foreign_binary_op_type
}
{τ₁ τ₂ τ
out
} :
foreign_binary_op_typing_infer
fb
τ₁ τ₂ =
Some
τ
out
->
foreign_binary_op_typing_has_type
fb
τ₁ τ₂ τ
out
;
foreign_binary_op_typing_infer_least
{
fb
:
foreign_binary_op_type
}
{τ₁ τ₂ τ
out
₁ τ
out
₂} :
foreign_binary_op_typing_infer
fb
τ₁ τ₂ =
Some
τ
out
₁ ->
foreign_binary_op_typing_has_type
fb
τ₁ τ₂ τ
out
₂ ->
τ
out
₁ ≤ τ
out
₂
;
foreign_binary_op_typing_infer_complete
{
fb
:
foreign_binary_op_type
}
{τ₁ τ₂ τ
out
} :
foreign_binary_op_typing_infer
fb
τ₁ τ₂ =
None
->
~
foreign_binary_op_typing_has_type
fb
τ₁ τ₂ τ
out
;
foreign_binary_op_typing_infer_sub
(
fb
:
foreign_binary_op_type
)
:
rtype
->
rtype
->
option
(
rtype
*
rtype
*
rtype
)
}.
End
ForeignOpsTyping
.