Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6 Functions Show that the function f on the natural numbers N given by f ( n ) = 5 n + 2 in injective,

6 Functions
Show that the function f on the natural numbers N given by f(n)=5n +2
in injective, but not surjective. The Coq definition of this function can be expressed as a relation,
Definition f := by_formula (fun x : nat =>5* x +1).
Prove that f is injective and not surjective,
Lemma prob6 : injective f /\ ~surjective f.
You will likely find it necessary to use Nat.add cancel r, Nat.mul cancel l, and discriminate in the first proof. You might use discriminate in the second step.
Use the template:
From Coq Require Import Bool.Bool.
From Coq Require Import Classes.RelationClasses.
Variable (choice : forall {A P}(prf : exists a : A, P a), A).
Hypothesis (choice_ok : forall {A P}(prf : exists a : A, P a), P (choice prf)).
Record Func (dom cod : Type) : Type :=
mkFunc {
rel : dom -> cod -> Prop
; total : forall x : dom, exists y : cod, rel x y
; functional : forall x : dom, forall y z : cod, rel x y -> rel x z -> y = z
}.
Definition app : forall {dom cod}, Func dom cod -> dom -> cod.
Proof.
intros dom cod f x.
exact (choice (f.(total dom cod) x)).
Defined.
Lemma app_iff_rel : forall {dom cod}(f : Func dom cod)(x : dom)(y : cod),
app f x = y <->(f.(rel dom cod) x y).
Proof.
intros dom cod f x y.
set (s := total dom cod f x).
unfold app.
fold s.
split.
- intros app.
rewrite <- app.
exact (choice_ok s).
- intros rel.
apply (f.(functional dom cod)) with (x := x).
+ exact (choice_ok s).
+ exact rel.
Qed.
Definition by_formula : forall {dom cod : Type},(dom -> cod)-> Func dom cod.
Proof.
intros dom cod f.
refine (mkFunc dom cod (fun x y => f x = y)__).
- intros x.
exists (f x).
reflexivity.
- intros x y z eq1 eq2.
rewrite <- eq1.
rewrite <- eq2.
reflexivity.
Defined.
Lemma by_formula_ok : forall {dom cod : Type}(formula : dom -> cod)(x : dom),
app (by_formula formula) x = formula x.
Proof.
intros dom cod formula x.
unfold by_formula.
unfold app.
simpl.
set (ok := choice_ok
(ex_intro (fun y : cod => formula x = y)(formula x) eq_refl)).
symmetry.
exact ok.
Qed.
Definition surjective {dom cod}(f : Func dom cod) := forall y : cod,
exists x : dom, app f x = y.
Definition injective {dom cod}(f : Func dom cod) := forall x xp : dom,
app f x = app f xp -> x = xp.
Definition f := by_formula (fun x : nat =>5* x +1).
Lemma prob6 : injective f /\ ~surjective f.
Proof.
Qed.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Creating A Database In Filemaker Pro Visual QuickProject Guide

Authors: Steven A. Schwartz

1st Edition

0321321219, 978-0321321213

More Books

Students also viewed these Databases questions