functional programming - How to prove uniqueness of a function in Coq given a specification? -
given specification of function, e.g., specification_of_sum
, how prove in coq 1 such function exists?
i studying mathematics, , prove in hand, skills in coq limited (proving using rewrite
, apply
).
i found code snippet below, i've been struggling time now.
i try unfold specification in proof, using old friend rewrite
doesn't seem let me go further.
can explain how approach problem using simple syntax?
definition specification_of_sum (sum : (nat -> nat) -> nat -> nat) := forall f : nat -> nat, sum f 0 = f 0 /\ forall n' : nat, sum f (s n') = sum f n' + f (s n'). (* ********** *) theorem there_is_only_one_sum : forall sum1 sum2 : (nat -> nat) -> nat -> nat, specification_of_sum sum1 -> specification_of_sum sum2 -> forall (f : nat -> nat) (n : nat), sum1 f n = sum2 f n. proof. abort.
the following start ejgallego described.
intros sum1 sum2 h1 h2 f n. (* introduce hypotheses *) unfold specification_of_sum in *. (* unfold definition in places *) specialize h1 (f := f). (* narrow statement f *) specialize h2 (f := f). (* narrow statement f *) inversion_clear h1. (* split , statements *) inversion_clear h2. (* induction on n, , rewrites *)
i have included few more basic commands make slower simpler. rest of proof requires rewrite
, reflexivity
.
Comments
Post a Comment