The definition of int comes from compcert,
Record int: Type := mkint { intval: Z; intrange: -1 < intval < modulus }.
I wanna prove foo, suppose that the induction strategy needs to be used, because there is a recursive relationship in P1 and P2, and i is positive in P1 and P2 actually.
From compcert Require Import Integers.
Parameter P1 : int -> Prop.
Parameter P2 : int -> Prop.
Theorem foo:
forall i: int,
(P1 i) -> (P2 i).
Proof.
destruct i. induction intval.
admit.
induction p.
Abort.
If induction p, I need to prove two cases, BinNums.Zpos (BinNums.xI p) and BinNums.Zpos (BinNums.xO p). it is hard to prove, I would like to be able to use int like nat, that is something to prove P1 (i + 1) -> P2 (i + 1) by (P1 i) -> (P2 i)
Any hints? thank you very much!
The fact that you are using
intnumbers from CompCert makes everything more complicated, because there is too little arithmetic available for this datatype.If you were using just plain integers of type
Z, you would be able to perform the proof you require by usingwell_founded_inductionandZwf.Zwf_well_founded. Here is an example.Now, if we want to make a similar proof using numbers of type
int, life is more complicated because these numbers are in a record, and this record contains a field that is a proof. Usually, the value of the proof is irrelevant, only its existence matters, in in this case we would rather have theintvalprojection be injective. To make it short, I simply place myself in a theoretical setting where this is granted, this well known and acceptable in most use cases. Here is the full example:Note that
mkint _ (modulo_Z_bound (intval x + 1))is just a way to writex + 1whenxhas typeint(with the convention that the successor of the largest number is 0).There is a way to avoid using the
proof_irrelevanceaxiom, but this would make this answer even longer.