Skip to Content.
Sympa Menu

ssreflect - Re: [ssreflect] Defining functions of fintypes

Subject: Ssreflect Users Discussion List

List archive

Re: [ssreflect] Defining functions of fintypes


Chronological Thread 
  • From: Nicolas Magaud <>
  • To: Cyril <>
  • Cc:
  • Subject: Re: [ssreflect] Defining functions of fintypes
  • Date: Thu, 28 Sep 2017 09:28:40 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:dyms4ByeCz7QfczXCy+O+j09IxM/srCxBDY+r6Qd0uwQIJqq85mqBkHD//Il1AaPBtqLra8cw8Pt8IneGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2NBXupSiZ/CQTHl2rPhtvJ+CzEYnSgsKf1uao+pSVbR8e1xSnZrYnChS9qgHYrYEziIRrN6p5nh7ArXJVd8xLw2JzOUia2RjmsJTjtKV/+jhd7qpyv/VLVr/3Kvw1

Thanks for this example.

This function has type : simpl_fun (prod_eqType nat_eqType nat_eqType) nat.

I have 2 other questions :

1/ Is it possible to have the type "simpl_fun (prod_eqType ‘I_3 ‘I_3)" nat
instead ?

2/ Moreover, is it possible to have a curryfing version of f’ whose type
would be "simpl_fun ‘I_3 (simpl_fun ‘I_3 nat)" ?

Nicolas Magaud


> On 27 Sep 2017, at 15:09, Cyril
> <>
> wrote:
>
> Dear Nicolas, your code almost work, because there is no need for a pattern
> matching:
>
> Definition f' :=
> [fun _ => 0 with (0,0) |-> 42,
> (0,1) |-> 7,
> (0,2) |-> 28,
> (1,0) |-> 2,
> (1,1) |-> 8,
> (1,2) |-> 70,
> (2,0) |-> 116,
> (2,1) |-> 53,
> (2,2) |-> 47].
>
> --
> Cyril
>
> On 27/09/2017 14:19, Nicolas Magaud wrote:
>> Dear all,
>> I have trouble defining finite functions (on finite domains) which have 2
>> or more arguments using the [] notation.
>> Below is a example of what I am trying to do.
>> I would like to define the function f’ using pattern matching on a couple
>> or on the 2 separate arguments (in a currified way) but without doing
>> explicit lambda-abstraction.
>> Is there a way to do that ? This would make the code more readable once
>> the fun and => keywords are gone.
>> Nicolas Magaud
>> (* full example *)
>> Definition Symb := 'I_3.
>> (* code that works *)
>> Definition easy := [fun x : Symb => 0 with 0 |-> 16, 1 |-> 18, 2|-> 34].
>> Definition f :=
>> [ fun x:Symb =>
>> [ fun y:Symb => 0 with
>> 0 |-> [fun x':Symb => 17 with 0 |-> 42, 1 |-> 7, 2 |-> 28] x,
>> 1 |-> [fun x':Symb => 34 with 0 |-> 2, 1 |-> 8, 2 |-> 70] x,
>> 2 |-> [fun x':Symb => 72 with 0 |-> 116, 1 |-> 53, 2 |-> 47] x]].
>> (* code I would like to write or something like that, i.e. with no
>> lambda-abstractions *)
>> Definition f' :=
>> [fun (x,y) => 0 with (0,0) |-> 42,
>> (0,1) |- 7,
>> (0,2) |- 28,
>> (1,0) |-> 2,
>> (1,1) |- 8,
>> (1,2) |- 70,
>> (2,0) |-> 116,
>> (2,1) |- 53,
>> (2,2) |- 47].
>
> --
> Cyril



Archive powered by MHonArc 2.6.18.

Top of Page