Answered step by step
Verified Expert Solution
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,
Functions
Show that the function f on the natural numbers N given by fnn
in injective, but not surjective. The Coq definition of this function can be expressed as a relation,
Definition f : byformula fun x : nat x
Prove that f is injective and not surjective,
Lemma prob : 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 Pprf : exists a : A P a A
Hypothesis choiceok : forall A Pprf : 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 ftotal dom cod x
Defined.
Lemma appiffrel : forall dom codf : Func dom codx : domy : cod
app f x y frel 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 choiceok s
intros rel.
apply ffunctional dom cod with x : x
exact choiceok s
exact rel.
Qed.
Definition byformula : forall dom cod : Typedom 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 eq eq
rewrite eq
rewrite eq
reflexivity.
Defined.
Lemma byformulaok : forall dom cod : Typeformula : dom codx : dom
app byformula formula x formula x
Proof.
intros dom cod formula x
unfold byformula.
unfold app.
simpl.
set ok : choiceok
exintro fun y : cod formula x yformula x eqrefl
symmetry.
exact ok
Qed.
Definition surjective dom codf : Func dom cod : forall y : cod,
exists x : dom, app f x y
Definition injective dom codf : Func dom cod : forall x xp : dom,
app f x app f xp x xp
Definition f : byformula fun x : nat x
Lemma prob : injective f ~surjective f
Proof.
Qed.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started