Module Qcert.cNRAEnv.Lang.cNRAEnvSize
Require
Import
Lia
.
Require
Import
DataRuntime
.
Require
Import
cNRAEnv
.
Section
cNRAEnvSize
.
Context
{
fruntime
:
foreign_runtime
}.
Fixpoint
nraenv_core_size
(
a
:
nraenv_core
) :
nat
:=
match
a
with
|
cNRAEnvID
=> 1
|
cNRAEnvConst
d
=> 1
|
cNRAEnvBinop
op
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
cNRAEnvUnop
op
a
₁ =>
S
(
nraenv_core_size
a
₁)
|
cNRAEnvMap
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
cNRAEnvMapProduct
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
cNRAEnvProduct
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
cNRAEnvSelect
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
cNRAEnvDefault
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
cNRAEnvEither
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
cNRAEnvEitherConcat
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
cNRAEnvApp
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
cNRAEnvGetConstant
_
=> 1
|
cNRAEnvEnv
=> 1
|
cNRAEnvAppEnv
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
cNRAEnvMapEnv
a
₁ =>
S
(
nraenv_core_size
a
₁)
end
.
Lemma
nraenv_core_size_nzero
(
a
:
nraenv_core
) :
nraenv_core_size
a
<> 0.
Proof.
induction
a
;
simpl
;
lia
.
Qed.
Fixpoint
nraenv_core_depth
(
a
:
nraenv_core
) :
nat
:=
match
a
with
|
cNRAEnvID
=> 0
|
cNRAEnvConst
d
=> 0
|
cNRAEnvBinop
op
a
₁
a
₂ =>
max
(
nraenv_core_depth
a
₁) (
nraenv_core_depth
a
₂)
|
cNRAEnvUnop
op
a
₁ =>
nraenv_core_depth
a
₁
|
cNRAEnvMap
a
₁
a
₂ =>
max
(
S
(
nraenv_core_depth
a
₁)) (
nraenv_core_depth
a
₂)
|
cNRAEnvMapProduct
a
₁
a
₂ =>
max
(
S
(
nraenv_core_depth
a
₁)) (
nraenv_core_depth
a
₂)
|
cNRAEnvProduct
a
₁
a
₂ =>
max
(
nraenv_core_depth
a
₁) (
nraenv_core_depth
a
₂)
|
cNRAEnvSelect
a
₁
a
₂ =>
max
(
S
(
nraenv_core_depth
a
₁)) (
nraenv_core_depth
a
₂)
|
cNRAEnvDefault
a
₁
a
₂ =>
max
(
nraenv_core_depth
a
₁) (
nraenv_core_depth
a
₂)
|
cNRAEnvEither
a
₁
a
₂=>
max
(
nraenv_core_depth
a
₁) (
nraenv_core_depth
a
₂)
|
cNRAEnvEitherConcat
a
₁
a
₂=>
max
(
nraenv_core_depth
a
₁) (
nraenv_core_depth
a
₂)
|
cNRAEnvApp
a
₁
a
₂ =>
max
(
nraenv_core_depth
a
₁) (
nraenv_core_depth
a
₂)
|
cNRAEnvGetConstant
_
=> 0
|
cNRAEnvEnv
=> 0
|
cNRAEnvAppEnv
a
₁
a
₂ =>
max
(
nraenv_core_depth
a
₁) (
nraenv_core_depth
a
₂)
|
cNRAEnvMapEnv
a
₁ => (
S
(
nraenv_core_depth
a
₁))
end
.
End
cNRAEnvSize
.