Exercise

This is exercise 7 from chapter 3 of How to Prove It by Daniel J . Velleman .
In[]:=

Resolution

We create the lists
In[]:=
p={"Johann Sebastian Bach","Napoleon Bonaparte","Goethe","David Hume","Mozart","Newton","George Washingtong"};​​y={1750,1751,1752,1753,1754,1755,1756,1757,1758,1759};
We create the entities from the names ...
p1=Interpreter["Person"][#]&/@p
Out[]=

Johann Sebastian Bach
,
Napoleon
,
Johann Wolfgang von Goethe
,
David Hume
,
Wolfgang Amadeus Mozart
,
Isaac Newton
,
George Washington

... and the date objects from the years in the corresponding lists .
y1=DateObject[{#}]&/@y
Out[]=

Year: 1750
,
Year: 1751
,
Year: 1752
,
Year: 1753
,
Year: 1754
,
Year: 1755
,
Year: 1756
,
Year: 1757
,
Year: 1758
,
Year: 1759

Now a list with sublists containing the entity and its life span .
persona={#,DateInterval[{#["BirthDate"],#["DeathDate"]}]}&/@p1
Out[]=

Johann Sebastian Bach
,DateInterval
Beginning: Sat 31 Mar 1685
Through: Tue 28 Jul 1750
,
Napoleon
,DateInterval
Beginning: Tue 15 Aug 1769
Through: Sat 5 May 1821
,
Johann Wolfgang von Goethe
,DateInterval
Beginning: Thu 28 Aug 1749
Through: Thu 22 Mar 1832
,
David Hume
,DateInterval
Beginning: Thu 7 May 1711
Through: Sun 25 Aug 1776
,
Wolfgang Amadeus Mozart
,DateInterval
Beginning: Tue 27 Jan 1756
Through: Mon 5 Dec 1791
,
Isaac Newton
,DateInterval
Beginning: Sun 4 Jan 1643
Through: Mon 31 Mar 1727
,
George Washington
,DateInterval
Beginning: Fri 22 Feb 1732
Through: Sat 14 Dec 1799

A better view :
persona//TableForm
Out[]//TableForm=
Johann Sebastian Bach
DateInterval
Beginning: Sat 31 Mar 1685
Through: Tue 28 Jul 1750

Napoleon
DateInterval
Beginning: Tue 15 Aug 1769
Through: Sat 5 May 1821

Johann Wolfgang von Goethe
DateInterval
Beginning: Thu 28 Aug 1749
Through: Thu 22 Mar 1832

David Hume
DateInterval
Beginning: Thu 7 May 1711
Through: Sun 25 Aug 1776

Wolfgang Amadeus Mozart
DateInterval
Beginning: Tue 27 Jan 1756
Through: Mon 5 Dec 1791

Isaac Newton
DateInterval
Beginning: Sun 4 Jan 1643
Through: Mon 31 Mar 1727

George Washington
DateInterval
Beginning: Fri 22 Feb 1732
Through: Sat 14 Dec 1799

Functions
A function that maps each person' s name to identify whether the year "y" overlaps their life span . If it does, it returns the person' s name; if it does not, it returns nothing .
In[]:=
g[y_]:=If[DateOverlapsQ[Flatten[#][[2]],y],Flatten[#][[1]],Nothing]&/@persona
Now we map the function using the list of date objects created earlier . The result is a list of associations .
a=AssociationThread[#,{g[#]}]&/@y1
Out[]=

Year: 1750

Johann Sebastian Bach
,
Johann Wolfgang von Goethe
,
David Hume
,
George Washington
,
Year: 1751

Johann Wolfgang von Goethe
,
David Hume
,
George Washington
,
Year: 1752

Johann Wolfgang von Goethe
,
David Hume
,
George Washington
,
Year: 1753

Johann Wolfgang von Goethe
,
David Hume
,
George Washington
,
Year: 1754

Johann Wolfgang von Goethe
,
David Hume
,
George Washington
,
Year: 1755

Johann Wolfgang von Goethe
,
David Hume
,
George Washington
,
Year: 1756

Johann Wolfgang von Goethe
,
David Hume
,
Wolfgang Amadeus Mozart
,
George Washington
,
Year: 1757

Johann Wolfgang von Goethe
,
David Hume
,
Wolfgang Amadeus Mozart
,
George Washington
,
Year: 1758

Johann Wolfgang von Goethe
,
David Hume
,
Wolfgang Amadeus Mozart
,
George Washington
,
Year: 1759

Johann Wolfgang von Goethe
,
David Hume
,
Wolfgang Amadeus Mozart
,
George Washington

A better view :
a//TableForm
Out[]//TableForm=

Year: 1750

Johann Sebastian Bach
,
Johann Wolfgang von Goethe
,
David Hume
,
George Washington


Year: 1751

Johann Wolfgang von Goethe
,
David Hume
,
George Washington


Year: 1752

Johann Wolfgang von Goethe
,
David Hume
,
George Washington


Year: 1753

Johann Wolfgang von Goethe
,
David Hume
,
George Washington


Year: 1754

Johann Wolfgang von Goethe
,
David Hume
,
George Washington


Year: 1755

Johann Wolfgang von Goethe
,
David Hume
,
George Washington


Year: 1756

Johann Wolfgang von Goethe
,
David Hume
,
Wolfgang Amadeus Mozart
,
George Washington


Year: 1757

Johann Wolfgang von Goethe
,
David Hume
,
Wolfgang Amadeus Mozart
,
George Washington


Year: 1758

Johann Wolfgang von Goethe
,
David Hume
,
Wolfgang Amadeus Mozart
,
George Washington


Year: 1759

Johann Wolfgang von Goethe
,
David Hume
,
Wolfgang Amadeus Mozart
,
George Washington


Union and intersection

With what we have found we can obtain the union and intersection of the sets .
{"Union of sets"->Union@@Flatten[Values[a],1],"Intersection of sets"->Intersection@@Flatten[Values[a],1]}//TableForm
Out[]//TableForm=
Union of sets
David Hume
,
George Washington
,
Johann Wolfgang von Goethe
,
Johann Sebastian Bach
,
Wolfgang Amadeus Mozart

Intersection of sets
David Hume
,
George Washington
,
Johann Wolfgang von Goethe
