Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The truth value of a logical expression is defined recursively as: •The truth va

ID: 3587531 • Letter: T

Question

The truth value of a logical expression is defined recursively as:

•The truth value of t is t.

•The truth value of f is f.

•The truth value of (x1 x2) is t if both x1 and x2 have truth value t, it is f otherwise.

•The truth value of (x1 x2) is f if both x1 and x2 have truth value f, it is t otherwise.

•The truth value of ¬(x) is f if x has truth value t, it is t otherwise.

Define a CFG that generates the following language over{t, f,,,¬,(,),=}:

L={w=x: w is a logical expression over{t, f},x {t, f}, and x is the truth value of w}

Thus, “t = t”, “((t f) f) = f”, and “¬(((t f) f)) = t” are in L, but “((t f) f) = t”and “(t f) f = f” are not: the former because ((t f) f) is false and not true, the latter because the expression lacks the outermost set of parentheses.

Explanation / Answer

A context-free grammar G is defined by the 4-tuple:

G = {V, T, P, S} where

For the given language:

L={w=x: w is a logical expression over{t, f},x {t, f}, and x is the truth value of w}

The corresponding Context Free Grammar (CFG) can be written as:

S -> S or T | T

T -> T and F | F

F -> not F | t | f | (B)

Here in the above CFG

V = {S, T, F}

T = {t, f}

S = {S}