Definition ipv4part : Set := {n:nat | n<256}. Check sig. (* sig : forall A : Type, (A -> Prop) -> Type *) Print sig. (* Inductive sig (A : Type) (P : A -> Prop) : Type := exist : forall x : A, P x -> {x : A | P x} *) Lemma Lt3_256 : 3 < 256. Proof. repeat constructor. Qed. Check @exist nat (fun x:nat => x<256) 3 Lt3_256. Check @exist nat (fun x:nat => x<256) 3 Lt3_256: ipv4part. Check @exist nat (fun x:nat => x<256) 3 _:ipv4part. Check exist _ 3 _:ipv4part. (* Check exist (fun x=>x<256) 3. Check sig nat. Check sig nat 3 3<256. Check 3 3<256 :ipv4part. *) Inductive ipv4 : Set := | IPv4 : ipv4part -> ipv4part -> ipv4part -> ipv4part -> ipv4. Notation "a ; b ; c ; d" := (IPv4 (exist _ a _ : ipv4part) (exist _ b _ : ipv4part) (exist _ c _ : ipv4part) (exist _ d _ : ipv4part)) (at level 80, b at next level, c at next level, d at next level). Check 12;12;12;12. Definition projIPv4 (ip:ipv4) (n:nat): nat := let comp : ipv4part := match ip with | IPv4 p q r s => match n with | 0 => p | 1 => q | 2 => r | 3 => s | _ => p end end in match comp with | exist _ res _ => res end. Compute projIPv4 (12;13;14;15) 2. Theorem Th1 : forall (n:nat) (ip:ipv4), projIPv4 ip n < 256. Proof. intros. induction n. - induction ip. induction i. induction ip. - (* Notation "| n" := (exist _ n _ : ipv4part) (at level 100). Check |2. Check IPV4 (|2) (|2) (|2) (|2). *)