A person is guilty of criminal trespass if he knowingly enters or remains unlawfully in a dwelling or premises, or if he knowingly enters or remains unlawfully in a building or upon real property which is fenced or enclosed in a manner designed to exclude intruders. A person commits criminal trespass who, knowing he does not have the owner’s effective consent to do so, enters or remains on property, or a portion thereof. Laws vary by state, so local laws must be consulted to determine applicable requirements. It is a defense to the crime to show that an element of the crime, such as knowingly entering or remaining without authorization, is lacking. An attempted criminal trespass requires that a defendant act with the intent to commit criminal trespass, and his conduct must constitute a substantial step toward committing the aggravated criminal trespass.
The following is an example of a state statute defining "remain unlawfully":
A person "enters or remains unlawfully" in or upon premises when he is not licensed, invited or privileged to do so. A person who, regardless of his intent, enters or remains in or upon premises which are at the time open to the public does so with license and privilege unless he defies a lawful order not to enter or remain, personally communicated to him by the owner of such premises or other authorized person. A license or privilege to enter or remain in a building which is partly open to the public is not a license or privilege to enter or remain in that part of the building which is not open to the public. A person who enters or remains upon unimproved and apparently unused land, which is neither fenced nor otherwise enclosed in a manner designed to exclude intruders, does so with license and privileges unless notice against trespass is personally communicated to him by the owner of such land or other authorized person, or unless such notice is given by posting in a conspicuous manner."
Burglary laws also vary by state, but may generally be defined as when a person knowingly and unlawfully enters or remains unlawfully in a dwelling or building with intent to commit a crime therein. Degrees of burglary are defined by each state's laws. Laws vary by state, so local law should be consulted to determine the law applicable in your area.