While President Trump claims he can do it “100 percent,” the reality of whether can declare a state of emergency to build his wall is actually pretty complicated.

The first question is, “Can the president declare a state of emergency?” That answer is “Yes.”

Congress passed the National Emergencies Act in 1976 in an effort to regulate the haphazard manner that national emergencies had been handled in the past. In short, the president has authority to declare a national emergency but Congress can terminate it by passing a joint resolution and overturning a presidential veto.

That makes declaring an emergency easy a president to do and difficult for Congress to block. But what does that get him? What powers can he invoke?

The Constitution itself doesn’t grant the president any general-purpose emergency powers. The Supreme Court made that quite clear back in 1952 Youngstown Sheet & Tube v. Sawyer, when President Truman attempted to nationalize the steel industry to avert a strike during the Korean war. Instead, the president must rely on whatever emergency powers have been authorized by Congress. And there are quite a few.

When declaring an emergency under the National Emergencies Act, the president must specify which emergency powers are being invoked. These powers have been granted by various statutes that include a trigger giving the president additional powers during a national emergency. They are littered throughout the federal code, though, so identifying these emergency powers can be difficult. One study found at least 136 different statutory powers available to the president during a declared emergency.

Of course, most of these emergency powers aren’t very relevant to our current situation Being able to authorize the discharge of garbage at sea, for example isn’t going to be particularly useful for wall-building. (33 USC 1902(b)(3)(F).) The two emergency powers that appear to be the most relevant are found at 10 USC 2808 and 33 USC 2293. Each of these authorizes the diversion of existing construction funding to other projects “in the event of a declaration by the President of a national emergency.”

The devil, however, is in the details. 10 USC 2808 allows the president to redirect military construction funds that have already been approved by Congress to other military construction projects “not otherwise authorized by law.” There are two crucial restrictions, however. First, the emergency must “require the use of the armed forces.” Second, the statute only authorizes construction projects “that are necessary to support such use of the armed forces.”

Is there an emergency at the border that requires the use of the armed forces to enforce U.S. immigration laws or drug laws? That’s actually one of the easier questions to answer. There is no such emergency because, legally, there can be no such emergency. In what is often called the Posse Comitatus Act, 18 U.S. Code § 1385 makes it a federal crime punishable by two years in prison to use the Army or the Air Force to “execute the laws.” (There are similar laws and regulations restricting the use of the Navy and Marines.) In short, with some minor exceptions already authorized by Congress which include things like helping conducting border surveillance, the military may not be used to enforce immigration laws or any other domestic laws.

So it isn’t possible for President Trump to use 10 USC 2808 to build his wall. Short of an armed invasion by the Mexican army, there is no possible border emergency that would allow, much less require, the use of the U.S. military. By the same token, the wall isn’t – and can’t be – necessary to support the use of the U.S. military to secure the border against people trying to sneak into the country.

33 USC 2293 is titled “Reprogramming during national emergencies” and allows the president to redirect funds from Army civil works projects that aren’t deemed essential to the national defense to other “authorized civil works, military construction and civil defense projects” that are. “Army civil works projects” means projects run by the Army Corps of Engineers and are typically things like flood control and disaster relief projects.

This statute is slightly more flexible in that it’s only necessary that the national emergency “may require” the use of the armed forces. But the same argument applies. An immigration crisis on the border can’t legally require the use of the armed forces.

There’s another problem. While 10 USC 2808 allows for the construction of projects “not otherwise authorized by law,” 33 USC 2293 allows the president only to shift funds from one authorized project to another. As President’s Trump’s wall has most definitely not been authorized, this statute can’t be used to build it.

So no, President Trump probably cannot use a declared emergency to build his wall. And, if he were to try, the project would end up in court before he could dig the first posthole. Even if he were eventually successful in court, he still wouldn’t get his wall as neither of these statutes allow the president to spend money that hasn’t been appropriated, albeit for some other type of construction. Without congressional approval for the wall, the end result would either be no money for any military construction at all or military construction funding with express provisions preventing the president from diverting it.

In the end, there’s no getting around Congress. Somewhere, James Madison is smiling.