Cody

# Problem 44374. Tautology

Solution 1301428

Submitted on 19 Oct 2017
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = '0'; y_correct = false; assert(isequal(tautology(x),y_correct))

2   Pass
x = '1'; y_correct = true; assert(isequal(tautology(x),y_correct))

3   Pass
x = 'A'; y_correct = false; assert(isequal(tautology(x),y_correct))

4   Fail
x = '~A'; y_correct = false; assert(isequal(tautology(x),y_correct))

Assertion failed.

5   Pass
x = 'A|1'; y_correct = true; assert(isequal(tautology(x),y_correct))

6   Pass
x = '1&A'; y_correct = false; assert(isequal(tautology(x),y_correct))

7   Pass
x = 'A|B'; y_correct = false; assert(isequal(tautology(x),y_correct))

8   Pass
x = 'A&B'; y_correct = false; assert(isequal(tautology(x),y_correct))

9   Pass
x = 'A|A'; y_correct = false; assert(isequal(tautology(x),y_correct))

10   Pass
x = 'A|~A'; y_correct = true; assert(isequal(tautology(x),y_correct))

11   Pass
x = '0==0'; y_correct = true; assert(isequal(tautology(x),y_correct))

12   Pass
x = '~0'; y_correct = true; assert(isequal(tautology(x),y_correct))

13   Fail
x = '~(A & B) == (~A | ~B)'; y_correct = true; assert(isequal(tautology(x),y_correct))

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in tautology (line 9) y = ~tautology(x(2:end)); Error in Test13 (line 3) assert(isequal(tautology(x),y_correct))

14   Fail
assert(isequal(tautology('(A|B)|C'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test14 (line 1) assert(isequal(tautology('(A|B)|C'),false));

15   Fail
assert(isequal(tautology('(A|B)|(C == C)'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test15 (line 1) assert(isequal(tautology('(A|B)|(C == C)'),true));

16   Fail
assert(isequal(tautology('(A == B)|(B == C)|(C == A)'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 24) y = (tautology(terms{1}) == tautology(terms{2})); Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test16 (line 1) assert(isequal(tautology('(A == B)|(B == C)|(C == A)'),true));

17   Fail
assert(isequal(tautology('~(~(~(~(~(~(0))))))'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 9) y = ~tautology(x(2:end)); Error in Test17 (line 1) assert(isequal(tautology('~(~(~(~(~(~(0))))))'),false));

18   Fail
assert(isequal(tautology('~(~(~(~(~(~(~0))))))'),true)); % provided by Alfonso: assert(isequal(tautology('((0&1)|~B)&~B'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 9) y = ~tautology(x(2:end)); Error in Test18 (line 1) assert(isequal(tautology('~(~(~(~(~(~(~0))))))'),true));

19   Fail
assert(isequal(tautology('((0&~B)&~B)'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test19 (line 1) assert(isequal(tautology('((0&~B)&~B)'),false));

20   Fail
assert(isequal(tautology('((0|A)&~A)'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test20 (line 1) assert(isequal(tautology('((0|A)&~A)'),false));

21   Fail
assert(isequal(tautology('((0|A)|1)'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test21 (line 1) assert(isequal(tautology('((0|A)|1)'),true));

22   Fail
assert(isequal(tautology('((0|~B)|1)'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test22 (line 1) assert(isequal(tautology('((0|~B)|1)'),true));

23   Fail
assert(isequal(tautology('((1&0)|B)'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test23 (line 1) assert(isequal(tautology('((1&0)|B)'),false));

24   Fail
assert(isequal(tautology('((1&1)&A)'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test24 (line 1) assert(isequal(tautology('((1&1)&A)'),false));

25   Fail
assert(isequal(tautology('((1|0)|A)'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test25 (line 1) assert(isequal(tautology('((1|0)|A)'),true));

26   Fail
assert(isequal(tautology('((1|A)|0)'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test26 (line 1) assert(isequal(tautology('((1|A)|0)'),true));

27   Fail
assert(isequal(tautology('((1|~A)&B)'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test27 (line 1) assert(isequal(tautology('((1|~A)&B)'),false));

28   Fail
assert(isequal(tautology('((A&1)|~A)|A'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test28 (line 1) assert(isequal(tautology('((A&1)|~A)|A'),true));

29   Fail
assert(isequal(tautology('((A&~A)&~B)|~A'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test29 (line 1) assert(isequal(tautology('((A&~A)&~B)|~A'),false));

30   Fail
assert(isequal(tautology('((A&~B)&1)|B'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test30 (line 1) assert(isequal(tautology('((A&~B)&1)|B'),false));

31   Fail
assert(isequal(tautology('((A|0)&1)&~B'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test31 (line 1) assert(isequal(tautology('((A|0)&1)&~B'),false));

32   Fail
assert(isequal(tautology('((A|A)&A)|~A'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test32 (line 1) assert(isequal(tautology('((A|A)&A)|~A'),true));

33   Fail
assert(isequal(tautology('((B|0)&B)'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test33 (line 1) assert(isequal(tautology('((B|0)&B)'),false));

34   Fail
assert(isequal(tautology('((B|1)&B)&A'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test34 (line 1) assert(isequal(tautology('((B|1)&B)&A'),false));

35   Fail
assert(isequal(tautology('((B|A)|~A)'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test35 (line 1) assert(isequal(tautology('((B|A)|~A)'),true));

36   Fail
assert(isequal(tautology('((~A&~A)&0)&B'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test36 (line 1) assert(isequal(tautology('((~A&~A)&0)&B'),false));

37   Fail
assert(isequal(tautology('((~A&~A)|0)'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test37 (line 1) assert(isequal(tautology('((~A&~A)|0)'),false));

38   Fail
assert(isequal(tautology('((~A&~A)|~A)|1'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test38 (line 1) assert(isequal(tautology('((~A&~A)|~A)|1'),true));

39   Fail
assert(isequal(tautology('((~A|A)|~B)&1'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test39 (line 1) assert(isequal(tautology('((~A|A)|~B)&1'),true));

40   Fail
assert(isequal(tautology('((~A|B)|A)'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test40 (line 1) assert(isequal(tautology('((~A|B)|A)'),true));

41   Fail
assert(isequal(tautology('((~A|~A)|1)'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test41 (line 1) assert(isequal(tautology('((~A|~A)|1)'),true));

42   Fail
assert(isequal(tautology('((~A|~B)&0)'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test42 (line 1) assert(isequal(tautology('((~A|~B)&0)'),false));

43   Fail
assert(isequal(tautology('((~B&0)&A)'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test43 (line 1) assert(isequal(tautology('((~B&0)&A)'),false));

44   Fail
assert(isequal(tautology('(0&1)|1&1'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test44 (line 1) assert(isequal(tautology('(0&1)|1&1'),true));

45   Fail
assert(isequal(tautology('(0|~A&B)'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test45 (line 1) assert(isequal(tautology('(0|~A&B)'),false));

46   Fail
assert(isequal(tautology('(1|A&0)'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test46 (line 1) assert(isequal(tautology('(1|A&0)'),true));

47   Fail
assert(isequal(tautology('(A&A&~B)'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test47 (line 1) assert(isequal(tautology('(A&A&~B)'),false));

48   Fail
assert(isequal(tautology('(A&~A|1)'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test48 (line 1) assert(isequal(tautology('(A&~A|1)'),true));

49   Fail
assert(isequal(tautology('(A|1)|B'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test49 (line 1) assert(isequal(tautology('(A|1)|B'),true));

50   Fail
assert(isequal(tautology('(A|A)|A|1'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test50 (line 1) assert(isequal(tautology('(A|A)|A|1'),true));

51   Fail
assert(isequal(tautology('(B&1)|~B'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test51 (line 1) assert(isequal(tautology('(B&1)|~B'),true));

52   Fail
assert(isequal(tautology('(B&~B)&~B&0'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test52 (line 1) assert(isequal(tautology('(B&~B)&~B&0'),false));

53   Fail
assert(isequal(tautology('(B|~B)|B'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test53 (line 1) assert(isequal(tautology('(B|~B)|B'),true));

54   Fail
assert(isequal(tautology('(~A&B&0)'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test54 (line 1) assert(isequal(tautology('(~A&B&0)'),false));

55   Fail
assert(isequal(tautology('(~A|0)|~B&~A'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test55 (line 1) assert(isequal(tautology('(~A|0)|~B&~A'),false));

56   Fail
assert(isequal(tautology('(~A|1)|1'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test56 (line 1) assert(isequal(tautology('(~A|1)|1'),true));

57   Fail
assert(isequal(tautology('(~A|B&B)'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test57 (line 1) assert(isequal(tautology('(~A|B&B)'),false));

58   Fail
assert(isequal(tautology('(~A|B)|~B'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test58 (line 1) assert(isequal(tautology('(~A|B)|~B'),true));

59   Fail
assert(isequal(tautology('(~A|~A)|0'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 20) y = y | tautology(terms{i}); Error in Test59 (line 1) assert(isequal(tautology('(~A|~A)|0'),false));

60   Fail
assert(isequal(tautology('(~B&0)&1|1'),true));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in tautology (line 14) y = y & tautology(terms{i}); Error in Test60 (line 1) assert(isequal(tautology('(~B&0)&1|1'),true));

61   Pass
assert(isequal(tautology('1&B|~B|0'),true));

62   Pass
assert(isequal(tautology('B&1&A&1'),false));

63   Pass
assert(isequal(tautology('~A&0&1|1'),true));

64   Fail
assert(isequal(tautology('~B&0&~A|B'),false));

Assertion failed.

65   Fail
assert(isequal(tautology('~B|1|1|~B'),true));

Assertion failed.

66   Fail
assert(isequal(tautology('~B|~B&1|1'),true));

Assertion failed.