Proof of the Promise

notes from my resurrection sunday message last year:

 

risen 1

 

As we celebrate easter Sunday today I thought it would be great to open the bible and see what it has to say about the resurrection and how that is relevant for us today. We’re going to be reading from Matthew 28 if you want to turn there and stick in a finger in it until we get to it…

I know some of you have been blest to be Christians for a long time and I know also that some of you here are newbies to the Christian thing – but it doesn’t matter if you’ve being a Christian for 50 years or 5 minutes – or even if you’re just asking questions at this stage – this is what we build our life on – who jesus is and what jesus did – we can never tire of hearing about what Jesus did for us upon the cross and it is good to remind ourselves of the power of His promises and the reality of His work in our lives.

 

My goal today is to anchor us firmly to the reality of the resurrection and refresh our hearts to what that means for us right here today and that we would leave here today inspired and challenged – that we would grasp more of the reality of how BIG God is and that He has the power to fulfil all His promises…

 

The resurrection is the proof of the power for the promises of God.

 

So let’s jump right into what happened:

On Friday we remembered how Jesus bled and died for us – how He suffered and bore the punishment – pierced for our transgressions, crushed for our iniquities – note the small word there FOR – it was FOR us that Jesus died. Not for His own wrongdoing but for OUR wrongdoing.

Now even the disciples didn’t see it pan out this way –this was not their plan A. Plan A for the disciples was for Jesus to go PACHING HERE IS MY GLORY (you might have had to see that bit to get the paching!)  The last thing they expected was that jesus would be executed as a common criminal on the cross. His death ended their hope. They expected him to declare himself rightful king and messiah and to kick the romans out and enter in an age of glory for Israel. Death on the cross wasn’t part of the plan.

Their hero was dead. Their friend was dead. Their leader was dead.

Their Saturday sucked. On Saturday all hope was lost. But on Sunday we know that nothing is impossible! We have the joy of knowing the end of the story but they were broken and grieving and shocked.

 

Let’s jump right into Matthew 28 to find out what happens next:

After the Sabbath, at dawn on the first day of the week, Mary Magdalene and the other Mary went to look at the tomb.    2 There was a violent earthquake, for an angel of the Lord came down from heaven and, going to the tomb, rolled back the stone and sat on it.    3 His appearance was like lightning, and his clothes were white as snow.    4 The guards were so afraid of him that they shook and became like dead men.    5 The angel said to the women, Do not be afraid, for I know that you are looking for Jesus, who was crucified.    6 He is not here; he has risen, just as he said. Come and see the place where he lay.    7 Then go quickly and tell his disciples: ‘He has risen from the dead and is going ahead of you into Galilee. There you will see him.’ Now I have told you.    8 So the women hurried away from the tomb, afraid yet filled with joy, and ran to tell his disciples.    9 Suddenly Jesus met them. Greetings, he said. They came to him, clasped his feet and worshipped him.    10 Then Jesus said to them, Do not be afraid. Go and tell my brothers to go to Galilee; there they will see me. Matthew 28:1-10

That is worth a Woohooo!

Jesus appeared not only to the women near the tomb but to all the disciples, including Thomas who when he heard that jesus had risen from the dead did a tui “yeah right” and jesus got Thomas to touch him and feel the wounds. Jesus also appeared to various other “disciples” including a group of 500 at a time.

 

Some say that jesus rose just as a spirit, or that Jesus was just unconscious and not really dead dead dead on good Friday. But as I said, Jesus could be touched, and he ate, though he also had supernatural abilities such as appearing in a locked room etc. His body bore some of the scars from his crucifixion but a majority of the wounds were healed. And I mean healed without 6 months in intensive care…

The disciple Peter sums it up this way: This man was handed over to you by God’s set purpose and foreknowledge; and you, with the help of wicked men, put him to death by nailing him to the cross. But God raised him from the dead, freeing him from the agony of death, because it was impossible for death to keep its hold on him. Acts 2:23-24

But the facts are: Jesus died. And Jesus rose. And is alive now. Seated in heaven ruling and reigning beside His Father, preparing to come again.

 

“Jesus lived the life we could not live and died the death we should have died and given the gift we can never earn.” Mark Driscoll

The promises of the Word and the purchases of the cross are shown to be TRUE and REAL by the power of the resurrection!

The cross purchased our salvation.

The cross purchased our forgiveness.

The cross purchased our access to draw near to God.

The cross purchased our family status – before we were rejected guilty strangers and now because of the cross, because of the sacrifice of Jesus, we are now beloved children of God, we’re part of the whanau now.

But as awesome as the cross is and all that jesus did there upon it – I always think its more AWESOMER that he didn’t stay dead, that He rose from death, defeated death, and is alive. Right now ALIVE!

 

The Resurrection assures us of God’s ability to save us.

It assures us of God’s forgiveness. The Resurrection assures us that we can be changed and forgiven and born again.

It assures us of God’s power and of God’s ultimate triumph.

It declares loudly and beyond shadow of a doubt that YES God has the power to remove the guilt and stain of sin from us – that we can be born again and rescued and draw near to God, whereas before we were guilty and sinful – it’s an inside change, an inside transformation that before you experience it you wonder if this can really be too good to be true…

 

It shows us that God has the power to do the things He promises.

Healing.

Deliverance.

Forgiveness.

Provision.

Direction.

Strength to overcome temptation.

Empowerment to serve Him.

Peace.

Faith.

 

The resurrection is the guarantee that God can perform the promises of the Word and the work of the cross in our lives.

Look to the cross and the resurrection for the POWER demonstrated there.

 

But the Holy Spirit proved that Jesus is the powerful Son of God, because he was raised from death. Romans 1:4 CEV

 

The resurrection is the PROOF that we need that God CAN DO THOSE THINGS THAT HE PROMISES.

 

But what if you’re like most people… that you need some proof that the proof of the promise happened… what about proof of the resurrection… is there evidence that it happened? I’m glad you asked me that…

Dr. Frank Morrison (a rationalistic lawyer) decided to take three years off from his law practice in order to try to disprove the resurrection of Jesus Christ. After three years of intense study, he found that the sheer weight of the evidence compelled him to conclude that Jesus Christ actually did rise from the dead. As a consequence he wrote the famous book entitled "Who Moved the Stone?"

 

Evidence Factoid #1 The first witnesses are WOMEN (shock!)

The fact that the resurrection accounts in the gospels include women make them more reliable because no one trying to sell a cover up in those days would have relied on the testimony of women. A woman’s testimony in a court of law was not considered valid except in very rare cases. 

 

Evidence Factoid #2 CONSPIRACY THEORY

Matthew 28:11-15 has a fascinating insight into some of the cover ups and conspiracies by the religious leaders aka Jesus’ enemies…

While the women were on their way, some of the guards went into the city and reported to the chief priests everything that had happened.    When the chief priests had met with the elders and devised a plan, they gave the soldiers a large sum of money,     telling them, You are to say, ‘His disciples came during the night and stole him away while we were asleep.’     If this report gets to the governor, we will satisfy him and keep you out of trouble.     So the soldiers took the money and did as they were instructed. And this story has been widely circulated among the Jews to this very day.

 

Don’t you love a good conspiracy theory!   

 

But let’s think rationally. Do you think the guards would have been “rewarded” for really losing a body? To fall asleep on the job would have been punishment and perhaps death for the guards. One way a guard was put to death was by being stripped of his clothes and then burned alive in a fire started with his garments. If it was not apparent which soldier had failed in his duty, then lots were drawn to see which one would be punished with death for the guard unit’s failure. Certainly the entire unit would not have fallen asleep with that kind of threat over their heads.

The guards had witnessed the earthquake and the angel rolling away the massive stone and perhaps even peeked in to see the empty tomb… they went back to the chief priests and told them everything that had happened EVERYTHING… and the priests made the call to cover it up rather than punish the guards for losing a body… interesting…

 

Evidence Factoid #3 The Disciples Died for Jesus

As we said earlier, if any enemies of the Christians or of Jesus had stolen the body, they would have produced it to stop the disciples preaching and people becoming christians. They would have put it on the news and tweeted their hearts out… They would have been out there saying: "Wait! We moved the body, see, He didn’t rise from the grave"? They would have paraded the body around as proof that Jesus was a fraud.

But let’s play along and suggest what if the DISCIPLES of Jesus stole the body? First off, they had no reason to do this because by starting a religion in opposition to the Jewish customs was not the cool thing to do.

But more importantly, all but one of the disciples lived their lives for Jesus and His church and out of the main 12, 11 of them suffered martyrs’ deaths and not one of them said “stop we made it all up. It was all peters idea!” None of the disciples recanted their belief that Jesus had risen from the dead. The 12th disciple, who was not martyred was john and they did TRY to kill him by boiling him a huge pot of oil, but couldn’t kill him. He was then was exiled to Patmos where he wrote the book of revelation. But it wasn’t just the 12 disciples who faced death because of their faith – ordinary Christians were persecuted and locked up and thrown to lions and stoned to death and killed because of Jesus. Every effort was made to stop the disciples and early believers but they kept on believing and talking about it. And the church kept on growing.

 

Another point to note is that right after Jesus’ death the disciples locked themselves away in the upper room, but after His resurrection they were bold, fearless and out there on the streets working miracles and preaching the gospel. In other words, if they had created a lie, they would certainly not have lived for it or died for it. They lived and died because the resurrection is REAL.

 

Dr. Simon Greenleaf (a very famous Harvard University professor of Law) proclaimed: "According to the laws of legal evidence used in courts of law, there is more evidence for the historical fact of the resurrection of Jesus Christ than for just about any other event in history."

 

The only possible reason why early Christianity began and took the shape it did is that the tomb really was empty and that people really did meet Jesus, alive again. This is what we believe in. There IS proof of the resurrection.

 

The resurrection of Jesus is the foundation of the Christian faith. Without it, there is no gospel message, no saviour, no supernatural power. There is no hope of us going to heaven when we die, and no hope of drawing near to God, no forgiveness of sins. This is absolutely essential to Christian belief.  Paul writes in 1 Corinthians 15:14 and 17, “If Christ has not been raised, then our preaching is useless and your faith is in vain…And if Christ has not been raised, your faith is futile and you are still in your sins.” Black and white. If Jesus didn’t rise from death then this is all useless and we’re all still guilty and separated from God. If Jesus didn’t rise from the dead then He’s not who He says He is and its all for nothing. But the good news is He HAS been raised! The resurrection is REAL!

 

Jesus opened a door through His death for us to come near to God again.

 

God himself was pleased to live fully in his Son. And God was pleased for him to make peace by sacrificing his blood on the cross, so that all beings in heaven and on earth would be brought back to God. You used to be far from God. Your thoughts made you his enemies, and you did evil things. But his Son became a human and died. So God made peace with you, and now he lets you stand in his presence as people who are holy and faultless and innocent. Colossians 1:19-22 CEV

 

Because of Him we can be free from sin and guilt, we can be friends with God and be confident and assured of where we’ll spend eternity.

Don’t you love how sometimes it seems that paul gets so excited that he forgets to breathe and include full stops… here is another one: He prays that we would know “what is the exceeding greatness of His power toward us who believe, according to the working of His mighty power  which He worked in Christ when He raised Him from the dead and seated Him at His right hand in the heavenly places,  far above all principality and power and might and dominion, and every name that is named, not only in this age but also in that which is to come.”

The CEV puts it this way:

I want you to know about the great and mighty power that God has for us followers. It is the same wonderful power he used when he raised Christ from death and let him sit at his right side in heaven. There Christ rules over all forces, authorities, powers, and rulers. He rules over all beings in this world and will rule in the future world as well.

God is at work in our lives – with great and mighty power – demonstrating that same power He used to raise Jesus from the grave. God is at work in us to heal us, set us free, transform us, guide us, give us His peace and to empower us to show the world that He is real. Through unbelief and disbelief we can sometimes live far below what the cross and resurrection has won for us. Let’s raise our expectations and our outliving to the level of the power demonstrated in the resurrection!

The resurrection is the proof of the power for every promise of God.

Any answer and any need you have CAN be answered in Jesus. He HAS the power!

Now to Him Who, by His power that is at work within us, is able to carry out His purpose and do superabundantly, far over and above all that we dare ask or think, infinitely beyond our highest prayers, desires, thoughts, hopes, or dreams—Ephesians 3:20

 

Paul goes on to say in Romans 10:9: That if you confess with your mouth, Jesus is Lord, and believe in your heart that God raised him from the dead, you will be saved.

 

Jesus lived the life we could never live and died the death we deserved and gives us the gift we can never earn.

 

Will you accept that gift today?

As the band comes up for a closing song in worship lets consider our response.

How do we respond to what Jesus has done on the cross? How do we live responding to His great love poured out on the cross?

Will you put your faith in the one who undeniably rose from the dead?

Let’s raise our level of expectation in the promises of God. Let’s have greater confidence in God to move and work in our lives.

 

Today… what impossibility do you need God to touch? 2000 years ago He declared the reality of the power in His promises. Do you need healing? He is our healer. Do you need provision? He is the God who provides. Do you need hope and comfort? He is the one who calls us to come and find strength and hope in His love. Do you need salvation? He is our Saviour. Do you need a new start and forgiveness? Nothing is impossible for God. He is alive today and forever more!

How to distribute ad hoc build with XCode 4

Here are some notes on how to build an ad hoc distribution and deploy your app onto another iOS device.

Overview

Deploying your application onto other iOS devices is non-trivial to say the least. Apple has done it’s best to document how it all works, but I found it extremely confusing and convoluted. So don’t feel you are alone if you are struggling.

There are two configuration steps we need to go through when creating an ad hoc distribution.

First we need to create something called a distribution via the iOS Provisioning Portal. Then we need to import that provision into XCode and use it as part of our build.

Note: I am not sure if this is required but some tutorials I’ve seen say you need an icon for your app. So to be save you may want to add one.

iOS Provisioning Portal

Register device(s)

First thing we need to do is register any devices we want to deploy our app onto. This part is actually pretty easy and this link shows you how to do it:

https://developer.apple.com/ios/manage/devices/howto.action

Create ad hoc provision

Here’s an example of what provisioning profiles look like (these I created).

There are two types of deployments you can make. Ad hoc or App store. Ad hoc is like a test deploy. You just want to make a build, and deploy it onto someone elses machine.

App store is self explanatory. Many of the steps we are doing here for ad hoc you can repeat for app store (just different selections in configuration).

Provisioning profiles are how apple tracks who can run your app, and on which devices. Here we want create a new ad hoc provision profile call Ad Hoc.

Here we just choose an App ID and then add any devices at the bottom you would like to include in the profile.

Deploy provision into XCode

Now that you’ve got a Ad Hoc provision setup, you need to get it into your XCode for a build.

Easiest way to do this is do download the provision you just created (if it says pending click another tab and come back once it’s enabled).

Then open XCode, and drag it onto the XCode docking icon at the bottom.

You can verify the provision distribution was imported by going Window -> Organizer clicking the ‘Devices’ tab and then the ‘Provisioning Profile’ section on the left.

Now we are done with the iOS Provisioning Portal and can switch to XCode.

XCode 4

Create a new configuration

Click on the project keyword, then your project, and then the ‘Info’ tab.

Then under ‘Configurations’ click the + sign and duplicate the ‘Release’ Configuration.

Setup your Target

Now we need to configure our Target (the thing below the blue project) so that the new configuration we just created uses the ad hoc provision we just created in the iOS Provision Portal.

Click the target for your app (just below your blue project keyword). Then find the ‘Ad Hoc Distribution’ we just created in XCode and point it to the ‘Ad Hoc’ provision distribution we created via the portal.

Setup your archive

Here we need to setup our archive build step so that it uses the ‘Ad Hoc Distribution’ we just created and configured in XCode.

Create the archive

Product -> Archive

If everything goes well you should see the archive like this:

Create the ipa

Highlighting the archive we just created click ‘Distribute’ and then choose the type of distribution you’d like to create (‘Ad Hoc’ in our case).

Click through the last couple menus then voila! You should have an ipa you can distribute to your friends who’s devices you added in the beginning.

I struggled mightily to get ad hoc deploys so if this works for you consider yourself lucky. For those of you struggling keep googling. Hopefully this tutorial will help.

Links that help

http://www.musicalgeometry.com/?p=1237
https://developer.apple.com/ios/manage/overview/index.action

254A, addendum: Some notes on nilprogressions

This is an addendum to last quarter’s course notes on Hilbert’s fifth problem, which I am in the process of reviewing in order to transcribe them into a book (as was done similarly for several other sets of lecture notes on this blog). When reviewing the zeroth set of notes in particular, I found that I had made a claim (Proposition 11 from those notes) which asserted, roughly speaking, that any sufficiently large nilprogression was an approximate group, and promised to prove it later in the course when we had developed the ability to calculate efficiently in nilpotent groups. As it turned out, I managed finish the course without the need to develop these calculations, and so the proposition remained unproven. In order to rectify this, I will use this post to lay out some of the basic algebra of nilpotent groups, and use it to prove the above proposition, which turns out to be a bit tricky. (In my paper with Breuillard and Green, we avoid the need for this proposition by restricting attention to a special type of nilprogression, which we call a nilprogression in {C}-normal form, for which the computations are simpler.)

There are several ways to think about nilpotent groups; for instance one can use the model example of the Heisenberg group

\displaystyle  H(R) :=\begin{pmatrix} 1 & R & R \\ 0 & 1 & R\\ 0 & 0 & 1 \end{pmatrix}

over an arbitrary ring {R} (which need not be commutative), or more generally any matrix group consisting of unipotent upper triangular matrices, and view a general nilpotent group as being an abstract generalisation of such concrete groups. (In the case of nilpotent Lie groups, at least, this is quite an accurate intuition, thanks to Engel’s theorem.) Or, one can adopt a Lie-theoretic viewpoint and try to think of nilpotent groups as somehow arising from nilpotent Lie algebras; this intuition is rigorous when working with nilpotent Lie groups (at least when the characteristic is large, in order to avoid issues coming from the denominators in the Baker-Campbell-Hausdorff formula), but also retains some conceptual value in the non-Lie setting. In particular, nilpotent groups (particularly finitely generated ones) can be viewed in some sense as “nilpotent Lie groups over {{\bf Z}}“, even though Lie theory does not quite work perfectly when the underlying scalars merely form an integral domain instead of a field.

Another point of view, which arises naturally both in analysis and in algebraic geometry, is to view nilpotent groups as modeling “infinitesimal” perturbations of the identity, where the infinitesimals have a certain finite order. For instance, given a (not necessarily commutative) ring {R} without identity (representing all the “small” elements of some larger ring or algebra), we can form the powers {R^j} for {j=1,2,\ldots}, defined as the ring generated by {j}-fold products {r_1 \ldots r_j} of elements {r_1,\ldots,r_j} in {R}; this is an ideal of {R} which represents the elements which are “{j^{th}} order” in some sense. If one then formally adjoins an identity {1} onto the ring {R}, then for any {s \geq 1}, the multiplicative group {G := 1+R \hbox{ mod } R^{s+1}} is a nilpotent group of step at most {s}. For instance, if {R} is the ring of strictly upper {s \times s} matrices (over some base ring), then {R^{s+1}} vanishes and {G} becomes the group of unipotent upper triangular matrices over the same ring, thus recovering the previous matrix-based example. In analysis applications, {R} might be a ring of operators which are somehow of “order” {O(\epsilon)} or {O(\hbar)} for some small parameter {\epsilon} or {\hbar}, and one wishes to perform Taylor expansions up to order {O(\epsilon^s)} or {O(\hbar^s)}, thus discarding (i.e. quotienting out) all errors in {R^{s+1}}.

From a dynamical or group-theoretic perspective, one can also view nilpotent groups as towers of central extensions of a trivial group. Finitely generated nilpotent groups can also be profitably viewed as a special type of polycylic group; this is the perspective taken in this previous blog post. Last, but not least, one can view nilpotent groups from a combinatorial group theory perspective, as being words from some set of generators of various “degrees” subject to some commutation relations, with commutators of two low-degree generators being expressed in terms of higher degree objects, and all commutators of a sufficiently high degree vanishing. In particular, generators of a given degree can be moved freely around a word, as long as one is willing to generate commutator errors of higher degree.

With this last perspective, in particular, one can start computing in nilpotent groups by adopting the philosophy that the lowest order terms should be attended to first, without much initial concern for the higher order errors generated in the process of organising the lower order terms. Only after the lower order terms are in place should attention then turn to higher order terms, working successively up the hierarchy of degrees until all terms are dealt with. This turns out to be a relatively straightforward philosophy to implement in many cases (particularly if one is not interested in explicit expressions and constants, being content instead with qualitative expansions of controlled complexity), but the arguments are necessarily recursive in nature and as such can become a bit messy, and require a fair amount of notation to express precisely. So, unfortunately, the arguments here will be somewhat cumbersome and notation-heavy, even if the underlying methods of proof are relatively simple.

— 1. Some elementary group theory —

Let {g, h} be two elements of a group {G = (G,\cdot)}. We define the conjugate {g^h} and commutator {[g,h]} by the formulae

\displaystyle  g^h := h^{-1} g h \ \ \ \ \ (1)

and

\displaystyle  [g,h] := g^{-1} h^{-1} gh. \ \ \ \ \ (2)

(Note that this convention for {[g,h]} is not universal; for instance, the alternate convention {[g,h] = ghg^{-1}h^{-1}} also appears in the literature. The distinctions between the two conventions however are quite minor; the conventions here are optimised for pulling group elements to the right of a word, whereas other conventions may be slightly better for pulling group elements to the left of a word.)

Conjugation by a fixed element {h} is an automorphism of {G}, thus

\displaystyle  (gk)^h = g^h k^h

and

\displaystyle  (g^h)^{-1} = (g^{-1})^h

and

\displaystyle  1^h = 1

and

\displaystyle  [g,k]^h = [g^h,k^h]

for all {g,h,k \in G}. Conjugation is also an action, thus

\displaystyle  (g^h)^k = g^{hk}

and

\displaystyle  g^1 = g.

An automorphism of the form {g \mapsto g^h} is called an inner automorphism.

Conjugation is related to multiplication by the identity

\displaystyle  gh = h g^h,

thus one can pull {g} to the right of {h} at the cost of twisting (i.e. conjugating) it by {h}. Commutation is related to multiplication by the identity

\displaystyle  gh = hg [g,h],

thus one can pull {g} to the right of {h} at the cost of adding an additional commutator factor {[g,h]} to the right. Finally, commutation is related to conjugation by the identity

\displaystyle  g^h = g [g,h].

The commutator can be viewed as a nonlinear group-theoretic analogue of the Lie bracket. For instance, in a matrix group {G = GL_n({\bf C})}, we observe that the commutator {[1+\epsilon A, 1+\epsilon B]} of two elements {1+\epsilon A} and {1+\epsilon B} close to the identity is of the form {1 + \epsilon (AB-BA) + O(\epsilon^2)}, thus linking the group-theoretic commutator to the Lie bracket {A,B \mapsto AB-BA}.

Because of this link, we expect the group-theoretic commutator to obey some nonlinear analogues of the basic Liebracket identities, and this is indeed the case. For instance, one easily observes that the commutator is antisymmetric in the sense that

\displaystyle  [h,g] = [g,h]^{-1} \ \ \ \ \ (3)

and is approximately odd in the sense that

\displaystyle  [g^{-1},h] = ([g,h]^{-1})^{g^{-1}} \ \ \ \ \ (4)

and

\displaystyle  [g,h^{-1}] = ([g,h]^{-1})^{h^{-1}} \ \ \ \ \ (5)

for any {g,h \in G}. We also have the easily verified approximate bilinearity identities

\displaystyle  [g,hk] = [g,h] [g,k]^h

and

\displaystyle  [gh,k] = [g,k]^h [h,k]

for any {g,h,k \in G}. Finally, we have the approximate Jacobi identity (better known as the Hall-Witt identity)

\displaystyle  [[g,h^{-1}],k]^h [[h,k^{-1}],g]^k [[k,g^{-1}],h]^g = 1. \ \ \ \ \ (6)

A subgroup {H} of {G} is said to be normal if it is preserved by all inner automorphisms, thus {H^g = H} for all {g} (writing {H^g := \{h^g: h \in H \}}, of course), and characteristic if it is preserved by all automorphisms (not necessarily inner). Thus, all characteristic subgroups are normal, but the converse is not necessarily true. We write {H \leq G} or {G \geq H} if {H} is a subgroup of {G}, and {H \rhd G} or {G \lhd H} if {H} is a normal subgroup of {G}.

If {N} is a normal subgroup of {G}, we write {g \mapsto g \hbox{ mod } N} for the quotient map from {G} to {G/N}, thus {g = h \hbox{ mod } N} if {g \in hN = Nh}. Given any other subgroup {H} of {G}, we write {H \hbox{ mod } N} for the image of {H} under the {\hbox{ mod } N} map, thus

\displaystyle  H \hbox{ mod } N \equiv HN / N = NH / N \equiv H / (H \cap N).

Given two subgroups {H,K} of a group {G}, we define the commutator group {[H,K]} to be the group generated by the commutators {[h,k]} with {h \in H, k\in K}. We say that {H} and {K} commute if {[H,K]} is trivial, or equivalently if every element of {H} commutes with every element of {K}. Note that if {H, K} are normal, then {[H,K]} is also normal. In this case, one can view {[H,K]} as the smallest subgroup of {G} such that {H, K} commute modulo {[H,K]} (or equivalently, that {H \hbox{ mod } [H,K]} and {K \hbox{ mod } [H,K]} commute). Similarly, if {H,K} are characteristic, then {[H,K]} is also characteristic.

Observe from (3) that

\displaystyle  [H,K] = [K,H]

for any subgroups {H, K}. Also that if {N} is a normal subgroup of {G}, then (as {\hbox{ mod } N} is a homomorphism)

\displaystyle  HK \hbox{ mod } N = (H \hbox{ mod } N) (K \hbox{ mod } N)

and

\displaystyle  [H,K] \hbox{ mod } N = [H \hbox{ mod } N, K \hbox{ mod } N] \ \ \ \ \ (7)

Exercise 1

  • (i) If {H, K} are normal subgroups of {G} generated by subsets {A \subset H}, {B \subset K} respectively, show that {[H,K]} is the normal subgroup of {G} generated (as a normal subgroup) by the commutators {[a,b]} with {a \in A}, {b \in B}.
  • (ii) If {N,H,K} are normal subgroups of {G}, show that {[[N,H],K]} lies in the normal subgroup generated by {[[H,K],N]} and {[[K,N],H]}. (Hint: use the Hall-Witt identity (6).)

Given an arbitrary group {G}, we define the lower central series {G = G_1 \lhd G_2 \ldots} of {G} by setting {G_1 := G} and {G_{i+1} := [G,G_i]} for all {i \geq 1}. Observe that all of the groups {G_i} in this series are characteristic and thus normal. A group {G} is said to be nilpotent of step at most {s} if {G_{s+1}} is trivial; in particular, by (7), we see that {G \mod G_{s+1} = G/G_{s+1}} is nilpotent of step at most {s} for any group {G}. We have a basic inclusion:

Exercise 2 We have {[G_i,G_j] \subset G_{i+j}} for all {i,j \geq 1}. (Hint: use Exercise 1.)

We now consider the subquotients {V_i := G_i \mod G_{i+1}} of the group {G} for {i=1,2,\ldots}. As {G_{i+1}} contains {[G_i,G_i]}, we see that each group {V_i} is abelian. To emphasise this, we will write {V_i} additively instead of multiplicatively, thus we shall denote the group operation on {V_i} as {+}.

Lemma 1 For each {i,j \geq 1}, the commutator map {[,]: G_i \times G_j \rightarrow [G_i,G_j]} descends to a map {[,]_{i,j}: V_i \times V_j \rightarrow V_{i+j}}, thus

\displaystyle  [g, h] \mod G_{i+j+1} = [g \mod G_{i+1}, h \mod G_{j+1}]_{i,j} \ \ \ \ \ (8)

for {g \in G_i, h \in G_j}.

Proof: We can quotient out by {G_{i+j+1}}, and assume that {G_{i+j+1}} is trivial. In particular, by Lemma 2, {G_{i+1}} commutes with {G_j}, and {G_i} commutes with {G_{j+1}}. As such, it is easy to see that if {g \in G_i, h \in G_j}, then {[g,h]} is unchanged if one multiplies {g} (on the left or right) by an element of {G_{i+1}}, and similarly for {h} and {G_{j+1}}. This defines the map {[,]_{i,j}} as required. \Box

We refer to the maps {[,]_{i,j}} as quotiented commutator maps. The identity (8) asserts that these maps {[,]_{i,j}} capture the “top order” nonlinear behaviour of the group {G}. As the following exercise shows, these maps behave like (graded components of) a Lie bracket.

Exercise 3 Let {G} be a group with lower central series {G = G_1 \lhd G_2 \lhd \ldots}, subquotients {V_i}, and quotiented commutator maps {[,]_{i,j}: V_i \times V_j \rightarrow V_{i+j}}. Let {i,j,k \geq 1}, let {x,x' \in V_i}, {y, y' \in V_j}, and {z \in V_k}. Establish the antisymmetry

\displaystyle  [x,y]_{i,j} = -[y,x]_{j,i},

the bihomomorphism properties

\displaystyle  [x+x',y]_{i,j} = [x,y]_{i,j} + [x',y]_{i,j}

\displaystyle  [-x,y]_{i,j} = -[x,y]_{i,j}

\displaystyle  [0,y]_{i,j} = 0

and

\displaystyle  [x,y+y']_{i,j} = [x,y]_{i,j} + [x,y']_{i,j}

\displaystyle  [x,-y]_{i,j} = -[x,y]_{i,j}

\displaystyle  [x,0]_{i,j} = 0

and the Jacobi identity

\displaystyle  [[x,y]_{i,j}, z]_{i+j,k} + [[y,z]_{j,k},x]_{j+k,i} + [[z,x]_{k,i},y]_{k+i,j} = 0.

Remark 1 If one wished, one could combine all of these subquotients {V_i} and quotiented commutator maps {[,]_{i,j}} into a single graded object, namely the additive group {V := \oplus_i V_i} consisting of tuples {(v_i)_{i =1}^\infty} with {v_i \in V_i} (and all but finitely many of the {v_i} trivial), with a bracket {[,]: V \times V \rightarrow V} defined by

\displaystyle  [ (v_i)_{i=1}^\infty, (w_j)_{j=1}^\infty} ] := (\sum_{i+j=k} [v_i,w_j]_{i,j})_{k=1}^\infty .

Then this bracket is an antisymmetric bihomomorphism obeying the Jacobi identity, thus {V} is a Lie algebra over the integers {{\bf Z}}. One could view this object as the “top order” or “Carnot” component of the “Lie algebra” of {G}. We will however not need this object here.

We can iterate the “bilinear” commutator operations to create “multilinear” operations. Given a non-empty finite set {{\mathcal A}} of formal group elements {{\bf g}}, we can define a formal commutator word {w} on {{\mathcal A}} to be a word that can be generated by the following rules:

  • If {{\bf g}} is a formal group element, then {{\bf g}} is a formal commutator word on {\{ {\bf g} \}}.
  • If {{\mathcal A}, {\mathcal B}} are disjoint finite non-empty sets of formal group elements, and {u, v} are formal commutator words on {{\mathcal A}, {\mathcal B}} respectively, then {[u,v]} is a formal commutator word on {{\mathcal A} \cup {\mathcal B}}.

We refer to {|{\mathcal A}|} as the length of the formal commutator word. Thus, for instance, {[[{\bf g}_1, {\bf g}_2], [{\bf g}_3, {\bf g}_4]]} is a formal commutator word on {\{ {\bf g}_1, {\bf g}_2, {\bf g}_3, {\bf g}_4 \}} of length {4}. Given a formal commutator word {w} on {{\mathcal A}} and an assignment {g: {\bf g} \mapsto g({\bf g})} of group elements {g({\bf g})\in G} to each formal group element {{\bf g} \in {\mathcal A}}, we can define the group element {w(g) \in G} by substituting {g({\bf g})} for {{\bf g}} in {w} for each {{\bf g} \in G}. This gives a commutator word map {w: G^{\mathcal A} \rightarrow G}. Given an assignment {i: {\bf g} \mapsto i({\bf g})} of a positive integer (or “degree”) {i({\bf g})} to each formal group element {{\mathcal A}}, Lemma 1 and induction then gives a map {w_i: \prod_{{\bf g} \in {\mathcal A}} V_{i({\bf g})} \rightarrow V_{\sum_{{\bf g} \in {\mathcal A}} i({\bf g})}} which is a multihomomorphism (i.e. a homomorphism in each variable). From (8) one has that

\displaystyle  w( g ) \hbox{ mod } G_{\sum_{{\bf g} \in {\mathcal A}} i({\bf g}) + 1} = w_i( g \hbox{ mod } G_{i+1} )

where {g \hbox{ mod } G_{i+1}} is shorthand for the assignment {{\bf g} \mapsto g({\bf g}) \hbox{ mod } G_{i({\bf g}) + 1}}.

In particular, using the degree map {i({\bf g}) := 1}, we obtain a multihomomorphism

\displaystyle  w_1: V_1^l \rightarrow V_l

for any commutator word {w} of length {l}, such that

\displaystyle  w( g ) \hbox{ mod } G_{l + 1} = w_1( g \hbox{ mod } G_2 ).

From the multihomomorphism nature of {w_1}, we conclude in particular that

\displaystyle  w( g_1^{n_1}, \ldots, g_l^{n_l} ) = w(g_1,\ldots,g_l)^{n_1 \ldots n_l} \hbox{ mod } G_{l+1} \ \ \ \ \ (9)

for any {g_1,\ldots,g_l \in G} and integers {n_1,\ldots,n_l}. A variant of this approximate identity will be key in understanding nilprogressions.

One can use commutator words to generate a nilpotent group {G} and its lower central series:

Exercise 4 Let {G} be a nilpotent group that is generated by a set {S} of generators.

  • (i) Show that for every positive integer {i}, {G_i} is generated by the words {w(g)}, where {w} ranges over formal commutator words of length {l} at least {i}, and {g} is a collection of {l} generators from {S} (possibly with repetition).
  • (ii) Suppose further that {S} is finite (so that there are only finitely many possible choices for {w(g)} for any given length {l}, and let {e_1,\ldots,e_n} be all the values of {w(g)} as {w} varies over formal commutator words of length at most {s}, and {g} ranges over collections of generators from {S}, arranged in non-decreasing length of {w} (this arrangement is not unique, and may contain repeated values). Show that for every positive integer {i}, any element in {G_i} can be expressed in the form {e_j^{a_j} \ldots e_n^{a_n}}, where {e_j,\ldots,e_n} are the elements of {e_1,\ldots,e_n} arising from words {w} of length at least {i}, and {a_j,\ldots,a_n} are integers.

— 2. Nilprogressions —

Recall from Notes 0 that a noncommutative progression {P(a_1,\ldots,a_r;N_1,\ldots,N_r)} in a group {G} with generators {a_1,\ldots,a_r \in G} and dimensions {N_1,\ldots,N_r > 0} is the set of all words with alphabet {a_1^{\pm 1}, \ldots, a_r^{\pm 1}}, such that for each {1 \leq i \leq r}, the symbols {a_i, a_i^{-1}} are used a total of at most {N_i} times. A nilprogression is a noncommutative progression in a nilpotent group. The objective of this section is to prove Proposition 11 from Notes 0, restated here:

Proposition 2 Suppose that {a_1,\ldots,a_r \in G} generate a nilpotent group of step {s}, and suppose that {N_1,\ldots,N_r} are all sufficiently large depending on {r,s}. Then {P := P( a_1,\ldots,a_r;N_1,\ldots,N_r)} is an {O_{r,s}(1)}-approximate group.

Recall that a subset {A} of a group {G} is a {K}-approximate group if it is symmetric, contains the origin, and if {A^2} can be covered by {K} left-translates (or equivalently, right-translates) of {A}. The first two properties are clear, so it suffices to show that {P^2} can be covered by {O_{r,s}(1)} right-translates of {P}.

We allow all implied constants to depend on {r, s}. We pick a small constant {\epsilon>0} (depending on {r,s}). It will suffice to show the inclusion

\displaystyle  P( a_1,\ldots,a_r;2N_1,\ldots,2N_r) \subset P( a_1,\ldots,a_r;O(\epsilon N_1 + 1),\ldots,O( \epsilon N_r + 1) ) X

for some set {X} of cardinality {|X| \ll_\epsilon 1}.

We will need some auxiliary objects. For {i \geq 1} and {t>0}, let

\displaystyle  Q^t_i( a_1,\ldots,a_r;N_1,\ldots,N_r) := P( a'_1,\ldots,a'_R; tN'_1,\ldots,tN'_R ),

where {a'_1,\ldots,a'_R} consists of all group elements of the form {w(a_{i_1},\ldots,a_{i_l})} where {w} is a formal commutator word of length {l \geq i}, {1 \leq i_1,\ldots,i_l \leq r}, and each {a'_j = w(a_{i_1},\ldots,a_{i_l})} is associated to the dimension {N'_j := N_{i_1} \ldots N_{i_l}}. Thus the {Q_i(a_1,\ldots,a_r;N_1,\ldots,N_r)} are non-increasing in {i} and become trivial for {i \geq s}. We will usually abbreviate {Q^t_i(a_1,\ldots,a_r;N_1,\ldots,N_r)} as {Q^t_i}. Trivially we also have

\displaystyle  P(a_1,\ldots,a_r;N_1,\ldots,N_r) \subset Q^t_1.

Observe also that the {Q^t_i} are symmetric, contain the identity, and {Q^t_i Q^{t'}_i \subset Q^{t+t'}_i}.

Exercise 5 (Approximate filtration property) If {g \in Q_i^{O(1)}} and {h \in Q_j(a_1,\ldots,a_r;N_1,\ldots,N_r)}, show that

\displaystyle  [g,h] \in Q_{i+j}^{O(1)}

and

\displaystyle  g^h \in Q_i^{O(1)}.

Next, we need the following variant of (9).

Lemma 3 Let {w} be a formal commutator word of length {l \geq 1}, and let {1 \leq i_1,\ldots,i_l \leq r}. For each {1 \leq j \leq r}, let {n_j} be an integer with {n_j = O(N_{i_j})}. Then

\displaystyle  w(a_{i_1}^{n_1},\ldots,a_{i_l}^{n_l}) \in w(a_{i_1},\ldots,a_{i_l})^{n_1 \ldots n_l} Q_{l+1}^{O(1)}.

Proof: When {l > s}, the expressions involving {w} collapse to the identity, and the claim follows, so we may assume that {1 \leq l \leq s}. We induct on {l}. The claim {l=1} is trivial, so suppose that {1 < l \leq s} and that the claim has been proven for smaller values of {l}.

We first establish the key case {l=2}. In this case, it suffices to show that

\displaystyle  [a^n, b^m] \in [a,b]^{nm} Q_3^{O(1)}( a,b; |n|, |m| ) \ \ \ \ \ (10)

for any {a,b \in G} and {n,m \in {\bf Z}}. By using commutator identities (4), (5) we may assume that {n,m} are positive. It suffices to show that

\displaystyle  (a^n)^{b^m} \in a^n [a,b]^{nm} Q_3^{O(1)}(a,b; n, m ).

We can write {(a^n)^{b^m} = (a^{b^m})^n}. It is then not difficult to see that the claim will follow if we can show

\displaystyle  (a)^{b^m} \in a [a,b]^{m} Q_3^{O(1)}(a,b; 1, m ),

or equivalently

\displaystyle  [a,b^m] \in [a,b]^m Q_3^{O(1)}(a,b; 1,m).

Thus we have effectively reduced the problem to the case {n=1}. A similar argument allows us to also obtain the additional reduction {m=1}, at which point the claim is trivial. This completes the treatment of the {l=2} case.

Now we handle the general case. After some relabeling, we may write {w = [u,v]}, where {u,v} are words of length {l_1,l_2} respectively for some {l_1,l_2<l} adding up to {l}, with

\displaystyle  w(a_{i_1}^{n_1},\ldots,a_{i_l}^{n_l}) = [u(a_{i_1}^{n_1},\ldots,a_{i_{l_1}}^{n_{l_1}}), v(a_{i_{l_1+1}}^{n_{l_1+1}},\ldots,a_{i_l}^{n_l}) ]

and similarly

\displaystyle  w(a_{i_1},\ldots,a_{i_l}) = [u(a_{i_1},\ldots,a_{i_{l_1}}, v(a_{i_{l_1+1}},\ldots,a_{i_l}) ].

By induction hypothesis, one has

\displaystyle  u(a_{i_1}^{n_1},\ldots,a_{i_{l_1}}^{n_{l_1}}) \in u(a_{i_1},\ldots,a_{i_{l_1}})^{n_1 \ldots n_{l_1}} Q_{l_1+1}^{O(1)}.

In particular we have

\displaystyle  u(a_{i_1}^{n_1},\ldots,a_{i_{l_1}}^{n_{l_1}}) \in Q_{l_1}^{O(1)}.

Similarly we have

\displaystyle  v(a_{i_{l_1+1}}^{n_{l_1+1}},\ldots,a_{i_l}^{n_l}) \in v(a_{i_{l_1+1}},\ldots,a_{i_l})^{n_{l_i+1}\ldots n_l} Q_{l_2+1}^{O(1)} \subset Q_{l_2}^{O(1)}.

Using (5) and the approximate homomorphism properties of commutators, we conclude that

\displaystyle  [u(a_{i_1}^{n_1},\ldots,a_{i_{l_1}}^{n_{l_1}}), v(a_{i_{l_1+1}}^{n_{l_1+1}},\ldots,a_{i_l}^{n_l}) ] \in [u(a_{i_1},\ldots,a_{i_{l_1}})^{n_1 \ldots n_{l_1}}, v(a_{i_{l_1+1}},\ldots,a_{i_l})^{n_{l_i+1}\ldots n_l}] Q_{l+1}^{O(1)},

but from (10) we have

\displaystyle  [u(a_{i_1},\ldots,a_{i_{l_1}})^{n_1 \ldots n_{l_1}}, v(a_{i_{l_1+1}},\ldots,a_{i_l})^{n_{l_i+1}\ldots n_l}] \subset [u(a_{i_1},\ldots,a_{i_{l_1}}), v(a_{i_{l_1+1}},\ldots,a_{i_l})]^{n_1 \ldots n_l} Q_{l+1}^{O(1)}.

The claim follows.

Next, we need the following elementary number-theoretic lemma:

Exercise 6 Let {M_1,\ldots,M_l \geq 1}, and let {n} be an integer with {n = O(M_1 \ldots M_l)}. Show that {n} can be expressed as the sum of {O_l(1)} terms of the form {n_1 \ldots n_l}, where the {n_1,\ldots,n_l} are integers with {n_i = O(M_i)} for each {i=1,\ldots,l}. (Hint: Despite the superficial similarity here with non-trivial number-theoretic questions such as the Waring problem, this is actually a very elementary fact which can be proven by induction on {l}.)

Exercise 7 Let {w} be a formal commutator word of length {l \geq 1}, and let {1 \leq i_1,\ldots,i_l \leq r}. Let {n = O(N_{i_1} \ldots N_{i_r})}. Show that

\displaystyle  w(a_{i_1},\ldots,a_{i_l})^n \in P^{O(1)} Q_{l+1}^{O(1)}.

Conclude that

\displaystyle  Q_l^C \subset P^{O(1)} Q_{l+1}^{O(1)}

whenever {C=O(1)}, and on iteration conclude that

\displaystyle  Q_1^C \subset P^{O(1)}

whenever {C = O(1)}.

A similar argument shows that {Q_1^\epsilon \subset P} for a sufficiently small {\epsilon>0} depending only on {r,s}, assuming that {N_1,\ldots,N_r} are sufficiently large depending on {r,s}. Since {P^2 \subset Q^2_1}, it thus suffices to show that for any {\delta>0}, that {Q^2_1} can be covered by {O_\delta(1)} right-translates of {Q^{O(\delta)}_1}. But this then follows by iterating the following exercise:

Exercise 8 Let {\delta>0}, {l \geq 1}, and {C = O(1)}. Show that {Q^C_l} can be covered by {O_\delta(1)} right-translates of {Q^{O(\delta)}_l \cdot Q^{O(1)}_{l+1}}. (Hint: this is similar to Exercise 5. Factor an element of {Q^C_l} into words {w(a_{i_1},\ldots,a_{i_l})} of length {l}, together with words of higher length. Gather all the words of length {l} into monomials {w(a_{i_1},\ldots,a_{i_l})^n} with {n = O( N_{i_1} \ldots N_{i_l})}, times a factor in {Q^{O(1)}_{l+1}}. Split these monomials into a monomial with exponent {O(\delta N_{i_1} \ldots N_{i_l})}, times a monomial which can take at most {O_\delta(1)} possible values. Then push the latter monomials (and the {Q^{O(1)}_{l+1}} factor) to the right.)

How to setup OCMock XCode 4 iOS 5 How to setup OCMock XCode 4 iOS 5

This was harder than I would have liked. Here’s some notes on how to set it up.

Setup OCUnit on your existing project

These notes from Apple are pretty good about how to setup OCUnit on your XCode project.

The only difference was when I ran my unit tests (Product -> Test) I had to manually add my own unit test scheme.

Just hit the ‘Edit Scheme’ button, then hit the ‘+’ sign and click on your target unit tests and click the ‘Add button’.

You should now be able to run your tests against the simulator (not real phone) and see the failure.

Setup OCMock

Create a Libraries directory

Create a ‘Libraries’ directory in your project by right clicking on your project icon and selecting ‘Add Files to …’.

Click the ‘New folder’ button, type the name ‘Libraries’, and click ‘Add’ so your libraries directory is at the same level as your project and unit test target. When your done it should look something like this:

Copy in libOCMock.a

Download the libOCMock.a and stick it in the Libraries directory we just created.

Then add it to your project by dragging it into the Libraries directory we just added to your project.

When you do a window will pop up, make sure you select the ‘Copy items’ box at the top and click on your unit test target so it will be linked to OCMock.

Copy OCMock header files

Download the latest OCMock dmg file, located the OCMock directory inside containing the header files, and just like we did before, drag it into the Libraries directory.

Again select ‘Copy’ and click your unit test target and now your directory structure should look like this:

Configure Build Settings

We now need to tell our project how to find these header files we just added.

Click your blue project icon (click somewhere else and then click it again if it doesn’t immediately change) and click the ‘Build Settings’ tab for your project.

In the ‘Search Paths -> Library Search Paths’ section add $(SRCROOT)/Libraries in double quotes to Debug and Release sections. Once you do they will automatically convert to your local machine paths as shown below.

And then do the exact same thing for the ‘Search Paths ->Header Search Path’ section (be sure to double click on it after and make sure both are set to ‘recursive’).

Next head down to the ‘Linking -> Other Link Flags’ section and add the ‘-all_load’ option.

If you don’t do this you’ll get a “Did you forget to add the -force_load linker flag?” error when you run your tests and you can read about why here.

Add a mock test case

We should now be good to go. Open you the default test case OCUnit created for you and add the following:

1
#import &quot;UnitTests.h&quot;#import &lt;OCMock/OCMock.h&gt;@implementation UnitTests- (void)setUp{ [super setUp]; // Set-up code here.}- (void)tearDown{ // Tear-down code here. [super tearDown];}- (void)testExample{ //STFail(@&quot;Unit tests are not implemented yet in UnitTests&quot;);}- (void)testOCMockPass { id mock = [OCMockObject mockForClass:NSString.class]; [[[mock stub] andReturn:@&quot;mocktest&quot;] lowercaseString]; NSString *returnValue = [mock lowercaseString]; STAssertEqualObjects(@&quot;mocktest&quot;, returnValue, @&quot;Should have returned the expected string.&quot;);}@end

If everything worked, you should be able to run your test now and see a nice failure in your log output window:

Links that help:

https://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/UnitTesting/02-Setting_Up_Unit_Tests_in_a_Project/setting_up.html#//apple_ref/doc/uid/TP40002143-CH3-SW1

http://www.raywenderlich.com/3716/unit-testing-in-xcode-4-quick-start-guide

https://developer.apple.com/library/mac/#qa/qa1490/_index.html

http://ocmock.org/

Advertisement

254B, Notes 6: Non-concentration in subgroups

In the last three notes, we discussed the Bourgain-Gamburd expansion machine and two of its three ingredients, namely quasirandomness and product theorems, leaving only the non-concentration ingredient to discuss. We can summarise the results of the last three notes, in the case of fields of prime order, as the following theorem.

Theorem 1 (Non-concentration implies expansion in {SL_d}) Let {p} be a prime, let {d \geq 1}, and let {S} be a symmetric set of elements in {G := SL_d(F_p)} of cardinality {|S|=k} not containing the identity. Write {\mu := \frac{1}{|S|} \sum_{s\in S}\delta_s}, and suppose that one has the non-concentration property

\displaystyle  \sup_{H < G}\mu^{(n)}(H) < |G|^{-\kappa} \ \ \ \ \ (1)

for some {\kappa>0} and some even integer {n \leq \Lambda \log |G|}. Then {Cay(G,S)} is a one-sided {\epsilon}-expander for some {\epsilon>0} depending only on {k, d, \kappa,\Lambda}.

Proof: From (1) we see that {\mu^{(n)}} is not supported in any proper subgroup {H} of {G}, which implies that {S} generates {G}. The claim now follows from the Bourgain-Gamburd expansion machine (Theorem 2 of Notes 4), the product theorem (Theorem 1 of Notes 5), and quasirandomness (Exercise 8 of Notes 3). \Box

Remark 1 The same argument also works if we replace {F_p} by the field {F_{p^j}} of order {p^j} for some bounded {j}. However, there is a difficulty in the regime when {j} is unbounded, because the quasirandomness property becomes too weak for the Bourgain-Gamburd expansion machine to be directly applicable. On theother hand, the above type of theorem was generalised to the setting of cyclic groups {{\bf Z}/q{\bf Z}} with {q} square-free by Varju, to arbitrary {q} by Bourgain and Varju, and to more general algebraic groups than {SL_d} and square-free {q} by Salehi Golsefidy and Varju. It may be that some modification of the proof techniques in these papers may also be able to handle the field case {F_{p^j}} with unbounded {j}. Finally, we remark that we can also obtain two-sided expansion by the same methods if one works with the lazy random walk, generated by {\frac{1}{2} + \frac{1}{2} \mu} instead of {\mu}.

It thus remains to construct tools that can establish the non-concentration property (1). The situation is particularly simple in {SL_2(F_p)}, as we have a good understanding of the subgroups of that group. Indeed, from Theorem 14 from Notes 5, we obtain the following corollary to Theorem 1:

Corollary 2 (Non-concentration implies expansion in {SL_2}) Let {p} be a prime, and let {S} be a symmetric set of elements in {G := SL_2(F_p)} of cardinality {|S|=k} not containing the identity. Write {\mu := \frac{1}{|S|} \sum_{s\in S}\delta_s}, and suppose that one has the non-concentration property

\displaystyle  \sup_{B}\mu^{(n)}(B) < |G|^{-\kappa} \ \ \ \ \ (2)

for some {\kappa>0} and some even integer {n \leq \Lambda \log |G|}, where {B} ranges over all Borel subgroups of {SL_2(\overline{F})}. Then, if {|G|} is sufficiently large depending on {k,\kappa,\Lambda}, {Cay(G,S)} is a one-sided {\epsilon}-expander for some {\epsilon>0} depending only on {k, \kappa,\Lambda}.

It turns out (2) can be verified in many cases by exploiting the solvable nature of the Borel subgroups {B}. We give two examples of this in these notes. The first result, due to Bourgain and Gamburd (with earlier partial results by Gamburd and by Shalom) generalises Selberg’s expander construction to the case when {S} generates a thin subgroup of {SL_2({\bf Z})}:

Theorem 3 (Expansion in thin subgroups) Let {S} be a symmetric subset of {SL_2({\bf Z})} not containing the identity, and suppose that the group {\langle S \rangle} generated by {S} is not virtually solvable. Then as {p} ranges over all sufficiently large primes, the Cayley graphs {Cay(SL_2(F_p), \pi_p(S))} form a one-sided expander family, where {\pi_p: SL_2({\bf Z}) \rightarrow SL_2(F_p)} is the usual projection.

Remark 2 One corollary of Theorem 3 is that {\pi_p(S)} generates {SL_2(F_p)} for all sufficiently large {p}, if {\langle S \rangle} is not virtually solvable. This is a special case of a much more general result, known as the strong approximation theorem.

Exercise 1 In the converse direction, if {\langle S\rangle} is virtually solvable, show that for sufficiently large {p}, {\pi_p(S)} fails to generate {SL_2(F_p)}. (Hint: use Theorem 14 from Notes 5 to prevent {SL_2(F_p)} from having bounded index solvable subgroups.)

Exercise 2 (Lubotzsky’s 1-2-3 problem) Let {S := \{ \begin{pmatrix}1 & \pm 3 \\ 0 & 1 \end{pmatrix}, \begin{pmatrix}1 & 0 \\ \pm 3 & 1 \end{pmatrix}}.

  • (i) Show that {S} generates a free subgroup of {SL_2({\bf Z})}. (Hint: use a ping-pong argument, as in Exercise 23 of Notes 2.)
  • (ii) Show that if {v, w} are two distinct elements of the sector {\{ (x,y) \in {\bf R}^2_+: x/2 < y < 2x \}}, then there os no element {g \in \langle S \rangle} for which {gv = w}. (Hint: this is another ping-pong argument.) Conclude that {\langle S \rangle} has infinite index in {SL_2({\bf Z})}. (Contrast this with the situation in which the {3} coefficients in {S} are replaced by {1} or {2}, in which case {\langle S \rangle} is either all of {SL_2({\bf Z})}, or a finite index subgroup, as demonstrated in Exercise 23 of Notes 2).
  • (iii) Show that {Cay(SL_2(F_p), \pi_p(S))} for sufficiently large primes {p} form a one-sided expander family.

Remark 3 Theorem 3 has been generalised to arbitrary linear groups, and with {F_p} replaced by {{\bf Z}/q{\bf Z}} for square-free {q}; see this paper of Salehi Golsefidy and Varju. In this more general setting, the condition of virtual solvability must be replaced by the condition that the connected component of the Zariski closure of {\langle S \rangle} is perfect. An effective version of Theorem 3 (with completely explicit constants) was recently obtained by Kowalski.

The second example concerns Cayley graphs constructed using random elements of {SL_2(F_p)}.

Theorem 4 (Random generators expand) Let {p} be a prime, and let {x,y} be two elements of {SL_2(F_p)} chosen uniformly at random. Then with probability {1-o_{p \rightarrow \infty}(1)}, {Cay(SL_2(F_p), \{x,x^{-1},y,y^{-1}\})} is a one-sided {\epsilon}-expander for some absolute constant {\epsilon}.

Remark 4 As with Theorem 3, Theorem 4 has also been extended to a number of other groups, such as the Suzuki groups (in this paper of Breuillard, Green, and Tao), and more generally to finite simple groups of Lie type of bounded rank (in forthcoming work of Breuillard, Green, Guralnick, and Tao). There are a number of other constructions of expanding Cayley graphs in such groups (and in other interesting groups, such as the alternating groups) beyond those discussed in these notes; see this recent survey of Lubotzky for further discussion. It has been conjectured by Lubotzky and Weiss that any pair {x,y} of (say) {SL_2(F_p)} that generates the group, is a one-sided {\epsilon}-expander for an absolute constant {\epsilon}: in the case of {SL_2(F_p)}, this has been established for a density one set of primes by Breuillard and Gamburd.

— 1. Expansion in thin subgroups —

We now prove Theorem 3. The first observation is that the expansion property is monotone in the group {\langle S \rangle}:

Exercise 3 Let {S, S'} be symmetric subsets of {SL_2({\bf Z})} not containing the identity, such that {\langle S \rangle \subset \langle S' \rangle}. Suppose that {Cay(SL_2(F_p), \pi_p(S))} is a one-sided expander family for sufficiently large primes {p}. Show that {Cay(SL_2(F_p), \pi_p(S'))} is also a one-sided expander family.

As a consequence, Theorem 3 follows from the following two statments:

Theorem 5 (Tits alternative) Let {\Gamma \subset SL_2({\bf Z})} be a group. Then exactly one of the following statements holds:

  • (i) {\Gamma} is virtually solvable.
  • (ii) {\Gamma} contains a copy of the free group {F_2} of two generators as a subgroup.

Theorem 6 (Expansion in free groups) Let {x,y \in SL_2({\bf Z})} be generators of a free subgroup of {SL_2({\bf Z})}. Then as {p} ranges over all sufficiently large primes, the Cayley graphs {Cay(SL_2(F_p), \pi_p(\{x,y,x^{-1},y^{-1}\}))} form a one-sided expander family.

Theorem 5 is a special case of the famous Tits alternative, which among other things allows one to replace {SL_2({\bf Z})} by {GL_d(k)} for any {d \geq 1} and any field {k} of characteristic zero (and fields of positive characteristic are also allowed, if one adds the requirement that {\Gamma} be finitely generated). We will not prove the full Tits alternative here, but instead just give an ad hoc proof of the special case in Theorem 5 in the following exercise.

Exercise 4 Given any matrix {g \in SL_2({\bf Z})}, the singular values are {\|g\|_{op}} and {\|g\|_{op}^{-1}}, and we can apply the singular value decomposition to decompose

\displaystyle  g = u_1(g) \|g\|_{op} v_1^*(g) + u_2(g) \|g\|_{op}^{-1} v_2(g)^*

where {u_1(g),u_2(g)\in {\bf C}^2} and {v_1(g), v_2(g) \in {\bf C}^2} are orthonormal bases. (When {\|g\|_{op}>1}, these bases are uniquely determined up to phase rotation.) We let {\tilde u_1(g) \in {\bf CP}^1} be the projection of {u_1(g)} to the projective complex plane, and similarly define {\tilde v_2(g)}.

Let {\Gamma} be a subgroup of {SL_2({\bf Z})}. Call a pair {(u,v) \in {\bf CP}^1 \times {\bf CP}^1} a limit point of {\Gamma} if there exists a sequence {g_n \in \Gamma} with {\|g_n\|_{op} \rightarrow \infty} and {(\tilde u_1(g_n), \tilde v_2(g_n)) \rightarrow (u,v)}.

  • (i) Show that if {\Gamma} is infinite, then there is at least one limit point.
  • (ii) Show that if {(u,v)} is a limit point, then so is {(v,u)}.
  • (iii) Show that if there are two limit points {(u,v), (u',v')} with {\{u,v\} \cap \{u',v'\} = \emptyset}, then there exist {g,h \in \Gamma} that generate a free group. (Hint: Choose {(\tilde u_1(g), \tilde v_2(g))} close to {(u,v)} and {(\tilde u_1(h),\tilde v_2(h))} close to {(u',v')}, and consider the action of {g} and {h} on {{\bf CP}^1}, and specifically on small neighbourhoods of {u,v,u',v'}, and set up a ping-pong type situation.)
  • (iv) Show that if {g \in SL_2({\bf Z})} is hyperbolic (i.e. it has an eigenvalue greater than 1), with eigenvectors {u,v}, then the projectivisations {(\tilde u,\tilde v)} of {u,v} form a limit point. Similarly, if {g} is regular parabolic (i.e. it has an eigenvalue at 1, but is not the identity) with eigenvector {u}, show that {(\tilde u,\tilde bu)} is a limit point.
  • (v) Show that if {\Gamma} has no free subgroup of two generators, then all hyperbolic and regular parabolic elements of {\Gamma} have a common eigenvector. Conclude that all such elements lie in a solvable subgroup of {\Gamma}.
  • (vi) Show that if an element {g \in SL_2({\bf Z})} is neither hyperbolic nor regular parabolic, and is not a multiple of the identity, then {g} is conjugate to a rotation by {\pi/2} (in particular, {g^2=-1}).
  • (vii) Establish Theorem 5. (Hint: show that two square roots of {-1} in {SL_2({\bf Z})} cannot multiply to another square root of {-1}.)

Now we prove Theorem 6. Let {\Gamma} be a free subgroup of {SL_2({\bf Z})} generated by two generators {x,y}. Let {\mu := \frac{1}{4} (\delta_x +\delta_{x^{-1}} + \delta_y + \delta_{y^{-1}})} be the probability measure generating a random walk on {SL_2({\bf Z})}, thus {(\pi_p)_* \mu} is the corresponding generator on {SL_2(F_p)}. By Corollary 2, it thus suffices to show that

\displaystyle  \sup_{B}((\pi_p)_* \mu)^{(n)}(B) < p^{-\kappa}

for all sufficiently large {p}, some absolute constant {\kappa>0}, and some even {n = O(\log p)} (depending on {p}, of course), where {B} ranges over Borel subgroups.

As {\pi_p} is a homomorphism, one has {((\pi_p)_* \mu)^{(n)}(B) = (\pi_p)_* (\mu^{(n)})(B) = \mu^{(n)}(\pi_p^{-1}(B))} and so it suffices to show that

\displaystyle  \sup_{B} \mu^{(n)}(\pi_p^{-1}(B)) < p^{-\kappa}.

To deal with the supremum here, we will use an argument of Bourgain and Gamburd, taking advantage of the fact that all Borel groups of {SL_2} obey a common group law, the point being that free groups such as {\Gamma} obey such laws only very rarely. More precisely, we use the fact that the Borel groups are solvable of derived length two; in particular we have

\displaystyle  [[a,b],[c,d]] = 1 \ \ \ \ \ (3)

for all {a,b,c,d \in B}. Now, {\mu^{(n)}} is supported on matrices in {SL_2({\bf Z})} whose coefficients have size {O(\exp(O(n)))} (where we allow the implied constants to depend on the choice of generators {x,y}), and so {(\pi_p)_*( \mu^{(n)} )} is supported on matrices in {SL_2(F_p)} whose coefficients also have size {O(\exp(O(n)))}. If {n} is less than a sufficiently small multiple of {\log p}, these coefficients are then less than {p^{1/10}} (say). As such, if {\tilde a,\tilde b,\tilde c,\tilde d \in SL_2({\bf Z})} lie in the support of {\mu^{(n)}} and their projections {a = \pi_p(\tilde a), \ldots, d = \pi_p(\tilde d)} obey the word law (3) in {SL_2(F_p)}, then the original matrices {\tilde a, \tilde b, \tilde c, \tilde d} obey the word law (3) in {SL_2({\bf Z})}. (This lifting of identities from the characteristic {p} setting of {SL_2(F_p)} to the characteristic {0} setting of {SL_2({\bf Z})} is a simple example of the “Lefschetz principle”.)

To summarise, if we let {E_{n,p,B}} be the set of all elements of {\pi_p^{-1}(B)} that lie in the support of {\mu^{(n)}}, then (3) holds for all {a,b,c,d \in E_{n,p,B}}. This severely limits the size of {E_{n,p,B}} to only be of polynomial size, rather than exponential size:

Proposition 7 Let {E} be a subset of the support of {\mu^{(n)}} (thus, {E} consists of words in {x,y,x^{-1},y^{-1}} of length {n}) such that the law (3) holds for all {a,b,c,d \in E}. Then {|E| \ll n^2}.

The proof of this proposition is laid out in the exercise below.

Exercise 5 Let {\Gamma} be a free group generated by two generators {x,y}. Let {B} be the set of all words of length at most {n} in {x,y,x^{-1},y^{-1}}.

  • (i) Show that if {a,b \in \Gamma} commute, then {a, b} lie in the same cyclic group, thus {a = c^i, b = c^j} for some {c \in \Gamma} and {i,j \in {\bf Z}}.
  • (ii) Show that if {a \in \Gamma}, there are at most {O(n)} elements of {B} that commute with {a}.
  • (iii) Show that if {a,c \in \Gamma}, there are at most {O(n)} elements {b} of {B} with {[a,b] = c}.
  • (iv) Prove Proposition 7.

Now we can conclude the proof of Theorem 3:

Exercise 6 Let {\Gamma} be a free group generated by two generators {x,y}.

  • (i) Show that {\| \mu^{(n)} \|_{\ell^\infty(\Gamma)} \ll c^n} for some absolute constant {0 < c<1}. (For much more precise information on {\mu^{(n)}}, see this paper of Kesten.)
  • (ii) Conclude the proof of Theorem 3.

Exercise 7 Strengthen the one-sided expansion in Theorem 3 to two-sided expansion.

— 2. Random generators expand —

We now prove Theorem 4. Let {{\bf F}_2} be the free group on two formal generators {a,b}, and let {\mu := \frac{1}{4}(\delta_a + \delta_b + \delta_{a^{-1}}+ \delta_{b^{-1}}} be the generator of the random walk. For any word {w \in {\bf F}_2} and any {x,y} in a group {G}, let {w(x,y) \in G} be the element of {G} formed by substituting {x,y} for {a,b} respectively in the word {w}; thus {w} can be viewed as a map {w: G \times G \rightarrow G} for any group {G}. Observe that if {w} is drawn randomly using the distribution {\mu^{(n)}}, and {x,y \in SL_2(F_p)}, then {w(x,y)} is distributed according to the law {\tilde \mu^{(n)}}, where {\tilde \mu := \frac{1}{4}(\delta_x + \delta_y + \delta_{x^{-1}}+ \delta_{y^{-1}})}. Applying Corollary 2, it suffices to show that whenever {p} is a large prime and {x,y} are chosen uniformly and independently at random from {SL_2(F_p)}, that with probability {1-o_{p \rightarrow \infty}(1)}, one has

\displaystyle  \sup_B {\bf P}_w ( w(x,y) \in B ) \leq p^{-\kappa} \ \ \ \ \ (4)

for some absolute constant {\kappa}, where {B} ranges over all Borel subgroups of {SL_2(\overline{F_p})} and {w} is drawn from the law {\mu^{(n)}} for some even natural number {n = O(\log p)}.

Let {B_n} denote the words in {{\bf F}_2} of length at most {n}. We may use the law (3) to obtain good bound on the supremum in (4) assuming a certain non-degeneracy property of the word evaluations {w(x,y)}:

Exercise 8 Let {n} be a natural number, and suppose that {x,y \in SL_2(F_p)} is such that {w(x,y) \neq 1} for {w \in B_{100n} \backslash \{1\}}. Show that

\displaystyle  \sup_B {\bf P}_w ( w(x,y) \in B ) \ll \exp(-cn)

for some absolute constant {c>0}, where {w} is drawn from the law {\mu^{(n)}}. (Hint: use (3) and the hypothesis to lift the problem up to {{\bf F}_2}, at which point one can use Proposition 7 and Exercise 6.)

In view of this exercise, it suffices to show that with probability {1-o_{p \rightarrow\infty}(1)}, one has {w(x,y) \neq 1} for all {w \in B_{100n} \backslash \{1\}} for some {n} comparable to a small multiple of {\log p}. As {B_{100n}} has {\exp(O(n))} elements, it thus suffices by the union bound to show that

\displaystyle  {\bf P}_{x,y}(w(x,y)=1) \leq p^{-\gamma} \ \ \ \ \ (5)

for some absolute constant {\gamma > 0}, and any {w \in {\bf F}_2 \backslash \{1\}} of length less than {c\log p} for some sufficiently small absolute constant {c>0}.

Let us now fix a non-identity word {w} of length {|w|} less than {c\log p}, and consider {w} as a function from {SL_2(k) \times SL_2(k)} to {SL_2(k)} for an arbitrary field {k}. We can identify {SL_2(k)} with the set {\{ (a,b,c,d)\in k^4: ad-bc=1\}}. A routine induction then shows that the expression {w((a,b,c,d),(a',b',c',d'))} is then a polynomial in the eight variables {a,b,c,d,a',b',c',d'} of degree {O(|w|)} and coefficients which are integers of size {O( \exp( O(|w|) ) )}. Let us then make the additional restriction to the case {a,a' \neq 0}, in which case we can write {d = \frac{bc+1}{a}} and {d' =\frac{b'c'+1}{a'}}. Then {w((a,b,c,d),(a',b',c',d'))} is now a rational function of {a,b,c,a',b',c'} whose numerator is a polynomial of degree {O(|w|)} and coefficients of size {O( \exp( O(|w|) ) )}, and the denominator is a monomial of {a,a'} of degree {O(|w|)}.

We then specialise this rational function to the field {k=F_p}. It is conceivable that when one does so, the rational function collapses to the constant polynomial {(1,0,0,1)}, thus {w((a,b,c,d),(a',b',c',d'))=1} for all {(a,b,c,d),(a',b',c',d') \in SL_2(F_p)} with {a,a' \neq 0}. (For instance, this would be the case if {w(x,y) = x^{|SL_2(F_p)|}}, by Lagrange’s theorem, if it were not for the fact that {|w|} is far too large here.) But suppose that this rational function does not collapse to the constant rational function. Applying the Schwarz-Zippel lemma (Exercise 23 from Notes 5), we then see that the set of pairs {(a,b,c,d),(a',b',c',d') \in SL_2(F_p)} with {a,a' \neq 0} and {w((a,b,c,d),(a',b',c',d'))=1} is at most {O( |w| p^5 )}; adding in the {a=0} and {a'=0} cases, one still obtains a bound of {O(|w|p^5)}, which is acceptable since {|SL_2(F_p)|^2 \sim p^6} and {|w| = O( \log p )}. Thus, the only remaining case to consider is when the rational function {w((a,b,c,d),(a',b',c',d'))} is identically {1} on {SL_2(F_p)} with {a,a' \neq 0}.

Now we perform another “Lefschetz principle” maneuvre to change the underlying field. Recall that the denominator of rational function {w((a,b,c,d),(a',b',c',d'))} is monomial in {a,a'}, and the numerator has coefficients of size {O(\exp(O(|w|)))}. If {|w|} is less than {c\log p} for a sufficiently small {p}, we conclude in particular (for {p} large enough) that the coefficients all have magnitude less than {p}. As such, the only way that this function can be identically {1} on {SL_2(F_p)} is if it is identically {1} on {SL_2(k)} for all {k} with {a,a' \neq 0}, and hence for {a=0} or {a'=0} also by taking Zariski closures.

On the other hand, we know that for some choices of {k}, e.g. {k={\bf R}}, {SL_2(k)} contains a copy of the free group on two generators (see e.g. Exercise 23 of Notes 2). As such, it is not possible for any non-identity word {w} to be identically trivial on {SL_2(k) \times SL_2(k)}. Thus this case cannot actually occur, completing the proof of (5) and hence of Theorem 4.

How to setup OCMock XCode 4 iOS 5 How to setup OCMock XCode 4 iOS 5

This was harder than I would have liked. Here’s some notes on how to set it up.

Setup OCUnit on your existing project

These notes from Apple are pretty good about how to setup OCUnit on your XCode project.

The only difference was when I ran my unit tests (Product -> Test) I had to manually add my own unit test scheme.

Just hit the ‘Edit Scheme’ button, then hit the ‘+’ sign and click on your target unit tests and click the ‘Add button’.

You should now be able to run your tests against the simulator (not real phone) and see the failure.

Setup OCMock

Create a Libraries directory

Create a ‘Libraries’ directory in your project by right clicking on your project icon and selecting ‘Add Files to …’.

Click the ‘New folder’ button, type the name ‘Libraries’, and click ‘Add’ so your libraries directory is at the same level as your project and unit test target. When your done it should look something like this:

Copy in libOCMock.a

Download the libOCMock.a and stick it in the Libraries directory we just created.

Then add it to your project by dragging it into the Libraries directory we just added to your project.

When you do a window will pop up, make sure you select the ‘Copy items’ box at the top and click on your unit test target so it will be linked to OCMock.

Copy OCMock header files

Download the latest OCMock dmg file, located the OCMock directory inside containing the header files, and just like we did before, drag it into the Libraries directory.

Again select ‘Copy’ and click your unit test target and now your directory structure should look like this:

Configure Build Settings

We now need to tell our project how to find these header files we just added.

Click your blue project icon (click somewhere else and then click it again if it doesn’t immediately change) and click the ‘Build Settings’ tab for your project.

In the ‘Search Paths -> Library Search Paths’ section add $(SRCROOT)/Libraries in double quotes to Debug and Release sections. Once you do they will automatically convert to your local machine paths as shown below.

And then do the exact same thing for the ‘Search Paths ->Header Search Path’ section (be sure to double click on it after and make sure both are set to ‘recursive’).

Next head down to the ‘Linking -> Other Link Flags’ section and add the ‘-all_load’ option.

If you don’t do this you’ll get a “Did you forget to add the -force_load linker flag?” error when you run your tests and you can read about why here.

Add a mock test case

We should now be good to go. Open you the default test case OCUnit created for you and add the following:

1
#import &quot;UnitTests.h&quot;#import &lt;OCMock/OCMock.h&gt;@implementation UnitTests- (void)setUp{ [super setUp]; // Set-up code here.}- (void)tearDown{ // Tear-down code here. [super tearDown];}- (void)testExample{ //STFail(@&quot;Unit tests are not implemented yet in UnitTests&quot;);}- (void)testOCMockPass { id mock = [OCMockObject mockForClass:NSString.class]; [[[mock stub] andReturn:@&quot;mocktest&quot;] lowercaseString]; NSString *returnValue = [mock lowercaseString]; STAssertEqualObjects(@&quot;mocktest&quot;, returnValue, @&quot;Should have returned the expected string.&quot;);}@end

If everything worked, you should be able to run your test now and see a nice failure in your log output window:

Links that help:

https://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/UnitTesting/02-Setting_Up_Unit_Tests_in_a_Project/setting_up.html#//apple_ref/doc/uid/TP40002143-CH3-SW1

http://www.raywenderlich.com/3716/unit-testing-in-xcode-4-quick-start-guide

https://developer.apple.com/library/mac/#qa/qa1490/_index.html

http://ocmock.org/

How to display image on iPhone using UIImageView and UIScrollView

These are abbreviated notes from the Lecture 8 Imaginarium demo of Paul Hegarty’s excellent iPhone course. For the full walk through go there.

After you’ve created a blank single view project with an ImaginariumViewController….

Drag an Image View into the ViewController view area.

Drag an image into your project.

Add image to display.

Note – it will automatically scale the image to fit the view (will change the aspect ratio).

Change to only show top left

Now the image aspect ratio is respected, but the image is so big we only start showing the top left. So now we’ll add a scroll bar.

Select the image view (use doc view pop out on right of story board if you need to make sure you have the right view).

And click Editor -> Embed In -> Scroll View

Note how imageView is now embedded in scrollView.

Our scroll view struts and springs are now out of wack.

Fix them so they expand and use the entire area.

If we run this now we’ll see our image but no scrolling.

ScrollView has to have it’s content size set.

This scroll view currently doesn’t know how big an area to scroll over. So we need to set it (set the content area, and then set the frame of the image view so it’s in the right spot).

Going to talk to these guys from our ViewController. Therefore we need outlets.

Note you can drag the outlets from the docView we saw earlier.
Call them imageView and scrollView and stick them in the private interface of the ViewController.

Note when you do this it will auto create the synthesize and it will also add itself to the ViewDidUnload() the low memory thing.

Now use viewDidLoad to set your content size (the size of the image) and it’s frame to be the full size.

ImaginariumViewController.m

1
-(void)viewDidLoad{ [super viewDidLoad]; self.scrollView.contentSize = self.imageView.image.size; self.imageView.frame = CGRectMake(0, 0, self.imageView.image.size.width, self.imageView.image.size.height);}

Now when we run should work.

Bonus points – zoom

So how to we get this thing to zoom?

Set the min and max zoom on the scrollView.

Set the delegate.

1
@interface ImaginariumViewController()

Implement the zoom method.

1
-(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView{ // return which subview we want to zoom return self.imageView;}

Now set ourselves as the delegate.

1
-(void)viewDidLoad{ [super viewDidLoad]; self.scrollView.delegate = self;

Note you can also set the delegate entirely within the story board using the doc view by dragging the scrollView to the controller.

Should now be able to zoom.

Code in it’s entirety.

ImaginariumViewController.m

1
#import &quot;ImaginariumViewController.h&quot;@interface ImaginariumViewController() &lt;UIScrollViewDelegate&gt;@property (weak, nonatomic) IBOutlet UIImageView *imageView;@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;@end@implementation ImaginariumViewController@synthesize imageView;@synthesize scrollView;-(void)viewDidLoad{ [super viewDidLoad]; self.scrollView.delegate = self; self.scrollView.contentSize = self.imageView.image.size; self.imageView.frame = CGRectMake(0, 0, self.imageView.image.size.width, self.imageView.image.size.height);}-(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView{ // return which subview we want to zoom return self.imageView;}- (void)viewDidUnload { [self setImageView:nil]; [self setScrollView:nil]; [super viewDidUnload];}@end