summaryrefslogtreecommitdiff
path: root/eval.c
blob: 02b85f1679eb8fd11e1f8973a6a74b05bf1a4659 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdlib.h>
#include "eval.h"
#include "parse.h"
char just_is_sound(prop_t prop, just_t just, lineSet_t lines) {
	prop_t a;
	prop_t b;
	if (!prop.isSimple) {
		a = *prop.propA;
		b = *prop.propB;
	}
	prop_t w;
	prop_t x;
	prop_t y;
	prop_t z;
	if (just.referencesCount > 0) {
		w = lines.lines[just.references[0] - 1].proposition;
	}
	if (just.referencesCount > 1) {
		x = lines.lines[just.references[1] - 1].proposition;
	}
	if (just.referencesCount > 2) {
		y = lines.lines[just.references[2] - 1].proposition;
	}
	if (just.referencesCount > 3) {
		z = lines.lines[just.references[3] - 1].proposition;
	}
	switch (just.rule) {
		case PREMISE_R:
			return 1;
		case ASSUMPTION_R:
			return 1;
		case CONJUNCT_INTRO:
			return (peq(a, w) && peq(b, x)) || (peq(a, x) && peq(b, w));
		default:
			return 0;
	}
}