Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@718 ab42f6e0-554d-0410-b580-99e487e6eeb2
- Loading branch information
1 parent
3a51a1b
commit c62bd85
Showing
5 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
none: | ||
|
||
test: | ||
swipl -f Test.pro | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
% See slide 186 | ||
|
||
term(var(X)) :- atom(X). | ||
term(app(T1,T2)) :- term(T1), term(T2). | ||
term(V) :- val(V). | ||
|
||
val(lam(X,XT,T)) :- atom(X), type(XT), term(T). | ||
val(true). | ||
val(false). | ||
|
||
type(bool). | ||
type(maps(T1,T2)) :- type(T1), type(T2). | ||
|
||
value(lam(X,T)) :- variable(X), term(T). | ||
value(var(X)) :- variable(X). % pragmatic extension to deal with open terms | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
:- ['Typing.pro']. | ||
|
||
% | ||
% Testing typing rules; see slide 165 | ||
% | ||
:- | ||
hastype([],app(lam(f,maps(bool,bool),app(var(f),false)),lam(g,bool,var(g))),T), | ||
write(T), nl. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
% See slide 183 | ||
:- ['Syntax.pro']. | ||
|
||
% hastype(Context,Term,Type) | ||
|
||
% T-Variable | ||
hastype(G,var(V),Type) :- | ||
member([V,Type],G). | ||
|
||
% T-Abstraction | ||
hastype(G,lam(X,XT,T),maps(XT,U)) :- | ||
hastype([[X,XT]|G],T,U). | ||
|
||
% T-Application | ||
hastype(G,app(T,U),Type) :- | ||
hastype(G,U,UT), | ||
hastype(G,T,maps(UT,Type)). | ||
|
||
% See slide 184 | ||
|
||
% T-True | ||
hastype(_,true,bool). | ||
|
||
% T-False | ||
hastype(_,false,bool). |