Skip to Content.
Sympa Menu

k-user - [K-user] Bags

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

[K-user] Bags


Chronological Thread 
  • From: "Saha, Shambwaditya" <ssaha6 AT illinois.edu>
  • To: k-user AT cs.uiuc.edu
  • Subject: [K-user] Bags
  • Date: Thu, 26 Dec 2013 16:06:52 -0600
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

Hi,

I want to define a search function on Bag of Ints. I tried to write something of the form :

  syntax Bool ::= "search" Bag Int
  rule search ( V:BagItem Bg:Bag) V1:Int => true when V ==K V1
  rule search (V1:BagItem Bg:Bag) V:Int => search Bg V when V1 =/=K V 
  rule search .Bag V:Int => false 

This definition is obviously not correct, and I have a few questions about it : 

1. How do we specifically mention in the syntax that we want Bag of Ints. 
2. It is showing an error : "Variable V is contextually expected to have sort K but it has been declared (or infered) of sort BagItem", how should we solve it. 
3. And what should be a valid instance of this program. i.e. how should we specify a bag, in krun.

Thanks in Advance!

Regards,
Shambwaditya



Archive powered by MHonArc 2.6.16.

Top of Page