<commit_before># Test inputs :)
var('x,y,z,a,b,c,d,e,f,g,h,i')

f1 = a*x*y + b
f2 = c*y*z + d*y*x + e
f3 = g*x*h + i

# to compute the termination probability of the above system:
pobabilistic_subs = dict( [(a,0.4),(b,0.6),(c,0.3),(d,0.4),(e,0.3),(g,0.3),(h,1),(i,0.7) ] )


F = vector(SR,[f1,f2,f3]).column()
# J = jacobian(F,[x,y,z])

# n = newton_fixpoint_solve(F, [x,y,z], 10)
# n.subs( a=0.5, b=0.3 )
# TODO (plan, long run):
# substitute either functions (p_(i,j)(n) = transition probabilities) or constants for some parameters
# and substitute the function f(x) = 1/(1-x) for s() to evaluate :) --> we get a rational expression in the free parameters
# Ultimately: Use it to approximate e.g. the expected value of the "runtime" (or some other "cost") as well as its variance (in terms of the input size n)
# Also:
# - Derive the equations from Flowgraphs, Remopla/PDS (which are derived from e.g. Java Bytecode)
# - More semirings (other analyses), integrate semirings, polynomials over them, and Newton's method nicely into Sage


# symbolic functions for the Kleene star of elements
# TODO: perhaps add an evaluation function for "s" (so that we have s(0) = 1 etc.)?
s = function('s', nargs=1)

def compute_mat_star(M) :
#    var('a_11 a_12 a_21 a_22 A_11 A_12 A_21 A_22 as_11 as_22 N')
    if M.nrows() == 1 and M.ncols() == 1: # just a scalar
        N = s(M[0,0]) # apply the Kleene star to the only element and return
    else: # there is a matrix to deconstruct<commit_msg>typo :)<commit_after># Test inputs :)
var('x,y,z,a,b,c,d,e,f,g,h,i')

f1 = a*x*y + b
f2 = c*y*z + d*y*x + e
f3 = g*x*h + i

# to compute the termination probability of the above system:
probabilistic_subs = dict( [(a,0.4),(b,0.6),(c,0.3),(d,0.4),(e,0.3),(g,0.3),(h,1),(i,0.7) ] )


F = vector(SR,[f1,f2,f3]).column()
# J = jacobian(F,[x,y,z])

# n = newton_fixpoint_solve(F, [x,y,z], 10)
# n.subs( a=0.5, b=0.3 )
# TODO (plan, long run):
# substitute either functions (p_(i,j)(n) = transition probabilities) or constants for some parameters
# and substitute the function f(x) = 1/(1-x) for s() to evaluate :) --> we get a rational expression in the free parameters
# Ultimately: Use it to approximate e.g. the expected value of the "runtime" (or some other "cost") as well as its variance (in terms of the input size n)
# Also:
# - Derive the equations from Flowgraphs, Remopla/PDS (which are derived from e.g. Java Bytecode)
# - More semirings (other analyses), integrate semirings, polynomials over them, and Newton's method nicely into Sage


# symbolic functions for the Kleene star of elements
# TODO: perhaps add an evaluation function for "s" (so that we have s(0) = 1 etc.)?
s = function('s', nargs=1)

def compute_mat_star(M) :
#    var('a_11 a_12 a_21 a_22 A_11 A_12 A_21 A_22 as_11 as_22 N')
    if M.nrows() == 1 and M.ncols() == 1: # just a scalar
        N = s(M[0,0]) # apply the Kleene star to the only element and return
    else: # there is a matrix to deconstruct
{'fraction_non_alphanumeric': 0.15358706635230718, 'fraction_numerical': 0.037723139104075445, 'mean_word_length': 4.103092783505154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '854672', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1119, 'n_words': 390}