Exemplo n.º 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))
}
Exemplo n.º 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))
}
Exemplo n.º 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))

}
Exemplo n.º 4
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))
	}
}
Exemplo n.º 5
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"),
	)
}
Exemplo n.º 6
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))
}
Exemplo n.º 7
0
func nexto(a, b, block interface{}) l.Goal {
	return l.Or(
		righto(a, b, block),
		righto(b, a, block))
}
Exemplo n.º 8
0
func west_east_bridge(a, b interface{}) l.Goal {
	return l.Or(
		db.Deref().Find(a, East_of, b),
		db.Deref().Find(b, East_of, a))
}
Exemplo n.º 9
0
func north_south_bridge(a, b interface{}) l.Goal {
	return l.Or(
		db.Deref().Find(a, North_of, b),
		db.Deref().Find(b, North_of, a))
}
Exemplo n.º 10
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),
	)
}