Larch: Slide 1

INTRODUCTION TO 
Larch


NOTES:


Larch: Slide 2

Role of Specification


Larch: Slide 3

Two Tiered Specification Language


Larch: Slide 4

Larch Shared Language


Larch: Slide 5

Larch Interface Language


Larch: Slide 6


Larch: Slide 7

Basic concepts of logic


Larch: Slide 8


Larch: Slide 9

  • Example of a model of a set of sentences:

  • NOTES 9:

    Normally you would see the sentences written with the symbol < instead of $.


    Larch: Slide 10


    Larch: Slide 11

    A few more definitions (semantic description):


    Larch: Slide 12

    Proof and consequences -- Syntactic Characterization


    Larch: Slide 13


    Larch:Slide 14


    LSL: The Larch Shared Language :
    A discussion using examples.

    What is a table?



    Larch: Slide 15

    Table:  trait 
    %Specification of Tables that store values in indexed places.
    introduces 
       new: -> Tab
       add: Tab, Ind, Val->Tab
       __ \in __: Ind, Tab->Val
       lookup: Tab, Ind->Bool
       isEmpty: Tab->Bool
       size: Tab->Int
       0,1: ->Int
       __ + __: Int, Int->Int
    
    asserts 
      forall i, i1: Ind, val: Val, t:Tab 
       ~(i \in new) 
       i \in add(t, i1, val) == i = i1 \/ i \in t; 
       lookup(add(t, i, val), i1) == 
           if i = i1 then val else lookup(t, i1);
       size(new) == 0;
       size(add(t, i, val)) 
           = if i \in t then size(t) else size(t) + 1;
       isEmpty(t) == size(t) = 0
    


    Larch: Slide 16

    Explanation of reserved words in LSL on Slide 15


    Notes 16

    ~(i \in new)

    is an abbreviation for

    ~(i \in new) == true


    Larch: Slide 17

    Precedence scheme: most tightly to least tightly binding

    Example:


    Larch: Slide 18

    For specifying an abstract type a theory stronger than equational theory is often needed.


    Larch: Slide 19

    The table specification including the use of partitioned by and generated by.

    Table:  trait 
    %Specification of Tables 
    %that store values in 
    %indexed places.
    introduces 
      new: -> Tab
      add: Tab, Ind, Val->Tab
      __ \in __: Ind, Tab->Val
      lookup: Tab, Ind->Bool
      isEmpty: Tab->Bool
      size: Tab->Int
      0,1: ->Int
      __ + __: Int, Int->Int
    asserts 
     Tab generated by new, add
     Tab partitioned by \in, lookup
     forall i, i1: Ind, val: Val, t:Tab 
       ~(i \in new) 
       i \in add(t, i1, val) == i = i1 \/ i \in t; 
       lookup(add(t, i, val), i1) ==
          if i = i1 then val else lookup(t, i1);
       size(new) == 0;
       size(add(t, i, val)) ==
          if i \in t then size(t) else size(t) + 1;
       isEmpty(t) == size(t) = 0


    Larch: Slide 20

    Using generated by a list of operations to prove

    forall t:Tab, i:Ind (i \in t => size (t) > 0) 
    forall i:Ind (i \in new => size(new) > 0)
    forall t:Tab, i1:Ind, v1:Val
      (forall i:Ind ( i \in t => size(t) > 0)
        => (forall i:Ind ( i \in add(t,i1,v1) 
          => size (add(t,i1,v1)) > 0))
    forall i1:Ind (i1 \in t1 = i1 \in t2),
        forall i1:Ind (lookup(t1, i1) = lookup(t2,i1))
    --------------------------------------------------
                        t1 = t2
    forall t:Tab, i,i1:Ind, v:Val 
      (add(add(t,i,v), i1,v)
           = add(add(t,i1,v) i,v) )
    forall i2:Ind
      (i2 \in add(add(t,i,v), i1,v) = i2 \in add(add(t,i1,v), i,v))
    
    forall i2:Ind
       (lookup(add(add(t,i,v) i1,v),i2)
           = lookup(add(add(t,i1,v),i,v),i2))
    


    Larch: Slide 21

    Combining Traits:


    Larch: Slide 22

    Table:  trait 
    %Specification of Tables that store values in indexed places.
    includes Integer
    introduces 
       new: -> Tab
       add: Tab, Ind, Val->Tab
       __ \in __: Ind, Tab->Val
       lookup: Tab, Ind->Bool
       isEmpty: Tab->Bool
       size: Tab->Int
       0,1: ->Int
       __ + __: Int, Int->Int
    asserts 
      Tab generated by new, add
      Tab partitioned by \in, lookup
      forall i, i1: Ind, val: Val, t:Tab 
         ~(i \in new) 
         i \in add(t, i1, val) == i = i1 \/ i \in t; 
         lookup(add(t, i, val), i1) ==
            if i = i1 then val else lookup(t, i1);
         size(new) == 0;
         size(add(t, i, val)) ==
            if i \in t then size(t) else size(t) + 1;
         isEmpty(t) == size(t) = 0


    Larch: Slide 23

    Another Example of includes:Given Specifications of relations,


    Larch: Slide 24

    Renaming: Any sort or operator can be renamed when the trait is referenced in another trait.

    to Slide 25


    NOTES 24:

    Two specifications of sparse arrays:


    Larch: Slide 25


    Larch: Slide 26


    Larch: Slide 27


    Larch: Slide 28

    More Examples:


    Notes: 28

    When specifying abstract data types you should add assertions for how to generate the data and how to observe the data. (ie Include assertions on generate by and partition by.)


    Larch: Slide 29


    Larch: Slide 30


    Notes 30:

    Check out LSL Handbook of Table of Contents web page for more examples of LSL specifications.