79095494

Date: 2024-10-16 19:10:59
Score: 0.5
Natty:
Report link

The correct solution to the problem is the following:

class A {
    var x : int 
    var y : int

  }

  class B 
  {
    const l : seq<A>

    method m()
        modifies (set a | a in l)`x
        ensures forall a :: a in l ==> a.x == 10
        ensures forall a :: a in l ==>  unchanged(a`y)
    {
       var it := 0;
       while it < |l|
            invariant 0 <= it <= |l|
            invariant forall a :: a in l[..it] ==> a.x == 10
        {
            l[it].x := 10;
            it := it + 1;
        }
    }
  }
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: redo