8. Type Systems Flashcards

1
Q

Type systems are most widely used form of static analysis. T/F

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Motivation for type system (basic example of what it is/does)

A

required a boolean but you gave it a float.

Tried to return an array when the function expected to return an int.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a type?

A

A type is a set of values
int is a set of all integers between -2^31 and the opposite of that

Example of an abstract value. Represents a set of concrete values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

More types

A
Foo is the set of all objects of class Foo
List is set of all Lists of Integer objects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Abstraction

A

represents sets of concrete values as abstract values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In type systems, every concrete value is an element of some abstract value.

A

every concrete value has a type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

english to inference rule for

if e1 has type int and e2 has type int, then e1+e2 has type int

A

(e1:int ^ e2:int)=> e1+e2 : int

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Notation for inference rules

A

|-Conclusion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Inference rule axiom

A

|-e:t

something with no hypotheses but we know is true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Type judgement

A

Hypotheses and conclusions are type judgments that take the form:
|-e:t

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

|-

A

it is provable that

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Schema

A

something very basic and template like.

|- i : int
i is integers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Rules for integers: inference rule for e1+e2

A

|-e1:int |-e2:int
————————- [Add] (name)
|-e1+e2 :int

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Hypotheses state facts about ______

Conclusions state facts about ______

A

sub-expressions

entire expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Bound variable

A

a variable in an expression that is defined within the expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Free variable

A

in an expression not defined within the expression

17
Q

Type Environments notation: What does this mean in english?

A |- e : t

A

Under the assumption that variables have types given by A, it is provable that the expression has type t

18
Q

Explain what the following means and when it is used:

A[ x->t]

A

means “A modified to map x to type t”
used when x would be a free variable in a conclusion. Include the statement after the environment A in the hypothesis. Lesson 22.

19
Q

A |- e1 e2 : t2

A

if under the environment A, it is provable that e1 has type t1->t2,
and under the environment A it is provable that e2 has type t2,
then
it is provable that calling e1 with argument e2 will yield type t2

20
Q

Type Derivation

A

Procedure to determine the type of a program if one exists.

come back to this 24/25

21
Q

side condition

A

additional condition that needs to be satisfied for the inference rule to be valid.
looks like;
t1=t2

22
Q

Soundness verifies _____

A

absence of a class of errors

23
Q

Soundness comes at a price:

A

false positives

24
Q

Unsound analysis =

A

reduced false positives

introduces false negatives

25
Q

Global analysis

A

requires overall environment
Usually technically simpler than local analysis
may need extra work to model environments for unfinished programs

26
Q

local analysis

A

more flexible in application

technically harder: need to allow unknown parameters, more side conditions

27
Q

flow insensitive

A

we don’t give afuck about the order (flow) of statementsq

28
Q

flow sensitive analysis downside

A

expensive/complex

polynomial increase in cost over flow insensitive due to each statement having its own model of state