Module cNRAEnvSize
Section
cNRAEnvSize
.
Require
Import
Omega
.
Require
Import
BasicRuntime
.
Require
Import
cNRAEnv
.
Context
{
fruntime
:
foreign_runtime
}.
Fixpoint
nraenv_core_size
(
a
:
nraenv_core
) :
nat
:=
match
a
with
|
ANID
=> 1
|
ANConst
d
=> 1
|
ANBinop
op
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
ANUnop
op
a
₁ =>
S
(
nraenv_core_size
a
₁)
|
ANMap
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
ANMapConcat
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
ANProduct
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
ANSelect
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
ANDefault
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
ANEither
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
ANEitherConcat
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
ANApp
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
ANGetConstant
_
=> 1
|
ANEnv
=> 1
|
ANAppEnv
a
₁
a
₂ =>
S
(
nraenv_core_size
a
₁ +
nraenv_core_size
a
₂)
|
ANMapEnv
a
₁ =>
S
(
nraenv_core_size
a
₁)
end
.
Lemma
nraenv_core_size_nzero
(
a
:
nraenv_core
) :
nraenv_core_size
a
<> 0.
Proof.
induction
a
;
simpl
;
omega
.
Qed.
Fixpoint
nraenv_core_depth
(
a
:
nraenv_core
) :
nat
:=
match
a
with
|
ANID
=> 0
|
ANConst
d
=> 0
|
ANBinop
op
a
₁
a
₂ =>
max
(
nraenv_core_depth
a
₁) (
nraenv_core_depth
a
₂)
|
ANUnop
op
a
₁ =>
nraenv_core_depth
a
₁
|
ANMap
a
₁
a
₂ =>
max
(
S
(
nraenv_core_depth
a
₁)) (
nraenv_core_depth
a
₂)
|
ANMapConcat
a
₁
a
₂ =>
max
(
S
(
nraenv_core_depth
a
₁)) (
nraenv_core_depth
a
₂)
|
ANProduct
a
₁
a
₂ =>
max
(
nraenv_core_depth
a
₁) (
nraenv_core_depth
a
₂)
|
ANSelect
a
₁
a
₂ =>
max
(
S
(
nraenv_core_depth
a
₁)) (
nraenv_core_depth
a
₂)
|
ANDefault
a
₁
a
₂ =>
max
(
nraenv_core_depth
a
₁) (
nraenv_core_depth
a
₂)
|
ANEither
a
₁
a
₂=>
max
(
nraenv_core_depth
a
₁) (
nraenv_core_depth
a
₂)
|
ANEitherConcat
a
₁
a
₂=>
max
(
nraenv_core_depth
a
₁) (
nraenv_core_depth
a
₂)
|
ANApp
a
₁
a
₂ =>
max
(
nraenv_core_depth
a
₁) (
nraenv_core_depth
a
₂)
|
ANGetConstant
_
=> 0
|
ANEnv
=> 0
|
ANAppEnv
a
₁
a
₂ =>
max
(
nraenv_core_depth
a
₁) (
nraenv_core_depth
a
₂)
|
ANMapEnv
a
₁ => (
S
(
nraenv_core_depth
a
₁))
end
.
End
cNRAEnvSize
.