regular expressions any character is a regexp Kleene * matches - - PowerPoint PPT Presentation

regular expressions
SMART_READER_LITE
LIVE PREVIEW

regular expressions any character is a regexp Kleene * matches - - PowerPoint PPT Presentation

how hard can it be? algorithms: what can they do? what cant they do? Saturday, 3 December 2011 regular expressions any character is a regexp Kleene * matches itself if R and S are regexps, so is RS matches a


slide-1
SLIDE 1

how hard can it be?

algorithms:

  • what can they do?
  • what can’t they do?

Saturday, 3 December 2011

slide-2
SLIDE 2
  • any character is a regexp
  • matches itself
  • if R and S are regexps, so is RS
  • matches

a match for R followed by a match for S

  • if R and S are regexps, so is R|S
  • matches

any match for R or S (or both)

  • if R is a regexp, so is R*
  • matches

any sequence of 0 or more matches for R

regular expressions

Stephen Kleene 1909-1994

Kleene *

Saturday, 3 December 2011

slide-3
SLIDE 3

http://xkcd.com/

Saturday, 3 December 2011

slide-4
SLIDE 4

algorithms

in three easy parts

  • giving instructions
  • sequence, parameters
  • conditionals, iteration, recursion
  • needles in haystacks
  • hard to find; easy to recognise
  • some things are impossible
  • “I never tell the truth”

Saturday, 3 December 2011

slide-5
SLIDE 5

sequence

  • separate four eggs
  • beat the whites
  • ...

Saturday, 3 December 2011

slide-6
SLIDE 6

parametrisation

  • separate three eggs
  • beat the whites
  • ...

Saturday, 3 December 2011

slide-7
SLIDE 7

parametrisation

  • separate n eggs
  • beat the whites
  • ...

Saturday, 3 December 2011

slide-8
SLIDE 8

if your potatoes are large

  • cut them into bite-sized pieces

conditional

Saturday, 3 December 2011

slide-9
SLIDE 9

iteration

  • beat until the whites

form stiff peaks

Saturday, 3 December 2011

slide-10
SLIDE 10

recursion: sourdough

  • To make sourdough
  • take your sourdough out of the fridge
  • add a cup of warm water and a cup of flour to

the bowl

  • leave to prove for eight hours
  • put half of the mixture in the fridge
  • use the other half to make bread

Saturday, 3 December 2011

slide-11
SLIDE 11

sourdough bread

  • Ingredients
  • sourdough starter
  • unbleached flour
  • 2 tablespoons of olive oil
  • r softened margarine
  • 4 teaspoons of sugar
  • 2 teaspoons of salt
  • Method
  • mix all ingredients adding

flour until you have a stiff dough

  • repeat twice
  • knead well
  • leave to rise
  • form into a loaf and bake

Saturday, 3 December 2011

slide-12
SLIDE 12

non-termination

beat the milk until it forms stiff peaks

Saturday, 3 December 2011

slide-13
SLIDE 13

algorithms

in three easy parts

  • giving instructions
  • sequence, parameters
  • conditionals, iteration, recursion
  • needles in haystacks
  • hard to find; easy to recognise
  • some things are impossible

Saturday, 3 December 2011

slide-14
SLIDE 14

Saturday, 3 December 2011

slide-15
SLIDE 15

Saturday, 3 December 2011

slide-16
SLIDE 16

Saturday, 3 December 2011

slide-17
SLIDE 17

Saturday, 3 December 2011

slide-18
SLIDE 18

maze generator

Saturday, 3 December 2011

slide-19
SLIDE 19

Saturday, 3 December 2011

slide-20
SLIDE 20

algorithms

in three easy parts

  • giving instructions
  • sequence, parameters
  • conditionals, iteration, recursion
  • needles in haystacks
  • hard to find; easy to recognise
  • some things are impossible

Saturday, 3 December 2011

slide-21
SLIDE 21

Saturday, 3 December 2011

slide-22
SLIDE 22

circular reference

  • A:

statement B is true

  • B:

statement A is false

Saturday, 3 December 2011

slide-23
SLIDE 23

self reference

  • A:

statement A is false

  • E:

statement E is true

Escher, Hands

Saturday, 3 December 2011

slide-24
SLIDE 24

Albert says "Everything Caroline says is true" Betty says "Everything I say is false" Caroline says "Everything David says is true" David says "Everything Caroline says is false"

Who is the only person who can be telling the truth?

This is a sample question for the Cambridge admissions test for philosophy.

exercise

Saturday, 3 December 2011