Module NRASize
Section
NRASize
.
Require
Import
Omega
.
Require
Import
BasicRuntime
NRA
.
Context
{
fruntime
:
foreign_runtime
}.
Fixpoint
nra_size
(
a
:
nra
) :
nat
:=
match
a
with
|
AID
=> 1
|
AConst
d
=> 1
|
ABinop
op
a
₁
a
₂ =>
S
(
nra_size
a
₁ +
nra_size
a
₂)
|
AUnop
op
a
₁ =>
S
(
nra_size
a
₁)
|
AMap
a
₁
a
₂ =>
S
(
nra_size
a
₁ +
nra_size
a
₂)
|
AMapConcat
a
₁
a
₂ =>
S
(
nra_size
a
₁ +
nra_size
a
₂)
|
AProduct
a
₁
a
₂ =>
S
(
nra_size
a
₁ +
nra_size
a
₂)
|
ASelect
a
₁
a
₂ =>
S
(
nra_size
a
₁ +
nra_size
a
₂)
|
ADefault
a
₁
a
₂ =>
S
(
nra_size
a
₁ +
nra_size
a
₂)
|
AEither
a
₁
a
₂=>
S
(
nra_size
a
₁ +
nra_size
a
₂)
|
AEitherConcat
a
₁
a
₂ =>
S
(
nra_size
a
₁ +
nra_size
a
₂)
|
AApp
a
₁
a
₂ =>
S
(
nra_size
a
₁ +
nra_size
a
₂)
|
AGetConstant
s
=> 1
end
.
Lemma
nra_size_nzero
(
a
:
nra
) :
nra_size
a
<> 0.
Proof.
induction
a
;
simpl
;
omega
.
Qed.
Fixpoint
nra_depth
(
a
:
nra
) :
nat
:=
match
a
with
|
AID
=> 0
|
AConst
d
=> 0
|
ABinop
op
a
₁
a
₂ =>
max
(
nra_depth
a
₁) (
nra_depth
a
₂)
|
AUnop
op
a
₁ =>
nra_depth
a
₁
|
AMap
a
₁
a
₂ =>
max
(
S
(
nra_depth
a
₁)) (
nra_depth
a
₂)
|
AMapConcat
a
₁
a
₂ =>
max
(
S
(
nra_depth
a
₁)) (
nra_depth
a
₂)
|
AProduct
a
₁
a
₂ =>
max
(
nra_depth
a
₁) (
nra_depth
a
₂)
|
ASelect
a
₁
a
₂ =>
max
(
S
(
nra_depth
a
₁)) (
nra_depth
a
₂)
|
ADefault
a
₁
a
₂ =>
max
(
nra_depth
a
₁) (
nra_depth
a
₂)
|
AEither
a
₁
a
₂=>
max
(
nra_depth
a
₁) (
nra_depth
a
₂)
|
AEitherConcat
a
₁
a
₂ =>
max
(
nra_depth
a
₁) (
nra_depth
a
₂)
|
AApp
a
₁
a
₂ =>
max
(
nra_depth
a
₁) (
nra_depth
a
₂)
|
AGetConstant
s
=> 0
end
.
End
NRASize
.