Пример #1
0
func membero(p, t interface{}) l.Goal {
	return l.Or(
		l.Unify(News{p, v(), v(), v()}, t),
		l.Unify(News{v(), p, v(), v()}, t),
		l.Unify(News{v(), v(), p, v()}, t),
		l.Unify(News{v(), v(), v(), p}, t))
}
Пример #2
0
func righto(a, b, block interface{}) l.Goal {
	return l.Or(
		l.Unify(B{a, b, v(), v(), v()}, block),
		l.Unify(B{v(), a, b, v(), v()}, block),
		l.Unify(B{v(), v(), a, b, v()}, block),
		l.Unify(B{v(), v(), v(), a, b}, block))
}
Пример #3
0
func membero(a, block interface{}) l.Goal {
	return l.Or(
		l.Unify(B{a, v(), v(), v(), v()}, block),
		l.Unify(B{v(), a, v(), v(), v()}, block),
		l.Unify(B{v(), v(), a, v(), v()}, block),
		l.Unify(B{v(), v(), v(), a, v()}, block),
		l.Unify(B{v(), v(), v(), v(), a}, block))

}
Пример #4
0
func archo(q l.V) l.Goal {
	a, b := l.Fresh2()
	membero := l.StructMemberoConstructor4(t)
	return l.And(
		membero(Purchase{"The Foot Farm", v()}, q),
		membero(Purchase{"Heels in a Handcart", v()}, q),
		membero(Purchase{"The Shoe Palace", v()}, q),
		membero(Purchase{"Tootsies", v()}, q),
		membero(Purchase{v(), "ecru espadrilles"}, q),
		membero(Purchase{v(), "fuchsia flats"}, q),
		membero(Purchase{v(), "purple pumps"}, q),
		membero(Purchase{v(), "suede sandals"}, q),
		// 1
		membero(Purchase{"Heels in a Handcart", "fuchsia flats"}, q),
		// 3
		l.Unify(Trip{v(), Purchase{"The Foot Farm", v()}, v(), v()}, q),
		// 4
		aftero(Purchase{"The Shoe Palace", v()}, b, q),
		aftero(b, Purchase{v(), "suede sandals"}, q),
		// 2
		aftero(Purchase{v(), "purple pumps"}, Purchase{a, v()}, q),
		l.Neq(a, "Tootsies"),
	)

}
Пример #5
0
func main() {
	// v1, v2 := l.Fresh2()
	// g := func (a, b int) l.Goal {
	//         return l.Unify(a,b)
	// }
	// c := l.Run(v2, l.Or(l.And(l.Unify(v1,3),
	//                           l.Unify(v2,v1),
	//                           l.Unify(v1,l.Fresh()),
	// 	                  l.Unify(10,l.Fresh()),
	//                           g(1,1)),
	//                     l.Unify(v2,5),
	//                     l.Unify(v2,8)))

	// fmt.Println("# Results 1")

	// for {
	//         i := <- c
	//         if i != nil {
	//                 fmt.Println(i)
	//         } else {
	//                 break
	//         }
	// }

	q, x := l.Fresh2()
	c := l.Run(q, l.And(mult(q, x, 4), l.Unify(x, 2)))

	fmt.Println(<-c)

}
Пример #6
0
func scoreo(q interface{}) l.Goal {
	a, b, c, d := l.Fresh4()
	return l.And(
		l.Unify(Round{Dude{v(), v(), v(), a}, Dude{v(), v(), v(), b}, Dude{v(), v(), v(), c}, Dude{v(), v(), v(), d}}, q),
		betweeno(a, 70, 85),
		betweeno(b, 70, 85),
		betweeno(c, 70, 85),
		betweeno(d, 70, 85))
}
Пример #7
0
func betweeno(p interface{}, low, high int) l.Goal {
	if low > high {
		return l.Fail()
	} else {
		return l.Or(
			l.Unify(low, p),
			l.Call(betweeno, p, low+1, high))
	}
}
Пример #8
0
func newso(q l.V) l.Goal {
	baby_location := v()
	jimmy_location := v()
	lois_story := v()
	pc_story := v()
	sm_story := v()
	corey_location := v()
	whale_location := v()
	return l.And(
		l.Unify(News{Report{"Corey", corey_location, v()}, Report{"Jimmy", jimmy_location, v()}, Report{"Lois", v(), lois_story}, Report{"Perry", v(), v()}}, q),

		// 1
		l.Neq(baby_location, "South Amboy"),
		l.Neq(baby_location, "New Hope"),

		// 2
		l.Neq(jimmy_location, "Port Charles"),

		// 3
		l.Or(l.And(l.Unify(lois_story, "blimp launching"), l.Unify(pc_story, "skyscraper dedication")),
			l.And(l.Unify(lois_story, "skyscraper dedication"), l.Unify(pc_story, "blimp launching"))),

		// 5
		l.Or(l.Unify(corey_location, "Bayonne"),
			l.Unify(whale_location, "Bayonne"),
			l.And(l.Unify(corey_location, "Bayonne"),
				l.Unify(whale_location, "Bayonne"))),

		//
		membero(Report{v(), "Bayonne", v()}, q),
		membero(Report{v(), "New Hope", v()}, q),
		membero(Report{v(), "Port Charles", pc_story}, q),
		membero(Report{v(), "South Amboy", sm_story}, q),

		membero(Report{v(), baby_location, "30 pound baby"}, q),
		membero(Report{v(), v(), "blimp launching"}, q),
		membero(Report{v(), v(), "skyscraper dedication"}, q),
		membero(Report{v(), whale_location, "beached whale"}, q),

		// 4
		l.Neq(sm_story, "beached whale"),
		l.Neq(sm_story, "skyscraper dedication"),
	)
}
Пример #9
0
func islando(q l.V) l.Goal {
	db.Assert("A", North_of, "C")
	db.Assert("B", North_of, "D")
	db.Assert("D", East_of, "C")
	db.Assert("B", East_of, "A")

	membero := l.StructMemberoConstructor4(n)

	alabaster_island, durian_island, banana_island := l.Fresh3()
	pwana_island, quero_island, skern_island, rayou_island := l.Fresh4()
	hotel_island, koala_island, jai_island, skating_island := l.Fresh4()

	return l.And(
		l.Unify(Nation{Island{"A", v(), v(), v()}, Island{"B", v(), v(), v()}, Island{"C", v(), v(), v()}, Island{"D", v(), v(), v()}}, q),
		// 1
		north_of(pwana_island, koala_island),
		//2
		east_of(quero_island, alabaster_island),
		//3
		east_of(hotel_island, durian_island),
		//4
		north_south_bridge(skern_island, jai_island),
		//5
		west_east_bridge(rayou_island, banana_island),
		//6
		disconnected(skating_island, jai_island),
		//
		membero(Island{pwana_island, "Pwana", v(), v()}, q),
		membero(Island{quero_island, "Quero", v(), v()}, q),
		membero(Island{rayou_island, "Rayou", v(), v()}, q),
		membero(Island{skern_island, "Skern", v(), v()}, q),
		//
		membero(Island{alabaster_island, v(), "alabaster", v()}, q),
		membero(Island{banana_island, v(), "bananas", v()}, q),
		membero(Island{v(), v(), "coconuts", v()}, q),
		membero(Island{durian_island, v(), "durian fruit", v()}, q),
		//
		membero(Island{hotel_island, v(), v(), "hotel"}, q),
		membero(Island{skating_island, v(), v(), "ice skating rink"}, q),
		membero(Island{jai_island, v(), v(), "jai alai stadium"}, q),
		membero(Island{koala_island, v(), v(), "koala preserve"}, q),
	)
}
Пример #10
0
func zerbao(q l.V) l.Goal {
	return l.And(
		l.Unify(B{v(), v(), H{v(), v(), "milk", v(), v()}, v(), v()}, q),
		firsto(q, H{"norwegian", v(), v(), v(), v()}),
		nexto(H{"norwegian", v(), v(), v(), v()}, H{v(), v(), v(), v(), "blue"}, q),
		righto(H{v(), v(), v(), v(), "ivory"}, H{v(), v(), v(), v(), "green"}, q),
		membero(H{"englishmen", v(), v(), v(), "red"}, q),
		membero(H{v(), "kools", v(), v(), "yello"}, q),
		membero(H{"spaniard", v(), v(), "dog", v()}, q),
		membero(H{v(), v(), "coffee", v(), "green"}, q),
		membero(H{"ukranian", v(), "tea", v(), v()}, q),
		membero(H{v(), "lucky strikes", "oj", v(), v()}, q),
		membero(H{"japanese", "parliaments", v(), v(), v()}, q),
		membero(H{v(), "oldgolds", v(), "snails", v()}, q),
		nexto(H{v(), v(), v(), "horse", v()}, H{v(), "kools", v(), v(), v()}, q),
		nexto(H{v(), v(), v(), "fox", v()}, H{v(), "chesterfields", v(), v(), v()}, q),
		membero(H{v(), v(), v(), "zebra", v()}, q),
		membero(H{v(), v(), "water", v(), v()}, q))

}
Пример #11
0
func babbyo(q l.V) l.Goal {
	keiths_last_name, libbys_last_name, margos_last_name, noras_last_name, ottos_last_name := l.Fresh5()
	keiths_age, noras_age, margos_age, ottos_age, libbys_age := l.Fresh5()
	iveys_age, fells_age, halls_age := l.Fresh3()
	membero := l.StructMemberoConstructor5(c)
	return l.And(
		l.Unify(Children{Child{"Keith", keiths_last_name, keiths_age},
			Child{"Libby", libbys_last_name, libbys_age},
			Child{"Margo", margos_last_name, margos_age},
			Child{"Nora", noras_last_name, noras_age},
			Child{"Otto", ottos_last_name, ottos_age}}, q),

		//2
		l.Difference(keiths_age, 1, iveys_age),
		l.Difference(iveys_age, 1, noras_age),

		//3
		l.Difference(fells_age, 3, margos_age),

		//4
		l.Mult(halls_age, 2, ottos_age),

		// 1
		membero(Child{"Libby", "Jule", v()}, q),

		//
		membero(Child{v(), "Fell", fells_age}, q),
		membero(Child{v(), "Gant", v()}, q),
		membero(Child{v(), "Hall", halls_age}, q),
		membero(Child{v(), "Ivey", iveys_age}, q),
		membero(Child{v(), "Jule", v()}, q),
		membero(Child{v(), v(), 2}, q),
		membero(Child{v(), v(), 3}, q),
		membero(Child{v(), v(), 4}, q),
		membero(Child{v(), v(), 5}, q),
		membero(Child{v(), v(), 6}, q),
	)
}
Пример #12
0
func aftero(p1, p2, t interface{}) l.Goal {
	return l.Or(
		l.Unify(Trip{p1, p2, v(), v()}, t),
		l.Unify(Trip{v(), p1, p2, v()}, t),
		l.Unify(Trip{v(), v(), p1, p2}, t))
}
Пример #13
0
func firsto(block, a interface{}) l.Goal {
	return l.Unify(block, B{a, v(), v(), v(), v()})
}
Пример #14
0
func golfo(q l.V) l.Goal {
	membero := l.StructMemberoConstructor4(func(a, b, c, d interface{}) interface{} { return Round{a, b, c, d} })
	bills_job := v()
	bills_score := v()
	mr_clubb_first_name := v()
	mr_clubbs_score := v()
	pro_shop_clerk_score := v()
	frank_score := v()
	caddy_score := v()
	sands_score := v()
	score1, score2, score3, score4 := l.Fresh4()
	mr_carters_first_name := v()
	return l.And(
		l.Unify(Round{Dude{"Bill", v(), v(), score1}, Dude{"Jack", v(), v(), score2}, Dude{"Frank", v(), v(), score3}, Dude{"Paul", v(), v(), score4}}, q),
		l.Neq(score1, score2),
		l.Neq(score1, score3),
		l.Neq(score1, score4),
		l.Neq(score2, score3),
		l.Neq(score2, score4),
		l.Neq(score3, score4),

		membero(Dude{"Jack", v(), v(), v()}, q),
		membero(Dude{v(), "Green", v(), v()}, q),
		membero(Dude{v(), v(), "short-order cook", v()}, q),

		// // 1
		membero(Dude{"Bill", v(), bills_job, bills_score}, q),
		l.Neq(bills_job, "maintenance man"),
		membero(Dude{v(), v(), "maintenance man", v()}, q),
		l.Increasing(bills_score, score2),
		l.Increasing(bills_score, score3),
		l.Increasing(bills_score, score4),

		// // 2
		membero(Dude{mr_clubb_first_name, "Clubb", v(), mr_clubbs_score}, q),
		l.Neq(mr_clubb_first_name, "Paul"),
		membero(Dude{v(), v(), "pro-shop clerk", pro_shop_clerk_score}, q),
		l.Difference(mr_clubbs_score, 10, pro_shop_clerk_score),

		// //3
		membero(Dude{"Frank", v(), v(), frank_score}, q),
		membero(Dude{v(), v(), "caddy", caddy_score}, q),
		membero(Dude{v(), "Sands", v(), sands_score}, q),

		l.Or(l.And(l.Difference(frank_score, 7, sands_score),
			l.Difference(caddy_score, 4, sands_score)),
			l.And(l.Difference(frank_score, 4, sands_score),
				l.Difference(caddy_score, 7, sands_score))),

		// // // 4
		membero(Dude{mr_carters_first_name, "Carter", v(), 78}, q),
		l.Increasing(frank_score, 78),
		l.Neq(mr_carters_first_name, "Frank"),

		// // // 5
		l.Neq(score1, 81),
		l.Neq(score2, 81),
		l.Neq(score3, 81),
		l.Neq(score4, 81),

		scoreo(q),
	)
}