Skip to content

Instantly share code, notes, and snippets.

@shirhatti
Last active August 29, 2015 14:10
Show Gist options
  • Save shirhatti/a3aac0b35a564b2331d4 to your computer and use it in GitHub Desktop.
Save shirhatti/a3aac0b35a564b2331d4 to your computer and use it in GitHub Desktop.
382V Notes for November 11

#EE382V/379K: Multicore Computing

##Agenda 0. Communicating Sequencer Processes 0. Temporal Logic

##Backus-Naur Form

  • Developed to describe the Syntax of ALGOL
  • Context-free grammar used describe the syntax of programming langauages.
  • Example of a rule <symbol> ::= __expression__
  • Anything in < > is a non-terminal, anything without angle brackets is terminal
  • Rules are complete when everything ends in a terminal command
  • Tools like YACC (Yet Another Compiler Compiler) can produce a parser when you describe a language in a Analytical Grammar (similar to BNF)

BNF rules for Guarded Command Language

This is not a comlete list of rules. Just a few rules

  1. <command> ::= <simple command> | <structure command>
  2. <simple command> ::= <null command> | <assignment command> | <input command> | <output command>
  3. <structure command> ::= <alternative command> | <repetitive command> | <parallel command>
  4. <null command> ::= skip

Program to set at most 100 numbers

s(i : 1..100)::
  *[ 
      n: integer; s(i-1)? has(n) → s(0)! false
    ▯
      [ 
        n: integer;
        s(i-1)? insert(n) → 
        *[  
            m: integer;
            s(i-1)? has(m) →
            [ 
              m ≤ n → s(0)! (m=n)
            ▯
              m > n → s(i+1)! has(m)
            ]
          ▯
            m: integer; s(i-1)? insert(m) →
            [
              m < n → s(i+1)? insert(n);n := m;
            ▯
              m = n → skip;
            ▯
              m > n → s(i+1)! has(m)
            ]
          ]
      ]
    ] 

Producer - Consumer Bounded Buffer

x:: buffer(0..9) portion;
in,out:: integer;
in:= 0;
out:= 10;
// 0 ≤ out ≤ in ≤ out+10
*[
 (in < out +10); producer ? buffer (in mod 10) → in := in + 1;
▯
 out < in; consumemr? more () →
  consumer ! buffer (out mod 10); out := out +1;
]

Temporal Logic (E. M. Clarke)

Syntax of CTL

  1. Every atomic prop p ∈ AP is a CTL formula
  2. If f1 and f2 are CTL formulas then so are
  • ¬f1
  • f1 ^ f2
  • A x f1
  • E x f1
  • A[f1 ʋ f2]
  • E[f1 ʋ f2]

Semantics

Defined using M = (S, R, P)

Kripke Structure

  • S: finite set of sets
  • R: binary relation in S (R ⊆ S × S)
  • P: S → 2AP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment