Wild Life: lefun.c Source File

Wild Life 2.29

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Macros
lefun.c
Go to the documentation of this file.
1
2 /* Copyright 1991 Digital Equipment Corporation.
3 ** All Rights Reserved.
4 *****************************************************************/
5 /* $Id: lefun.c,v 1.4 1995/01/14 00:24:55 duchier Exp $ */
6
7 #include "defs.h"
8
9
10 static long attr_missing;
11 static long check_func_flag;
12
13
14 /* Create a new psi_term on the stack with value '@' (top) and no attributes. */
15 ptr_psi_term stack_psi_term(stat)
16 long stat;
17 {
18 ptr_psi_term result;
19
20 result=STACK_ALLOC(psi_term);
21 result->type=top;
22 result->status=stat;
23 result->flags=stat?QUOTED_TRUE:FALSE; /* 14.9 */
24 result->attr_list=NULL;
25 result->coref=NULL;
26 #ifdef TS
27 result->time_stamp=global_time_stamp; /* 9.6 */
28 #endif
29 result->resid=NULL;
30 result->value_3=NULL;
31
32 return result;
33 }
34
35
36
37 /* Create a new psi_term on the stack with a real number value. */
38 ptr_psi_term real_stack_psi_term(stat,thereal)
39 long stat;
40 REAL thereal;
41 {
42 ptr_psi_term result;
43
44 result=STACK_ALLOC(psi_term);
45 result->type = (thereal==floor(thereal)) ? integer : real;
46 result->status=stat;
47 result->flags=stat?QUOTED_TRUE:FALSE; /* 14.9 */
48 result->attr_list=NULL;
49 result->coref=NULL;
50 #ifdef TS
51 result->time_stamp=global_time_stamp; /* 9.6 */
52 #endif
53 result->resid=NULL;
54 result->value_3=heap_alloc(sizeof(REAL));
55 (* (REAL *)(result->value_3)) = thereal;
56
57 return result;
58 }
59
60
61
62 /* Create a new psi_term on the heap with value '@' (top) and no attributes. */
63 ptr_psi_term heap_psi_term(stat)
64 long stat;
65 {
66 ptr_psi_term result;
67
68 result=HEAP_ALLOC(psi_term);
69 result->type=top;
70 result->status=stat;
71 result->flags=stat?QUOTED_TRUE:FALSE; /* 14.9 */
72 result->attr_list=NULL;
73 result->coref=NULL;
74 #ifdef TS
75 result->time_stamp=global_time_stamp; /* 9.6 */
76 #endif
77 result->resid=NULL;
78 result->value_3=NULL;
79
80 return result;
81 }
82
83
84
85 /* Create an empty list on the stack, wiped out by RM: Dec 14 1992 */
86 /* ptr_psi_term stack_empty_list() is now aliased to stack_nil() */
87
88
89
90 /******** RESIDUATE_DOUBLE(t,u)
91 Residuate the current expression with T in the Residuation Variable set.
92 Also store the other variable, so that its sort can be used in the
93 'bestsort' calculation needed to implement disequality constraints.
94 */
95 void residuate_double(t,u) /* 21.9 */
96 ptr_psi_term t,u;
97 {
98 ptr_resid_list curr;
99
100 curr=STACK_ALLOC(resid_list);
101 curr->var=t;
102 curr->othervar=u;
103 curr->next=resid_vars;
104 resid_vars=curr;
105 }
106
107
108
109
110 /******** RESIDUATE(t)
111 Residuate the current expression with T in the Residuation Variable set.
112 */
113 void residuate(t)
114 ptr_psi_term t;
115 {
116 ptr_resid_list curr;
117
118 curr=STACK_ALLOC(resid_list);
119 curr->var=t;
120 curr->othervar=NULL; /* 21.9 */
121 curr->next=resid_vars;
122 resid_vars=curr;
123 }
124
125
126
127 /******** RESIDUATE2(u,v)
128 Residuate the current function on the two variables U and V.
129 */
130 void residuate2(u,v)
131 ptr_psi_term u,v;
132 {
133 residuate(u);
134 if (v && u!=v) residuate(v);
135 }
136
137
138
139 /******** RESIDUATE3(u,v,w)
140 Residuate the current function on the three variables U, V, and W.
141 */
142 void residuate3(u,v,w)
143 ptr_psi_term u,v,w;
144 {
145 residuate(u);
146 if (v && u!=v) residuate(v);
147 if (w && u!=w && v!=w) residuate(w);
148 }
149
150
151
152 /******** CURRY()
153 Decide that the current function will have to be curried.
154 This has become so simple it could be a MACRO.
155 The real work is done by DO_CURRY.
156 */
157 void curry()
158 {
159 if (can_curry)
160 curried=TRUE;
161 }
162
163
164
165
166 /******** RESIDUATEGOALONVAR(g,var,othervar)
167 Add the goal to the variable's residuation list.
168 Also update the residuation's 'bestsort' field if it exists (needed to
169 implement complete disequality semantics). The 'othervar' parameter
170 is needed for this.
171 */
172 long residuateGoalOnVar(g, var, othervar)
173 ptr_goal g;
174 ptr_psi_term var,othervar;
175 {
176 long result;
177 long resflag,resflag2;
178 GENERIC rescode,rescode2;
179 GENERIC resvalue;
180 GENERIC resvalue2;
181 /* Set to FALSE if the goal is already residuated on the var: */
182 long not_found = TRUE;
183 /* Points to a pointer to a residuation structure. Used so we can */
184 /* add the goal to the end of the residuation list, so that it can */
185 /* can be undone later if backtracking happens. See the call to */
186 /* push_ptr_value. */
187 ptr_residuation *r;
188
189 /* 5.8 PVR */
190 if ((GENERIC)var>=heap_pointer) {
191 Errorline("attempt to residuate on psi-term %P in the heap.\n",var);
192
193 return FALSE;
194 }
195
196 r= &(var->resid);
197
198 while (not_found && *r) {
199 if ((*r)->goal == g) { /* This goal is already attached */
200 /* Keep track of best sort so far */
201 /* Glb_code(..) tries to keep 'sortflag' TRUE if possible. */
202 result=glb_code((*r)->sortflag,(*r)->bestsort,
203 TRUE,(GENERIC)var->type,
204 &resflag,&rescode);
205 result=glb_value(result,resflag,rescode,(GENERIC)(*r)->value_2,var->value_3,
206 &resvalue); /* 6.10 */
207 if (!result)
208 return FALSE; /* 21.9 */
209 else if (othervar) {
210 result=glb_code(resflag,rescode,TRUE,(GENERIC)othervar->type,
211 &resflag2,&rescode2);
212 result=glb_value(result,resflag2,rescode2,resvalue,othervar->value_3,
213 &resvalue2); /* 6.10 */
214 if (!result) {
215 return FALSE;
216 }
217 else {
218 /* The value field only has to be trailed once, since its value */
219 /* does not change, once given. */
220 if ((*r)->value_2==NULL && resvalue2!=NULL) { /* 6.10 */
221 push_ptr_value(int_ptr,(GENERIC *)&((*r)->value_2));
222 }
223 if ((*r)->bestsort!=rescode2) {
224 push_ptr_value(((*r)->sortflag?def_ptr:code_ptr),
225 &((*r)->bestsort));
226 (*r)->bestsort=rescode2; /* 21.9 */
227 }
228 if ((*r)->sortflag!=resflag2) {
229 push_ptr_value(int_ptr,(GENERIC *)&((*r)->sortflag));
230 (*r)->sortflag=resflag2; /* 21.9 */
231 }
232 }
233 }
234 else {
235 if ((*r)->value_2==NULL && resvalue!=NULL) { /* 6.10 */
236 push_ptr_value(int_ptr,(GENERIC *)&((*r)->value_2));
237 }
238 if ((*r)->bestsort!=rescode) {
239 push_ptr_value(((*r)->sortflag?def_ptr:code_ptr),
240 &((*r)->bestsort));
241 (*r)->bestsort=rescode; /* 21.9 */
242 }
243 if ((*r)->sortflag!=resflag) {
244 push_ptr_value(int_ptr,(GENERIC *)&((*r)->sortflag));
245 (*r)->sortflag=resflag; /* 21.9 */
246 }
247 }
248 not_found = FALSE;
249 }
250 else
251 r= &((*r)->next); /* look at the next one */
252 }
253
254 if (not_found) {
255 /* We must attach this goal & the variable's sort onto this variable */
256
257 push_ptr_value(resid_ptr,(GENERIC *)r);
258 *r=STACK_ALLOC(residuation);
259 if (othervar) {
260 result=glb_code(TRUE,(GENERIC)var->type,TRUE,(GENERIC)othervar->type,&resflag,&rescode);
261 result=glb_value(result,resflag,rescode,var->value_3,othervar->value_3,
262 &resvalue); /* 6.10 */
263 if (!result) {
264 return FALSE;
265 }
266 else {
267 (*r)->sortflag=resflag;
268 (*r)->bestsort=rescode; /* 21.9 */
269 (*r)->value_2=resvalue; /* 6.10 */
270 }
271 }
272 else {
273 (*r)->sortflag=TRUE;
274 (*r)->bestsort=(GENERIC)var->type; /* 21.9 */
275 (*r)->value_2=var->value_3; /* 6.10 */
276 }
277 (*r)->goal=g;
278 (*r)->next=NULL;
279 }
280
281 if (!(g->pending)) {
282 /* this goal is not pending, so make sure it will be put on the goal
283 * stack later
284 */
285 push_ptr_value(int_ptr,(GENERIC *)&(g->pending));
286 g->pending=(ptr_definition)TRUE;
287 }
288
289 return TRUE; /* 21.9 */
290 }
291
292
293
294 /******** DO_RESIDUATION()
295 Undo anything that matching may have done, then
296 create a residuated expression. Check that the same constraint does not
297 hang several times on the same variable.
298
299 This routine takes time proportional to the square of the number of
300 residuations. This is too slow; eventually it should be sped up,
301 especially if equality constraints are often used.
302 */
303
304 /* LIFE-defined routines reset the goal stack to what it was */
305 /* before the function call. */
306 long do_residuation_user()
307 {
308 goal_stack=resid_aim->next; /* reset goal stack */
309 return do_residuation();
310 }
311
312 /* C-defined routines do all stack manipulation themselves */
313 long do_residuation()
314 {
315 long success;
316 ptr_psi_term t,u;
317 // ptr_goal *gs;
318
319 /* This undoes perfectly valid work! */
320 /* The old version of Wild_Life did not trail anything
321 during matching, so I think this was a nop for it. */
322 /* PVR 11.5 undo(resid_limit); */
323 /* PVR 11.5 choice_stack=cut_point; */
324
325 /* PVR 9.2.94 */
326 /* goal_stack=resid_aim->next; */
327
328 if (trace) {
329 tracing();
330 print_resid_message(resid_aim->aaaa_1,resid_vars);
331 }
332
333 while (resid_vars) {
334
335 t=resid_vars->var; /* 21.9 */
336 u=resid_vars->othervar; /* 21.9 */
337 /* PVR */ deref_ptr(t);
338 resid_vars=resid_vars->next;
339 traceline("residuating on %P (other = %P)\n",t,u);
340
341 success=residuateGoalOnVar(resid_aim, t, u); /* 21.9 */
342 if (!success) { /* 21.9 */
343 traceline("failure because of disentailment\n");
344 return FALSE;
345 }
346 }
347
348 traceline("no failure because of disentailment\n");
349 return TRUE; /* 21.9 */
350 }
351
352
353
354 /********* DO_CURRYING()
355 This performs CURRYing: all that needs to be done is to yield the calling
356 term as the result after having given up on evaluation. In effect the calling
357 psi-term is left intact.
358 */
359 void do_currying()
360 {
361 ptr_psi_term funct,result;
362
363 /* PVR 5.11 undo(resid_limit); */
364 /* PVR 5.11 choice_stack=cut_point; */
365 goal_stack=resid_aim->next;
366 funct=(ptr_psi_term )resid_aim->aaaa_1;
367 result=(ptr_psi_term )resid_aim->bbbb_1;
368
369 traceline("currying %P\n",funct);
370
371 push_goal(unify_noeval,funct,result,NULL);
372 resid_aim=NULL;
373 }
374
375
376
377 /******** RELEASE_RESID(t)
378 Release the residuations pending on the Residuation Variable T.
379 This is done by simply pushing the residuated goals onto the goal-stack.
380 A goal is not added if already present on the stack.
381 Two versions of this routine exist: one which trails t and one which never
382 trails t.
383 */
384 void release_resid_main(t,trailflag)
385 ptr_psi_term t;
386 long trailflag;
387 {
388 ptr_goal g;
389 ptr_residuation r;
390
391 if ((r=t->resid)) {
392 if (trailflag) push_ptr_value(resid_ptr,(GENERIC *)&(t->resid));
393 t->resid=NULL;
394
395 while (r) {
396 g=r->goal;
397 if (g->pending) {
398
399 push_ptr_value(int_ptr,(GENERIC *)&(g->pending));
400 g->pending=FALSE;
401
402 push_ptr_value(goal_ptr,(GENERIC *)&(g->next));
403
404 g->next=goal_stack;
405 goal_stack=g;
406
407 traceline("releasing %P\n",g->aaaa_1);
408 }
409 r=r->next;
410 }
411 }
412 }
413
414 void release_resid(t)
415 ptr_psi_term t;
416 {
417 release_resid_main(t,TRUE);
418 }
419
420 void release_resid_notrail(t)
421 ptr_psi_term t;
422 {
423 release_resid_main(t,FALSE);
424 }
425
426
427
428 /******** APPEND_RESID(u,v)
429 Append the residuations pending on V to U. This routine does not check that
430 the same constraint is not present twice in the end on U. This doesn't matter
431 since RELEASE_RESID ensures that the same constraint is not released more
432 than once.
433 */
434 void append_resid(u,v)
435 ptr_psi_term u,v;
436 {
437 ptr_residuation *g;
438
439 g= &(u->resid);
440 while (*g)
441 g = &((*g)->next);
442
443 push_ptr_value(resid_ptr,(GENERIC *)g);
444 *g=v->resid;
445 }
446
447
448
449 /******** EVAL_AIM()
450 Evaluate a function.
451 This copies the current definition of the function and
452 stacking the various goals that are necessary to evaluate the function
453 correctly.
454 It creates an extra psi-term (with value top) in which to write the result.
455 */
456 long eval_aim()
457 {
458 long success=TRUE;
459 ptr_psi_term funct,result,head,body;
460 ptr_pair_list rule;
461 /* RESID */ ptr_resid_block rb;
462 ptr_choice_point cutpt;
463 ptr_psi_term match_date; /* 13.6 */
464
465 funct=(ptr_psi_term )aim->aaaa_1;
466 deref_ptr(funct);
467
468 /* RM: Jun 18 1993 */
469 push2_ptr_value(int_ptr,(GENERIC *)&(funct->status),(GENERIC)(funct->status & SMASK));
470 funct->status=4;
471
472 /* if (!funct->type->evaluate_args) mark_quote(funct); 25.8 */ /* 18.2 PVR */
473 result=(ptr_psi_term )aim->bbbb_1;
474 rule=(ptr_pair_list )aim->cccc_1;
475
476 match_date=(ptr_psi_term )stack_pointer;
477 cutpt=choice_stack; /* 13.6 */
478
479 /* For currying and residuation */
480 curried=FALSE;
481 can_curry=TRUE;
482 /* resid_aim=aim; */
483 resid_vars=NULL;
484 /* resid_limit=(ptr_goal )stack_pointer; 12.6 */
485
486 if (rule) {
487 traceline("evaluate %P\n",funct);
488 if ((unsigned long)rule<=MAX_BUILT_INS) {
489
490 resid_aim=aim;
491 success=c_rule[(unsigned long)rule]();
492
493 if (curried)
494 do_currying();
495 else
496 if (resid_vars)
497 success=do_residuation(); /* 21.9 */
498 else {
499 /* resid_aim=NULL; */
500 }
501 }
502 else {
503 while (rule && (rule->aaaa_2==NULL || rule->bbbb_2==NULL)) {
504 rule=rule->next;
505 traceline("alternative rule has been retracted\n");
506 }
507 if (rule) {
508 /* push_choice_point(eval,funct,result,rule->next); */ /* 17.6 */
509
510 resid_aim=aim;
511 /* RESID */ rb = STACK_ALLOC(resid_block);
512 /* RESID */ save_resid(rb,match_date);
513 /* RESID */ /* resid_aim = NULL; */
514
515 clear_copy();
516
517 /* RM: Jun 18 1993: no functions in head */
518 /* if (TRUE)
519 head=eval_copy(rule->aaaa_1,STACK);
520 else */
521
522 head=quote_copy(rule->aaaa_2,STACK);
523 body=eval_copy(rule->bbbb_2,STACK);
524 head->status=4;
525
526 if (rule->next) /* 17.6 */
527 push_choice_point(eval,funct,result,(GENERIC)rule->next);
528
529 push_goal(unify,body,result,NULL);
530 /* RESID */ push_goal(eval_cut,body,(ptr_psi_term)cutpt,(GENERIC)rb); /* 13.6 */
531 /* RESID */ push_goal(match,funct,head,(GENERIC)rb);
532 /* eval_args(head->attr_list); */
533 }
534 else {
535 success=FALSE;
536 /* resid_aim=NULL; */
537 }
538 }
539 }
540 else {
541 success=FALSE;
542 /* resid_aim=NULL; */
543 }
544 resid_aim=NULL;
545 /* match_date=NULL; */ /* 13.6 */
546 return success;
547 }
548
549
550
551 /* Match the corresponding arguments */
552 /* RESID */ void match_attr1(u,v,rb)
553 ptr_node *u,v;
554 /* RESID */ ptr_resid_block rb;
555 {
556 long cmp;
557 ptr_node temp;
558
559 if (v) {
560 if (*u==NULL)
561 attr_missing=TRUE;
562 else {
563 cmp=featcmp((*u)->key,v->key);
564 if(cmp==0) {
565 ptr_psi_term t;
566 /* RESID */ match_attr1(&((*u)->right),v->right,rb);
567 t = (ptr_psi_term) (*u)->data;
568 /* RESID */ push_goal(match,(ptr_psi_term)(*u)->data,(ptr_psi_term)v->data,(GENERIC)rb);
569 /* deref2_eval(t); */
570 /* RESID */ match_attr1(&((*u)->left),v->left,rb);
571 }
572 else if (cmp>0) {
573 temp=v->right;
574 v->right=NULL;
575 /* RESID */ match_attr1(u,temp,rb);
576 /* RESID */ match_attr1(&((*u)->left),v,rb);
577 v->right=temp;
578 }
579 else {
580 temp=v->left;
581 v->left=NULL;
582 /* RESID */ match_attr1(&((*u)->right),v,rb);
583 /* RESID */ match_attr1(u,temp,rb);
584 v->left=temp;
585 }
586 }
587 }
588 }
589
590
591 /* Evaluate the lone arguments (for lazy failure + eager success) */
592 /* RESID */ void match_attr2(u,v,rb)
593 ptr_node *u,v;
594 /* RESID */ ptr_resid_block rb;
595 {
596 long cmp;
597 ptr_node temp;
598
599 if (v) {
600 if (*u==NULL) { /* PVR 12.03 */
601 ptr_psi_term t;
602 match_attr1(u,v->right,rb);
603 t = (ptr_psi_term) v->data;
604 deref2_rec_eval(t);
605 match_attr1(u,v->left,rb);
606 }
607 else {
608 cmp=featcmp((*u)->key,v->key);
609 if(cmp==0) {
610 /* RESID */ match_attr2(&((*u)->right),v->right,rb);
611 /* RESID */ match_attr2(&((*u)->left),v->left,rb);
612 }
613 else if (cmp>0) {
614 temp=v->right;
615 v->right=NULL;
616 /* RESID */ match_attr2(u,temp,rb);
617 /* RESID */ match_attr2(&((*u)->left),v,rb);
618 v->right=temp;
619 }
620 else {
621 temp=v->left;
622 v->left=NULL;
623 /* RESID */ match_attr2(&((*u)->right),v,rb);
624 /* RESID */ match_attr2(u,temp,rb);
625 v->left=temp;
626 }
627 }
628 }
629 else if (*u!=NULL) {
630 ptr_psi_term t /* , empty */ ;
631 match_attr1(&((*u)->right),v,rb);
632 t = (ptr_psi_term) (*u)->data;
633 /* Create a new psi-term to put the (useless) result: */
634 /* This is needed so that *all* arguments of a function call */
635 /* are evaluated, which avoids incorrect 'Yes' answers. */
636 deref2_rec_eval(t); /* Assumes goal_stack is already restored. */
637 match_attr1(&((*u)->left),v,rb);
638 }
639 }
640
641
642 /* Evaluate the corresponding arguments */
643 /* RESID */ void match_attr3(u,v,rb)
644 ptr_node *u,v;
645 /* RESID */ ptr_resid_block rb;
646 {
647 long cmp;
648 ptr_node temp;
649
650 if (v) {
651 if (*u==NULL)
652 attr_missing=TRUE;
653 else {
654 cmp=featcmp((*u)->key,v->key);
655 if(cmp==0) {
656 ptr_psi_term t1,t2;
657 /* RESID */ match_attr3(&((*u)->right),v->right,rb);
658 t1 = (ptr_psi_term) (*u)->data;
659 t2 = (ptr_psi_term) v->data;
660 /* RESID */ /* push_goal(match,(*u)->data,v->data,rb); */
661 deref2_eval(t1); /* Assumes goal_stack is already restored. */
662 deref2_eval(t2); /* PVR 12.03 */
663 /* RESID */ match_attr3(&((*u)->left),v->left,rb);
664 }
665 else if (cmp>0) {
666 temp=v->right;
667 v->right=NULL;
668 /* RESID */ match_attr3(u,temp,rb);
669 /* RESID */ match_attr3(&((*u)->left),v,rb);
670 v->right=temp;
671 }
672 else {
673 temp=v->left;
674 v->left=NULL;
675 /* RESID */ match_attr3(&((*u)->right),v,rb);
676 /* RESID */ match_attr3(u,temp,rb);
677 v->left=temp;
678 }
679 }
680 }
681 }
682
683
684
685 /******** MATCH_ATTR(u,v)
686 Match the attribute trees of psi_terms U and V.
687 If V has an attribute that U doesn't then curry.
688 U is the calling term, V is the definition.
689 This routine is careful to push nested eval and match goals in
690 descending order of feature names.
691 */
692 void match_attr(u,v,rb)
693 ptr_node *u,v;
694 ptr_resid_block rb;
695 {
696 match_attr1(u,v,rb); /* Match corresponding arguments (third) */
697 match_attr2(u,v,rb); /* Evaluate lone arguments (second) */
698 match_attr3(u,v,rb); /* Evaluate corresponding arguments (first) */
699 }
700
701
702
703
704
705 /******** MATCH_AIM()
706 This is very similar to UNIFY_AIM, only matching cannot modify the calling
707 psi_term. The first argument is the calling term (which may not be changed)
708 and the second argument is the function definition (which may be changed).
709 Residuate the expression if the calling term is more general than the
710 function definition.
711 */
712 long match_aim()
713 {
714 long success=TRUE;
715 ptr_psi_term u,v; // ,tmp;
716 REAL r;
717 long /* less, */ lesseq;
718 ptr_resid_block rb;
719 ptr_psi_term match_date;
720
721 u=(ptr_psi_term )aim->aaaa_1;
722 v=(ptr_psi_term )aim->bbbb_1;
723 deref_ptr(u);
724 deref_ptr(v);
725 rb=(ptr_resid_block)aim->cccc_1;
726 restore_resid(rb,&match_date);
727
728 if (u!=v) {
729 if ((success=matches(u->type,v->type,&lesseq))) {
730 if (lesseq) {
731 if (u->type!=cut || v->type!=cut) { /* Ignore value field for cut! */
732 if (v->value_3) {
733 if (u->value_3) {
734 if (overlap_type(v->type,real))
735 success=(*((REAL *)u->value_3)==(*((REAL *)v->value_3)));
736 else if (overlap_type(v->type,quoted_string))
737 success=(strcmp((char *)u->value_3,(char *)v->value_3)==0);
738 /* DENYS: BYTEDATA */
739 else if (overlap_type(v->type,sys_bytedata)) {
740 unsigned long ulen = *((unsigned long *) u->value_3);
741 unsigned long vlen = *((unsigned long *) v->value_3);
742 success=(ulen==vlen && bcmp((char *)u->value_3,(char *)v->value_3,ulen)==0);
743 }
744 }
745 else
746 residuate_double(u,v);
747 }
748 }
749 }
750 else if (u->value_3) {
751 /* Here we have U <| V but U and V have values which cannot match. */
752 success=TRUE;
753
754 if (v->value_3) {
755 if (overlap_type(v->type,real))
756 success=(*((REAL *)u->value_3)==(*((REAL *)v->value_3)));
757 }
758 else if (overlap_type(u->type,integer)) {
759 r= *((REAL *)u->value_3);
760 success=(r==floor(r));
761 }
762
763 if (success) residuate_double(u,v);
764 }
765 else
766 residuate_double(u,v);
767
768 if (success) {
769 if (FUNC_ARG(u) && FUNC_ARG(v)) { /* RM: Feb 10 1993 */
770 /* residuate2(u,v); 21.9 */
771 residuate_double(u,v); /* 21.9 */
772 residuate_double(v,u); /* 21.9 */
773 }
774 else if (FUNC_ARG(v)) { /* RM: Feb 10 1993 */
775 residuate_double(v,u); /* 21.9 */
776 }
777 else {
778 v->coref=u;
779 } /* 21.9 */
780 attr_missing=FALSE;
781 match_attr(&(u->attr_list),v->attr_list,rb);
782 if (attr_missing) {
783 if (can_curry)
784 curried=TRUE;
785 else
786 residuate_double(u,v);
787 }
788 /* } 21.9 */
789 }
790 }
791 }
792
793 can_curry=FALSE;
794 save_resid(rb,match_date); /* updated resid_block */
795 /* This should be a useless statement: */
796 resid_aim = NULL;
797
798 return success;
799 }
800
801
802
803 /******************************************************************************
804 The following routines prepare terms for unification, proof or matching.
805 They deal with conjunctions, disjunctions, functions and arguments which
806 have to be examined before the general proof can continue.
807 */
808
809
810
811
812
813 /******** EVAL_ARGS(n)
814 N is an attribute tree, the attributes must be examined, if any reveal
815 themselves to need evaluating then return FALSE.
816 */
817 long i_eval_args(n)
818 ptr_node n;
819 {
820 check_func_flag=FALSE;
821 return eval_args(n);
822 }
823
824
825
826 long eval_args(n)
827 ptr_node n;
828 {
829 long flag=TRUE;
830
831 if (n) {
832 flag = eval_args(n->right);
833 flag = check_out((ptr_psi_term)n->data) && flag;
834 flag = eval_args(n->left) && flag;
835 }
836
837 return flag;
838 }
839
840
841
842 /******** CHECK_DISJ(t)
843 Deal with disjunctions.
844 */
845 void check_disj(t)
846 ptr_psi_term t;
847 {
848 traceline("push disjunction goal %P\n",t);
849 if (t->value_3)
850 push_goal(disj,t,t,(GENERIC)TRUE); /* 18.2 PVR */
851 else
852 push_goal(fail,NULL,NULL,NULL);
853 }
854
855
856
857 /******** CHECK_FUNC(t)
858 Deal with an unevaluated function: push an 'eval' goal for it, which will
859 cause it to be evaluated.
860 */
861 void check_func(t)
862 ptr_psi_term t;
863 {
864 ptr_psi_term result,t1,copy;
865
866 /* Check for embedded definitions
867 RM: Dec 16 1992 Re-instated this check then disabled it again
868 if (resid_aim) {
869 Errorline("embedded functions appeared in %P.\n",resid_aim->aaaa_1);
870 fail_all();
871 }
872 else */ {
873
874 traceline("setting up function call %P\n",t);
875 /* Create a psi-term to put the result */
876 result = stack_psi_term(0);
877
878 /* Make a partial copy of the calling term */
879 copy=stack_copy_psi_term(*t);
880 copy->status &= ~RMASK;
881
882 /* Bind the calling term to the result */
883 /* push_ptr_value(psi_term_ptr,(GENERIC *)&(t->coref)); */
884 push_psi_ptr_value(t,(GENERIC *)&(t->coref));
885 t->coref=result;
886
887 /* Evaluate the copy of the calling term */
888 push_goal(eval,copy,result,(GENERIC)t->type->rule);
889
890 /* Avoid evaluation for built-in functions with unevaluated arguments */
891 /* (cond and such_that) */
892 check_func_flag=TRUE;
893 if (t->type==iff) {
894 get_one_arg(t->attr_list,&t1);
895 if (t1) {
896 /* mark_eval(t1); 24.8 */
897 (void)check_out(t1);
898 }
899 }
900 else if(t->type==disjunction) {
901 }
902 else if (t->type!=such_that) {
903 if (t->type->evaluate_args)
904 (void)eval_args(t->attr_list);
905 /* else mark_quote_tree(t->attr_list); 24.8 25.8 */
906 }
907 }
908 }
909
910
911
912
913 /******** CHECK_TYPE(t)
914 Here we deal with a type which may need checking.
915 This routine will have to be modified to deal with the infinite loops
916 currently caused by definitions such as:
917
918 :: H:husband(spouse => wife(spouse => H)).
919 :: W:wife(spouse => husband(spouse => W)).
920
921 */
922 long check_type(t)
923 ptr_psi_term t;
924 {
925 long flag=FALSE;
926
927 push2_ptr_value(int_ptr,(GENERIC *)&(t->status),(GENERIC) (t->status & SMASK));
928 /* push_ptr_value(int_ptr,(GENERIC *)&(t->status)); */
929
930 if (t->type->properties) {
931 if (t->attr_list || t->type->always_check) {
932 /* Check all constraints here: */
933 fetch_def(t, TRUE); /* PVR 18.2.94 */
934 /* t->status=(2 & SMASK) | (t->status & RMASK); PVR 18.2.94 */
935
936 (void)eval_args(t->attr_list);
937 flag=FALSE;
938 }
939 else {
940 /* definition pending on more information */
941 t->status= (2 & SMASK) | (t->status & RMASK);
942 flag=TRUE;
943 }
944 }
945 else {
946
947 /* RM: Dec 15 1992 I don't know what this is for
948 if (!ovverlap_type(t->type,alist))
949 t->status= (4 & SMASK) | (t->status & RMASK);
950 */
951
952 flag=eval_args(t->attr_list);
953 }
954
955 return flag;
956 }
957
958
959
960 /******** CHECK_OUT(t)
961 This routine checks out psi_term T.
962 It deals with the following cases:
963 - T is a conjunction,
964 - T is a type which has properties to check.
965 - The same for T's arguments.
966 If any of the above holds then proof has to be suspended until the
967 case has been dealt with. This is done by pushing goals on the goal_stack
968 to handle the case. If all is dealt with then CHECK_OUT returns TRUE.
969 I.e., CHECK_OUT returns TRUE iff it has not pushed any goals on the stack.
970
971 Evaluation is *not* done here, but as a part of dereferencing when a value
972 is needed.
973
974 Of all the routines related to check_out, only i_check_out, check_func,
975 i_eval_args, and the dereference routines are called from outside of this
976 file (lefun.c).
977 - i_check_out(t) checks out everything except functions. When a function
978 is encountered, check_out returns immediately without looking inside it.
979 - f_check_out(t) checks out functions too.
980 - i_eval_args(n) checks out all arguments, except functions.
981 - check_func(t) checks out a function & all its arguments (including all
982 nested functions. This is done as part of dereferencing, which is part
983 of unification, matching, built-ins, and user-defined routines.
984 */
985 long i_check_out(t)
986 ptr_psi_term t;
987 {
988 check_func_flag=FALSE;
989 return check_out(t);
990 }
991
992 long f_check_out(t)
993 ptr_psi_term t;
994 {
995 check_func_flag=TRUE;
996 return check_out(t);
997 }
998
999 long check_out(t)
1000 ptr_psi_term t;
1001 {
1002 long flag=FALSE;
1003 deref_ptr(t);
1004
1005 /* traceline("PVR: entering check_out with status %d and term %P\n",
1006 t->status,t); for brunobug.lf PVR 14.2.94 */
1007 traceline("PVR: entering check_out with status %d and term %P\n",
1008 t->status,t); /* for brunobug.lf PVR 14.2.94 */
1009
1010 if (t->status || (GENERIC)t>=heap_pointer) /* RM: Feb 8 1993 */
1011 flag=TRUE;
1012 else {
1013 t->status |= RMASK;
1014
1015 switch((long)t->type->type_def) { /* RM: Feb 8 1993 */
1016
1017 case (long)function_it:
1018 if (check_func_flag) {
1019 check_func(t);
1020 flag=TRUE;
1021 }
1022 else {
1023 /* Function evaluation handled during matching and unification */
1024 flag=TRUE;
1025 }
1026 break;
1027
1028 case (long)type_it:
1029 flag=check_type(t);
1030 break;
1031
1032 case (long)global: /* RM: Feb 8 1993 */
1033 eval_global_var(t);
1034 (void)check_out(t);
1035 flag=FALSE;
1036 break;
1037
1038 default:
1039 flag=eval_args(t->attr_list);
1040 }
1041 t->status &= ~RMASK;
1042 }
1043
1044 return flag;
1045 }
1046
1047
1048
1049 /********************************************************************/
1050 /* */
1051 /* New dereference routines for Wild_Life */
1052 /* These routines handle evaluation-by-need. Check_out is changed */
1053 /* to no longer call check_func, which is done in the new routines. */
1054 /* Functions inside of psi-terms are only evaluated if needed. It */
1055 /* is assumed that 'needed' is true when they are derefed. */
1056 /* */
1057 /* There are three new dereference routines: */
1058 /* deref_eval(P) */
1059 /* If the psi-term P is a function, call check_func to */
1060 /* push eval goals so that the function will be evaluated. */
1061 /* Then return TRUE so that the caller can itself return. */
1062 /* This only looks at the top level. */
1063 /* deref_rec(P) */
1064 /* If the psi-term P recursively contains any functions, then */
1065 /* push eval goals to evaluate all of them. Set a global */
1066 /* variable deref_flag if this is the case. */
1067 /* deref_args(P,S) */
1068 /* Same as above, except does not look at the top level or at */
1069 /* the arguments named in the set S. */
1070 /* This is needed to guarantee evaluation of all arguments of */
1071 /* a built-in, even those not used by the built-in. */
1072 /* */
1073 /* The original dereference macro is renamed to: */
1074 /* deref_ptr(P) = while (P->coref) P=P->coref */
1075 /* There are three new macros: */
1076 /* deref(P) = deref_ptr(P); */
1077 /* if (deref_eval(P)) then return TRUE */
1078 /* deref_rec(P) = deref_ptr(P); */
1079 /* if (deref_rec_eval(P)) then return TRUE */
1080 /* deref_args(P,S) = deref_ptr(P); */
1081 /* if (deref_args_eval(P,S)) then return TRUE */
1082 /* */
1083 /********************************************************************/
1084
1085 static long deref_flag;
1086 /* Ensure evaluation of top of psi-term */
1087 long deref_eval(t)
1088 ptr_psi_term t;
1089 {
1090 ptr_goal save=goal_stack;
1091
1092 deref_flag=FALSE;
1093 goal_stack=aim;
1094
1095 if (t->status==0) {
1096 if(t->type->type_def==(def_type)function_it) {
1097 check_func(t); /* Push eval goals to evaluate the function. */
1098 deref_flag=TRUE; /* TRUE so that caller will return to main_prove. */
1099 }
1100 else
1101 if(t->type->type_def==(def_type)global) { /* RM: Feb 10 1993 */
1102 eval_global_var(t);
1103 deref_ptr(t);/* RM: Jun 25 1993 */
1104 deref_flag=deref_eval(t);
1105 }
1106 else {
1107 if (((long)t->status)!=2) {
1108 if((GENERIC)t<heap_pointer)
1109 push_ptr_value(int_ptr,(GENERIC *)&(t->status)); /* RM: Jul 15 1993 */
1110 t->status=4;
1111 deref_flag=FALSE;
1112 }
1113 }
1114 }
1115 else
1116 deref_flag=FALSE;
1117
1118 if (!deref_flag) goal_stack=save;
1119 return (deref_flag);
1120 }
1121
1122 /* Ensure evaluation of *all* of psi-term */
1123 long deref_rec_eval(t)
1124 ptr_psi_term t;
1125 {
1126 ptr_goal save=goal_stack;
1127
1128 deref_flag=FALSE;
1129 goal_stack=aim;
1130 deref_rec_body(t);
1131 if (!deref_flag) goal_stack=save;
1132 return (deref_flag);
1133 }
1134
1135 void deref_rec_body(t)
1136 ptr_psi_term t;
1137 {
1138 if (t->status==0) {
1139 if (t->type->type_def==(def_type)function_it) {
1140 check_func(t);
1141 deref_flag=TRUE;
1142 }
1143 else
1144 if(t->type->type_def==(def_type)global) { /* RM: Feb 10 1993 */
1145 eval_global_var(t);
1146 deref_ptr(t);/* RM: Jun 25 1993 */
1147 deref_rec_body(t);
1148 }
1149 else {
1150 /* if (t->status!=2) Tried adding this -- PVR 9.2.94 */
1151 if((GENERIC)t<heap_pointer)
1152 push_ptr_value(int_ptr,(GENERIC *)&(t->status));/* RM: Jul 15 1993 */
1153 t->status=4;
1154 deref_rec_args(t->attr_list);
1155 }
1156 }
1157 }
1158
1159 void deref_rec_args(n)
1160 ptr_node n;
1161 {
1162 ptr_psi_term t1;
1163
1164 if (n) {
1165 deref_rec_args(n->right);
1166 t1 = (ptr_psi_term) (n->data);
1167 deref_ptr(t1);
1168 deref_rec_body(t1);
1169 deref_rec_args(n->left);
1170 }
1171 }
1172
1173 /* Same as deref_rec_eval, but doesn't look at either the top level or */
1174 /* the arguments in the set. */
1175 long deref_args_eval(t,set)
1176 ptr_psi_term t;
1177 long set;
1178 {
1179 ptr_goal save = goal_stack;
1180 ptr_goal top_loc = aim;
1181
1182 deref_flag = FALSE;
1183 goal_stack = top_loc;
1184 deref_rec_args_exc(t->attr_list,set);
1185 if (!deref_flag) goal_stack = save;
1186 return (deref_flag);
1187 }
1188
1189 /* Return TRUE iff string (considered as number) is in the set */
1190 /* This routine only recognizes the strings "1", "2", "3", */
1191 /* represented as numbers 1, 2, 4. */
1192 long in_set(str,set)
1193 char *str;
1194 long set;
1195 {
1196 if (set&1 && !featcmp(str,"1")) return TRUE;
1197 if (set&2 && !featcmp(str,"2")) return TRUE;
1198 if (set&4 && !featcmp(str,"3")) return TRUE;
1199 if (set&8 && !featcmp(str,"4")) return TRUE;
1200 return FALSE;
1201 }
1202
1203 void deref_rec_args_exc(n,set)
1204 ptr_node n;
1205 long set;
1206 {
1207 ptr_psi_term t;
1208
1209 if (n) {
1210 deref_rec_args_exc(n->right,set);
1211 if (!in_set(n->key,set)) {
1212 t = (ptr_psi_term) (n->data);
1213 deref_ptr(t);
1214 deref_rec_body(t);
1215 }
1216 deref_rec_args_exc(n->left,set);
1217 }
1218 }
1219
1220
1221 /* These two needed only for match_aim and match_attr: */
1222
1223 /* Same as deref_eval, but assumes goal_stack already restored. */
1224 void deref2_eval(t)
1225 ptr_psi_term t;
1226 {
1227 deref_ptr(t);
1228 if (t->status==0) {
1229 if (t->type->type_def==(def_type)function_it) {
1230 check_func(t);
1231 }
1232 else
1233 if(t->type->type_def==(def_type)global) { /* RM: Feb 10 1993 */
1234 eval_global_var(t);
1235 deref_ptr(t);/* RM: Jun 25 1993 */
1236 deref2_eval(t);
1237 }
1238 else {
1239 t->status=4;
1240 }
1241 }
1242 }
1243
1244 /* Same as deref_rec_eval, but assumes goal_stack already restored. */
1245 void deref2_rec_eval(t)
1246 ptr_psi_term t;
1247 {
1248 deref_ptr(t);
1249 deref_rec_body(t);
1250 }
1251
1252 /********************************************************************/
1253
1254 /* Saving & restoring residuation information */
1255
1256 void save_resid(rb,match_date)
1257 ptr_resid_block rb;
1258 ptr_psi_term match_date;
1259 {
1260 if (rb) {
1261 rb->cc_cr = (can_curry<<1) + curried; /* 11.9 */
1262 rb->ra = resid_aim;
1263 rb->rv = resid_vars;
1264 /* rb->cr = curried; 11.9 */
1265 /* rb->cc = can_curry; 11.9 */
1266 rb->md = match_date;
1267 }
1268 }
1269
1270 void restore_resid(rb,match_date)
1271 ptr_resid_block rb;
1272 ptr_psi_term *match_date;
1273 {
1274 if (rb) {
1275 can_curry = (rb->cc_cr&2)?TRUE:FALSE; /* 11.9 */
1276 curried = (rb->cc_cr&1)?TRUE:FALSE; /* 11.9 */
1277 resid_aim = rb->ra;
1278 resid_vars = rb->rv;
1279 /* curried = rb->cr; 11.9 */
1280 /* can_curry = rb->cc; 11.9 */
1281 *match_date = rb->md;
1282 }
1283 }
1284
1285
1286
1287 /******** EVAL_GLOBAL_VAR(t)
1288 Dereference a global variable.
1289 */
1290
1291 void eval_global_var(t) /* RM: Feb 10 1993 */
1292
1293 ptr_psi_term t;
1294 {
1295 deref_ptr(t);
1296
1297 /* Global variable (not persistent) */
1298
1299 traceline("dereferencing variable %P\n",t);
1300
1301 /* Trails the heap RM: Nov 10 1993 */
1302 if(!t->type->global_value) {
1303
1304 /* Trail the heap !! */
1305 {
1306 ptr_stack n;
1307 n=STACK_ALLOC(stack);
1308 n->type=psi_term_ptr;
1309 n->aaaa_3= (GENERIC *) &(t->type->global_value);
1310 n->bbbb_3= (GENERIC *) NULL;
1311 n->next=undo_stack;
1312 undo_stack=n;
1313 }
1314
1315
1316 clear_copy();
1317 t->type->global_value=eval_copy(t->type->init_value,STACK);
1318
1319 }
1320
1321 /* var_occurred=TRUE; RM: Feb 4 1994 */
1322
1323 if(t->type->type_def==(def_type)global && t!=t->type->global_value) {
1324 /*traceline("dereferencing variable %P\n",t);*/
1325 push_psi_ptr_value(t,(GENERIC *)&(t->coref));
1326 t->coref=t->type->global_value;
1327 }
1328 }
1329
1330
1331
1332
1333 /******** INIT_GLOBAL_VARS()
1334 Initialize all non-persistent global variables.
1335 */
1336
1337 void init_global_vars() /* RM: Feb 15 1993 */
1338
1339 {
1340 ptr_definition def;
1341
1342 /* printf("initializing global vars...\n"); */
1343
1344 /*
1345 for(def=first_definition;def;def=def->next) {
1346 if(def->type==global && ((GENERIC)def->global_value<heap_pointer)) {
1347 clear_copy();
1348 def->global_value=eval_copy(def->init_value,STACK);
1349 }
1350 }
1351 */
1352
1353 for(def=first_definition;def;def=def->next)
1354 if((GENERIC)(def->global_value)<(GENERIC)heap_pointer)
1355 def->global_value=NULL;
1356 }
1357
1358 /********************************************************************/
such_that
ptr_definition such_that
Definition: def_glob.h:105
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
wl_pair_list::aaaa_2
ptr_psi_term aaaa_2
Definition: def_struct.h:189
wl_psi_term::resid
ptr_residuation resid
Definition: def_struct.h:173
function_it
#define function_it
Definition: def_const.h:362
do_residuation
long do_residuation()
Definition: lefun.c:313
glb_value
long glb_value(long result, long f, GENERIC c, GENERIC value1, GENERIC value2, GENERIC *value)
Definition: types.c:1206
ptr_resid_block
struct wl_resid_block * ptr_resid_block
Definition: def_struct.h:244
deref2_eval
void deref2_eval(ptr_psi_term t)
Definition: lefun.c:1224
eval_args
long eval_args(ptr_node n)
Definition: lefun.c:826
deref_eval
long deref_eval(ptr_psi_term t)
Definition: lefun.c:1087
eval_global_var
void eval_global_var(ptr_psi_term t)
Definition: lefun.c:1291
clear_copy
void clear_copy()
Definition: copy.c:52
real_stack_psi_term
ptr_psi_term real_stack_psi_term(long stat, REAL thereal)
Definition: lefun.c:38
push2_ptr_value
void push2_ptr_value(type_ptr t, GENERIC *p, GENERIC v)
Definition: login.c:531
deref_rec_args
void deref_rec_args(ptr_node n)
Definition: lefun.c:1159
wl_choice_point
Definition: def_struct.h:231
check_out
long check_out(ptr_psi_term t)
Definition: lefun.c:999
push_ptr_value
void push_ptr_value(type_ptr t, GENERIC *p)
Definition: login.c:360
goal_stack
ptr_goal goal_stack
Definition: def_glob.h:50
deref_flag
static long deref_flag
Definition: lefun.c:1085
match_attr2
void match_attr2(ptr_node *u, ptr_node v, ptr_resid_block rb)
Definition: lefun.c:592
attr_missing
static long attr_missing
Definition: lefun.c:10
push_choice_point
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:591
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
def_ptr
#define def_ptr
Definition: def_const.h:173
wl_residuation::goal
ptr_goal goal
Definition: def_struct.h:156
wl_goal
Definition: def_struct.h:222
wl_residuation::next
ptr_residuation next
Definition: def_struct.h:157
global
#define global
Definition: def_const.h:364
wl_pair_list::next
ptr_pair_list next
Definition: def_struct.h:191
wl_stack::bbbb_3
GENERIC * bbbb_3
Definition: def_struct.h:218
wl_goal::cccc_1
GENERIC cccc_1
Definition: def_struct.h:226
c_rule
long(* c_rule[MAX_BUILT_INS])()
Definition: def_glob.h:247
push_psi_ptr_value
void push_psi_ptr_value(ptr_psi_term q, GENERIC *p)
Definition: login.c:443
do_currying
void do_currying()
Definition: lefun.c:359
residuate3
void residuate3(ptr_psi_term u, ptr_psi_term v, ptr_psi_term w)
Definition: lefun.c:142
tracing
void tracing()
Definition: error.c:604
defs.h
wl_psi_term
Definition: def_struct.h:161
matches
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
Definition: types.c:1565
wl_stack
Definition: def_struct.h:215
wl_resid_list::next
ptr_resid_list next
Definition: def_struct.h:62
wl_residuation
Definition: def_struct.h:152
get_one_arg
void get_one_arg(ptr_node t, ptr_psi_term *a)
Definition: login.c:86
wl_pair_list
Definition: def_struct.h:188
check_type
long check_type(ptr_psi_term t)
Definition: lefun.c:922
top
ptr_definition top
Definition: def_glob.h:106
NULL
#define NULL
Definition: def_const.h:203
init_global_vars
void init_global_vars()
Definition: lefun.c:1337
resid_aim
ptr_goal resid_aim
Definition: def_glob.h:220
overlap_type
long overlap_type(ptr_definition t1, ptr_definition t2)
Definition: types.c:1486
REAL
#define REAL
Definition: def_const.h:72
resid_vars
ptr_resid_list resid_vars
Definition: def_glob.h:221
eval
#define eval
Definition: def_const.h:278
trace
long trace
Definition: def_glob.h:272
residuate_double
void residuate_double(ptr_psi_term t, ptr_psi_term u)
Definition: lefun.c:95
wl_node::left
ptr_node left
Definition: def_struct.h:183
traceline
void traceline(char *format,...)
Definition: error.c:157
fetch_def
void fetch_def(ptr_psi_term u, long allflag)
Definition: login.c:1128
type_it
#define type_it
Definition: def_const.h:363
wl_definition::next
ptr_definition next
Definition: def_struct.h:148
undo_stack
ptr_stack undo_stack
Definition: def_glob.h:53
quote_copy
ptr_psi_term quote_copy(ptr_psi_term t, long heap_flag)
Definition: copy.c:200
Errorline
void Errorline(char *format,...)
Definition: error.c:414
real
ptr_definition real
Definition: def_glob.h:102
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
print_resid_message
void print_resid_message(ptr_psi_term t, ptr_resid_list r)
Definition: print.c:1562
wl_stack::type
type_ptr type
Definition: def_struct.h:216
TRUE
#define TRUE
Definition: def_const.h:127
first_definition
ptr_definition first_definition
Definition: def_glob.h:3
copy
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
Definition: copy.c:219
RMASK
#define RMASK
Definition: def_const.h:159
deref_rec_eval
long deref_rec_eval(ptr_psi_term t)
Definition: lefun.c:1123
integer
ptr_definition integer
Definition: def_glob.h:93
match
#define match
Definition: def_const.h:283
iff
ptr_definition iff
Definition: def_glob.h:92
wl_definition::rule
ptr_pair_list rule
Definition: def_struct.h:126
wl_definition::global_value
ptr_psi_term global_value
Definition: def_struct.h:141
FALSE
#define FALSE
Definition: def_const.h:128
wl_resid_list
Definition: def_struct.h:59
f_check_out
long f_check_out(ptr_psi_term t)
Definition: lefun.c:992
code_ptr
#define code_ptr
Definition: def_const.h:174
match_aim
long match_aim()
Definition: lefun.c:712
quoted_string
ptr_definition quoted_string
Definition: def_glob.h:101
ptr_definition
struct wl_definition * ptr_definition
Definition: def_struct.h:31
deref_args_eval
long deref_args_eval(ptr_psi_term t, long set)
Definition: lefun.c:1175
check_func
void check_func(ptr_psi_term t)
Definition: lefun.c:861
wl_psi_term::value_3
GENERIC value_3
Definition: def_struct.h:170
release_resid
void release_resid(ptr_psi_term t)
Definition: lefun.c:414
wl_pair_list::bbbb_2
ptr_psi_term bbbb_2
Definition: def_struct.h:190
wl_resid_list::var
ptr_psi_term var
Definition: def_struct.h:60
fail
#define fail
Definition: def_const.h:272
aim
ptr_goal aim
Definition: def_glob.h:49
disjunction
ptr_definition disjunction
Definition: def_glob.h:84
heap_pointer
GENERIC heap_pointer
Definition: def_glob.h:12
wl_psi_term::coref
ptr_psi_term coref
Definition: def_struct.h:172
wl_resid_block
Definition: def_struct.h:246
append_resid
void append_resid(ptr_psi_term u, ptr_psi_term v)
Definition: lefun.c:434
STACK_ALLOC
#define STACK_ALLOC(A)
Definition: def_macro.h:16
unify
#define unify
Definition: def_const.h:274
wl_stack::aaaa_3
GENERIC * aaaa_3
Definition: def_struct.h:217
stack_copy_psi_term
ptr_psi_term stack_copy_psi_term(psi_term t)
Definition: parser.c:183
featcmp
long featcmp(char *str1, char *str2)
Definition: trees.c:89
wl_psi_term::status
long status
Definition: def_struct.h:166
wl_psi_term::flags
long flags
Definition: def_struct.h:169
wl_definition
Definition: def_struct.h:121
heap_psi_term
ptr_psi_term heap_psi_term(long stat)
Definition: lefun.c:63
can_curry
long can_curry
Definition: def_glob.h:224
FUNC_ARG
#define FUNC_ARG(t)
Definition: def_macro.h:26
unify_noeval
#define unify_noeval
Definition: def_const.h:275
stack_psi_term
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
sys_bytedata
ptr_definition sys_bytedata
Definition: def_glob.h:336
curried
long curried
Definition: def_glob.h:223
wl_resid_list::othervar
ptr_psi_term othervar
Definition: def_struct.h:61
eval_cut
#define eval_cut
Definition: def_const.h:279
match_attr1
void match_attr1(ptr_node *u, ptr_node v, ptr_resid_block rb)
Definition: lefun.c:552
curry
void curry()
Definition: lefun.c:157
residuateGoalOnVar
long residuateGoalOnVar(ptr_goal g, ptr_psi_term var, ptr_psi_term othervar)
Definition: lefun.c:172
i_eval_args
long i_eval_args(ptr_node n)
Definition: lefun.c:817
ptr_psi_term
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
eval_aim
long eval_aim()
Definition: lefun.c:456
save_resid
void save_resid(ptr_resid_block rb, ptr_psi_term match_date)
Definition: lefun.c:1256
i_check_out
long i_check_out(ptr_psi_term t)
Definition: lefun.c:985
residuate2
void residuate2(ptr_psi_term u, ptr_psi_term v)
Definition: lefun.c:130
cut
ptr_definition cut
Definition: def_glob.h:83
check_func_flag
static long check_func_flag
Definition: lefun.c:11
match_attr
void match_attr(ptr_node *u, ptr_node v, ptr_resid_block rb)
Definition: lefun.c:692
global_time_stamp
unsigned long global_time_stamp
Definition: login.c:19
match_attr3
void match_attr3(ptr_node *u, ptr_node v, ptr_resid_block rb)
Definition: lefun.c:643
deref_rec_body
void deref_rec_body(ptr_psi_term t)
Definition: lefun.c:1135
disj
#define disj
Definition: def_const.h:276
glb_code
long glb_code(long f1, GENERIC c1, long f2, GENERIC c2, long *f3, GENERIC *c3)
Definition: types.c:1263
MAX_BUILT_INS
#define MAX_BUILT_INS
Definition: def_const.h:82
stack_pointer
GENERIC stack_pointer
Definition: def_glob.h:14
eval_copy
ptr_psi_term eval_copy(ptr_psi_term t, long heap_flag)
Definition: copy.c:205
deref_rec_args_exc
void deref_rec_args_exc(ptr_node n, long set)
Definition: lefun.c:1203
wl_node
Definition: def_struct.h:181
residuate
void residuate(ptr_psi_term t)
Definition: lefun.c:113
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:165
deref2_rec_eval
void deref2_rec_eval(ptr_psi_term t)
Definition: lefun.c:1245
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:225
in_set
long in_set(char *str, long set)
Definition: lefun.c:1192
GENERIC
unsigned long * GENERIC
Definition: def_struct.h:17
resid_ptr
#define resid_ptr
Definition: def_const.h:171
release_resid_notrail
void release_resid_notrail(ptr_psi_term t)
Definition: lefun.c:420
release_resid_main
void release_resid_main(ptr_psi_term t, long trailflag)
Definition: lefun.c:384
QUOTED_TRUE
#define QUOTED_TRUE
Definition: def_const.h:123
goal_ptr
#define goal_ptr
Definition: def_const.h:175
HEAP_ALLOC
#define HEAP_ALLOC(A)
Definition: def_macro.h:15
SMASK
#define SMASK
Definition: def_const.h:160
wl_stack::next
ptr_stack next
Definition: def_struct.h:219
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:171
do_residuation_user
long do_residuation_user()
Definition: lefun.c:306
wl_goal::pending
ptr_definition pending
Definition: def_struct.h:228
restore_resid
void restore_resid(ptr_resid_block rb, ptr_psi_term *match_date)
Definition: lefun.c:1270
heap_alloc
GENERIC heap_alloc(long s)
Definition: memory.c:1518
choice_stack
ptr_choice_point choice_stack
Definition: def_glob.h:51
check_disj
void check_disj(ptr_psi_term t)
Definition: lefun.c:845
STACK
#define STACK
Definition: def_const.h:148
wl_node::right
ptr_node right
Definition: def_struct.h:184
wl_goal::next
ptr_goal next
Definition: def_struct.h:227
psi_term_ptr
#define psi_term_ptr
Definition: def_const.h:170
int_ptr
#define int_ptr
Definition: def_const.h:172