SlideShare a Scribd company logo
Programs as Strategies
Programs as Strategies
Computers and
     software are...

• Important
• Ubiquitous
• Complicated
Layers of complexity
•   Programs

•   Compilers

•   Operating System

•   Hardware

•   ... and that’s just on one
    computer.
The usual answer:
            models
•   The “layers” are already
    abstractions.

•   They encapsulate parts
    of the system and
    interact with the rest via
    reduced interfaces.

•   We don’t understand
    the whole truth - just a
    model.
Two models of drinking
     from a tap

•   I turn on the tap and I
    get a drink
Two models of drinking
     from a tap

•   Turning the tap opens a
    valve which releases
    water supplied at a
    pressure of 2 bar...
Models and
          abstractions
• Our conceptual models and their
  corresponding abstractions make complex
  systems tractable.
• Really good models (e.g. scientific theories)
  help us predict, design, and discover.
• What models will help us with
  programming?
Turing machines

•   Alan Turing devised an
    early model of
    computation: the Turing
    Machine.

•   A TM manipulates data
    stored on a tape
    according to a table of
    rules - a fixed program.
Turing machines
• Turing machines expose powerful and
  central concepts:
  • computability
  • time usage
  • space usage
• But they are monolithic, and too low-level
  to be of use in analysing modern software.
Goal: compositionality

• Software is built by assembling small pieces
  of code into large programs.
• Our models should reflect and empower
  this compositionality.
• We need abstractions that support
  composition.
Functions
•   Possibly the most widely used (mathematical) abstraction.
•   We can happily plug functions together:
    •   2x
    •   sin(x)
    •   sin(2x)
    •   x2
    •   sin(2x) + x2

•   These are all functions of type (R→R)
Understanding +

• The + in the last example operates on two
  functions to give another function
                  sin(2x) +   x 2


• So + has the type
         (R→R) ⨉ (R→R) → (R→R)
Higher-order functions
  and programming
• These higher order functions provide both a
  mathematical model of programming and
  an approach to programming itself.
  • higher-order functional programming
    began with LISP in the 1950s.
Programs as functions

function addOne(x:int):int {
  return (x+1);
}
            x↦x+1
Programs as functions

function fact(x:int):int {
  if (x == 0) return 1
  else return (x * fact(x-1));
}

             x ↦ x!
        3↦3⨉2 ⨉1=6
            but why?
Programs as functions

function fact(x:int):int {
  if (x == 0) return 1
  else return (x * fact(x-1));
}

             x ↦ x!
        3↦3⨉2 ⨉1=6
            but why?
Infinity
• Recursion introduces infinity to the picture.
• For programmers, infinity is where the power
  lies.
• For models, infinity is where the problems lie.
• We need some topology to interpret
  recursion: a recursive function is modelled as
  the limit of an infinite sequence of
  approximants.
Imperative programs?
function fact(x:int):int {
  y := x;
  z := 1;
  while (y ≠ 0) {
    z := z ⨉ y;
    y := y-1;
  }
  return z;
}
Modelling memory
• Code like
                  y := y-1
  manipulates (an abstraction of) the memory
  of the computer.
• To model these with functions, we need to
  model the memory itself as a function
              identifiers → values.
Mathematical semantics
• These ideas were the basis of mathematical
  semantics developed by Strachey, Scott and
  others from around 1970.
• The theory provides:
 • an understanding of recursion and loops
 • ways of proving certain correctness
    properties of programs (e.g. Hoare logic)
But

• For imperative programs, the theory breaks
  abstractions: functions can manipulate the
  memory in arbitrary ways.
• There is no way to see the two factorial
  programs as “the same.”
A different abstraction:
       interaction
• Replace functions with interacting agents.
• An agent is a “black box” that receives
  messages from its environment and sends
  out responses.
• Ideas like these were first used in modelling
  concurrent systems (Hoare’s CSP, Milner’s
  CCS) around 1980.
Functions as agents
    input   output
Functions as agents
      input       output




•That was easy!
Functions as agents
      input          output




•That was easy!
•It turns out to be more convenient to add a
“request” protocol at the beginning.
Functions as agents
    request          request
      input          output


•That was easy!
•It turns out to be more convenient to add a
“request” protocol at the beginning.
Plugging together
request         request   request         request
                                                    q
           x2                       x+3
 input          output     input          output
Plugging together
request         request       request         request
                          q
           x2                           x+3
 input          output         input          output
Plugging together
    request         request   request         request
q
               x2                       x+3
     input          output     input          output
Plugging together
request           request   request         request
             x2                       x+3
    input         output     input          output
2
Plugging together
request            request   request         request
              x2                       x+3
 input             output     input          output
          2
Plugging together
request             request   request         request
           x2                           x+3
 input              output     input          output
                4
Plugging together
request         request   request           request
           x2                         x+3
 input          output        input         output
                          4
Plugging together
request         request   request             request
           x2                           x+3
 input          output     input              output
                                    4
Plugging together
request         request   request             request
           x2                       x+3
 input          output     input              output
                                          7
Plugging together
request         request   request         request
           x2                       x+3
 input          output     input          output
                                                    7
Plugging together
request                       request
                                        q
                 x2+3
 input                        output
Plugging together
    request                       request
q
                     x2+3
     input                        output
Plugging together
request                         request
                   x2+3
    input                       output
2
Plugging together
request                       request
                 x2+3
 input                        output
          2
Plugging together
request                       request
                 x2+3
 input                        output
                          7
Plugging together
request                       request
                 x2+3
 input                        output
                                        7
A formalisation: game
      semantics
• This idea can be made precise in lots of
  ways. Here’s one.
• Interaction is the playing of a game between
  the agent and its environment.
• The game specifies what moves are available
  and when they can be played.
• Agent and environment take turns.
The integer game

          request         environment


      0    1   2    ...      agent

A game is a tree of moves. Child moves can
only be played once their parents have been
played.
and its dual

    request            agent


0   1    2    ...   environment
int → int
    request             request


0   1    2    ...   0   1    2    ...
Strategies


• Our “agents” are strategies: plans telling the
  agent what to do in any given situation.
The identity function
     request             request


 0   1    2    ...   0   1    2    ...
The identity function
     request             request


 0   1    2    ...   0   1    2    ...
The identity function
     request             request


 0   1    2    ...   0   1    2    ...
The identity function
     request             request


 0   1    2    ...   0   1    2    ...
The identity function
     request             request


 0   1    2    ...   0   1    2    ...
The identity function
         request              request


     0    1   2    ...    0    1   2    ...

•This strategy implements the function x ↦ x by
copying information.
•It works for any game, with no knowledge of
the moves: pure logic.
History-free strategies

• Every strategy we have seen so far chooses
  its move based only on the last move by
  the environment.
• Notice: history-freeness is preserved by
  plugging.
A new theory
• These ideas form game semantics.
• Games models possess a lot of the
  mathematical structure from the function-
  based semantics:
  • compositionality,
  • recursion as a limit of approximants, etc.
• But also...
A theorem
Theorem [Abramsky-Jagadeesan-
Malacaria 1993/2000; cf. Hyland-Ong,
Nickau]
Every pure functional program denotes a
history-free strategy.
Every computable history-free strategy
can be programmed.
Imperative programs
• Imperative programs work by interacting
  with the computer’s memory.
• Idea: model a memory location as an agent.
 write(true)    write(false)          read

     ok             ok         true          false
Interacting with the
      memory
                write(true)
         cell
Interacting with the
      memory
       write(true)
         cell
Interacting with the
      memory

         cell
           ok
Interacting with the
      memory

         cell
                ok
Interacting with the
      memory
                 read
         cell
Interacting with the
      memory
         read
         cell
Interacting with the
       memory
                      read
                      cell



write(true) ok      read ...then what?
A good memory location cannot be history
free. But the right history-sensitive strategy is
clear.
Extending the theory

• The theory of game semantics extends to
  arbitrary history-sensitive strategies.
• Then the cell can respond appropriately to
  read moves, so we can model the memory.
• Hence...
Another theorem

Theorem [Abramsky-M]
Every program of a certain imperative
language denotes a strategy.
Every computable strategy can be
programmed in this language.
Infinity
• Infinity enters the games models because
  we have to allow moves to be repeated.
Infinity
• Infinity enters the games models because
  we have to allow moves to be repeated.
Infinity
• Infinity enters the games models because
  we have to allow moves to be repeated.
Infinity
• Infinity enters the games models because
  we have to allow moves to be repeated.




• As usual, this is where all the technical
  problems are.
Taming infinity
• We need infinity to interpret recursion and
  loops.
• But we can tame it too:
 • restrict to finite data sets
 • limit the ways moves can be repeated
 • find out what programs are left
Towards automated
correctness checking
Theorem [Ghica-M]
For a certain constrained class of
programs, strategies are finite state
machines.
Therefore, we can automatically check
whether two such programs are equal.
More
•   Lots of other kinds of games to model other
    kinds of programs, logic, ... [numerous authors]
•   Implementation of strategies as circuits [Ghica]
•   Logical counterparts of history-sensitive
    strategies [Churchill, Laird, M]
•   Relational and geometrical foundations of
    game semantics [Calderon, M, Power,
    Wingfield].
Further

•   Modelling the whole
    system - all layers,
    multiple computers,
    people?

•   Quantitative models?
    Power consumption,
    transmission and storage
    costs, ...
Legal bits
•   Photographs used under Creative Commons Attribution-
    NonCommercial-ShareAlike licence:
    •   Circuit Board http://www.flickr.com/photos/loganwilliams/
    •   Tic Tac Toe http://www.flickr.com/photos/anonymonk/
    •   Code http://www.flickr.com/photos/circle_hk
    •   Go http://www.flickr.com/photos/spwelton/
    •   Lego http://www.flickr.com/photos/kaptainkobold/
    •   Cat drinking http://www.flickr.com/photos/meantux/
    •   Alan Turing http://www.flickr.com/photos/sbisson/
    •   Blue Sky http://www.flickr.com/photos/11247304@N06

More Related Content

What's hot

Max Koretskyi "Why are Angular and React so fast?"
Max Koretskyi "Why are Angular and React so fast?"Max Koretskyi "Why are Angular and React so fast?"
Max Koretskyi "Why are Angular and React so fast?"
Fwdays
 
Computer Programming- Lecture 6
Computer Programming- Lecture 6Computer Programming- Lecture 6
Computer Programming- Lecture 6
Dr. Md. Shohel Sayeed
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
rik0
 
C++ Course - Lesson 2
C++ Course - Lesson 2C++ Course - Lesson 2
C++ Course - Lesson 2Mohamed Ahmed
 
Functional solid
Functional solidFunctional solid
Functional solid
Matt Stine
 
Python Programming: Data Structure
Python Programming: Data StructurePython Programming: Data Structure
Python Programming: Data Structure
Chan Shik Lim
 
C++ L09-Classes Part2
C++ L09-Classes Part2C++ L09-Classes Part2
C++ L09-Classes Part2
Mohammad Shaker
 
Lecture02 class -_templatev2
Lecture02 class -_templatev2Lecture02 class -_templatev2
Lecture02 class -_templatev2Hariz Mustafa
 
C# - What's next
C# - What's nextC# - What's next
C# - What's next
Christian Nagel
 
Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...
Andreas Dewes
 
Python Puzzlers
Python PuzzlersPython Puzzlers
Python Puzzlers
Tendayi Mawushe
 
Learning from other's mistakes: Data-driven code analysis
Learning from other's mistakes: Data-driven code analysisLearning from other's mistakes: Data-driven code analysis
Learning from other's mistakes: Data-driven code analysis
Andreas Dewes
 
Objective-Cひとめぐり
Objective-CひとめぐりObjective-Cひとめぐり
Objective-Cひとめぐり
Kenji Kinukawa
 
Chapter 4 - Classes in Java
Chapter 4 - Classes in JavaChapter 4 - Classes in Java
Chapter 4 - Classes in Java
Khirulnizam Abd Rahman
 
Chapter 7 functions (c)
Chapter 7 functions (c)Chapter 7 functions (c)
Chapter 7 functions (c)
hhliu
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
PrudhviVuda
 
Python GUI Programming
Python GUI ProgrammingPython GUI Programming
Python GUI Programming
RTS Tech
 
Chapter 3 Arrays in Java
Chapter 3 Arrays in JavaChapter 3 Arrays in Java
Chapter 3 Arrays in Java
Khirulnizam Abd Rahman
 
Scala best practices
Scala best practicesScala best practices
Scala best practices
Alexander Zaidel
 

What's hot (20)

Max Koretskyi "Why are Angular and React so fast?"
Max Koretskyi "Why are Angular and React so fast?"Max Koretskyi "Why are Angular and React so fast?"
Max Koretskyi "Why are Angular and React so fast?"
 
Computer Programming- Lecture 6
Computer Programming- Lecture 6Computer Programming- Lecture 6
Computer Programming- Lecture 6
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
 
C++ Course - Lesson 2
C++ Course - Lesson 2C++ Course - Lesson 2
C++ Course - Lesson 2
 
Functional solid
Functional solidFunctional solid
Functional solid
 
Python Programming: Data Structure
Python Programming: Data StructurePython Programming: Data Structure
Python Programming: Data Structure
 
C++ L09-Classes Part2
C++ L09-Classes Part2C++ L09-Classes Part2
C++ L09-Classes Part2
 
Lecture02 class -_templatev2
Lecture02 class -_templatev2Lecture02 class -_templatev2
Lecture02 class -_templatev2
 
Python lecture 03
Python lecture 03Python lecture 03
Python lecture 03
 
C# - What's next
C# - What's nextC# - What's next
C# - What's next
 
Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...
 
Python Puzzlers
Python PuzzlersPython Puzzlers
Python Puzzlers
 
Learning from other's mistakes: Data-driven code analysis
Learning from other's mistakes: Data-driven code analysisLearning from other's mistakes: Data-driven code analysis
Learning from other's mistakes: Data-driven code analysis
 
Objective-Cひとめぐり
Objective-CひとめぐりObjective-Cひとめぐり
Objective-Cひとめぐり
 
Chapter 4 - Classes in Java
Chapter 4 - Classes in JavaChapter 4 - Classes in Java
Chapter 4 - Classes in Java
 
Chapter 7 functions (c)
Chapter 7 functions (c)Chapter 7 functions (c)
Chapter 7 functions (c)
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Python GUI Programming
Python GUI ProgrammingPython GUI Programming
Python GUI Programming
 
Chapter 3 Arrays in Java
Chapter 3 Arrays in JavaChapter 3 Arrays in Java
Chapter 3 Arrays in Java
 
Scala best practices
Scala best practicesScala best practices
Scala best practices
 

Similar to Programs as Strategies

Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)
Scott Wlaschin
 
Yin Yangs of Software Development
Yin Yangs of Software DevelopmentYin Yangs of Software Development
Yin Yangs of Software Development
Naveenkumar Muguda
 
Iterarators and generators in python
Iterarators and generators in pythonIterarators and generators in python
Iterarators and generators in python
Sarfaraz Ghanta
 
C++ Language
C++ LanguageC++ Language
C++ Language
Syed Zaid Irshad
 
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
Tech in Asia ID
 
Computing with P systems
Computing with P systemsComputing with P systems
Computing with P systems
Apostolos Syropoulos
 
Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)Peter Kofler
 
Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssionseShikshak
 
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsGo Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Jonas Bonér
 
Overview of Python - Bsides Detroit 2012
Overview of Python - Bsides Detroit 2012Overview of Python - Bsides Detroit 2012
Overview of Python - Bsides Detroit 2012
Tazdrumm3r
 
python ppt.pptx
python ppt.pptxpython ppt.pptx
python ppt.pptx
MONAR11
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011Juan Gomez
 
Concurrency for dummies
Concurrency for dummiesConcurrency for dummies
Concurrency for dummiesAzrul MADISA
 
vhdl.ppt Verilog Hardware Description Language
vhdl.ppt Verilog Hardware Description Languagevhdl.ppt Verilog Hardware Description Language
vhdl.ppt Verilog Hardware Description Language
shreenathji26
 
[系列活動] 一日搞懂生成式對抗網路
[系列活動] 一日搞懂生成式對抗網路[系列活動] 一日搞懂生成式對抗網路
[系列活動] 一日搞懂生成式對抗網路
台灣資料科學年會
 
Functional Programming and Composing Actors
Functional Programming and Composing ActorsFunctional Programming and Composing Actors
Functional Programming and Composing Actors
legendofklang
 
LEC 7-DS ALGO(expression and huffman).pdf
LEC 7-DS  ALGO(expression and huffman).pdfLEC 7-DS  ALGO(expression and huffman).pdf
LEC 7-DS ALGO(expression and huffman).pdf
MuhammadUmerIhtisham
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learningbutest
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learningbutest
 

Similar to Programs as Strategies (20)

Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)
 
Clojure intro
Clojure introClojure intro
Clojure intro
 
Yin Yangs of Software Development
Yin Yangs of Software DevelopmentYin Yangs of Software Development
Yin Yangs of Software Development
 
Iterarators and generators in python
Iterarators and generators in pythonIterarators and generators in python
Iterarators and generators in python
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
 
Computing with P systems
Computing with P systemsComputing with P systems
Computing with P systems
 
Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)
 
Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssions
 
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsGo Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
 
Overview of Python - Bsides Detroit 2012
Overview of Python - Bsides Detroit 2012Overview of Python - Bsides Detroit 2012
Overview of Python - Bsides Detroit 2012
 
python ppt.pptx
python ppt.pptxpython ppt.pptx
python ppt.pptx
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011
 
Concurrency for dummies
Concurrency for dummiesConcurrency for dummies
Concurrency for dummies
 
vhdl.ppt Verilog Hardware Description Language
vhdl.ppt Verilog Hardware Description Languagevhdl.ppt Verilog Hardware Description Language
vhdl.ppt Verilog Hardware Description Language
 
[系列活動] 一日搞懂生成式對抗網路
[系列活動] 一日搞懂生成式對抗網路[系列活動] 一日搞懂生成式對抗網路
[系列活動] 一日搞懂生成式對抗網路
 
Functional Programming and Composing Actors
Functional Programming and Composing ActorsFunctional Programming and Composing Actors
Functional Programming and Composing Actors
 
LEC 7-DS ALGO(expression and huffman).pdf
LEC 7-DS  ALGO(expression and huffman).pdfLEC 7-DS  ALGO(expression and huffman).pdf
LEC 7-DS ALGO(expression and huffman).pdf
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 

Recently uploaded

Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 

Recently uploaded (20)

Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 

Programs as Strategies

  • 3. Computers and software are... • Important • Ubiquitous • Complicated
  • 4. Layers of complexity • Programs • Compilers • Operating System • Hardware • ... and that’s just on one computer.
  • 5. The usual answer: models • The “layers” are already abstractions. • They encapsulate parts of the system and interact with the rest via reduced interfaces. • We don’t understand the whole truth - just a model.
  • 6. Two models of drinking from a tap • I turn on the tap and I get a drink
  • 7. Two models of drinking from a tap • Turning the tap opens a valve which releases water supplied at a pressure of 2 bar...
  • 8. Models and abstractions • Our conceptual models and their corresponding abstractions make complex systems tractable. • Really good models (e.g. scientific theories) help us predict, design, and discover. • What models will help us with programming?
  • 9. Turing machines • Alan Turing devised an early model of computation: the Turing Machine. • A TM manipulates data stored on a tape according to a table of rules - a fixed program.
  • 10. Turing machines • Turing machines expose powerful and central concepts: • computability • time usage • space usage • But they are monolithic, and too low-level to be of use in analysing modern software.
  • 11. Goal: compositionality • Software is built by assembling small pieces of code into large programs. • Our models should reflect and empower this compositionality. • We need abstractions that support composition.
  • 12. Functions • Possibly the most widely used (mathematical) abstraction. • We can happily plug functions together: • 2x • sin(x) • sin(2x) • x2 • sin(2x) + x2 • These are all functions of type (R→R)
  • 13. Understanding + • The + in the last example operates on two functions to give another function sin(2x) + x 2 • So + has the type (R→R) ⨉ (R→R) → (R→R)
  • 14. Higher-order functions and programming • These higher order functions provide both a mathematical model of programming and an approach to programming itself. • higher-order functional programming began with LISP in the 1950s.
  • 15. Programs as functions function addOne(x:int):int { return (x+1); } x↦x+1
  • 16. Programs as functions function fact(x:int):int { if (x == 0) return 1 else return (x * fact(x-1)); } x ↦ x! 3↦3⨉2 ⨉1=6 but why?
  • 17. Programs as functions function fact(x:int):int { if (x == 0) return 1 else return (x * fact(x-1)); } x ↦ x! 3↦3⨉2 ⨉1=6 but why?
  • 18. Infinity • Recursion introduces infinity to the picture. • For programmers, infinity is where the power lies. • For models, infinity is where the problems lie. • We need some topology to interpret recursion: a recursive function is modelled as the limit of an infinite sequence of approximants.
  • 19. Imperative programs? function fact(x:int):int { y := x; z := 1; while (y ≠ 0) { z := z ⨉ y; y := y-1; } return z; }
  • 20. Modelling memory • Code like y := y-1 manipulates (an abstraction of) the memory of the computer. • To model these with functions, we need to model the memory itself as a function identifiers → values.
  • 21. Mathematical semantics • These ideas were the basis of mathematical semantics developed by Strachey, Scott and others from around 1970. • The theory provides: • an understanding of recursion and loops • ways of proving certain correctness properties of programs (e.g. Hoare logic)
  • 22. But • For imperative programs, the theory breaks abstractions: functions can manipulate the memory in arbitrary ways. • There is no way to see the two factorial programs as “the same.”
  • 23. A different abstraction: interaction • Replace functions with interacting agents. • An agent is a “black box” that receives messages from its environment and sends out responses. • Ideas like these were first used in modelling concurrent systems (Hoare’s CSP, Milner’s CCS) around 1980.
  • 24. Functions as agents input output
  • 25. Functions as agents input output •That was easy!
  • 26. Functions as agents input output •That was easy! •It turns out to be more convenient to add a “request” protocol at the beginning.
  • 27. Functions as agents request request input output •That was easy! •It turns out to be more convenient to add a “request” protocol at the beginning.
  • 28. Plugging together request request request request q x2 x+3 input output input output
  • 29. Plugging together request request request request q x2 x+3 input output input output
  • 30. Plugging together request request request request q x2 x+3 input output input output
  • 31. Plugging together request request request request x2 x+3 input output input output 2
  • 32. Plugging together request request request request x2 x+3 input output input output 2
  • 33. Plugging together request request request request x2 x+3 input output input output 4
  • 34. Plugging together request request request request x2 x+3 input output input output 4
  • 35. Plugging together request request request request x2 x+3 input output input output 4
  • 36. Plugging together request request request request x2 x+3 input output input output 7
  • 37. Plugging together request request request request x2 x+3 input output input output 7
  • 38. Plugging together request request q x2+3 input output
  • 39. Plugging together request request q x2+3 input output
  • 40. Plugging together request request x2+3 input output 2
  • 41. Plugging together request request x2+3 input output 2
  • 42. Plugging together request request x2+3 input output 7
  • 43. Plugging together request request x2+3 input output 7
  • 44. A formalisation: game semantics • This idea can be made precise in lots of ways. Here’s one. • Interaction is the playing of a game between the agent and its environment. • The game specifies what moves are available and when they can be played. • Agent and environment take turns.
  • 45. The integer game request environment 0 1 2 ... agent A game is a tree of moves. Child moves can only be played once their parents have been played.
  • 46. and its dual request agent 0 1 2 ... environment
  • 47. int → int request request 0 1 2 ... 0 1 2 ...
  • 48. Strategies • Our “agents” are strategies: plans telling the agent what to do in any given situation.
  • 49. The identity function request request 0 1 2 ... 0 1 2 ...
  • 50. The identity function request request 0 1 2 ... 0 1 2 ...
  • 51. The identity function request request 0 1 2 ... 0 1 2 ...
  • 52. The identity function request request 0 1 2 ... 0 1 2 ...
  • 53. The identity function request request 0 1 2 ... 0 1 2 ...
  • 54. The identity function request request 0 1 2 ... 0 1 2 ... •This strategy implements the function x ↦ x by copying information. •It works for any game, with no knowledge of the moves: pure logic.
  • 55. History-free strategies • Every strategy we have seen so far chooses its move based only on the last move by the environment. • Notice: history-freeness is preserved by plugging.
  • 56. A new theory • These ideas form game semantics. • Games models possess a lot of the mathematical structure from the function- based semantics: • compositionality, • recursion as a limit of approximants, etc. • But also...
  • 57. A theorem Theorem [Abramsky-Jagadeesan- Malacaria 1993/2000; cf. Hyland-Ong, Nickau] Every pure functional program denotes a history-free strategy. Every computable history-free strategy can be programmed.
  • 58. Imperative programs • Imperative programs work by interacting with the computer’s memory. • Idea: model a memory location as an agent. write(true) write(false) read ok ok true false
  • 59. Interacting with the memory write(true) cell
  • 60. Interacting with the memory write(true) cell
  • 61. Interacting with the memory cell ok
  • 62. Interacting with the memory cell ok
  • 63. Interacting with the memory read cell
  • 64. Interacting with the memory read cell
  • 65. Interacting with the memory read cell write(true) ok read ...then what? A good memory location cannot be history free. But the right history-sensitive strategy is clear.
  • 66. Extending the theory • The theory of game semantics extends to arbitrary history-sensitive strategies. • Then the cell can respond appropriately to read moves, so we can model the memory. • Hence...
  • 67. Another theorem Theorem [Abramsky-M] Every program of a certain imperative language denotes a strategy. Every computable strategy can be programmed in this language.
  • 68. Infinity • Infinity enters the games models because we have to allow moves to be repeated.
  • 69. Infinity • Infinity enters the games models because we have to allow moves to be repeated.
  • 70. Infinity • Infinity enters the games models because we have to allow moves to be repeated.
  • 71. Infinity • Infinity enters the games models because we have to allow moves to be repeated. • As usual, this is where all the technical problems are.
  • 72. Taming infinity • We need infinity to interpret recursion and loops. • But we can tame it too: • restrict to finite data sets • limit the ways moves can be repeated • find out what programs are left
  • 73. Towards automated correctness checking Theorem [Ghica-M] For a certain constrained class of programs, strategies are finite state machines. Therefore, we can automatically check whether two such programs are equal.
  • 74. More • Lots of other kinds of games to model other kinds of programs, logic, ... [numerous authors] • Implementation of strategies as circuits [Ghica] • Logical counterparts of history-sensitive strategies [Churchill, Laird, M] • Relational and geometrical foundations of game semantics [Calderon, M, Power, Wingfield].
  • 75. Further • Modelling the whole system - all layers, multiple computers, people? • Quantitative models? Power consumption, transmission and storage costs, ...
  • 76. Legal bits • Photographs used under Creative Commons Attribution- NonCommercial-ShareAlike licence: • Circuit Board http://www.flickr.com/photos/loganwilliams/ • Tic Tac Toe http://www.flickr.com/photos/anonymonk/ • Code http://www.flickr.com/photos/circle_hk • Go http://www.flickr.com/photos/spwelton/ • Lego http://www.flickr.com/photos/kaptainkobold/ • Cat drinking http://www.flickr.com/photos/meantux/ • Alan Turing http://www.flickr.com/photos/sbisson/ • Blue Sky http://www.flickr.com/photos/11247304@N06

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n