Name of unsigned literals in clause normal form - logic

The elements of a logical statement in clause normal form, are called literals.
For example, given the clause {a, !b}
The literals are a , !b.
But suppose you want to obtain the set of elements regardless of whether they are negated.
The 'unsigned literals'(?) are a , b.
What would be a better/more standard term than 'unsigned literals'? One could say 'variables' I suppose, but that seems incongruous in a context where they could be constants, or complex terms in their own right.

The best available answer seems to be 'atoms' as in https://en.wikipedia.org/wiki/Atomic_formula - though the objects in question could be complex terms, they are atoms from the perspective of propositional logic.

Related

Are operators a subset of statements?

Basically in all high-level languages (as I know) we have two main categories of language mechanisms to create a program: statements and expressions.
Usually statements are represented by some subset of language's keywords: if/else/switch, for/foreach/while, {} (or BEGIN/END), etc.
Expressions are represented by literals (which represent some data) and operators: literals: 1, 2, -100, testTest, etc; operators: +, -, /, *, ==, ===, etc.
If we think deeper, we can notice that statements usually answer on question "what?" and expressions -- on question "how?". Statements represent actions, expressions represent the context of actions.
Then we may look in expressions' parts again: literals and operators. Operators are actions too.
And here is my question again: are operators a subset of statement?
P.S. Generally, I understand that statements and expression are used together to aim some programming target. Separation of this categories is mostly theoretical.
In general, "operator" describes a kind of syntactic form, which can be used to produce an expression, a statement, or some other class of language entity. So, technically, the answer to your question is, "no".
For example, Haskell uses a | operator to generate an algebraic type spec, which is neither an expression nor a statement:
data Maybe a = Just a | Nothing

Retrieve internal/canonical representation of terms in Prolog

I am writing a program for which I need terms in their prefix notation.
The point is to being able to parse mathematical expressions to prefix notation, while preserving the correct order of Operations. I then want to save the result in the database for later use (using assert), which includes translating to another language, which uses prefix notation. Prolog Operators do all have a fixed priority which is a feature I want to use, as I will be using all sorts of operators (including clp operators).
As among others I need to include complete mathematical expressions, such as the equality operator. Thus I cannot recursively use the Univ operator (=..), because it won't accept equality operators etc. Or can I somehow use =.. ?
Essentially I want to work with the internal representation of
N is 3*4+5 % just a random example
which would be
is(N,+(*(3,4),5))
Now, I do know that I can use, write_canonical(N is 3*4+5) to get the internal representation as seen above.
So is there a way to somehow get the internal representation as a term or a list, or something.
Would it be possible to bind the output of write_canonical to a variable?
I hope my question is clear enough.
Prolog terms can be despicted as trees. But, when writing a term, the way a term is displayed depends on the defined operators and write options. Consider:
?- (N is 3*4+5) = is(N,+(*(3,4),5)).
true.
?- (N is 3*4+5) = is(Variable, Expression).
N = Variable,
Expression = 3*4+5.
?- 3*4+5 = +(*(3,4),5).
true.
I.e. operators are syntactic sugar. They don't change how terms are represented, only how terms are displayed.

How to query using ← / back arrow / asignment / naming / renaming / declaration

Student(id, name, address, city, birthYear)
Course(code, courseName, lengthWeeks, institution°)
Institution(instNr, instName, instCity)
Takes(id°, code°)
List the ids and names of students who do not take the Databases course.
t1 ← σ courseName=Databases (Course)
t2 ← t1 ⋈ Takes
t3 ← t2 ⋈ Student
t4 ← π id, name (t3)
t5 ← π id, name (Student)
R ← t5 \ t4
I don't understand the logic behind t5. How can you pick id's and names that are already removed from the relation? Could you do it another way with the ¬?
RA (relational algebra) operators return values given input relation values. (As with everyday addition for integers.) They don't change or establish the values associated with names of variables or constants. That's outside an algebra. The only way a name might get associated with a new value is if your ← is defined to be variable assignment rather than constant declaration. You have to tell us that. Either way it's not a relational algebra operator. It is a symbol in a language whose expressions include more than just names denoting relations (terminals) and nested algebra operator calls (non-terminals). We can in a certain sense consider it an operator of that language but it is not an operator of the algebra. And either way your code never associates a second value with the same name.
(Some RAs have operators that input names as well as relation values in order to disambiguate inputs. But using such input names to associate variable/constant names with values on output is not a RA operation.)
(A RA could define its notion of relation as containing a name and a set of tuples, so it could have an algebraic renaming operator that takes a name and a relation and returns a relation with the given name in its name part. But again that would not affect the value associated with any variable/constant name used to identify the input relation.)
Re "do it another way": Usually we assume some RA operators & some way to name relation values, and then there is an obvious set of query expressions: We take an expression that is a name to denote its associated value and we take an expression that is an operator call to denote the value of calling the operator on the values of its argument expressions. (As with everyday integer arithmetic expressions.)
But a particular query language although defined in terms of such expressions might not actually allow you to write any or all such expressions. (Eg relational tuple calculus & domain calculus.) And/or it might define additional expressions in terms of expression rearrangement without explicitly giving a corresponding operator.
(Some presentations of relational algebras confuse RA operators with expressions of a query language inspired by RA. Then there might be query expressions whose results depend on the variable/constant names that appear as arguments, rather than just the values named by the names that appear as arguments. Then there can be query expressions that you might not be able to write via a nesting of operator calls and that might need you to associate a value with a name via assignment/declaration.)

Is a single constant value considered an expression?

After reading this answer on a CSS question, I wonder:
In Computer Science, is a single, constant value considered an expression?
In other words, is 7px an expression? What about just 7?
Quoting Wikipedia, emphasis mine:
An expression in a programming language is a combination of one or more explicit values, constants, variables, operators, and functions that the programming language interprets [...] and computes to produce [...] another value. This process, as for mathematical expressions, is called evaluation.
Quoting MS Docs, emphasis mine:
An expression is a sequence of one or more operands and zero or more operators that can be evaluated to a single value, object, method, or namespace. Expressions can consist of a literal value [...].
These both seems to indicate that values are expressions. However, one could argue that a value will not be evaluated, as it is already only a value, and therefore doesn't qualify.
Quoting Techopedia, emphasis mine:
[...] In terms of structure, experts point out that an expression inherently needs at least one 'operand’ or value that is acted on, and must have one or more operators. [...]
This suggests that even x does not qualify as expression as it is lacking one or more operators.
It depends on the exact definition of course, but under most definitions expressions are defined recursively with constants being one of the basis cases. So, yes, literal values are special cases of expressions.
You can look at grammars for various languages such as the one for Python
If you trace through the grammar you see that an expr can be an atom which includes number literals. The fact that number literals are Python expressions is also obvious when you consider productions like:
comparison: expr (comp_op expr)*
This is the production which captures expressions like x < 7, which wouldn't be captured if 7 isn't a valid expression.
In Computer Science, is a single, constant value considered an expression?
It depends entirely on the context. For example, FORTRAN, BASIC, and COBOL all have line numbers. Those are numeric constant values that are not expressions.
In other contexts (even within those languages) a numeric constant may be an expression.

Untyped set operations in Isabelle

I have the following code in Isabelle:
typedecl type1
typedecl type2
consts
A::"type1 set"
B::"type2 set"
When I want to use union operation with A and B as bellow:
axiomatization where
c0: "A ∩ B = {}"
Since A and B are sets of different types, I get an error of clash of types which makes sense!
I am wondering if there are any counterparts for set operations that they implicitly consider their operands as pure sets (i.e., ignore their types), therefore something like A ∩' B become possible ( ∩' is ∩ operation counterpart in above sense).
PS:
Another workaround is type casting that I wrote this as a separate question here to better organize my questions.
Thanks
Sets in Isabelle/HOL are always typed, i.e., they contain only elements of one type. If you want to have untyped sets, you have to switch to another logic such as Isabelle/ZF.
Similarly, all values in HOL are annotated with their type, and this is fundamental to the logic. Equality, for example, can only be applied to two values of the same type. Hence, there is no notion of equality between values of different types. Consequently, there is no set operation that ignores the type of values, because such an operation would necessarily have to know how to identify values of different types.

Resources