def add_common_objects(self): self.a = common_vars.a() self.b = common_vars.b() self.c = common_vars.c() self.d = common_vars.d() self.e = common_vars.e() self.b_of_a = formula.Always(formula.Holds(self.a, self.b)) self.a_of_b = formula.Always(formula.Holds(self.b, self.a)) self.a_of_a = formula.Always(formula.Holds(self.a, self.a)) self.b_of_c = formula.Always(formula.Holds(self.c, self.b)) self.d_of_c = formula.Always(formula.Holds(self.c, self.d)) self.e_of_e = formula.Always(formula.Holds(self.e, self.e)) self.and_b_of_a_functor = endofunctor.And(side=endofunctor.left, other=self.b_of_a) self.b_of_a_and_functor = endofunctor.And(side=endofunctor.right, other=self.b_of_a) self.or_d_of_c_functor = endofunctor.Or(side=endofunctor.left, other=self.d_of_c) self.d_of_c_or_functor = endofunctor.Or(side=endofunctor.right, other=self.d_of_c) self.exists_a_functor = endofunctor.Exists(variable=self.a) self.exists_b_functor = endofunctor.Exists(variable=self.b) self.exists_c_functor = endofunctor.Exists(variable=self.c) self.exists_d_functor = endofunctor.Exists(variable=self.d) self.not_not_functor = endofunctor.not_functor.compose(endofunctor.not_functor) self.equivalence = variable.StringVariable('equiv')
def add_common_objects(self): self.a = common_vars.a() self.b = common_vars.b() self.c = common_vars.c() self.d = common_vars.d() self.e = common_vars.e() self.A = constructors.Always(constructors.Holds(self.a, self.a)) self.B = constructors.Always(constructors.Holds(self.b, self.b)) self.W = constructors.Always(constructors.Holds(self.a, self.b)) self.X = constructors.Always(constructors.Holds(self.a, self.c)) self.Y = constructors.Always(constructors.Holds(self.a, self.d)) self.Z = constructors.Always(constructors.Holds(self.a, self.e)) self.a_in_domain_b = constructors.Always(constructors.Holds(self.a, variable.ApplySymbolVariable(self.b, common_symbols.domainSymbol))) self.and_W = endofunctor.And(values = [self.W], index = 0) self.W_and = endofunctor.And(values = [self.W], index = 1) self.X_and_and_Y = endofunctor.And(values = [self.X, self.Y], index = 1) self.W_and_X = constructors.And([self.W, self.X]) self.X_and_Y_and_Z = constructors.Always(constructors.And([self.X, self.Y, self.Z])) self.W_AND_X_and_Y_and_Z = constructors.And([self.W, self.X_and_Y_and_Z]) self.exists_a_in_domain_b_X_and_Y_and_Z = constructors.Exists( [constructors.BoundedVariableBinding(self.a, self.b)], self.X_and_Y_and_Z) self.exists_wd_a_in_domain_b_X_and_Y_and_Z = constructors.Exists( [constructors.WelldefinedVariableBinding(self.a, self.b)], self.X_and_Y_and_Z) self.exists_d = endofunctor.Exists([constructors.OrdinaryVariableBinding(self.d)]) self.exists_e = endofunctor.Exists([constructors.OrdinaryVariableBinding(self.e)]) self.exists_d_e = endofunctor.Exists([ constructors.OrdinaryVariableBinding(self.d) , constructors.OrdinaryVariableBinding(self.e)])
def Plus(a, b): return variable.ApplySymbolVariable( variable.ProductVariable([(common_symbols.leftSymbol, a), (common_symbols.rightSymbol, b)]), plus ) def ExpandPlus(a, b, c): base = And([Equal(natural.zero, a), Equal(b, c)]) z = common_vars.z() step = ExistsNatural([z], And([Equal(S(z), a), Equal(S(Plus(z, b)), c)])) return Or([base, step]) a = common_vars.a() b = common_vars.b() c = common_vars.c() define_plus = Always(ForallNatural([a, b, c], Iff(left=Equal(Plus(a, b), c), right=ExpandPlus(a, b, c)))) a = common_vars.a() b = common_vars.b() plus_natural = Always(ForallNatural([a, b], natural.Natural(Plus(a, b)))) # define multiplication times = variable.StringVariable("*", infix=(common_symbols.leftSymbol, common_symbols.rightSymbol)) def Times(a, b): return variable.ApplySymbolVariable( variable.ProductVariable([(common_symbols.leftSymbol, a), (common_symbols.rightSymbol, b)]), times )