, Heap :
:
Inductive Heap A : Type :=
| Node : Heap A -> A -> Heap A -> Heap A
| Leaf : Heap A.
f
Fixpoint f A (h : Heap A) : list A :=
match h with
| Node h1 a h2 => f h1 ++ a :: f h2
| Leaf => []
end.
, f
Heap A list A A.
g : forall A, list A -> Heap A ,
forall A (l : list A), f (g l) = l
, , Heap, list
,
, .
,
, , Coq.
, parametricity, ,
,
.
,
. , (, foo)
++ nth. foo
Heap ,
foo ,
:
Definition foo (T : Set -> Set)
(app : forall A, T A -> T A -> T A)
(nth : forall A, T A -> nat -> option A)
A (l : T A) : T A :=
(* ... *)
foo,
:
Definition list_foo := foo list @app @nth.
Lemma list_foo_lemma : (* Some statement *).
, H_app H_nth
foo ,
,
Definition H_foo := foo Heap @H_app @H_nth.
Lemma foo_param : forall A (h : Heap A),
f (H_foo h) = list_foo (f h).
,
list_foo H_foo. ,
, , H_app ,
:
forall A (h1 h2 h3 : Heap A),
list_foo (H_app h1 (H_app h2 h3)) =
list_foo (H_app (H_app h1 h2) h3).
, ,
: ,
,
foo_param.
.
, , ,
. , ,
, foo_param
, Coq ,
. ,
:
Coq (CoqParam),
.
, , .
Coq ( CoqEAL, )
, ,
. ,
nat BinNat,
. ,
- ,
, ,
CoqParam.