static
Clause conflicts(Clause a, Clause b)
{
  if (!unit_clause(a) || !unit_clause(b))
    return NULL;
  else if (a->literals->sign == b->literals->sign)
    return NULL;
  else {
    Clause empty = NULL;
    Term a_atom = a->literals->atom;
    Term b_atom = b->literals->atom;
    Context ca = get_context();
    Context cb = get_context();
    Trail tr = NULL;
    if (unify(a_atom, ca, b_atom, cb, &tr)) {
      Ilist j = NULL;
      undo_subst(tr);
      empty = get_clause();

      j = ilist_append(j, a->id);
      j = ilist_append(j, 1);
      j = ilist_append(j, b->id);
      j = ilist_append(j, 1);
      empty->justification = resolve_just(j, BINARY_RES_JUST);
      upward_clause_links(empty);
      assign_clause_id(empty);
    }
    free_context(ca);
    free_context(cb);
    return empty;
  }
}  /* conflicts */
Exemplo n.º 2
0
void CBaseScrollingMenu::SetProperties(Script::CStruct *pProps)
{
	float just[2] = { 0.0f, 0.0f };
	if (resolve_just(pProps, CRCD(0x67e093e4,"internal_just"), just, just+1))
		SetInternalJust(just[0], just[1]);
	
	int scroll_speed;
	if (pProps->GetInteger(CRCD(0x9020a1d1,"scroll_speed"), &scroll_speed))
		m_scroll_speed = (float) scroll_speed;
	
	pProps->GetInteger(CRCD(0xc855511c,"num_items_to_show"), &m_num_items_to_display);

	if (pProps->ContainsFlag(CRCD(0xed889e1f,"reset_window_top")))
	{
		m_top_or_left_line = 0;
		m_needs_update = true;
	}
	else if (pProps->ContainsFlag(CRCD(0xc3a894f6,"reset_window_bottom")))
	{
		CScreenElementPtr p_child = mp_the_menu->GetLastChild();
		float element_x, element_z, element_w, element_l;
		compute_element_area(p_child, element_x, element_z, element_w, element_l);
		m_top_or_left_line = element_z + element_l - m_window_dimension;
		m_needs_update = true;
	}
	else if ( pProps->ContainsFlag( CRCD(0xa1f3b8bb,"reset_window") ) )
	{
		m_needs_update = true;
	}
	
	CScreenElement::SetProperties(pProps);
}
static
Clause cd(Clause maj, Clause min)
{
  if (!unit_clause(maj) || !unit_clause(min))
    return NULL;
  else if (!maj->literals->sign || !min->literals->sign)
    return NULL;
  else {
    Term a = ARG(maj->literals->atom,0);
    Term b = ARG(min->literals->atom,0);
    if (ARITY(a) != 2)
      return NULL;
    else {
      Clause resolvent = NULL;
      Term a0 = ARG(a,0);
      Term a1 = ARG(a,1);
      Context ca = get_context();
      Context cb = get_context();
      Trail tr = NULL;
      if (unify(a0, ca, b, cb, &tr)) {
	Term r = apply(a1, ca);
	Term r_atom = build_unary_term(SYMNUM(maj->literals->atom), r);
	Literal r_literal = get_literal();
	Ilist j = NULL;
	r_literal->sign = TRUE;
	r_literal->atom = r_atom;
	resolvent = get_clause();
	append_literal(resolvent, r_literal);
	
	j = ilist_append(j, maj->id);
	j = ilist_append(j, 1);
	j = ilist_append(j, min->id);
	j = ilist_append(j, 1);

	resolvent->justification = resolve_just(j, BINARY_RES_JUST);
	upward_clause_links(resolvent);
	renumber_variables(resolvent, MAX_VARS);

	undo_subst(tr);
      }
      free_context(ca);
      free_context(cb);
      return resolvent;
    }
  }
}  /* cd */
Exemplo n.º 4
0
static
Clause resolve(Clash first, Just_type rule)
{
  Clause r = get_clause();
  Clause nuc =  first->nuc_lit->atom->container;
  Ilist j = ilist_append(NULL, nuc->id);
  Clash p;
  int n;

  /* First, include literals in the nucleus. */
  for (p = first; p != NULL; p = p->next, n++) {
    if (!p->clashed)
      append_literal(r, apply_lit(p->nuc_lit, p->nuc_subst));
  }

  r->attributes = cat_att(r->attributes,
			  inheritable_att_instances(nuc->attributes,
						    first->nuc_subst));

  /* Next, include literals in the satellites. */

  n = 1;  /* n-th nucleus literal, starting with 1 */
  for (p = first; p != NULL; p = p->next, n++) {
    if (p->clashed) {
      Literal lit;
      Clause sat = p->sat_lit->atom->container;
      j = ilist_append(j, n);
      j = ilist_append(j, sat->id);
      j = ilist_append(j, lit_position(sat, p->sat_lit));
      for (lit = sat->literals; lit != NULL; lit = lit->next) {
	if (lit != p->sat_lit)
	  append_literal(r, apply_lit(lit,  p->sat_subst));
      }
      r->attributes = cat_att(r->attributes,
			      inheritable_att_instances(sat->attributes,
							p->sat_subst));
    }
  }
  r->justification = resolve_just(j, rule);
  upward_clause_links(r);
  return r;
}  /* resolve */