Membership with decidable equality

Assignment Help Programming Languages
Reference no: EM133168869

Assignment: Properties and logic

- Please never change names or statements of Theorems,
Lemmas, Definitions, Examples or anything else provided here.
- [Abort] only additional lemmas that you did not manage to prove.
For theorems provided here, either use [Qed]/[Defined] or keep [Admitted].
- Please do not change the file name.
- Do not post your solution in any publically available location.
- Please submit on time, late solutions not accepted.
- Before submission, please check from command line if your script compiles.
In other words, do run [coqc] to make sure it accepts your file.
If it doesn't, no points can be awarded.
- Please submit _only_ the source file of the solution, i.e., [*.v]!
- Compiled output [*.vo] is useless for submission.

Exercise 1: Membership with decidable equality

(** Recall the type [sumbool] from ProSeSu22.v*)
(** An alternate way to characterize decision procedures, widely used in Coq, is via the inductive type [sumbool].

Suppose [Q] is a proposition, that is, [Q: Prop].
- We say [Q] is _decidable_ if there is an algorithm for
computing a proof of [Q] or [~Q].
- More generally, when [P] is a predicate
(a function from some type [T] to [Prop]),
we say [P] is decidable when [forall x:T, decidable(P)].

We represent this concept in Coq by an inductive datatype: *)

Exercise 2: Reflection for predicates on lists

** The standard library offers an inductive predicate for comparing lists wrt to a given binary relation *)

Print Forall2.

(**

Inductive Forall2 (A B : Type) (R : A -> B -> Prop) : list A -> list B -> Prop :=
Forall2_nil : Forall2 R [] []
| Forall2_cons : forall (x : A) (y : B) (l : list A) (l' : list B),
R x y -> Forall2 R l l' -> Forall2 R (x :: l) (y :: l')
*)

(** First, let us recall what it means for a relation to be reflected by a binary function. *)

Definition Rreflected {A B : Type} (R : A -> B -> Prop) (f: A -> B -> bool) :=
forall a b, reflect (R a b) (f a b).

(** Define its boolean counterpart. It might be a good idea to do pattern matching on two arguments at the same time. *)

Fixpoint forall2 {A B : Type} (R : A -> B -> Prop) (f: A -> B -> bool) (P: Rreflected R f) (la: list A) (lb : list B) : bool (* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.

(** In the following proof, you might:
- want to think whether you do induction first, or rather
apply some trivial reflection view first to split the goal
- recall you can handle boolean conjunctions with [move => /andP ...]
- realize that (instantiated) premises can be also used as reflection views.
*)

Theorem forall2P {A B : Type} (R : A -> B -> Prop) (f: A -> B -> bool) : forall (P: Rreflected R f), Rreflected (Forall2 R) (forall2 R f P).
Proof.

Exercise 3: constructive quantification *)

(** **** Exercise: 3 stars, standard (quantifiers) *)

(** Many of familiar laws for quantifiers still hold for constructive logic.
Here and everywhere below you can actually provide a normal tactic proof if writing down proof term provides too difficult. *)

Definition notexists_forallnot : forall (X:Type) (P : X -> Prop),
~ (exists x : X, P x) -> (forall x : X, ~ P x)
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.

Definition forallnot_notexists : forall (X:Type) (P : X -> Prop),
(forall x, ~ P x) -> ~ (exists x, P x)
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.

Definition forallnot_equiv_notexists : forall (X:Type) (P : X -> Prop),
(forall x, ~ P x) <-> ~ (exists x, P x)
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.

Definition forallnotnot_equiv_notexistsnot : forall (X:Type) (P : X -> Prop),
(forall x, ~ ~ P x) <-> ~ (exists x, ~ P x)
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.

Lemma CEpqENpNq : forall P Q, (P <-> Q) -> (~P <-> ~Q).
Proof.
(* FILL IN HERE *) Admitted.

Definition notforallnot_equiv_notnotexists : forall (X:Type) (P : X -> Prop),
~(forall x, ~ P x) <-> ~ ~ (exists x, P x)
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.

Definition existsnot_notforall : forall (X:Type) (P : X -> Prop),
(exists x, ~ P x) -> ~ (forall x, P x)
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.

Definition forall_notexistsnot : forall (X:Type) (P : X -> Prop),
(forall x, P x) -> ~ (exists x, ~ P x)
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.

(** How about the converse of the last one? As it turns out, it requires
classical logic, see below ... *)

Exercise 4, elective: classical axioms

(** **** Exercise: 4 stars, advanced, optional (classical_axioms) *)

(** Let us have a closer look at classical propositions in Coq. *)

(** Here are several "classical" properties and axioms. When universally quantified over all propositions, all of them imply each other. Sometimes, it makes sense to state them for individual propositions too, especially in the context of reflection with boolean functions. *)

(** Recall again: here and everywhere below you can actually provide a normal tactic proof if writing down proof term provides too difficult. *)

Definition em_for_P (P : Prop) := P \/ ~P.
(** The above is sometimes called _decidability_ for [P], but one should be slightly careful about this name. *)
Definition peirce_for_P (P:Prop) := forall Q: Prop,
((P->Q)->P)->P.
Definition dn_elimination_for_P (P : Prop) :=
~ ~P -> P.
Definition de_morgan_not_and_not_forPQ (P Q:Prop) :=
~(~P /\ ~Q) -> P\/Q.
Definition implies_to_or_forPQ (P Q:Prop) :=
(P->Q) -> (~P\/Q).

Definition excluded_middle := forall P, em_for_P P.
Definition peirce := forall P, peirce_for_P P.
Definition double_negation_elimination := forall P:Prop, dn_elimination_for_P P.
Definition de_morgan_not_and_not := forall P Q:Prop,
de_morgan_not_and_not_forPQ P Q.
Definition implies_to_or := forall P Q:Prop, implies_to_or_forPQ P Q.

Exercise 5: Kuroda and some classical aspects of negation

(** Warning: in this exercise you might find yourself in need of some theorems from the previous elective one. In such a case, go back and prove what's needed (thus earning more points). *)

(** Just like in the propositional case, there are many propositions which cannot be proved in the intuitionistic logic, but are not as strong as classical axioms either. Here is a famous example: *)

Definition kuroda (X:Type) (P : X -> Prop) :=
(forall x, ~ ~ P x) -> ~ ~(forall x, P x).

(** This law of course trivially holds in classical logic. *)

(** Here and everywhere below you can actually provide
a normal tactic proof
if writing down proof term provides too difficult. *)

Definition decprop {X: Type} P := forall (x : X), P x \/ ~ P x.

Definition classic_kuroda : forall X P, decprop P -> kuroda X P
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.

(** Here is an example of a law governing the interaction of negation and quantification, which only requires the Kuroda axiom: *)

Definition notforall_notnotexistsnot :
forall (X:Type) (P : X -> Prop), kuroda X P ->
~ (forall x, P x) -> ~ ~ (exists x, ~ P x)
(* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.

(** However, there are laws which require more of classical logic. Some not all that much: *)

Theorem notexistsnot_forall : forall (X:Type) (P : X -> Prop),
(decprop P) ->
~ (exists x, ~ P x) -> (forall x, P x).
Proof.
(* FILL IN HERE *) Admitted.

(** [] *)

Attachment:- Properties and logic.rar

Reference no: EM133168869

Questions Cloud

Discuss benefits of virtualization software : Discuss the benefits of virtualization software. Do you agree/disagree with these benefits? Also discuss the security concerns highlighted by server sprawl
Find expected outcome for each game : You can participate in one of two games: Game 1: Pays $1M with probability 1.0 and Game 2: Pays $5M with probability 0.1. Find expected outcome for each game
By what amount will Cox paid-in capital - share repurchase : By what amount will Cox's paid-in capital - share repurchase increase if Cox now sells 2 million treasury shares at $32 per share
Difference between internal and external stakeholder : What is the difference between an internal and external stakeholder? What is the difference between key and secondary?
Membership with decidable equality : Membership with decidable equality - here and everywhere below you can actually provide a normal tactic proof if writing down proof term provides too difficult
Compute the cost of plant that should be recognized : Service cost to maintain the plant is RM12,000 per annum. Compute the cost of plant that should be recognized by the company on date of acquisition
Policy evaluation and policy implement : There is relationship between policy evaluation and production identification, policy evaluation, policy implement and policy evaluation and policy formulation
What is digital transformation : ABCZ is a mid-size family-owned company in the beauty & skincare sector. They have their own brands, and they produce and sell their beauty and skincare product
What is the issue identification : What is the issue identification? What is the internal and external analysis?

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd