Baking Substitution Machine
sublist(ingrd("allspice",1,tsp),[ingrd("cinnamon",0.5,tsp),ingrd("ginger",0.25,tsp),ingrd("cloves",0.25,tsp)])
sublist(ingrd("apple pie spice",1,tsp),[ingrd("cinnamon",0.5,tsp),ingrd("nutmeg",0.25,tsp),ingrd("allspice",0.125,tsp)])
sublist(ingrd("arrowroot",1,tsp),[ingrd("all purpose flour",1,tbsp)])
sublist(ingrd("arrowroot",1,tsp),[ingrd("cornstarch",1,tsp)])
sublist(ingrd("baking powder",1,tsp),[ingrd("baking soda",0.25,tsp),ingrd("cream of tartar",0.5,tsp)])
sublist(ingrd("beer",1,cups),[ingrd("chicken broth",1,cups)])
sublist(ingrd("brandy",0.25,cups),[ingrd("brandy extract",1,tsp),ingrd("water",0.25,cups)])
sublist(ingrd("bread crumbs",1,cups),[ingrd("ground oats",1,cups)])
sublist(ingrd("brown sugar",1,cups),[ingrd("sugar",1,cups),ingrd("molasses",0.25,cups)])
sublist(ingrd("butter",1,cups),[ingrd("shortening",1,cups)])
sublist(ingrd("butter",1,cups),[ingrd("vegetable oil",0.875,cups),ingrd("salt",0.5,tsp)])
sublist(ingrd("butter",1,cups),[ingrd("buttermilk",0.5,cups),ingrd("applesauce",0.5,cups)])
sublist(ingrd("butter",1,cups),[ingrd("yogurt",1,cups)])
sublist(ingrd("buttermilk",1,cups),[ingrd("sour cream",0.75,cups),ingrd("milk",0.25,cups)])
sublist(ingrd("buttermilk",1,cups),[ingrd("yogurt",1,cups)])
sublist(ingrd("cake flour",1,cups),[ingrd("all purpose flour",0.875,cups),ingrd("cornstarch",2,tbsp)])
sublist(ingrd("cardamom",1,tsp),[ingrd("ginger",1,tsp)])
sublist(ingrd("chili powder",1,tsp),[ingrd("cumin",1,tsp)])
sublist(ingrd("chives",1,tbsp),[ingrd("green onions",1,tbsp)])
sublist(ingrd("cinnamon",1,tsp),[ingrd("allspice",0.5,tsp)])
sublist(ingrd("cinnamon",1,tsp),[ingrd("nutmeg",0.5,tsp)])
sublist(ingrd("cocoa",0.25,cups),[ingrd("unsweetened chocolate",1,oz)])
sublist(ingrd("corn syrup",1,cups),[ingrd("sugar",1.25,cups),ingrd("water",0.33,cups)])
sublist(ingrd("cornstarch",1,tsp),[ingrd("flour",2,tsp)])
sublist(ingrd("cream cheese",1,cups),[ingrd("ricotta cheese",1,cups)])
sublist(ingrd("cream of tartar",1,tsp),[ingrd("lemon juice",2,tsp)])
sublist(ingrd("cream of tartar",1,tsp),[ingrd("vinegar",2,tsp)])
sublist(ingrd("cumin",1,tsp),[ingrd("chili powder",1,tsp)])
sublist(ingrd("dried herbs",1,tsp),[ingrd("fresh herbs",1,tbsp)])
sublist(ingrd("egg",1,whole),[ingrd("yogurt (in brownies)",0.25,cups)])
sublist(ingrd("egg",1,whole),[ingrd("buttermilk (in cakes)",0.5,cups)])
sublist(ingrd("egg",1,whole),[ingrd("vegetable oil (in cookies)",0.25,cups)])
sublist(ingrd("egg",1,whole),[ingrd("water",1,tbsp),ingrd("cornstarch (in cookies)",1,tbsp)])
sublist(ingrd("garlic",1,"clove(s)"),[ingrd("garlic powder",0.125,tsp)])
sublist(ingrd("gelatin",1,tbsp),[ingrd("agar agar",2,tsp)])
sublist(ingrd("gelatin",1,tbsp),[ingrd("agar agar",2,tsp)])
sublist(ingrd("ginger",1,tsp),[ingrd("cardamom",1,tsp)])
sublist(ingrd("half and half",1,cups),[ingrd("whole milk",0.875,cups),ingrd("melted butter",2,tbsp)])
sublist(ingrd("heavy cream",1,cups),[ingrd("butter",0.33,cups),ingrd("milk",0.67,cups)])
sublist(ingrd("honey",1,cups),[ingrd("sugar",0.75,cups),ingrd("other liquid",0.25,cups)])
sublist(ingrd("honey",1,cups),[ingrd("maple syrup",0.75,cups),ingrd("sugar",0.5,cups)])
sublist(ingrd("honey",1,cups),[ingrd("date paste",1,cups)])
sublist(ingrd("fresh herbs",1,tbsp),[ingrd("dried herbs",1,tsp)])
sublist(ingrd("ketchup",1,cup),[ingrd("tomato sauce",1,cups),ingrd("vinegar",1,tsp),ingrd("sugar",1,tsp)])
sublist(ingrd("italian seasoning",1,tbsp),[ingrd("basil",0.33,tsp),ingrd("oregano",0.33,tsp),ingrd("rosemary",0.33,tsp)])
sublist(ingrd("lemon juice",1,tsp),[ingrd("vinegar",0.5,tsp)])
sublist(ingrd("lemon zest",1,tsp),[ingrd("lemon extract",0.5,tsp)])
sublist(ingrd("light cream",1,cups),[ingrd("evaporated milk",1,cups)])
sublist(ingrd("margarine",1,tbsp),[ingrd("olive oil (for frying)",0.5,tsp)])
sublist(ingrd("mashed potatoes",1,cups),[ingrd("mashed cauliflower",1,cups)])
sublist(ingrd("mayonnaise",1,cups),[ingrd("plain yogurt",1,cups)])
sublist(ingrd("mozzarella cheese",1,ounces),[ingrd("sliced tofu",1,ounces)])
sublist(ingrd("parmesan cheese",1,cups),[ingrd("grated Asiago cheese",1,cups)])
sublist(ingrd("parmesan cheese",1,cups),[ingrd("grated Romano cheese",1,cups)])
sublist(ingrd("poultry seasoning",1,tsp),[ingrd("sage",0.75,tsp),ingrd("thyme",0.25,tsp)])
sublist(ingrd("powdered sugar",1,cups),[ingrd("sugar",1,cups),ingrd("cornstarch",0.33,cups)])
sublist(ingrd("red wine",1,cups),[ingrd("grape juice",1,cups)])
sublist(ingrd("red wine",1,cups),[ingrd("beef broth",1,cups)])
sublist(ingrd("saffron",1,tsp),[ingrd("turmeric",1,tsp)])
sublist(ingrd("self-raising flour",1,cups),[ingrd("all purpose flour",0.875,cups),ingrd("baking powder",1.5,tsp),ingrd("salt",0.5,tsp)])
sublist(ingrd("soy sauce",0.5,cups),[ingrd("Worcestershire sauce",4,tbsp),ingrd("water",1,tbsp)])
sublist(ingrd("sour cream",1,cups),[ingrd("milk",1,cups),ingrd("vinegar",1.33,tbsp)])
sublist(ingrd("sour cream",1,cups),[ingrd("pureed tofu",1,cups)])
sublist(ingrd("sugar",1,tbsp),[ingrd("stevia",0.125,tbsp)])
sublist(ingrd("sugar",1,cups),[ingrd("agave nectar",0.67,cups)])
sublist(ingrd("tapioca",1,tbsp),[ingrd("all purpose flour",1.5,tbsp)])
sublist(ingrd("turmeric",1,tsp),[ingrd("saffron",1,tsp)])
sublist(ingrd("unsweetened chocolate",1,oz),[ingrd("cocoa",4,tbsp),ingrd("butter",1,tbsp)])
sublist(ingrd("white wine",1,cups),[ingrd("apple juice",1,cups)])
sublist(ingrd("white wine",1,cups),[ingrd("chicken broth",1,cups)])
sublist(ingrd("whole milk",1,cups),[ingrd("fat free milk",1,cups),ingrd("canola oil",1,tbsp)])
hsublist(ingrd("bread crumbs",1,cups),[ingrd("ground oats",1,cups)])
hsublist(ingrd("butter",1,cups),[ingrd("avocado",1,cups)])
hsublist(ingrd("butter",1,cups),[ingrd("pureed prunes",0.75,cups),ingrd("water",0.25,cups)])
hsublist(ingrd("butter",1,cups),[ingrd("yogurt",1,cups)])
hsublist(ingrd("butter",1,cups),[ingrd("applesauce",1,cups)])
hsublist(ingrd("butter",1,cups),[ingrd("mashed banana",1,cups)])
hsublist(ingrd("butter",1,cups),[ingrd("butter",0.5,cups),ingrd("pumpkin puree",0.5,cups)])
hsublist(ingrd("butter",1,cups),[ingrd("buttermilk",0.5,cups),ingrd("applesauce",0.5,cups)])
hsublist(ingrd("buttermilk",1,cups),[ingrd("yogurt",1,cups)])
hsublist(ingrd("cream cheese",1,cups),[ingrd("ricotta cheese",1,cups)])
hsublist(ingrd("honey",1,cups),[ingrd("date paste",1,cups)])
hsublist(ingrd("egg",1,whole),[ingrd("chia seeds",1,tbsp),ingrd("water",3,tbsp)])
hsublist(ingrd("egg",1,whole),[ingrd("egg whites",2,whole)])
hsublist(ingrd("egg",1,whole),[ingrd("yogurt (in brownies)",0.25,cups)])
hsublist(ingrd("egg",1,whole),[ingrd("buttermilk (in cakes)",0.5,cups)])
hsublist(ingrd("egg",1,whole),[ingrd("pureed fruit (in cakes)",3,tbsp)])
hsublist(ingrd("egg",1,whole),[ingrd("pureed tofu",0.25,cups),ingrd("flour",1,tbsp)])
hsublist(ingrd("heavy cream",1,cups),[ingrd("evaporated skim milk",1,cups)])
hsublist(ingrd("margarine",1,cups),[ingrd("pureed prunes",0.75,cups),ingrd("water",0.25,cups)])
hsublist(ingrd("margarine",1,cups),[ingrd("applesauce",1,cups)])
hsublist(ingrd("margarine",1,cups),[ingrd("mashed banana",1,cups)])
hsublist(ingrd("mashed potatoes",1,cups),[ingrd("mashed cauliflower",1,cups)])
hsublist(ingrd("mayonnaise",1,cups),[ingrd("plain yogurt",1,cups)])
hsublist(ingrd("mozzarella cheese",1,ounces),[ingrd("sliced tofu",1,ounces)])
hsublist(ingrd("oil",1,cups),[ingrd("applesauce",1,cups)])
hsublist(ingrd("oil",1,cups),[ingrd("mashed banana",1,cups)])
hsublist(ingrd("oil",1,cups),[ingrd("pureed prunes",0.75,cups),ingrd("water",0.25,cups)])
hsublist(ingrd("sour cream",1,cups),[ingrd("yogurt",1,cups)])
hsublist(ingrd("sour cream",1,cups),[ingrd("pureed tofu",1,cups)])
hsublist(ingrd("sugar",1,cups),[ingrd("applesauce",0.5,cups)])
hsublist(ingrd("sugar",1,cups),[ingrd("agave nectar",0.67,cups)])
select(ingredient,X) :: value(ingredient,X)
select(ingredient,X) :: value(ingredient,Y) ==> ~value(ingredient,Y)
select(measure,X) :: value(measure,X)
select(measure,X) :: value(measure,Y) ==> ~value(measure,Y)
select(amount,X) :: value(amount,X)
select(amount,X):: value(amount,Y) ==> ~value(amount,Y)
click(find) :: value(ingredient,X) & value(amount,Y) & value(measure,Z) & distinct(X,unknown) & distinct(amount,"") & distinct(Z,unknown) ==> ingrd(X,Y,Z)
click(find) :: ingrd(X,Y,Z) ==> ~ingrd(X,Y,Z)
listtostring([A],A)
listtostring(A!B,S) :- listtostring(B,S1) & evaluate(stringappend(A," + ",S1),S)
listtostringi([A],S) :- toingrd(A,S)
listtostringi(A!B,S) :- listtostringi(B,S1) & toingrd(A,A1) & evaluate(stringappend(A1," + ",S1),S)
cupconvert(Y,S,S) :- ~evaluate(S,cups)
cupconvert(Y,cups,cup) :- evaluate(min(Y,0.999),0.999) & evaluate(max(Y,1.001),1.001)
cupconvert(Y,cups,cups) :- evaluate(min(Y,0.999),Y)
cupconvert(Y,cups,cups) :- evaluate(max(Y,1.001),Y)
innerhtml(ingrd1,E) :- ~holds(healthy,on) & ~error & ingrd(X,Y,Z) & sublist(ingrd(X,A,B),C) & cupconvert(Y,Z,Z1) & evaluate(stringappend(Y," ",Z1," ",X," = "),E)
innerhtml(ingrd1,E) :- holds(healthy,on) & ~error & ingrd(X,Y,Z) & hsublist(ingrd(X,A,B),C) & cupconvert(Y,Z,Z1) & evaluate(stringappend(Y," ",Z1," ",X," = "),E)
isingred(subs,I):- ~holds(healthy,on) & ingrd(X,Y,Z) & sublist(ingrd(X,A,B),L) & member(ingrd(C,D,E),L) & convert(Z,B,F) & evaluate(quotient(Y,A),J) & evaluate(times(D,J,F),K) & cupconvert(K,E,E1) & evaluate(stringappend(K," ",E1," ",C),I)
isingred(subs,I):- holds(healthy,on) & ingrd(X,Y,Z) & hsublist(ingrd(X,A,B),L) & member(ingrd(C,D,E),L) & convert(Z,B,F) & evaluate(quotient(Y,A),J) & evaluate(times(D,J,F),K) & cupconvert(K,E,E1) & evaluate(stringappend(K," ",E1," ",C),I)
convert(Z,B,1) :- same(Z,B)
convert(Z,B,3) :- same(Z,tbsp) & same(B,tsp)
convert(Z,B,16) :- same(Z,cups) & same(B,tbsp)
convert(Z,B,48) :- same(Z,cups) & same(B,tsp)
convert(Z,B,F) :- same(Z,tsp) & same(B,tbsp) & evaluate(quotient(1,3),F)
convert(Z,B,F) :- same(Z,tbsp) & same(B,cups) & evaluate(quotient(1,16),F)
convert(Z,B,F) :- same(Z,tsp) & same(B,cups) & evaluate(quotient(1,48),F)
innerhtml(ingrd1, A) :- ingrd(X,Y,Z) & sublist(ingrd(X,C,D),L) & error & evaluate(stringappend("No conversion between ",Z," and ",D,". Try a different measure"),A)
innerhtml(subs,"") :- error
style(ingrd1,color,red) :- error
style(ingrd1,color,black) :- ~error
error :- ~holds(healthy,on) & ingrd(X,Y,Z) & sublist(ingrd(X,C,D),L) & same(D,whole) & distinct(Z,D)
error :- ~holds(healthy,on) & ingrd(X,Y,Z) & sublist(ingrd(X,C,D),L) & same(D,"clove(s)") & distinct(Z,D)
error :- ~holds(healthy,on) & ingrd(X,Y,Z) & sublist(ingrd(X,C,D),L) & same(Z,whole) & distinct(Z,D)
error :- ~holds(healthy,on) & ingrd(X,Y,Z) & sublist(ingrd(X,C,D),L) & same(Z,"clove(s)") & distinct(Z,D)
error :- holds(healthy,on) & ingrd(X,Y,Z) & hsublist(ingrd(X,C,D),L) & same(D,whole) & distinct(Z,D)
error :- holds(healthy,on) & ingrd(X,Y,Z) & hsublist(ingrd(X,C,D),L) & same(D,"clove(s)") & distinct(Z,D)
error :- holds(healthy,on) & ingrd(X,Y,Z) & hsublist(ingrd(X,C,D),L) & same(Z,whole) & distinct(Z,D)
error :- holds(healthy,on) & ingrd(X,Y,Z) & hsublist(ingrd(X,C,D),L) & same(Z,"clove(s)") & distinct(Z,D)
allsubs(L) :- evaluate(setofall(X,isingred(subs,X)),L)
onesub :- ~holds(healthy,on) & ingrd(X,A1,B1) & evaluate(countofall(L,sublist(ingrd(X,A,B),L)),1)
onesub :- holds(healthy,on) & ingrd(X,A1,B1) & evaluate(countofall(L,hsublist(ingrd(X,A,B),L)),1)
innerhtml(subs,S) :- ~error & onesub & allsubs(L) & listtostring(L,S)
isingredlist(subs,L) :- ~holds(healthy,on) & ingrd(X,Y,Z) & sublist(ingrd(X,A,B),L)
isingredlist(subs,L) :- holds(healthy,on) & ingrd(X,Y,Z) & hsublist(ingrd(X,A,B),L)
toingrd(ingrd(A,B,C),I) :- ingrd(X,Y,Z) & sublist(ingrd(X,B1,C1),L) & member(ingrd(A,B,C),L) & convert(Z,C1,F) & evaluate(quotient(Y,B1),J) & evaluate(times(B,J,F),K) & cupconvert(K,C,C2) & evaluate(stringappend(K," ",C2," ",A),I)
toingrd(ingrd(A,B,C),I) :- ingrd(X,Y,Z) & hsublist(ingrd(X,B1,C1),L) & member(ingrd(A,B,C),L) & convert(Z,C1,F) & evaluate(quotient(Y,B1),J) & evaluate(times(B,J,F),K) & cupconvert(K,C,C2) & evaluate(stringappend(K," ",C2," ",A),I)
alllists(L1) :- evaluate(setofall(L,isingredlist(subs,L)),L1)
listconcat([L],S) :- listtostringi(L,S1) & evaluate(S1,S)
listconcat(L!L1,S) :- listtostringi(L,S1) & listconcat(L1,S2) & evaluate(stringappend(S1," or <br> ",S2),S)
innerhtml(subs,S) :- ~error & ~onesub & alllists(L) & listconcat(L,S)
select(healthy,X) :: holds(healthy,X)
deselect(healthy,X) :: ~holds(healthy,X)
|