Skip to Content.
Sympa Menu

maude-help - [Maude-help] Parametrized list and subsorting...

maude-help AT lists.cs.illinois.edu

Subject: Maude-help mailing list

List archive

[Maude-help] Parametrized list and subsorting...


Chronological Thread 
  • From: Marc Boyer <Marc.Boyer AT onera.fr>
  • To: maude-help AT cs.uiuc.edu
  • Subject: [Maude-help] Parametrized list and subsorting...
  • Date: Mon, 18 Jan 2010 16:02:55 +0100
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/maude-help>
  • List-id: <maude-help.cs.uiuc.edu>

ear all,

I am trying to implement some parametrized programming. As simple
example, I try to build a module that filter a list given some
condition. The example is to remove all elements of a list
of Nat <= a given bound.

My question is in the middle of the code. I have put english
remarks in Maude comments to allow to cut/paste and run it.

**** I need some "generic condition".

fth COND is
including TRIV .
protecting BOOL .
sort CmpParam .
op select( _ , _ ) : Elt CmpParam -> Bool .
endfth

**** I then can write my Filtering generic module.

*** This view allow toi have a LIST of X :: COND
view COND from TRIV to COND is endv

**** Main module
fmod FILTER{ X :: COND } is
protecting LIST{COND}{X} *
( sort List{COND}{X} to List{X},
sort NeList{COND}{X} to NeList{X}
).
op filter( _ , _ ) : List{X} X$CmpParam -> List{X} .

var x : X$Elt .
var cmp : X$CmpParam .
var l : List{X} .
eq filter( nil , cmp ) = nil .
eq filter( x l , cmp) =
if ( select( x , cmp) ) then
x filter( l , cmp )
else
filter( l , cmp )
fi .
endfm


**** Then, I have to instanciate it

view NAT-COND-LTH from COND to NAT is
sort Elt to Nat .
sort CmpParam to Nat .
op select( X:Elt , Y:CmpParam ) to term ( X:Nat < Y:Nat ) .
endv

fmod TEST-FILTER is
protecting LIST{Nat} .
protecting FILTER{NAT-COND-LTH} .
**** Here is my question: why did I need this line ? I have looked at
**** the definition of WEAKLY-SORTABLE-LIST{X :: STRICT-WEAK-ORDER}
**** in the prelude.maude file, I no such subsort declaration is
**** needed. What did I miss ?
subsort List{Nat} < List{NAT-COND-LTH} .

op l : -> List{Nat} .
eq l = 3 4 2 8 6 9 3 2 .
endfm
red filter( l , 3 ) .

--
Marc Boyer, Ingenieur de recherche ONERA
Tel: (33) 5.62.25.26.36 DTIM
Fax: (33) 5.62.25.26.52 2, av Edouard Belin
http://www.onera.fr/staff/marc-boyer/ 31055 TOULOUSE Cedex 4




Archive powered by MHonArc 2.6.16.

Top of Page