# Expression Matching With MatchQ and HoldForm

I am learning to work with MatchQ for pattern matching in expressions. For instance:

MatchQ[x + y, Plus[_,__]]


returns True.

However,

MatchQ[1+1, Plus[_,__]]


returns False.

I believe the reason for this is that Mathematica has evaluated 1+1, and the structure of the expression has changed.

To check this:

FullForm[HoldForm[1+1]]


returns HoldForm[Plus[1,1]]

Ok. Getting closer.

Where I am stuck is passing the unevaluated expression of 1+1 to MatchQ in functional format to test.

How would I structure MatchQ to evaluate the expression 1+1 as True?

• MatchQ does not have any Hold attributes. Therefore, Plus is evaluated before it is passed into MatchQ. Run the following to see the affect: Trace[MatchQ[1 + 1, Plus[_, __]]]. – Edmund Sep 20 '16 at 0:02
• Are you looking for MatchQ[Unevaluated[1 + 1], Plus[_, __]]? – Karsten 7. Sep 20 '16 at 0:03
• Also you can check out Inactive, IgnoringInactive, etc. – QuantumDot Sep 20 '16 at 0:52
• Unevaluated was what I was looking for. Thanks. – Todd Dixon Sep 20 '16 at 13:34