Silent House

A young woman named Sarah (Elizabeth Olsen) is staying at her family's dilapidated Victorian house in the countryside with her father and her uncle, helping them fix it up. Due to petty fighting between Sarah's uncle and her father, her uncle decides to take a break from working and drives into town to get tools. While her father works upstairs, there is a knock on the door and Sarah answers it, meeting a young woman named Sophia who claims to be one of Sarah's childhood friends, though Sarah does not remember her. The two plan to meet again later.
Soon after, Sarah hears strange noises upstairs and immediately notifies her father. He is not worried, but goes to check, finding nothing. Sarah calms down, but soon hears the sound of her father falling down the stairs. Panicked, she tries to leave the house but all exits are locked or boarded up, and she hides from an unknown perpetrator who attempts to grab hold of her under a table. Sarah searches for her father and finds him unconscious with a head wound. She runs to the basement in search of the cellar door leading outside, and finds a bed and other human necessities, evidence that someone else has been living there, possibly squatters. She sees a figure shining a light in the basement to find her but she escapes out the cellar door.
Outside, she meets her uncle, who has returned, and sees a young girl on the side of the road who disappears before her eyes. Her uncle insists on driving them back to the house to rescue her father, despite Sarah's plea that they should both go get help. They discover her father's body to be missing, and find a generator lamp running on the third floor of the house in the billiard room. While searching the billiard room, the generator kicks off; the only source of light available is a Polaroid camera's flash.
Through a series of intermittent camera flashes, Sarah sees the young girl and an unidentified man in the room. The power returns to reveal that her uncle is missing. She hides under the pool table while two men take pictures, presumably pedophilic in nature, of an unseen girl on the top of the table. Sarah then sees one of the men dragging her uncle's body toward the staircase. She attempts unsuccessfully to shoot one of the men with her uncle's gun.
Sarah returns to her room to hide, and begins to exhibit signs of paranoia and psychosis. She has hallucinations that depict traumatic childhood events, including a blood stain appearing on her bed, a young girl in the bathtub with beer bottles and bloody water, and a toilet spewing blood. These vivid hallucinations frighten Sarah, and she runs downstairs.
In the foyer, she runs into Sophia, and finds her now conscious father wrapped in plastic, sitting up in the living room. Sophia gives Sarah a key to a box containing pedophilic pictures of Sarah as a little girl, implying that her father sexually abused and photographed her. It is suggested that her recent interactions and hallucinations with the little girl and mystery attacker have been a kind of traumatic repressed memory. Events at the house have caused this memory to reappear, and Sarah is now exacting her revenge, although she has been confusing the difference between the events that are in her subconscious from her childhood and what she is actually doing now.
Sarah is then shown dragging her unconscious uncle into the living room. Sarah realizes Sophia is a figment of her imagination and Sophia vanishes. Her father convinces Sarah, who is still deeply traumatised and reliving her horrific childhood experiences with him, to untie him. Once untied, her father slaps her and whips her to the floor with his belt. Her uncle then regains consciousness and tries to stop her father, who mocks his brother's pleas. As his back is turned, Sarah bludgeons his head with a sledgehammer. Her uncle begs for mercy and tells her he should have stopped the rape and abuse that went on at the hands of her father. Sarah leaves him and walks outside silently. The film cuts to black.

Question: who realizes Sophia is a figment ?
Answer: Sarah