Skip to content

Instantly share code, notes, and snippets.

@mndrix
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mndrix/27ffca5247ab79d21165 to your computer and use it in GitHub Desktop.
Save mndrix/27ffca5247ab79d21165 to your computer and use it in GitHub Desktop.
Qualifications for foreign earned income exclusion
% Requirements, using Prolog syntax, to qualify for the foreign earned income exclusion
% See http://www.irs.gov/Individuals/International-Taxpayers/Foreign-Earned-Income-Exclusion
% facts which act as parameters to the loophole solver
:- dynamic
us_citizen/0,
us_resident_alien/0.
% See http://www.irs.gov/Individuals/International-Taxpayers/Foreign-Earned-Income-Exclusion-Can-I-Claim-the-Exclusion-or-Deduction
qualify :-
foreign_earned_income,
foreign_tax_home,
( us_citizen ->
question_4
; us_resident_alien, home_country_has_tax_treaty ->
question_4
; otherwise ->
question_5
).
question_4 :-
bona_fide_resident,
residence_for_entire_tax_year,
!.
question_4 :-
question_5.
question_5 :-
foreign_physical_presence(Days),
Days >= 330.
% See http://www.irs.gov/Individuals/International-Taxpayers/Foreign-Earned-Income-Exclusion---What-is-Foreign-Earned-Income
foreign_earned_income :-
todo.
% See http://www.irs.gov/Individuals/International-Taxpayers/Foreign-Earned-Income-Exclusion---Tax-Home-in-Foreign-Country
foreign_tax_home :-
todo.
% See http://www.irs.gov/Individuals/International-Taxpayers/Foreign-Earned-Income-Exclusion---Bona-Fide-Residence-Test
bona_fide_resident :-
todo.
residence_for_entire_tax_year :-
foreign_physical_presence(Days),
Days >= 365.
% See http://www.irs.gov/Individuals/International-Taxpayers/Foreign-Earned-Income-Exclusion---Physical-Presence-Test
foreign_physical_presence(_Days) :-
todo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment