13.07.2015 Views

A Graph-Based Generic Type System for Object-Oriented Programs

A Graph-Based Generic Type System for Object-Oriented Programs

A Graph-Based Generic Type System for Object-Oriented Programs

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Type</strong> <strong>System</strong> 38Table 8: <strong>Type</strong>-Checking of Commands, Methods and <strong>Programs</strong>(T-Skip) Γ, ∆ ⊢ skip → skip (T-Assign) Γ, ∆ ⊢ le, e → le′ : t, e ′ : t ′ Γ ⊢ t ′ tΓ, ∆ ⊢ le := e → le ′ := e ′(T-New) Γ ⊢ Cc → ⌈u⌋ Γ, ∆ ⊢ le → le′ : u ′ u ∈ C ∨ t-var(Γ, u) ≠ ∅ Γ ⊢ u u ′Γ, ∆ ⊢ Cc.new(le) → ⌈u⌋.new(le ′ )(T-Invk) Γ, ∆ ⊢ e, ve, re → e′ : u, ve ′ : t, re ′ : t ′ {· x−→ t ′′ } = mfr(Γ u, m) Γ ⊢ t t ′′ t ′Γ, ∆ ⊢ e.m(ve • x • re) → e ′ .m(ve ′ • x • re ′ )Γ ⊢ Te → ⌈t⌋ k = size(∆)(T-Decl)Γ, ∆ → push(∆, x, t) : k ⊢ var Te x → var ⌈t⌋ xvar(∆) = {x} k = size(∆) ≥ 1(T-End)Γ, ∆ → pop(∆) : k − 1 ⊢ end x → end x(T-If) Γ, ∆ ⊢ e, c 1, c 2 → e ′ : B, c ′ 1, c ′ 2Γ, ∆ ⊢ c 1 ⊳ e ⊲ c 2 → c ′ 1 ⊳ e ′ ⊲ c ′ 2Γ, ∆ → ∆ ′′ : k 1 ⊢ c 1 → c ′ 1Γ, ∆ ′′ → ∆ ′ : k 2 ⊢ c 2 → c ′ 2(T-Seq)Γ, ∆ → ∆ ′ : min(k 1 , k 2 ) ⊢ c 1 ; c 2 → c ′ 1; c ′ 2(T-While) Γ, ∆ ⊢ e, c → e′ : B, c ′Γ, ∆ ⊢ e ∗ c → e ′ ∗ c ′(T-Meth) Γ ⊢ j ∼ self (u) {· x−→ t} = mfr(Γ j, m) Γ, push(∆ ∅ , (self , x), (j, t)) ⊢ c → c ′Γ ⊢ u :: m{c} → u :: m{c ′ }(T-Main) Γ ⊢ Te → ⌈t⌋ Γ, push(∆ ∅, x, t) ⊢ c → c ′Γ ⊢ {Te x; c} → {⌈t⌋ x; c ′ }(T-Prog)Γ ⊢ md, Md → md ′ , Md ′Γ ⊢ md • Md → md ′ • Md ′ .1. a ≠ σ ∧ a −→ n ∈ clo(Γ t) =⇒ ∃ a −→ n ′ ∈ clo(Γ j) • Γ ⊢ n ′ ∼ n〈s〉,2. σ.m −−→ n ∈ clo(Γ t) =⇒ ∃ σ.m −−→ n ′ ∈ clo(Γ j) • Γ ⊢ n ′ ∼ n〈s〉.Proof. By the definition of clo, the properties of the instantiation function in Definition 12 andDefinition 13.□From the above two lemmas, an instantiation of a well-typed command is also well-typed. Weinstantiate commands and type contexts by the functions insc and insd, respectively.Theorem 2 (<strong>Type</strong>-Safety of Command Instantiations) Given a type graph Γ and a well<strong>for</strong>medtype substitution s, if Γ, ∆ 1 → ∆ 2 : k ⊢ c, letthen Γ, ∆ ′ 1 → ∆′ 2 : k ⊢ c′ .c ′ = insc(Γ, c, s), ∆ ′ 1 = insd(Γ, ∆ 1 , s), ∆ ′ 2 = insd(Γ, ∆ 2 , s),Report No. 448, June 2011UNU-IIST, P.O. Box 3058, Macao

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!