Examples and sets
Download
1 / 15

Examples and Sets - PowerPoint PPT Presentation


  • 83 Views
  • Uploaded on

Examples and Sets. Synthesize each of These. choose (( x,y ) => 10 x + 14 y == a ) . choose (( x,y ) => 10 x + 14 y == a && x < y ) . choose (( x,y ) => 10 x + 14 y == a && 0 < x && x < y ) . Constructive (Extended) Euclid’s Algorithm: gcd (10,14).

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Examples and Sets' - kedma


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Synthesize each of these
Synthesize each of These

choose((x,y) => 10 x + 14 y == a )

choose((x,y) => 10 x + 14 y == a && x < y)

choose((x,y) => 10 x + 14 y == a

&& 0 < x && x < y)


Constructive extended euclid s algorithm gcd 10 14
Constructive (Extended) Euclid’s Algorithm: gcd(10,14)

10 1410 4

6 4

4

2 2

2 0

10 x + 14 y == 10 x + 14 y == a


Result of synthesis for one equation
Result of Synthesis for one Equation

choose((x,y) => 10 x + 14 y == a )

assert ( )

valx = valy =

check the solution:

Change in requirements! Customer also wants: x < y

does our solution work for e.g. a=2


Idea eliminate variables
Idea: Eliminate Variables

choose((x,y) => 10 x + 14 y == a && x < y)

Cannot easily eliminate one of the x,y.

  • Eliminate both x,y, get one free - z

x = 3/2 a + c1 z

y = -a + c2 z

c1 = ?

c2= ?

  • Find general form, characterize all solutions,

  • parametric solution


Idea eliminate variables1
Idea: Eliminate Variables

choose((x,y) => 10 x + 14 y == a && x < y)

x = 3/2 a + c1 z

y = -a + c2 z

c1 = ?

c2= ?

10 x0+ 14 y0 + (10 c1 + 14 c2) == a

10 c1+ 14 c2 == 0


choose((x,y) => 10 x + 14 y == a && x < y)

x = 3/2 a + 5 z

y = -a - 7 z


Synthesis for sets
Synthesis for sets

defsplitBalanced[T](s: Set[T]) : (Set[T], Set[T]) =

choose((a: Set[T], b: Set[T]) ⇒ (

a union b == s && a intersect b == empty

&& a.size – b.size ≤ 1

&& b.size – a.size ≤ 1

))

defsplitBalanced[T](s: Set[T]) : (Set[T], Set[T]) =

val k = ((s.size + 1)/2).floor

valt1 = k

val t2 = s.size – k

val s1 = take(t1, s)

vals2 = take(t2, s minus s1)

(s1, s2)

s

b

a


From data structures to numbers
From Data Structures to Numbers

  • Observation:

    • Reasoning about collections reduces to reasoning about linear integer arithmetic!

a.size == b.size && a union b == bigSet && a intersect b == empty

a

b

bigSet


From data structures to numbers1
From Data Structures to Numbers

  • Observation:

    • Reasoning about collections reduces to reasoning about linear integer arithmetic!

a.size == b.size && a union b == bigSet && a intersect b == empty

a

b

bigSet


From data structures to numbers2
From Data Structures to Numbers

  • Observation:

    • Reasoning about collections reduces to reasoning about linear integer arithmetic!

a.size == b.size && a union b == bigSet && a intersect b == empty

a

b

bigSet


From data structures to numbers3
From Data Structures to Numbers

  • Observation:

    • Reasoning about collections reduces to reasoning about linear integer arithmetic!

a.size == b.size&& a union b == bigSet && a intersect b == empty

New specification:

kA = kB

a

b

bigSet


From data structures to numbers4
From Data Structures to Numbers

  • Observation:

    • Reasoning about collections reduces to reasoning about linear integer arithmetic!

a.size == b.size && a union b == bigSet && a intersect b == empty

New specification:

kA = kB && kA +kB = |bigSet|

a

b

bigSet


ad