An expression is a unit of language that has meaning; a signifying linguistic unit. For example, the word "dog" is an expression because it signifies the idea, DOG, the sentence the "All men are mortal" is an expression because it expresses the proposition (forall (x) (man x) => (mortal x)). However, 1 / 0 is not an expression because it has no definition, nor is "Colorless green ideas sleep furiously" because it does not express an idea (nonsense). "Stop!" is not an expression because it lacks propositional value, and "Walks the store the man" is not an expression because it is grammatically invalid.


1   Form

An expression consists of data and operators.

is some variables and constants along with operators symbols.

An expression consists of:

  1. Atoms
  2. Expressions

An interpretation of an expression produces a value, which is determined in a systematic way the values it gives to the component expressions.

2   Properties

A expression is simple iff it is atomic otherwise it is complex. For example, "4" and "True" are simple, while "2 + 2" and "not False" are complex.

Morpho-syntactic Hierarchy:

  1. Morpheme
  2. Word
  3. Phrase
  4. Sentence (clause)
  5. Text

3   Meaning

3.1   Idiomatic

An idiom is the specific grammatical, syntactic, and structural character of a given language.

A commonly used and understood way of expressing an fact, idea or intention.

Idiomatic meaning is not predictable in regular ways by the meaning of its parts. It is frequently contrasted with compositional meaning, which can be determined by its parts. For example, "babysit" or "the cat is out of the bag". Similarly, in software, design patterns may be considered idiomatic frequently because the compositional meaning conveys too much information.

For example, the idiomatic way to perform an operation on all items in a list in the C programming language looks like this:

for (i=0; i < mylist_length; i++) {

3.2   Literal

The literal meaning (=signal meaning, sentence meaning, conventional nonnatural meaning, linguistic meaning, semantic interpretation) of an expression is the meaning determined by the meaning of its constituents and their arrangement. For example, a speaker could mean by 'Snow is white' that snow is white, or by "2 + 2" mean 4.

Formally we might say:

  • "S nonnaturally means (timeless) by x (that so-and-so)"
  • "x nonnaturally means (timeless) something (that so-and-so)"

3.2.1   Study

The study of literal meaning is called semantics. The study of semantics goes back to Aristotle, and forms a long tradition of philosophy and language.

The chief ideas used in semantics are reference and truth.

The connection or relation between words and the world is said to involve reference.

If the word of a sentence connect with world in the right sort of way, then it it plausible that the sentence is true.

Related to deductive system.

Every theory of semantics consists of two parts:

  1. Base rules: Rules that specify the meanings of the basic elements of the language
  2. Projection rules: Rules that specify how the meaning of the complex sentence are determined

The simplest sentence are called atomic sentences and are defined as those sentence of which no proper part is a sentence.

3.3   Contextual

Not actually sure this a line to split on.

The same sentence may have a different interpretation depending on where it is used. Consider the following conversation:

Jenny: What day of the week is it? Tuesday? Me (responding): What day of the week is it? Tuesday.

Exactly same set of syllables in these two lines, but position in the conversation, intonation, and timing / pauses give two different meanings. Nonverbal communication can add meaning and increase bandwidth.

See pragmatics.

4   Parsing

Mathematical expressions specified in infix notation can be parsed using the Shunting-yard algorithm, which can be implemented in the Python programming language like so:

def eval_a_expr(expression, precedence, operators):
    Evaluate an arithmetic expression.

    >>> import operator as op
    >>> eval_a_expr('2 + 11 - 3', {'+': 1, '-': 1}, {'+': op.add, '-': op.sub})
    >>> eval_a_expr('2 + 10 * 3', {'+': 1, '*': 2}, {'+': op.add, '*': op.mul})
    >>> eval_a_expr('( 3 + 4 ) * ( ( 6 + 2 * 3 ) )', {'+': 1, '*': 2}, {
    ...     '+': op.add,
    ...     '*': op.mul,
    ... })
    rv = []
    for token in gen_postfix(expression.split(), precedence):
            operator = operators[token]
        except KeyError:
            # NOTE: This only works with integers
            right, left = rv.pop(), rv.pop()
            rv.append(operator(left, right))
    return rv[0]

def gen_postfix(tokens, precedence):
    Generate a postfix expression from an infix expression.

    >>> list(gen_postfix('( 3 + 4 ) * ( ( 6 + 2 * 3 ) )'.split(), {
    ...     '+': 1,
    ...     '-': 1,
    ...     '*': 2,
    ... }))
    ['3', '4', '+', '6', '2', '3', '*', '+', '*']
    precedence['('] = float('-inf')
    operators = []  # stack of operators
    for token in tokens:
        if token == '(':
        elif token == ')':
            while operators:
                if operators[-1] == '(':
                    yield operators.pop()
                    if not operators:
                        raise ValueError('missing left paren')
        elif token in precedence:
            while operators:
                if precedence[operators[-1]] > precedence[token]:
                    yield operators.pop()
            yield token
    for operator in reversed(operators):
        if operator == '(':
            raise ValueError('missing right paren')
        yield operator

Or in the Haskell programming language like so:

import Data.List

-- Evaluate a postfix expression
evalPostfix :: (Num a, Read a) => String -> a
evalPostfix = head . foldl comb [] . words
    comb (x:y:ys) "*" = (x * y) : ys
    comb (x:y:ys) "+" = (x + y) : ys
    comb (x:y:ys) "-" = (y - x) : ys
    comb xs s = read s : xs

-- Apply the shunting-yard algorithm to turn an infix expression
-- into a postfix expression.
shunt :: [String] -> [String] -> [String] -> [String]
shunt o p [] = (reverse o) ++ p
shunt o [] (x:xs)
    | x `elem` ["*", "+", "-", "("] = shunt o [x] xs
    | x == ")" = error "mismatched parenthesis"
    | otherwise = shunt (x:o) [] xs
shunt o (p:ps) (x:xs)
    | x == "(" = shunt o (x:p:ps) xs
    | x == ")" = case (span (/= "(") (p:ps)) of
        (as, b:bs) -> shunt (as ++ o) bs xs
    | x == "*" = shunt o (x:p:ps) xs
    | x `elem` ["+", "-"] = case (p) of
        "*" -> shunt (p:o) (x:ps) xs
        "(" -> shunt o (x:p:ps) xs
        otherwise -> shunt (p:o) (x:ps) xs
    | otherwise = shunt (x:o) (p:ps) xs

-- | Convert an infix expression to postfix
toPostfix :: String -> String
toPostfix = intercalate " " . shunt [] [] . words

-- | Evaluate an infix expression
-- Note that parenthesis must have a space on either
-- RIGHT: 1 - ( 2 + 3 )
-- WRONG: 1 - (2 + 3)
eval :: (Num a, Read a) => String -> a
eval = evalPostfix . toPostfix

5   References

# Analysis

  1. Denotation & Connotation
  2. Sense & Reference

## Denotation & Connotation

Note: Generally, denotation and connotation are inversely proportional. Specific terms connote more but denote fewer.

## Intension & Extension

Intension and extension are correlative words that indicate the reference of a term or object.

The intension of a concept is a property or quality connoted by a symbol.

Example: The intension of "man" is its connotation, MAN Example: The intension of "ship" is 'vehicle for conveyance on water'

The extension of a concept is the set that is specified by that concept.

Example: The extension of "ship" is the set of all ships; i.e. cargo ships, passenger ships, battleships, sailing ships, etc. Example: The extension of a function is the set of all ordered pairs that pair the argument and values of the function.

### Coextension

Two terms are coextensive if they are extensionally equal.

Note: Coextensive terms may have different intensions.

Example: "Morning star", "Evening star" Example: "3 + 2", "2 + 3" Example: "A trilateral is a polygon with three side" or "A triangle is a polygon with three angles" Example: "has a mass", "has a volume" Example: "thinks", "acts" Example: "has a property", "is identical with something"

Example: Triangularity and trilaterality are distinct features of the figure, although it would not be possible to have on feature but not the other.

The distinction between being a trilateral and having three sides is a verbal distinction.

The distinction between coextensive terms is a formal distinction.

That two terms, F and G, are coextensive does not imply that f(F) and f(G) are cointensive.

Example: "has a mass of 1 kg", "has a volume of 1 kg" Example: "thinks before he acts"; "acts before he acts"

A concept is monadic if its extension contains one element.

Note: The extension of a statement is defined as its truth value.

The extension of a relational concept is the set of all tuples of objects that can be related.

### Comprehension

The comprehension of a concept is the totality of its intentions.

Syntactically distinct predicates may have the same comprehension.

Example: If the definition of" human" is "rational animal", then "humanity" comprehends "rationality" and "animosity".

## Sense & Reference

Mediated reference theory states that the meaning of a term consists of two parts.

  1. A Sense
  2. A Referent

The referent of an expression is the object to which it refers.

The sense of an expression sense is the way in which the reference is presented.

Example: "The Morning Star" presents its reference, the planet Venus, as a star that is visible in the morning Example: "The Evening Star" presents its reference, the planet Venus, as a star that is visible in the evening

Note: Meaning cannot be strictly just reference, as suggested by Mill, since then a proper name of an non-existent object would have no meaning. Example: Pegasus.

### Sense

Sense contains the mode of presentation; a single aspect of reference.

Every sign has a sense.

Some signs have no reference.

Example: "The celestial body most distant from the Earth" Example: "The least rapidly convergent series" Example: "The greatest integer is larger than one million"

Example: "2 + 2" and "2 ** 2" have the same reference but a different sense.

Note: Sense is not the same as intension, for Frege thinks of number as properties of collections, and surely any possible collection having the property '2 + 2' (that is, having '2 + 2' members) has the property '2 ** 2' and conversely. So the sense of '2 + 2' is not its intension.

### Reference

It is possible to refer to a sense.

Example: "Alice said 'Bob is ugly.'"

In reported speech, word have an indirect reference.

The indirect reference of a word is accordingly its customary sense.

### Idea

The reference and sense of a sign are distinct from the associated idea.

The same sense is not always connected with the same idea.

Example: A painter, a horseman, and a zoologist will probably have different ideas with the name "Bucephalus"

Different people may associate different senses with the same word.

Two men may grasp the same sense but they cannot have the same idea.

It is possible to determine that ideas are different, but impossible to assert they are the same.

We presuppose that the reference of a proper name is that object itself.

Example: "The Moon is smaller than the Earth" is different than "My idea of the Moon is smaller than the Earth."

The relationship between sign, idea, reference, and sense is:

Consider a person observing the Moon through a telescope.

Like the optical imagine in the telescope, which is objective, the sense is objective.

Each observer would have his own retinal image due to the disverse shapes of the observers' eyes.

An idea itself can be taken as an object if a person sees the retinal image of another.

SO, there may be three levels of difference during a discussion.

  1. Difference of idea
  2. Difference of sense
  3. Difference of reference

Example: Ideally, a translation of a source text should preserve the sense and reference. Example: Poetry is a difference in sense.

A proper name expresses it sense and designates (or stands for) its reference. By means of a sign we express its sense and designate its reference.

The thought of a statement must be its sense, not its reference, since we can replace a word in a sentence with another that is coreferent, but that changes the thought.

Example: "The morning star is a body illuminated by the Sun." Example: "The evening star is a body illuminated by the Sun."

Anyone who did not know that the evening start is the morning start might hold the one to be true, the other false, so the thought, accordingly, cannot be the reference of the sentence, but must be considered as the sense.

It is doubtful whether a sentence has reference if one its parts has no reference.

Example: "Odysseus was set ashore at Ithaca while sound asleep."

The striving for truth drives us always to advance from the sense to the reference.

The reference of a statement is its truth value, which is either the True or the False.

The sense of a statement is a proposition.

The truth value remains the same when a part of the sentence is replaced by a coreferent expression.

Note: All true sentences have the same referent. Note: All false sentences have the same referent.

A command has no reference but only a sense. A command is not a thought, but stands on the same level as thought.

Some expressions have an opposite meaning then their literal one would suggest. For example, "literally" or "extraordinary".