Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] records ?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] records ?


Chronological Thread 
  • From: mukesh tiwari <mukeshtiwari.iiitm AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] records ?
  • Date: Mon, 6 Sep 2021 14:57:32 +1000
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=mukeshtiwari.iiitm AT gmail.com; spf=Pass smtp.mailfrom=mukeshtiwari.iiitm AT gmail.com; spf=None smtp.helo=postmaster AT mail-ed1-f52.google.com
  • Ironport-hdrordr: A9a23:Xw4R9asKXyM8vghxq344JbQt7skDd9V00zEX/kB9WHVpmwKj5qSTdZMgpGbJYVcqKRcdcLW7UpVoLkm8yXcY2/hzAV7AZniAhILLFu9fBOLZqlWKdkHDH4hmpMVdmodFZ+EYZmIbsS+V2njcL+od
  • Ironport-phdr: A9a23:5G/9ihQ80CAD/HR/cplr6nmPq9psonWfAWYlg6HPa5pwe6iut67vIFbYra00ygOTBcOKsrkZ1KL/iOPJYSQ4+5GPsXQPItRndiQuroEopTEmG9OPEkbhLfTnPGQQFcVGU0J5rTngaRAGUMnxaEfPrXKs8DUcBgvwNRZvJuTyB4Xek9m72/q99pHNfwlEnj6wba59IBi2rwjaq9Ubj5ZlJqst0BXCv2FGe/5RxWNmJFKTmwjz68Kt95N98Cpepuws+ddYXar1Y6o3Q7pYDC87M28u/83kqQPDTQqU6XQCVGgdjwdFDBLE7BH+WZfxrzf6u+9g0ySUIcH6UbY5Uimk4qx2ShHnlT0HOiY2/2HZiMN+jKxVrhG8qRJh34HZe5uaOOZkc67HYd8WWWhMU8BMXCJBGIO8aI4PAvIEPeZFrInyuUAOrRujDgmwBePuxCVHhmX33aYn1OkhFBzG3A8+ENIVsHTUsNT1NakIXuCvzanE1zTDb/JX2Tfh7YjFaR8hofSWUrJxdcrd01UgFwTAjliJr4HuIjya2PgXvWeB8+pgSfygi3QhqwxprTaiwtkhh4nVi4wVy13J6SZ0zog3KNGmVEJ2YdGqHZteuiyaOYZ4Qt4vTWF0tCok17ELvZ62cicExZg5yBDSafqKeJWG7BLkUeaeOzZ4hHR9dbK+gRay60mgxffmWsm6ylZHqDdOnNrUtn0VyRDf9syKRuF+80qhwzqDyRzf5+JeLU00i6bWLYMqzKQqmZoJq0vDGzf7mEXog6+ScUUp4u2o5P7mYrXiv5OTKZJ7hhznPqQgmsGzH/40MgcJX2ic9uS80KPs8VflT7VNi/06iqjZsJbEKsQHvqO1HRNZ34I55xu8DzqqysoUkWUEIV5feB+LkZDlO1TUL/D5Cfe/jU6skDBux/3eO73hH5bNIWbYkLfhYbZ96kBdxxApzdBe/Z5UC7ABIPPvWk/0r9HYARo5PBa1w+bjEtlyyoQeWWeXDq+DLKzSqUOI5v4oI+SUeIAVvy/9J+E56P7qkH82gkQQfbKp3JsScHC3BO5qI0SfYXr2g9cOC30GvgQkTL+itFrXWjlKIn22QqgU5zchCYvgA52QaJqqhemEwSS2BZ0eemFZA0qNWSPtaoaJQPcQaT2bOM4nkz0FSb2JRIoo1BXovwj/nek0ZtHI8zEV4MqwnON+4PfewElaHd1cCs2c1ySAQzgxkD5SATAx2697rAp2zVLRicCQbNRXENVS47VCVQJobPY0KsR1DtnzXkTKedLbED6b

Hi Jeremy,

The thing "{| c := ccc ; i := iii |}" is record data type [1] and you can also think of it as inductive data type with one constructor.  I wrote a simple example, see below.

Require Import Coq.Strings.String.
Record person := mk_name
{
name : string;
age : nat
}.

Lemma identity : forall p q : person, p = q -> q = p.
Proof.
intros ? ? Hpq.
(*

p, q: person
Hpq: p = q
-----------------
1/1
q = p
*)

destruct q. destruct p.

(* The context looks like:
name1: string
age1: nat
name0: string
age0: nat
Hpq: {| name := name1; age := age1 |} = {| name := name0; age := age0 |}
------------------------------------------------------------------------
1/1
{| name := name0; age := age0 |} = {| name := name1; age := age1 |}
*)

inversion Hpq. (* get the equality between the corresponding fields *)

(*
name1: string
age1: nat
name0: string
age0: nat
Hpq: {| name := name1; age := age1 |} = {| name := name0; age := age0 |}
H0: name1 = name0
H1: age1 = age0
--------------------------------------------------------------------------
1/1
{| name := name0; age := age0 |} = {| name := name0; age := age0 |}
*)
reflexivity.
Qed.

" If so how do I actually get hold of those things?"
You can access the individual field by using the corresponding field names, e.g., if you have a person p, then you can access its name by (name p) and age by (age p). 

"Then, when I have a goal of the form {| c := ccc ; i := iii |} what does that mean and what is the next step to solving it?
When we have a goal, say, of A (Type, Set, or Prop), then we need to produce a witness of A. For example, in the example below,
I am producing a person as a return type, and I can do that in many ways. I can just return p, or I can construct any  arbitrary person
by using the constructor 'mk_name'.

Theorem identity_function : forall p: person, person.
Proof.
intros p.

(* see the type of pn and qn *)
remember (name p ) as pn.
remember (age p) as qn.

exact ( {| name := name(p); age := age(p) |}).
(*
you can write 'exact p' or  you can provide it using the constructor
exact (mk_name EmptyString 10).
*)
Defined.

However, in your case, I believe, it will be type error because {| c := ccc ; i := iii |} is not of  Type, Set, or Prop.


Best,
Mukesh




[1] https://coq.inria.fr/refman/language/core/records.html


On Mon, Sep 6, 2021 at 12:25 PM Jeremy Dawson <Jeremy.Dawson AT anu.edu.au> wrote:

Hi,

I have a hypothesis (got by playing around with someone else's code) of
the form {| c := ccc ; i := iii |}

The command Locate "{|". produces no results.

I found in the documentation a syntax definition

term_record::={| field_def*; ;? |}

but I can't find anything about what that means or what you can do with it.

Does it mean I have a thing of type ccc and another thing of type iii?

If so how do I actually get hold of those things?

Then, when I have a goal of the form {| c := ccc ; i := iii |}
what does that mean and what is the next step to solving it?

Thanks

Jeremy




Archive powered by MHonArc 2.6.19+.

Top of Page