Parameters of Coquand's plays.

This is the list of parameters of the game.

In[243]:=

Logic                ... ;     (* "None", "TarskiPlay", "View" *) ;

In[247]:=

(* The only case in which no backtracking is allowed is when the logic is intuitionistic and the language is implication free *)

Looking for an assignment in a string.

Assume the string x includes an assignment "... y=n, ... ", or "... y=n". The assignment map computes n.
This is how do it. We remove first all characters until y, then all characters until "=", and in the case there is some ","  in the rest of the string, all characters from ","" . What is left is now "n". We compute n out of "n".

In[248]:=

Assignment[x_, y_] := CompoundExpression[val = EraseUntil[x, y] ; val = EraseU ... ringMemberQ[val, ","], val = EraseFrom[val, ","]] ; ToExpression[val]]

An example.

In[249]:=

TEXT = "Intuitionistic, FontSize = 12, CutFree, Width = 900"

Out[249]=

Intuitionistic, FontSize = 12, CutFree, Width = 900

In[250]:=

A = "FontSize" B = "Width"

Out[250]=

FontSize

Out[251]=

Width

In[252]:=

EraseUntil[TEXT, A]

Out[252]=

 = 12, CutFree, Width = 900

In[253]:=

EraseUntil[EraseUntil[TEXT, A], "="]

Out[253]=

 12, CutFree, Width = 900

In[254]:=

EraseFrom[EraseUntil[EraseUntil[TEXT, A], "="], ","]

Out[254]=

 12

In[255]:=

Assignment[TEXT, A]

Out[255]=

12

In[256]:=

Assignment[TEXT, B]

Out[256]=

900

Clearing symbols.

This map takes a string "s", including one symbol, and clears the symbol s.

In[257]:=

ClearString[x_String] := Clear[x] ;

This map takes a string "s1, ..., sn", including a list of symbols, and no blanks, and clears all symbols s1, ..., sn.

In[258]:=

ClearList0[S_String] := If[StringMemberQ[S, ","], CompoundEx ... [S, ","]], ClearList0[EraseUntil[S, ","]]], ClearString[S] ; ]

This map removes all blanks first.

In[259]:=

ClearList[S_] = ClearList0[StringReplace[S, " " ""]] ;

An example.

In[260]:=

{a1, a2, a3, a4, a5} = Range[5]

Out[260]=

{1, 2, 3, 4, 5}

We clear all symbols but a5.

In[261]:=

ClearList["a1, a2, a3, a4"] ;

In[262]:=

{a1, a2, a3, a4, a5}

Out[262]=

{a1, a2, a3, a4, 5}

Assigning symbols.

This map takes the left-hand-side "f(x1,...,xn)" of a definition "f(x1,...,xn) = ...", and turns it into the left-hand-side "f[x1_,...,xn_]" of a Mathematica assignment. We replace round by square brackets, and we add an underscore after each variable.

In[263]:=

LeftHandSide[X_] := StringReplace[X, {"("     ... 2371;","        "_,"}]

This map takes a term "t", with constants, variables and function symbols, in round brackets notation, and turns it into square brackets notation.

In[264]:=

Term[E_] := StringReplace[E, {"("       ... 62371;")"        "]"}]

This map takes two strings "f(x1,...,xn)" and "P(x1,...,xn)" (with P polynomial), and combines them into a Mathematica assignment "f[x1_,...,xn_]:=P(x1,...,xn)".

In[265]:=

PolynomialAssignment0[X_, E_] := ToExpression[ LeftHandSide[X]    <>   ":="  <>   E] ;

This map takes two strings "f(x1,...,xn)" and "t" (with t term in round brackets notation), and combines them into a Mathematica assignment "f[x1_,...,xn_]:=t" .

In[266]:=

TermAssignment0[X_, E_] := ToExpression[ LeftHandSide[X]    <>   ":="  <>   Term[E]] ;

This map takes one strings "f(x1,...,xn) =P(x1,...,xn)", and turns it into a Mathematica assignment f[x1_,...,xn_]:=P(x1,...,xn).

In[267]:=

PolynomialAssignment[S_] := PolynomialAssignment0[EraseFrom[S, "="], EraseUntil[S, "="]]

This map takes one strings "f(x1,...,xn) =t" (with t term in round brackets notation), and turns it into a Mathematica assignment "f[x1_,...,xn_]:=t".

In[268]:=

TermAssignment[S_] := TermAssignment0[EraseFrom[S, "="], EraseUntil[S, "="]]

An example.

In[269]:=

Clear[f, g]

In[270]:=

PolynomialAssignment["f(x,y) = x^2+y^2"] ; TermAssignment["g(x,y) = h(x,k(y))"] ;

In[272]:=

f[a, b] g[a, b]

Out[272]=

a^2 + b^2

Out[273]=

(⁃Graph:<6, 6, Undirected>⁃) ... (⁃Graph:<3, 4, Undirected>⁃)[b]]

In[274]:=

? f ? g

Global`f

f[x_, y_] := x^2 + y^2

Global`g

g[x_, y_] := h[x, k[y]]

In[276]:=

Clear[f, g]

Computing Game Parameters

This map asks for a string x, then update game parameters according to the content of the string x.

In[277]:=

GameParameters[] := CompoundExpression[x = InputString[] ; GameParameters[x] ;] ;

This map updates logic parameters according to the content of the string x.

In[278]:=

LogicParameters[x_] := CompoundExpression[(* Cut - Free or CutRule ? *) ... f[StringMemberQ[x, "Constructive*Implication"], MaterialImplication = False] ;] 

This map updates graphic parameters according to the content of the string x.

In[279]:=

GraphicParameters[x_] := CompoundExpression[(* FontSize : the integer value *) ... ringMemberQ[x, "Height*="], LevelHeight = Assignment[x, "Height"]] ; ]

This map updates language parameters according to the content of the string x.

In[280]:=

LanguageParameters[x_] := CompoundExpression[(* Symbol : the symbol list of th ... emberQ[x, "Term"], TermAssignment[ EraseUntil[x, "Term"]]] ; ]

This map updates all parameters according to the content of the string x.

In[281]:=

GameParameters[x_] := CompoundExpression[LogicParameters[x] ; GraphicParameters[x] ; LanguageParameters[x]] ;

An example.

In[282]:=

GameParameters["Cut-Free, LCM, Intuitionistic, Constructive Implication, cutrule, TreeWidth=500"]

We check that game parameters have been assigned correctly.

In[283]:=

{CutFree, Logic, MaterialImplication, TreeWidth}

Out[283]=

{False, LCM, False, 500}


Created by Mathematica  (October 17, 2006)